kms
kms copied to clipboard
Rust `KeyBlock` implementation not fully compliant with KMIP 2.1 specs
The KeyBlock struct with the current implementation and updated comments looks like this.
/// A Key Block object is a structure used to encapsulate all of the information
/// that is closely associated with a cryptographic key.
/// Section 3 of KMIP Reference 2.1
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct KeyBlock {
pub key_format_type: KeyFormatType,
/// Indicates the format of the elliptic curve public key. By default, the public key is uncompressed
#[serde(skip_serializing_if = "Option::is_none")]
pub key_compression_type: Option<KeyCompressionType>,
/// Byte String: for wrapped Key Value; Structure: for plaintext Key Value
pub key_value: KeyValue,
/// MAY be omitted only if this information is available from the Key Value.
/// Does not apply to Secret Data or Opaque.
/// If present, the Cryptographic Length SHALL also be present.
pub cryptographic_algorithm: CryptographicAlgorithm,
/// MAY be omitted only if this information is available from the Key Value.
/// Does not apply to Secret Data (or Opaque.
/// If present, the Cryptographic Algorithm SHALL also be present.
pub cryptographic_length: i32,
/// SHALL only be present if the key is wrapped.
#[serde(skip_serializing_if = "Option::is_none")]
pub key_wrapping_data: Option<KeyWrappingData>,
}
-
KeyValueshould be an enumeration with 2 variantsByteStringand a second variant wrapping the current structure -
cryptographic_algorithmshould be optional -
cryptographic_length: should be optional
Fixing these issues, implies fixes in at least the JS and Java implementations.
Fixing 2. and 3. as part of https://github.com/Cosmian/kms/pull/71, where it is required