Skip to content

Conversation

@athoelke
Copy link
Contributor

@athoelke athoelke commented Oct 24, 2024

This PR replaces #215, simplifying the API to only support key wrapping algorithms, and not wrapped-key formats. Wrapped-key formats will be considered later, along with import and export of formatted key data (see also #50, #149 and #207 for more discussion).

This added the psa_wrap_key() and psa_unwrap_key() functions, and support for AES-KW and AES-KWP algorithms.

Open issues:

  • 1. NIST 800-38F describes a generalised AES-KW and AES-KWP to support any 128-bit 'approved block cipher', which exactly matches RFC 3394 and RFC 5649 definitions for the AES block cipher. Is it valuable to define this as the more general algorithm identifier, compatible with any 128-bit block cipher key, or just keep the AES-specific name and AES-only compatibility?

  • 2. I have allocated a new algorithm category, as key-wrapping algorithms tend to be specialized authenticated encryption. However, AES-SIV can be used as a general AEAD algorithm, as well as a key-wrapping algorithm. Would that be problematic?

  • 3. I have recycled the 'S' bit in the algorithm identifier to flag whether the algorithm has alignment constraints on the input data (AES-KW does, AES-KWP does not) - similar to block-aligned sizes for some block-mode ciphers. Is this at all useful, or should we just make this bit 0 for key-wrap algorithms?

Partly fixes #50

@athoelke athoelke added enhancement New feature or request API design Related the design of the API Crypto API Issue or PR related to the Cryptography API labels Oct 24, 2024
@athoelke athoelke added this to the Crypto API 1.3 milestone Oct 24, 2024
@athoelke athoelke self-assigned this Oct 24, 2024
@athoelke athoelke marked this pull request as draft December 4, 2024 10:19
@athoelke athoelke removed this from the Crypto API 1.3 milestone Dec 4, 2024
@athoelke
Copy link
Contributor Author

athoelke commented Dec 4, 2024

After another round of review and consideration, this approach is not convincing.

Although it avoids the challenge of designing the key policy handling that comes with an API for handling wrapped-key formats (see #215), it will result in multiple APIs for key wrapping which is not ideal.

This PR will remain as Draft for the time being - this API should be considered experimentatal/Beta. We will revisit the API for wrapping and unwrapping keys after v1.3.

@athoelke
Copy link
Contributor Author

athoelke commented Sep 8, 2025

I think it is time to revive this PR and decide on the design of key wrapping APIs?

This simplified wrappign API for encrypting key material without structured output and key metadata, is vaulable for use cases such as encrypted firmware. For example, constrained bootloader runtimes benefit from the elimination of unused parameters and behavioral requirements that a unified, but more complex, wrapping/formatting API would entail.

This current proposed API is in use in some implementations of the specification.

@athoelke athoelke marked this pull request as ready for review September 9, 2025 09:23
@athoelke athoelke requested a review from oberon-sk September 9, 2025 09:23
@athoelke athoelke mentioned this pull request Sep 10, 2025
@bheeb
Copy link

bheeb commented Sep 11, 2025

We think this proposal is good, it works for us.

Copy link
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.

I think this should be NIST-KW or some such, not AES-KW. Apart from that I just have a couple of nits.

Copy link
Contributor

@MarcusJGStreets MarcusJGStreets left a comment

Choose a reason for hiding this comment

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

Looks OK to me.
While I would never use AES-KW, and while I doubt anyone will use it with a different algorithm - the construction works just as well, or indeed badly, with any other algorithm. Which makes this a sensible approach.

@athoelke
Copy link
Contributor Author

athoelke commented Oct 3, 2025

I have addressed Open issue 1 directly, and am happy with the encoding decisions

@athoelke athoelke force-pushed the crypto-key-wrap-v2 branch from 16009b6 to 01d3b2d Compare October 3, 2025 16:27
Copy link
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.

LGTM

@athoelke athoelke merged commit 3163ef7 into ARM-software:main Oct 13, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in PSA Certified API development Oct 13, 2025
@athoelke athoelke deleted the crypto-key-wrap-v2 branch October 13, 2025 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API design Related the design of the API 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 APIs to support wrapped keys

5 participants