Merge changes from topic "avb_testkey_rsa4096_pub_bin"

* changes:
  pvmfw: Use pvmfw_embedded_key from Rust
  pvmfw: Introduce pvmfw_embedded_key
diff --git a/pvmfw/Android.bp b/pvmfw/Android.bp
index d0fc9a9..b644905 100644
--- a/pvmfw/Android.bp
+++ b/pvmfw/Android.bp
@@ -10,6 +10,7 @@
     edition: "2021",
     rustlibs: [
         "liblog_rust_nostd",
+        "libpvmfw_embedded_key",
         "libvmbase",
     ],
     apex_available: ["com.android.virt"],
@@ -44,6 +45,34 @@
 }
 
 prebuilt_etc {
+    name: "pvmfw_embedded_key",
+    src: ":avb_testkey_rsa4096_pub_bin",
+    installable: false,
+}
+
+genrule {
+    name: "pvmfw_embedded_key_rs",
+    srcs: [":pvmfw_embedded_key"],
+    out: ["lib.rs"],
+    cmd: "(" +
+        "    echo '#![no_std]';" +
+        "    echo '#![allow(missing_docs)]';" +
+        "    echo 'pub const PUBLIC_KEY: &[u8] = &[';" +
+        "    xxd -i < $(in);" +
+        "    echo '];';" +
+        ") > $(out)",
+}
+
+rust_library_rlib {
+    name: "libpvmfw_embedded_key",
+    defaults: ["vmbase_ffi_defaults"],
+    prefer_rlib: true,
+    srcs: [":pvmfw_embedded_key_rs"],
+    crate_name: "pvmfw_embedded_key",
+    apex_available: ["com.android.virt"],
+}
+
+prebuilt_etc {
     name: "pvmfw_sign_key",
     src: ":avb_testkey_rsa4096",
     installable: false,
diff --git a/pvmfw/src/avb.rs b/pvmfw/src/avb.rs
new file mode 100644
index 0000000..1abe73f
--- /dev/null
+++ b/pvmfw/src/avb.rs
@@ -0,0 +1,17 @@
+// Copyright 2022, The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+//! Image verification.
+
+pub use pvmfw_embedded_key::PUBLIC_KEY;
diff --git a/pvmfw/src/main.rs b/pvmfw/src/main.rs
index 9f8cbd2..870172d 100644
--- a/pvmfw/src/main.rs
+++ b/pvmfw/src/main.rs
@@ -17,12 +17,14 @@
 #![no_main]
 #![no_std]
 
+mod avb;
 mod entry;
 mod exceptions;
 mod helpers;
 mod mmio_guard;
 mod smccc;
 
+use avb::PUBLIC_KEY;
 use log::{debug, info};
 
 fn main(fdt: &mut [u8], payload: &[u8]) {
@@ -33,6 +35,6 @@
         payload.as_ptr() as usize,
         payload.len(),
     );
-
+    debug!("AVB public key: addr={:?}, size={:#x} ({1})", PUBLIC_KEY.as_ptr(), PUBLIC_KEY.len());
     info!("Starting payload...");
 }