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 EDDSA FIPS self tests. #22112

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

Conversation

slontis
Copy link
Member

@slontis slontis commented Sep 15, 2023

See FIPS 140-3 IG Section 10.3.A Part 11
Indicates ECDSA requires a sign and verify test.
Note 11 states that HashEdDSA is not required to be tested if PureEdDSA is tested. Note 12 indicates that both ED25519 and X448 need to be tested.

Since ED uses the oneshot interface, additional API's needed to be exposed to the FIPS provider using #ifdef FIPS_MODULE.

Changed ED25518 and ED448 to use fips=true in the FIPS provider. Updated documentation for provider lists for EDDSA.

Checklist
  • documentation is added or updated
  • tests are added or updated

@slontis slontis added branch: master Merge to master branch approval: review pending This pull request needs review by a committer approval: otc review pending This pull request needs review by an OTC member labels Sep 15, 2023
@@ -86,7 +85,6 @@ static int evp_md_ctx_reset_ex(EVP_MD_CTX *ctx, int keep_fetched)
EVP_PKEY_CTX_free(ctx->pctx);
Copy link
Member Author

Choose a reason for hiding this comment

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

Without this change we get a memory leak.. since the digestsign interface uses ctx->pctx

Copy link
Member Author

Choose a reason for hiding this comment

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

Line 565 of self_test_kats.c..

Copy link
Member

Choose a reason for hiding this comment

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

I think you meant that last comment to go against the other thread about the init field in st_kat_sign_st... :-)

@github-actions github-actions bot added the severity: fips change The pull request changes FIPS provider sources label Sep 15, 2023
@mattcaswell mattcaswell removed the approval: otc review pending This pull request needs review by an OTC member label Sep 15, 2023
@slontis
Copy link
Member Author

slontis commented Sep 15, 2023

As this is FIPS related it is probably not required for OpenSSL 3.2 (unless 3.2 is going to become FIPS validated).

Copy link
Contributor

@paulidale paulidale left a comment

Choose a reason for hiding this comment

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

We could consider this for 3.1 if we end up validating a version other than 3.1.2.

@paulidale
Copy link
Contributor

OMC: should we including this in the 3.1.x validation?

@paulidale paulidale added the hold: need omc decision The OMC needs to make a decision label Sep 15, 2023
@t8m t8m added the triaged: feature The issue/pr requests/adds a feature label Sep 15, 2023
@paulidale paulidale added approval: done This pull request has the required number of approvals approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: review pending This pull request needs review by a committer approval: done This pull request has the required number of approvals labels Sep 26, 2023
@paulidale
Copy link
Contributor

IMO: this is a working group discussion.
I'm in favour of 3.1 getting this.
I'm unsure about 3.0.

@mattcaswell
Copy link
Member

There is a conflict in this PR.

Also, there is a hold on this PR, but the question seems to be about 3.1. Is this going into master, and should it be there for the beta?

@t8m
Copy link
Member

t8m commented Oct 25, 2023

I think we could give an post-beta exception if it would be approved to go in 3.1 by OMC.

Otherwise it can as well wait for 3.3.

@t-j-h
Copy link
Member

t-j-h commented Oct 25, 2023

This is a feature addition - this is not in the fips provider and it is being added.
It is not a simple addition of a "test".

As such it has to wait for 3.3.

@paulidale
Copy link
Contributor

I think this is a question for WG.

The 140-3 submission is long delayed and we've still got a possibility of including EdDSA.
We know that EdDSA works, so it's really just changing "no" to "yes" in a few places and adding this test.

The 140-3 submission requires other changes in addition.

@t8m
Copy link
Member

t8m commented Nov 15, 2023

OMC: This can go into master branch. Not in 3.1.

@t8m t8m added hold: need rebase The pull request needs to be rebased and removed hold: need omc decision The OMC needs to make a decision labels Nov 15, 2023
@t8m
Copy link
Member

t8m commented Nov 16, 2023

@slontis please rebase

@slontis
Copy link
Member Author

slontis commented Nov 17, 2023

rebased

@t8m
Copy link
Member

t8m commented Nov 20, 2023

CI is relevant

@t8m t8m removed the approval: ready to merge The 24 hour grace period has passed, ready to merge label Nov 20, 2023
@t8m t8m removed the hold: need rebase The pull request needs to be rebased label Nov 20, 2023
@t8m
Copy link
Member

t8m commented Nov 20, 2023

What about, instead of using the DigestSign API for the self test, adding the EDDSA support to the EVP_PKEY_sign()/verify()?

See FIPS 140-3 IG Section 10.3.A Part 11
Indicates ECDSA requires a sign and verify test.
Note 11 states that HashEdDSA is not required to be tested if PureEdDSA is tested.
Note 12 indicates that both ED25519 and X448 need to be tested.

Since ED uses the oneshot interface, additional API's needed to be exposed to the
FIPS provider using #ifdef FIPS_MODULE.

Changed ED25518 and ED448 to use fips=true in the FIPS provider.
Updated documentation for provider lists for EDDSA.
@slontis
Copy link
Member Author

slontis commented Feb 26, 2024

rebased again

@slontis slontis added the approval: done This pull request has the required number of approvals label Feb 26, 2024
"ED448",
NULL,
ed448_key,
NULL, 0, NULL, 0, NULL, 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi,

When I pick and test this commit, I found it should be as the following, or it will failed on self-tests.

        ITM(sig_kat_entropyin),
        ITM(sig_kat_nonce),
        ITM(sig_kat_persstr),

Therefore, I would like to know whether it is a typo here, or do I misunderstand something?

Thank you.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will have to reorder the code since this doesnt print anything when it fails here.

Copy link
Member Author

Choose a reason for hiding this comment

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

EDDSA works without the entropy.

Copy link
Contributor

Choose a reason for hiding this comment

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

I found that it failed in set_kat_drbg.

Since EDDSA works without the entropy, we may need to skip the KAT setup for it?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes - I need to shift this inside the function so that it runs the self test callback with an error set..

@slontis slontis added approval: review pending This pull request needs review by a committer approval: otc review pending This pull request needs review by an OTC member and removed approval: done This pull request has the required number of approvals labels Feb 26, 2024
@slontis
Copy link
Member Author

slontis commented Feb 26, 2024

It looks like the tests fail here - so I will fix it..

@slontis
Copy link
Member Author

slontis commented Feb 26, 2024

Had to do a slight change since a failure in the entropy setup was not being reported as a failure by the self test callback (since it was outside the onstart()/onend() callbacks.

@openssl-machine
Copy link
Collaborator

This PR is in a state where it requires action by @openssl/otc but the last update was 30 days ago

@openssl-machine
Copy link
Collaborator

This PR is in a state where it requires action by @openssl/otc but the last update was 61 days ago

paramsinit = OSSL_PARAM_BLD_to_param(bldinit);

fromctx = EVP_PKEY_CTX_new_from_name(libctx, t->algorithm, "");
if (fromctx == NULL\
Copy link
Member

Choose a reason for hiding this comment

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

Why the trailing \ here?

mctx = EVP_MD_CTX_new();
if (mctx == NULL
|| EVP_DigestSignInit_ex(mctx, NULL, NULL, libctx, NULL,
pkey, paramsinit)<= 0)
Copy link
Member

Choose a reason for hiding this comment

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

nit: missing space before <=

@@ -697,13 +786,16 @@ static int self_test_signatures(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx)

for (i = 0; ret && i < (int)OSSL_NELEM(st_kat_sign_tests); ++i) {
t = st_kat_sign_tests + i;
if (!set_kat_drbg(libctx, t->entropy, t->entropy_len,
t->nonce, t->nonce_len, t->persstr, t->persstr_len))
return 0;
Copy link
Member

Choose a reason for hiding this comment

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

Why is this no longer needed?

@openssl-machine
Copy link
Collaborator

This PR is in a state where it requires action by @openssl/otc but the last update was 30 days ago

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval: otc review pending This pull request needs review by an OTC member approval: review pending This pull request needs review by a committer branch: master Merge to master branch severity: fips change The pull request changes FIPS provider sources triaged: feature The issue/pr requests/adds a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants