mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
rust/pvimg: Convert variables to public for use with SE header tampering tool
Converting several variables to public and exporting some structures for use in SE header tampering tool. Signed-off-by: Gautam Gala <ggala@linux.ibm.com> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
@@ -36,9 +36,10 @@ pub mod misc {
|
||||
|
||||
pub mod uvdata {
|
||||
pub use crate::pv_utils::{
|
||||
BuilderTrait, ComponentMetadataV1, ControlFlagTrait, ControlFlagsTrait, FlagData,
|
||||
KeyExchangeTrait, PcfV1, PlaintextControlFlagsV1, ScfV1, SeHdr, SeHdrBuilder, SeHdrDataV1,
|
||||
SeHdrVersion, SecretControlFlagsV1, UvDataTrait, UvKeyHashesV1,
|
||||
AeadPlainDataTrait, BuilderTrait, ComponentMetadataV1, ControlFlagTrait, ControlFlagsTrait,
|
||||
FlagData, KeyExchangeTrait, PcfV1, PlaintextControlFlagsV1, ScfV1, SeHdr, SeHdrAadV1,
|
||||
SeHdrBinV1, SeHdrBuilder, SeHdrData, SeHdrDataV1, SeHdrPlain, SeHdrVersion, SeHdrVersioned,
|
||||
SecretControlFlagsV1, UvDataPlainTrait, UvDataTrait, UvKeyHashesV1,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@ pub use misc::{round_up, try_copy_slice_to_array};
|
||||
pub use psw::{ShortPsw, PSW, PSW_MASK_BA, PSW_MASK_EA};
|
||||
pub use se_hdr::{
|
||||
ComponentMetadataV1, ControlFlagTrait, ControlFlagsTrait, FlagData, PcfV1,
|
||||
PlaintextControlFlagsV1, ScfV1, SeHdr, SeHdrBuilder, SeHdrDataV1, SeHdrVersion,
|
||||
SecretControlFlagsV1,
|
||||
PlaintextControlFlagsV1, ScfV1, SeHdr, SeHdrAadV1, SeHdrBinV1, SeHdrBuilder, SeHdrData,
|
||||
SeHdrDataV1, SeHdrPlain, SeHdrVersion, SeHdrVersioned, SecretControlFlagsV1,
|
||||
};
|
||||
pub use secured_comp::{ComponentTrait, SecuredComponent, SecuredComponentBuilder};
|
||||
pub use serializing::{bytesize, serialize_to_bytes};
|
||||
pub use uv_keys::UvKeyHashesV1;
|
||||
pub use uvdata::{KeyExchangeTrait, UvDataTrait};
|
||||
pub use uvdata::{AeadPlainDataTrait, KeyExchangeTrait, UvDataPlainTrait, UvDataTrait};
|
||||
pub use uvdata_builder::BuilderTrait;
|
||||
|
||||
@@ -17,3 +17,4 @@ pub use flags::{
|
||||
ControlFlagTrait, ControlFlagsTrait, FlagData, PcfV1, PlaintextControlFlagsV1, ScfV1,
|
||||
SecretControlFlagsV1,
|
||||
};
|
||||
pub use hdr_v1::SeHdrAadV1;
|
||||
|
||||
@@ -85,10 +85,10 @@ impl SeHdrCommon {
|
||||
pub struct SeHdr {
|
||||
/// Common Secure Execution header part
|
||||
#[serde(flatten)]
|
||||
pub(crate) common: SeHdrCommon,
|
||||
pub common: SeHdrCommon,
|
||||
#[serde(flatten)]
|
||||
#[deku(ctx = "common.version")]
|
||||
pub(crate) data: SeHdrVersioned,
|
||||
pub data: SeHdrVersioned,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug, DekuRead, DekuWrite, Serialize)]
|
||||
@@ -96,10 +96,10 @@ pub struct SeHdr {
|
||||
/// Plain data Secure Execution header structure
|
||||
pub struct SeHdrPlain {
|
||||
#[serde(flatten)]
|
||||
pub(crate) common: SeHdrCommon,
|
||||
pub common: SeHdrCommon,
|
||||
#[serde(flatten)]
|
||||
#[deku(ctx = "common.version")]
|
||||
pub(crate) data: SeHdrData,
|
||||
pub data: SeHdrData,
|
||||
}
|
||||
|
||||
#[enum_dispatch(AeadCipherTrait, AeadDataTrait, KeyExchangeTrait)]
|
||||
|
||||
@@ -51,28 +51,28 @@ struct HdrSizesV1 {
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, DekuRead, DekuWrite, Serialize)]
|
||||
#[deku(endian = "endian", ctx = "endian: Endian", ctx_default = "Endian::Big")]
|
||||
struct SeHdrAadV1 {
|
||||
pub struct SeHdrAadV1 {
|
||||
#[deku(assert = "*sehs <= SeHdrDataV1::MAX_SIZE.try_into().unwrap()")]
|
||||
sehs: u32,
|
||||
pub sehs: u32,
|
||||
#[serde(serialize_with = "ser_hex")]
|
||||
iv: [u8; SymKeyType::AES_256_GCM_IV_LEN],
|
||||
pub iv: [u8; SymKeyType::AES_256_GCM_IV_LEN],
|
||||
res1: u32,
|
||||
#[deku(assert = "*nks <= (*sehs).into()", update = "self.keyslots.len()")]
|
||||
nks: u64,
|
||||
pub nks: u64,
|
||||
#[deku(assert = "*sea <= (*sehs).into()")]
|
||||
sea: u64,
|
||||
nep: u64,
|
||||
pub sea: u64,
|
||||
pub nep: u64,
|
||||
#[serde(serialize_with = "ser_lower_hex")]
|
||||
pcf: u64,
|
||||
cust_pub_key: EcPubKeyCoordV1,
|
||||
pub pcf: u64,
|
||||
pub cust_pub_key: EcPubKeyCoordV1,
|
||||
#[serde(serialize_with = "ser_hex")]
|
||||
pld: [u8; SHA_512_HASH_LEN],
|
||||
pub pld: [u8; SHA_512_HASH_LEN],
|
||||
#[serde(serialize_with = "ser_hex")]
|
||||
ald: [u8; SHA_512_HASH_LEN],
|
||||
pub ald: [u8; SHA_512_HASH_LEN],
|
||||
#[serde(serialize_with = "ser_hex")]
|
||||
tld: [u8; SHA_512_HASH_LEN],
|
||||
pub tld: [u8; SHA_512_HASH_LEN],
|
||||
#[deku(count = "nks")]
|
||||
keyslots: Vec<BinaryKeySlotV1>,
|
||||
pub keyslots: Vec<BinaryKeySlotV1>,
|
||||
}
|
||||
|
||||
impl SeHdrAadV1 {
|
||||
@@ -121,7 +121,7 @@ pub struct SeHdrConfV1 {
|
||||
xts: Aes256XtsKey,
|
||||
psw: PSW,
|
||||
#[serde(serialize_with = "ser_lower_hex")]
|
||||
scf: u64,
|
||||
pub scf: u64,
|
||||
#[deku(assert_eq = "0")]
|
||||
noi: u32,
|
||||
res2: u32,
|
||||
@@ -160,13 +160,13 @@ fn ser_confidential_confv1<S: Serializer>(
|
||||
#[deku(endian = "big")]
|
||||
pub struct SeHdrDataV1 {
|
||||
#[serde(flatten)]
|
||||
aad: SeHdrAadV1,
|
||||
pub aad: SeHdrAadV1,
|
||||
#[serde(flatten, serialize_with = "ser_confidential_confv1")]
|
||||
#[deku(
|
||||
reader = "confidential_read_sehdrconf_v1(deku::reader)",
|
||||
writer = "confidential_write_sehdrconf_v1(data, deku::writer)"
|
||||
)]
|
||||
data: Confidential<SeHdrConfV1>,
|
||||
pub data: Confidential<SeHdrConfV1>,
|
||||
#[serde(flatten)]
|
||||
tag: SeHdrTagV1,
|
||||
}
|
||||
@@ -443,7 +443,7 @@ impl SeHdrPubBuilderTrait for SeHdrDataV1 {
|
||||
#[deku(endian = "big")]
|
||||
pub struct SeHdrBinV1 {
|
||||
#[serde(flatten)]
|
||||
aad: SeHdrAadV1,
|
||||
pub aad: SeHdrAadV1,
|
||||
#[serde(serialize_with = "ser_hex")]
|
||||
#[deku(bytes_read = "aad.sea")]
|
||||
pub data: Vec<u8>,
|
||||
|
||||
@@ -74,13 +74,13 @@ impl TryFrom<EcPubKeyCoordV1> for PKey<Public> {
|
||||
pub struct BinaryKeySlotV1 {
|
||||
#[serde(serialize_with = "ser_hex")]
|
||||
/// Public host key hash
|
||||
pub(crate) phkh: [u8; 32],
|
||||
pub phkh: [u8; 32],
|
||||
/// Wrapper key
|
||||
#[serde(serialize_with = "ser_hex")]
|
||||
pub(crate) wrpk: [u8; 32],
|
||||
pub wrpk: [u8; 32],
|
||||
/// Tag
|
||||
#[serde(serialize_with = "ser_hex")]
|
||||
pub(crate) kst: [u8; 16],
|
||||
pub kst: [u8; 16],
|
||||
}
|
||||
static_assert!(size_of::<BinaryKeySlotV1>() == 80);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user