[rkp] Generate EC P-256 key pair for the RKP HAL
This cl generates the EC P-256 key pair needed by the RKP HAL.
The MAC of the public key and wrapping of the private key will be
handled in subsequent cls.
Bug: 299055662
Test: atest rialto_test
Change-Id: I253130e62bbf70cb5a7abe1a056fc4f77d30aa6e
diff --git a/rialto/src/main.rs b/rialto/src/main.rs
index 8b73130..43215a0 100644
--- a/rialto/src/main.rs
+++ b/rialto/src/main.rs
@@ -29,6 +29,7 @@
use crate::error::{Error, Result};
use crate::fdt::read_dice_range_from;
use alloc::boxed::Box;
+use bssl_ffi::CRYPTO_library_init;
use ciborium_io::Write;
use core::num::NonZeroUsize;
use core::slice;
@@ -134,6 +135,13 @@
e
})?;
}
+
+ // Initializes the crypto library before any crypto operations and after the heap is
+ // initialized.
+ // SAFETY: It is safe to call this function multiple times and concurrently.
+ unsafe {
+ CRYPTO_library_init();
+ }
let bcc_handover: Box<dyn DiceArtifacts> = match vm_type() {
VmType::ProtectedVm => {
let dice_range = read_dice_range_from(fdt)?;