Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add direct KDFs #90

Open
chrysn opened this issue Jul 31, 2019 · 4 comments
Open

Add direct KDFs #90

chrysn opened this issue Jul 31, 2019 · 4 comments

Comments

@chrysn
Copy link
Contributor

chrysn commented Jul 31, 2019

For use with OSCORE, it would be convenient to have COSE's direct key KDFs available (basically, a way to use the tables from COSE's table16).

Are there any plans to add support for that, would you accept PRs to that effect, or do you have concrete ideas on interface requirements for those?

@chrysn
Copy link
Contributor Author

chrysn commented Jul 31, 2019

To be more precise, what I'd need (and consider adding) is wrapping the necessary lower-library primitives to implement KDFs at the level of crypto.h which I'd use directly; I'm not sufficiently familiar with non-OSCORE COSE applications to understand where those could be useful in general).

@chrysn
Copy link
Contributor Author

chrysn commented Aug 1, 2019

For my application, it may also be sufficient to just expose the underlying HMACs, if they are relevant to the rest of COSE.

(The reason why I'd be also happy with that is that OSCORE uses only HMACs, which allows the optimization of splitting up the extraction and expansion steps for the (definitely happening) case when subsequent operations extract from the same key material but expand with different info elements.)

From the API point of view, if the info could be fed into the KDF segment-wise (you mentioned considerations for incremental APIs), that'd great as the info data don't come pre-assembled in a single buffer.

@chrysn
Copy link
Contributor Author

chrysn commented Mar 19, 2020

I think I can tell apart a bit better now what I'll need and what would have a good place in a generic COSE implementation:

  • The "direct key with KDF" mechanisms have their place in COSE. API-wise, they'd probably expose something like "Given the secret X, give me the content encryption key (alternatively, the IV) derived using algorithm Y (which is a direct+xKDF algorithm) for partyU nonce Z". The application does not do any stream-feeding into the library, and the library uses its knowledge of the CBOR object to build and to feed into the HKDF actual. (where "xKDF" stands for "probably HKDF, but could be any KDF really")
  • What I'd use of this is, similar to what I'm doing in the AEAD cases, to take the workhorse function of the above COSE public thing and say "Using algorithm Y (which is a direct+xKDF algorithm, but only used as an xKDF algorithm in this context), compute me the derived key for the input I'll be feeding to you piecemeal".

Background: OSCORE is using the same numbers as direct+xKDF algorithms (at least when explicitly talking about the algorithms explicitly, like they do in the hkdf field of oscore-profile, but the actual input material fed into the HKDF is not structured like in COSE, but a bespoke CBOR structure.

@chrysn
Copy link
Contributor Author

chrysn commented Mar 19, 2020

What's more, both APIs could offer optimizations for HKDFs that follow the extract-and-expand phases -- an application that does multiple key derivation from the same secret and different nonces could profit from doing the extract step once, storing the extracted material and doing the expand step multiple times.

For a first design stage, ignoring that in the API is probably good enough; if later the need for it does come up, it can still be added, and the original API would then become a convenience wrapper for applications with simple needs.

@chrysn chrysn mentioned this issue Dec 19, 2020
5 tasks
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 a pull request may close this issue.

1 participant