From 516bd8c2cff23b762195c24354853059ca40de6c Mon Sep 17 00:00:00 2001 From: Steffen Eiden Date: Wed, 26 Jun 2024 14:07:24 +0200 Subject: [PATCH] rust/pv: Move confidential.rs to pv_core MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Migrate Confidential to pv_core crate. This has no impact on the public API of pv as the migrated symbols are reexported. This enables pv_core to manage confidential data as well. Signed-off-by: Steffen Eiden Reviewed-by: Marc Hartmayer Signed-off-by: Steffen Eiden --- rust/pv/src/crypto.rs | 4 +++- rust/pv/src/lib.rs | 2 -- rust/{pv => pv_core}/src/confidential.rs | 2 +- rust/pv_core/src/lib.rs | 2 ++ 4 files changed, 6 insertions(+), 4 deletions(-) rename rust/{pv => pv_core}/src/confidential.rs (98%) diff --git a/rust/pv/src/crypto.rs b/rust/pv/src/crypto.rs index d49c3367..3b6a26e4 100644 --- a/rust/pv/src/crypto.rs +++ b/rust/pv/src/crypto.rs @@ -2,7 +2,6 @@ // // Copyright IBM Corp. 2023, 2024 -use crate::{confidential::Confidential, error::Result, Error}; use openssl::{ derive::Deriver, ec::{EcGroup, EcKey}, @@ -16,8 +15,11 @@ use openssl::{ sign::{Signer, Verifier}, symm::{decrypt_aead, encrypt_aead, Cipher}, }; +use pv_core::request::Confidential; use std::{convert::TryInto, ops::Range}; +use crate::{error::Result, Error}; + /// An AES256-GCM key that will purge itself out of the memory when going out of scope pub type Aes256Key = Confidential<[u8; 32]>; pub(crate) const AES_256_GCM_TAG_SIZE: usize = 16; diff --git a/rust/pv/src/lib.rs b/rust/pv/src/lib.rs index 1084f8e8..e5f94204 100644 --- a/rust/pv/src/lib.rs +++ b/rust/pv/src/lib.rs @@ -42,7 +42,6 @@ //! # Verify //! [`attest::AttestationItems`], [`attest::AttestationMeasurement`] mod brcb; -mod confidential; mod crypto; mod error; mod openssl_extensions; @@ -93,7 +92,6 @@ pub use pv_core::{FileAccessErrorType, FileIoErrorType}; /// Functionalities to build UV requests pub mod request { pub use crate::brcb::BootHdrTags; - pub use crate::confidential::{Confidential, Zeroize}; pub use crate::crypto::{SymKey, SymKeyType}; pub use crate::req::{Keyslot, ReqEncrCtx, Request}; pub use crate::verify::{CertVerifier, HkdVerifier, NoVerifyHkd}; diff --git a/rust/pv/src/confidential.rs b/rust/pv_core/src/confidential.rs similarity index 98% rename from rust/pv/src/confidential.rs rename to rust/pv_core/src/confidential.rs index 86eac854..0e8e6f96 100644 --- a/rust/pv/src/confidential.rs +++ b/rust/pv_core/src/confidential.rs @@ -48,7 +48,7 @@ impl Zeroize for Vec { /// Will never leak its wrapped value during [`Debug`] /// /// ```rust -/// use s390_pv::request::Confidential; +/// # use s390_pv_core::request::Confidential; /// fn foo(value: Confidential<[u8; 2]>) { /// println!("value: {value:?}"); /// } diff --git a/rust/pv_core/src/lib.rs b/rust/pv_core/src/lib.rs index c66d1b68..d351d2d9 100644 --- a/rust/pv_core/src/lib.rs +++ b/rust/pv_core/src/lib.rs @@ -10,6 +10,7 @@ unused_qualifications )] #![doc = include_str!("../README.md")] +mod confidential; mod error; mod macros; mod utils; @@ -46,6 +47,7 @@ pub mod uv { /// Functionalities to verify UV requests pub mod request { + pub use crate::confidential::{Confidential, Zeroize}; /// Version number of the request in system endianness pub type RequestVersion = u32; /// Request magic value