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

Support for KDF counter and feedback modes with HMAC #7313

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lealem47
Copy link
Contributor

@lealem47 lealem47 commented Mar 9, 2024

Description

Adds wc_HMAC_KDF_Counter() and wc_HMAC_KDF_Feedback() APIs enabled by defining HAVE_HMAC_PRF_KDF.
From feature request list.

Testing

Vectors from NIST in wolfCrypt test.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@lealem47 lealem47 self-assigned this Mar 9, 2024
@dgarske
Copy link
Contributor

dgarske commented Mar 11, 2024

Looks good to me, but haven't tested. @SparkiDev will you please review and provide feedback?

@SparkiDev
Copy link
Contributor

I'm seeing these different KDFs:

  1. mode == 1 (HMAC_KDF_FEEDBACK_MODE)
    IV or key | info
  2. mode == 0 (HMAC_KDF_CTR_MODE), ctrLocation = BEFORE_FIXED
    Counter | Info
  3. mode == 0 (HMAC_KDF_CTR_MODE), ctrLocation = AFTER_FIXED
    Info | Counter
  4. mode == 0 (HMAC_KDF_CTR_MODE), ctrLocation = MIDDLE_FIXED
    info | Counter | remainingInfo

I don't see n changing in the loop.

The underlying common operation is HMAC of 2 or three items.
Make the hidden API take three items which are all optional - NULL means don't hash.
Then, depending on mode and ctrLocation, pass different buffers in for the different items to be hashed.
One is sometimes a counter which needs to be updated based on a parameter to the hidden function.

@SparkiDev
Copy link
Contributor

2^n -1 == (1 << n) - 1

@dgarske dgarske assigned lealem47 and unassigned wolfSSL-Bot and SparkiDev Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants