Skip to content

Conversation

@kevinAlbs
Copy link
Contributor

@kevinAlbs kevinAlbs commented Mar 21, 2023

Summary

  • Add Cryptographic Usage Mask attribute to KMIP Register request.
  • Change Key Format Type from Raw to Opaque.
  • Fix error handling of calls to kms_kmip_request.*new

Changes were verified with this Evergreen patch build of the C driver using this branch of libmongocrypt.

Changes were tested with Vault 1.13.0 and verified to fix the reported error. Vault 1.11.8 and a development version of Vault were tested to ensure no regression.

libmongocrypt changes were verified in this Evergreen patch build.

Background & Motivation

XML comments in the test data was generated with the kmip_dump utility.

Add Cryptographic Usage Mask attribute to KMIP Register request.

It was reported on slack that versions 1.12 and 1.13 of HashiCorp Vault KMIP return an error on the KMIP Register request:

Error message: Caused by: com.mongodb.crypt.capi.MongoCryptException: Error getting UniqueIdentifer from KMIP Register response: KMIP response error. Result Status (1): Operation Failed. Result Reason (4): Invalid Message. Result Message: result reason: ResultReasonInvalidMessage; additional message: attribute Cryptographic Usage Mask is missing

4.3 Register lists the "Cryptographic Usage Mask" attribute as REQUIRED.

The "Cryptographic Usage Mask" attribute included is not included in the Register request for the SecretData object created by libmongocrypt.

3.14 Cryptographic Usage Mask lists "Cryptographic Usage Mask" in "When implicitly set" for the "Register" operation. 3 Attributes defines "When implicitly set" as "Which operations MAY cause this attribute to be set even if the attribute is not specified in the operation request itself?". I interpret this to mean: the KMIP server may implicitly set the Cryptographic Usage Mask, but it may not. If the KMIP server does not implicitly set Cryptographic Usage Mask, Cryptographic Usage Mask is required in the Request.

Change Key Format Type from Raw to Opaque.

After adding the Cryptographic Usage Mask attribute, Vault 1.13 returned this error:

Error getting UniqueIdentifer from KMIP Register response: KMIP response error. Result Status (1): Operation Failed. Result Reason (7): Invalid Field. Result Message: result reason: ResultReasonInvalidField; additional message: expected they key block's key format type to be "KeyFormatTypeOpaque", not "KeyFormatTypeRaw"

2.2.7 Secret Data notes:

The Key Block of the Secret Data object contains a Key Value of the Opaque type.

@kevinAlbs kevinAlbs marked this pull request as ready for review March 21, 2023 16:57
@kevinAlbs kevinAlbs requested a review from markbenvenuto March 21, 2023 18:33
}
kmip_writer_close_struct (writer); /* KMIP_TAG_TemplateAttribute */
kmip_writer_begin_struct (writer, KMIP_TAG_SecretData);
/* 0x01 = Password */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - 0x2 = Seed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@kevinAlbs kevinAlbs merged commit d8472ef into mongodb:master Mar 22, 2023
kevinAlbs added a commit that referenced this pull request Mar 22, 2023
* format kms_kmip_request.c

* fix error checks of `kms_kmip_request.*new`

On error, the calls return a `kms_request_t*` with an error attached.

* add `Cryptographic Usage Mask` attribute to KMIP `Register` request

* change `Key Format Type` from `Raw` to `Opaque`.

* update comments and test data

* fix comment. SecretDataType used is Seed, not Password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants