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

(3.x) Known result tests for EC compression compatibility validation + #16624 changes #18320

Closed
wants to merge 3 commits into from

Conversation

hlandau
Copy link
Member

@hlandau hlandau commented May 16, 2022

Follow-on from #18083.

These tests enforce 1.1 behaviour so they will naturally fail. I trust these results will be of interest.

@hlandau hlandau 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 triaged: bug The issue/pr is/fixes a bug labels May 16, 2022
@hlandau hlandau requested review from romen and mattcaswell May 16, 2022 12:34
@hlandau hlandau self-assigned this May 16, 2022
@t8m
Copy link
Member

t8m commented May 16, 2022

Now, could we rebase #16624 on top of this?

…o UNCOMPRESSED

Original patch by Nicola Tuveri.
@hlandau hlandau changed the title (3.x) Known result tests for EC compression compatibility validation (3.x) Known result tests for EC compression compatibility validation + #16624 changes May 17, 2022
@hlandau
Copy link
Member Author

hlandau commented May 17, 2022

PR updated to incorporate Nicola's changes. These don't in themselves appear to be enough to have the tests pass. @romen

@github-actions github-actions bot added the severity: fips change The pull request changes FIPS provider sources label May 17, 2022
@t8m
Copy link
Member

t8m commented May 18, 2022

The SM2 curve test failure is expected and correct. We no longer support SM2 curve with EC in 3.x. So that part of the tests needs to be dropped.

@hlandau
Copy link
Member Author

hlandau commented May 18, 2022

Updated to drop SM2.

@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

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.

I sort of wonder about the need for 1100 test files but more tests is better generally.

@@ -1209,9 +1216,17 @@ static int test_fromdata_ec(void)
if (OSSL_PARAM_BLD_push_utf8_string(bld, OSSL_PKEY_PARAM_GROUP_NAME,
curve, 0) <= 0)
goto err;
/*
* We intentionally provide the input point in compressed format,
* and avoid to set `OSSL_PKEY_PARAM_EC_POINT_CONVERSION_FORMAT`.
Copy link
Contributor

Choose a reason for hiding this comment

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

and avoid setting ...

|| !TEST_true(out_pub[0] == (POINT_CONVERSION_COMPRESSED + 1))

/*
* Our providers use uncompressed format as default if
Copy link
Contributor

Choose a reason for hiding this comment

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

use uncompressed format by default if

}

SKIP: {
skip "EC is not supported by this OpenSSL build", scalar @curves if disabled("ec");
Copy link
Contributor

Choose a reason for hiding this comment

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

Might a plan skip_all up at the plan be clearer?

size_t i;

num_known_curves = EC_get_builtin_curves(NULL, 0);
known_curves = OPENSSL_malloc(num_known_curves*sizeof(*known_curves));
Copy link
Contributor

Choose a reason for hiding this comment

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

space around the multiply

if (known_curve_names == NULL)
goto fail;

for (i=0; i<num_known_curves; ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

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

spaces around the equals and less than.

BIO *b = NULL;
char filename[256];

OPENSSL_assert(param_formats_i[param_format_i] >= 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

TEST_xxx instead of asserts perhaps?

* serialization and deserialization.
*/
/* For each supported compression format (and unspecified) */
for (ci=0; ci<OSSL_NELEM(comp_formats_i); ++ci)
Copy link
Contributor

Choose a reason for hiding this comment

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

Spaces around operators here and elsewhere.

@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

@t8m t8m removed 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 Jul 21, 2022
@jogme
Copy link

jogme commented Oct 6, 2022

@hlandau Hi, do you have any update on this? Do you need any help with it? It is open for quite a long time and I would like to have the changes.

Copy link
Member

@slontis slontis left a comment

Choose a reason for hiding this comment

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

This seems like overkill to me. @romen Is there a subset of this that would be sufficient for coverage?

@romen
Copy link
Member

romen commented Oct 6, 2022

This seems like overkill to me. @romen Is there a subset of this that would be sufficient for coverage?

Well, that's for OTC to say: so far I only indicated what was asked by the OTC before evaluating the merge of #16624.

Looking at my notes, the OTC ask was to:

  • test both programmatically (i.e., via EVP_PKEY_* and EC_*) and through the relevant CLI apps, what are all the possible outcomes in 1.1.1
  • ensure 1.1.1 behavior is matched in 3.0, both for functions and apps.
  • Tests should cover both newly generated keys and keys parsed from input, across all curves and encoding combinations (i.e., [compressed, uncompressed, hybrid] * [named_curve, custom_curve, named_but_with_explicit_params])

@hlandau
Copy link
Member Author

hlandau commented Oct 6, 2022

As far as I recall this PR revealed that the behaviour does not match that of 1.1.1. So revision to #16624 would be needed.

@romen
Copy link
Member

romen commented Oct 6, 2022

As far as I recall this PR revealed that the behaviour does not match that of 1.1.1. So revision to #16624 would be needed.

This PR already includes the changes from #16624 AFAICT.

IIRC, by asking the thorough testing mentioned before, OTC basically wanted to see 3 things before deciding:

  • diff of testing results between 1.1.1 and 3.0, before PR#16624 (to justify PR#16624 as a bug fix)
  • diff of testing results between 1.1.1 and 3.0, after PR#16624 (to confirm PR#16624 is a complete fix)
  • incorporate the developed tests in 3.0, to ensure we detect changes on this matter in the future, as it can be subtle

@hlandau
Copy link
Member Author

hlandau commented Oct 6, 2022

Yes, this PR includes #16624, however the tests fail, demonstrating that the behaviour is not the same between 1.1.1 and 3.0+#16624. So unless I'm mistaken, #16624 needs to be revised so that it creates the same behaviour as 1.1.1, or the OTC needs to decide what we want to do instead.

@romen
Copy link
Member

romen commented Oct 6, 2022

Closing and reopening to trigger the tests again, and see what fails

@romen romen closed this Oct 6, 2022
@romen romen reopened this Oct 6, 2022
@romen
Copy link
Member

romen commented Oct 6, 2022

Also, looking at the last commit, I think that while dropping SM2 from testing for 3.0 makes some sense, as it is handled differently, the fact that it shares the same encoding format as EC keys means that OTC should take an explicit decision about what to do with it.

  • Is it fine to just drop SM2 from these tests?
  • Do we need to compensate with tests that ensure parsing SM2 keys works according to expectations in 3.0 (and that these expectations are slightly different than 1.1.1?)

@beldmit
Copy link
Member

beldmit commented Oct 6, 2022

@InfoHunter could you please tell us anything about SM2?

@Jakuje
Copy link
Contributor

Jakuje commented Dec 21, 2022

If I am right, this was merged as #19681 and there is #19901 for the backport to 3.0 branch. Can we get this closed/updated as resolved?

@hlandau
Copy link
Member Author

hlandau commented Aug 1, 2023

Closing as non-current; can be re-opened if this is revisited

@hlandau hlandau closed this Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
branch: master Merge to master branch severity: fips change The pull request changes FIPS provider sources triaged: bug The issue/pr is/fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants