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

Fix some MAC issues #8584

Closed
wants to merge 3 commits into from
Closed

Fix some MAC issues #8584

wants to merge 3 commits into from

Conversation

mattcaswell
Copy link
Member

Don't allow SHAKE128/SHAKE256 with HMAC.
Correctly check the return code of EVP_MAC_ctrl everwhere it is used

Fixes #8563.

EVP_MAC_ctrl is documented to return 0 or -1 on failure. Numerous places
were not getting this check correct.
@mattcaswell mattcaswell added the branch: master Merge to master branch label Mar 26, 2019
@mattcaswell
Copy link
Member Author

1.1.1 backport in #8585.

@kroeckx
Copy link
Member

kroeckx commented Mar 26, 2019

I'm not sure how "currently" this is. The shake functions just don't seem to make sense to use since they do not have a fixed output length.

@mattcaswell
Copy link
Member Author

I could drop the word "currently" throughout if you prefer. My only reasoning for including it was allowing for the possibility that someone might in the future specify how to handle this type of digest.

@@ -202,6 +202,9 @@ For MAC implementations that use an underlying computation algorithm,
these controls set what the algorithm should be, and the engine that
implements the algorithm if needed.

Note that not all algorithms may support all digests. HMAC does not currently
support SHAKE128 or SHAKE256.
Copy link
Contributor

Choose a reason for hiding this comment

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

Worth saying this as variable output length digests?

@paulidale paulidale added the approval: done This pull request has the required number of approvals label Mar 26, 2019
Copy link
Contributor

@mspncp mspncp left a comment

Choose a reason for hiding this comment

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

I tested both branches #8584 and #8585 on linux using debug and release configuration and was able to verify Matt's #8563 (comment).

The "currently" should be dropped, the other suggestion is optional.

@@ -35,6 +35,10 @@ int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
return 0;
}

/* We currently don't support shake128 and shake256 with HMAC */
if ((EVP_MD_meth_get_flags(md) & EVP_MD_FLAG_XOF) != 0)
return 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @kroeckx that "currently" should be dropped because it is misleading. How about the following alternative formulation?

/*
 * The HMAC construction is not allowed  to be used with the
 * extendable-output functions (XOF) shake128 and shake256.
 */

(BTW: @tiran you could have told us this long time ago ;-) )

@@ -202,6 +202,9 @@ For MAC implementations that use an underlying computation algorithm,
these controls set what the algorithm should be, and the engine that
implements the algorithm if needed.

Note that not all algorithms may support all digests. HMAC does not currently
Copy link
Contributor

Choose a reason for hiding this comment

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

remove "currently"

Copy link
Contributor

@mspncp mspncp left a comment

Choose a reason for hiding this comment

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

reconfirmed

@mattcaswell
Copy link
Member Author

Updates pushed addressing all feedback. Please reconfirm?

Copy link
Contributor

@mspncp mspncp left a comment

Choose a reason for hiding this comment

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

LGTM

@mattcaswell
Copy link
Member Author

Pushed. Thanks.

levitte pushed a commit that referenced this pull request Mar 27, 2019
EVP_MAC_ctrl is documented to return 0 or -1 on failure. Numerous places
were not getting this check correct.

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from #8584)
levitte pushed a commit that referenced this pull request Mar 27, 2019
See discussion in github issue #8563

Fixes #8563

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from #8584)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval: done This pull request has the required number of approvals branch: master Merge to master branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants