Skip to content

Comments

Refactor sm2_id#11302

Merged
openssl-machine merged 6 commits intoopenssl:masterfrom
levitte:refactor-sm2id
Mar 15, 2020
Merged

Refactor sm2_id#11302
openssl-machine merged 6 commits intoopenssl:masterfrom
levitte:refactor-sm2id

Conversation

@levitte
Copy link
Member

@levitte levitte commented Mar 10, 2020

The idea is to stop special-casing the SM2 ID. In the center core, it means that digest_custom() is called slightly later, which allows all controls to be performed after EVP_DigestSignInit(), instead of having to call the SM2 ID setting control before and the rest after.

This allows us to remove the special -sm2-id and -sm2-hex-id flags in a number of apps.

For more information, see the commit comments.

Fixes #11293

@levitte levitte requested review from InfoHunter, romen and slontis March 10, 2020 22:16
@levitte
Copy link
Member Author

levitte commented Mar 10, 2020

(some famously heard me say "I have a branch" during a vid-call this morning... this is what I was talking about, with some cleanup)

@levitte
Copy link
Member Author

levitte commented Mar 12, 2020

Rebased and hopefully last fight with picky compilers

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I like this diagnostic output. The function seems to be generic but the output is for a particular case.

@InfoHunter
Copy link
Member

Rebased and hopefully last fight with picky compilers

Unfortunately it seems the red cross is relevant

@levitte
Copy link
Member Author

levitte commented Mar 12, 2020

CI kicking close/re-open

@levitte levitte closed this Mar 12, 2020
@levitte levitte reopened this Mar 12, 2020
@levitte
Copy link
Member Author

levitte commented Mar 12, 2020

@InfoHunter, it seems that Travis didn't pick up on my last update

@InfoHunter
Copy link
Member

Ahh, so it is.

@levitte
Copy link
Member Author

levitte commented Mar 12, 2020

Travis still out of sync, so I did some squashing and pushed that. Maybe that'll kick it hard enough...

@InfoHunter
Copy link
Member

Hmm, it remains...

@InfoHunter
Copy link
Member

Besides, considering the SM2 implementation changed recently , I think the man7/SM2.pod needs to get an update as well. Would you prefer to do that in this PR or I open a new PR fixing that, @levitte ?

@levitte
Copy link
Member Author

levitte commented Mar 13, 2020

I'm refactoring apps/lib/app_x509.c a bit

As for doc/man7/SM2.pod, I think that a separate PR is due. @InfoHunter, please feel free to work with it.

@levitte
Copy link
Member Author

levitte commented Mar 13, 2020

... some days, it's hard to stand over zealous compilers.
[sigh]
another round...

@levitte
Copy link
Member Author

levitte commented Mar 14, 2020

CIs are happy, the Travis failure is the usual timeout.

Copy link
Member

@InfoHunter InfoHunter left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@levitte levitte added approval: done This pull request has the required number of approvals branch: master Applies to master branch labels Mar 14, 2020
@openssl-machine
Copy link
Collaborator

24 hours has passed since 'approval: done' was set, but this PR has failing CI tests. Once the tests pass it will get moved to 'approval: ready to merge' automatically, alternatively please review and set the label manually.

@levitte levitte added approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: done This pull request has the required number of approvals labels Mar 15, 2020
@levitte levitte added this to the 3.0.0 milestone Mar 15, 2020
@levitte
Copy link
Member Author

levitte commented Mar 15, 2020

@InfoHunter, thanks for the review!

Merge coming up

levitte added 6 commits March 15, 2020 19:42
A huge problem with calling digest_custom() already in the
initialization of DigestSign, DigestVerify etc, is that it force all
callers to know that certain controls must be performed before Init
and the rest after.  This has lead to quite interesting hacks in our
own openssl app, where the SM2 ID had to get special treatment instead
of just being another sign option or verification option among others.

This change moves the call of digest_custom() to the Update and Final
functions, to be done exactly once, subject to a flag that's set in
the Init function.  Seeing to the process of data, through these
operations, this makes no difference at all.  Seeing to making it
possible to perform all controls after the Init call, this makes a
huge difference.

Fixes openssl#11293

Reviewed-by: Paul Yang <[email protected]>
(Merged from openssl#11302)
- X509_set0_sm2_id() -> X509_set0_distinguishing_id()
- X509_get0_sm2_id() -> X509_get0_distinguishing_id()
- X509_REQ_set0_sm2_id -> X509_REQ_set0_distinguishing_id()
- X509_REQ_get0_sm2_id -> X509_REQ_get0_distinguishing_id()

The reason for this rename is that the SM2 ID isn't really a unique
SM2 data item, but rather a re-use of the Distinguished that is
defined in ISO/IEC 15946-3 as well as in FIPS 196, with no special
attribution toward any algorithm in particular.

Fixes openssl#11293

Reviewed-by: Paul Yang <[email protected]>
(Merged from openssl#11302)
Because we start using Distinguished ID, we also define the key name
"distid", possibly prefixed with "hex", but keep "sm2_id" and
"sm2_hex_id" for compatibility with GmSSL.

Fixes openssl#11293

Reviewed-by: Paul Yang <[email protected]>
(Merged from openssl#11302)
This should really be part of libcrypto, but since this looks like
added legacy support, it's preferable to keep it in apps for now.

This allows to build functions that add user given verification
options to X509 and X509_REQ structures.

Fixes openssl#11293

Reviewed-by: Paul Yang <[email protected]>
(Merged from openssl#11302)
SM2 IDs are now passed entirely as '-pkeyopt', '-sigopt' or '-vfyopt'
values, just like any other valid option.

Fixes openssl#11293

Reviewed-by: Paul Yang <[email protected]>
(Merged from openssl#11302)
@openssl-machine openssl-machine merged commit fda127b into openssl:master Mar 15, 2020
@levitte levitte deleted the refactor-sm2id branch March 15, 2020 18:44
@InfoHunter
Copy link
Member

Since PR #11302 has been merged so I don't think this is a problem anymore

I had a re-thought on this. It seems current design doesn't allow passing the dist-ID into a provider, so the user can only set the dist-ID in advance and then the calculation of the dist-ID is computed in the update process inside a provider. Is this what you originally intended? @levitte

@InfoHunter
Copy link
Member

Hmmm. The above comment was intended to post in PR #1124, and I posted to the wrong PR but nevertheless we can still discuss here...

@levitte
Copy link
Member Author

levitte commented Mar 16, 2020

You mean #11248. I would prefer we have the discussion there, as that's an open PR

@levitte levitte mentioned this pull request Aug 23, 2020
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: ready to merge The 24 hour grace period has passed, ready to merge branch: master Applies to master branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The special treatment of sm2_id shouldn't be necessary

4 participants