Skip to content

The presence of optional Response Header fields causes response parsing to fail. #62

Description

@ximon18

Split out from ximon18/keyls#13 (comment).

This causes this code to be incompatible with Securosys Cloud HSM as it provides the "Server Correlation Value" in the response which is legal according to KMIP 1.4 specification specification section 6.1 Server Correlation Value.

KMIP specification 1.4 section 7.2 Operations defines the Response Header as follows:

Object REQUIRED in Message Comment
Response Header Yes Structure
Protocol Version Yes See 6.1
Time Stamp Yes See 6.5
Nonce No See 2.1.14
Attestation Type No, MAY be repeated REQUIRED in Attestation Required error message if client set Attestation Capable Indicator to True in the request, see 9.1.3.2.36
Client Correlation Value No See 6.18
Server Correlation Value No See 6.19
Batch Count Yes See 6.14

While the response parsing code defines ResponseHeader like so:

/// See KMIP 1.0 section 7.2 [Operations](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581257).
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
#[serde(rename = "0x42007A")]
pub struct ResponseHeader {
    #[serde(rename = "0x420069")]
    pub protocol_version: ProtocolVersion,

    #[serde(rename = "0x420092")]
    pub timestamp: i64,

    #[serde(rename = "0x42000D")]
    pub batch_count: i32,
}

Normally with Serde undefined fields are ignored by default if present when deserializing. But with the (legacy, as we have a new parser but are not yet using it for responses, only for requests) response parser in kmip-protocol that isn't the case, the parsing gets confused if the optional fields are present, presenting an error such as:

Error: Deserialize error: Error while deserializing the response: Expected KMIP TTLV type Integer (0x02) but found TextString (0x07)

These missing fields should be defined as Option types.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions