Skip to content

Add support for KDFs based on SP 800-108 recommendations#123

Merged
athoelke merged 6 commits intoARM-software:mainfrom
athoelke:crypto-kdf-sp800-108
Dec 11, 2023
Merged

Add support for KDFs based on SP 800-108 recommendations#123
athoelke merged 6 commits intoARM-software:mainfrom
athoelke:crypto-kdf-sp800-108

Conversation

@athoelke
Copy link
Copy Markdown
Contributor

@athoelke athoelke commented Nov 7, 2023

Define algorithm identifiers for HMAC and CMAC variants of a counter-mode KDF that follows the construction recommended by NIST SP 800-108r1.

As the specification defines a general construction, the Crypto API specification provides a precise definition, to ensure compatibility between different implementations. See #106 for the enhancement request, and discussion.

Fixes #106

@athoelke athoelke added enhancement New feature or request Crypto API Issue or PR related to the Cryptography API labels Nov 7, 2023
@athoelke athoelke added this to the Crypto API 1.2 milestone Nov 7, 2023
@athoelke athoelke self-assigned this Nov 7, 2023
@athoelke
Copy link
Copy Markdown
Contributor Author

athoelke commented Nov 7, 2023

@adeaarm @Vge0rge - please review this PR.

Comment thread doc/crypto/api/ops/kdf.rst
@athoelke athoelke force-pushed the crypto-kdf-sp800-108 branch from bd4acfd to e1d4c92 Compare November 13, 2023 14:32
@athoelke
Copy link
Copy Markdown
Contributor Author

Rebased to merge with changes from #91, and added cross-references from the key types to the new algorithms

@Vge0rge
Copy link
Copy Markdown

Vge0rge commented Nov 21, 2023

@athoelke Do you think that it has value to provide a reference implementation of these new algorithms using the PSA crypto MAC APIS? These can can be used to generate test vectors which future implementations can use to verify that they follow the algorithm as we intend it to be followed.

I think that it is a good idea to have them, if you agree let me know what is the most suitable place to put them and I can provide the code for them.

@gilles-peskine-arm
Copy link
Copy Markdown
Contributor

@Vge0rge We will implement this KDF in Mbed TLS, likely in our next release, so that can serve as sample code. With respect to test vectors, we'll likely generate our test data with Cryptodome.

@bheeb
Copy link
Copy Markdown

bheeb commented Nov 22, 2023

Cryptodome cannot be used to generate test vectors for PSA_ALG_SP800_108_COUNTER_CMAC because it implements the standard version, not the ‘robust’ variant suggested in these PR. The same holds for OpenSSL.

@athoelke
Copy link
Copy Markdown
Contributor Author

Cryptodome cannot be used to generate test vectors for PSA_ALG_SP800_108_COUNTER_CMAC because it implements the standard version, not the ‘robust’ variant suggested in these PR. The same holds for OpenSSL.

I guess it would be possible to use CMAC-AES in Cryptodome to construct the CMAC-based KDF defined here, in order to create test vectors; as the SP800-108 Counter KDF support in Cryptodome uses a different construction?

However, I think a reference would be valuable. Whether for constructing or validating text vectors, or just helping to illustrate the construction defined in the Crypto API.

let me know what is the most suitable place to put them and I can provide the code for them.

My suggestion for hosting such examples would be to place it in a new /examples folder in this repository. Perhaps:

/examples/crypto/a-good-name-for-the-example/

containing a readme.md to briefly describe the example, and any source files?

@Vge0rge
Copy link
Copy Markdown

Vge0rge commented Nov 23, 2023

Sounds reasonable to me, I will arrange this soon then.

Copy link
Copy Markdown
Contributor

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

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

A few local remarks, other than that LGTM.

Comment thread doc/crypto/api/ops/kdf.rst Outdated
Comment thread doc/crypto/api/ops/kdf.rst Outdated
Comment thread doc/crypto/api/ops/kdf.rst Outdated
Comment thread doc/crypto/api/ops/kdf.rst Outdated
@athoelke athoelke force-pushed the crypto-kdf-sp800-108 branch from f718c56 to 6b4ec8c Compare December 11, 2023 15:43
@athoelke athoelke dismissed gilles-peskine-arm’s stale review December 11, 2023 15:47

Reviewer is happy to proceed once comments addressed

@athoelke athoelke merged commit 1cd3d0a into ARM-software:main Dec 11, 2023
@athoelke athoelke deleted the crypto-kdf-sp800-108 branch December 11, 2023 15:47
@adeaarm
Copy link
Copy Markdown
Member

adeaarm commented Feb 19, 2025

@Vge0rge We will implement this KDF in Mbed TLS, likely in our next release, so that can serve as sample code. With respect to test vectors, we'll likely generate our test data with Cryptodome.

Is this available in any Mbed TLS released version at the moment? If not, is it being worked on currently?

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

Labels

Crypto API Issue or PR related to the Cryptography API enhancement New feature or request

Projects

Development

Successfully merging this pull request may close these issues.

Add support for CMAC based KDF algorithms

6 participants