kms icon indicating copy to clipboard operation
kms copied to clipboard

Rust `KeyBlock` implementation not fully compliant with KMIP 2.1 specs

Open bgrieder opened this issue 2 years ago • 1 comments

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>,
}
  1. KeyValue should be an enumeration with 2 variants ByteString and a second variant wrapping the current structure
  2. cryptographic_algorithm should be optional
  3. cryptographic_length: should be optional

Fixing these issues, implies fixes in at least the JS and Java implementations.

bgrieder avatar Oct 27 '23 14:10 bgrieder

Fixing 2. and 3. as part of https://github.com/Cosmian/kms/pull/71, where it is required

bgrieder avatar Oct 27 '23 14:10 bgrieder