Skip to content

Comments

Expose and report EC curve field degrees#29539

Closed
vdukhovni wants to merge 1 commit intoopenssl:masterfrom
vdukhovni:ec-bits
Closed

Expose and report EC curve field degrees#29539
vdukhovni wants to merge 1 commit intoopenssl:masterfrom
vdukhovni:ec-bits

Conversation

@vdukhovni
Copy link

Instead of reporting the bit count of the group order, report the field degree (matching any size number in the curve's name) and the symmetric-equivalent security-bits (adjusted down the the standard numbers (80, 112, 128, 192, 256).

Also expose the field degree as a gettable parameter, and add a getter for the EC_GROUP security bits.

Fixes: #29532

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

@vdukhovni vdukhovni requested review from beldmit, kroeckx and t-j-h January 3, 2026 11:18
@github-actions github-actions bot added severity: fips change The pull request changes FIPS provider sources severity: ABI change This pull request contains ABI changes labels Jan 3, 2026
beldmit
beldmit previously approved these changes Jan 3, 2026
Copy link
Member

@beldmit beldmit left a comment

Choose a reason for hiding this comment

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

LGTM

@beldmit beldmit added branch: master Applies to master branch approval: review pending This pull request needs review by a committer labels Jan 3, 2026
@beldmit
Copy link
Member

beldmit commented Jan 3, 2026

Do we need a similar change for EdDSA curves?

@petrovr
Copy link

petrovr commented Jan 3, 2026 via email

@vdukhovni
Copy link
Author

vdukhovni commented Jan 3, 2026

I would like to propose existing output lines to keep as is. Long story, but "printed" information could be the only way to know details for "externally managed keys". Please output new details on new line.

The original (now modified) output was a throw-away comment (%d bits) that was for human eyes only, unclear and often plausibly misleading. There is no stability contract on that particular output detail, especially in a new major release.

Perhaps "print" could write NIST security category(level) it is not in output yet. But this looks like general requirement for all key types. Roumen

That's a separate issue. There isn't presently a natural place to place such additional commentary, so a comment right after the key type is where it goes. It appears you're saying that this belongs across key types, that may be reasonable, but the TEXT output formats of the various key types are rather algorithm-specific, and we probably don't want to do a big-bang change for all the keys at once. If we can converge on a consensus in this PR, perhaps we could then tackle:

$ ./util/wrap.pl ./apps/openssl genpkey -quiet -algorithm rsa \
        -pkeyopt rsa_keygen_bits:1024 |
    ./util/wrap.pl ./apps/openssl pkey -noout -text | grep -v '^ '
Private-Key: (1024 bit, 2 primes)
modulus:
publicExponent: 65537 (0x10001)
privateExponent:
prime1:
prime2:
exponent1:
exponent2:
coefficient:

$ ./util/wrap.pl ./apps/openssl genpkey -genparam -algorithm DSA \
        -pkeyopt pbits:2048 -pkeyopt qbits:224 -pkeyopt digest:SHA256 \
        -pkeyopt gindex:1 -text |
    ./util/wrap.pl ./apps/openssl genpkey -paramfile /dev/stdin |
    ./util/wrap.pl ./apps/openssl pkey -noout -text | grep -v '^ ' 
Private-Key: (2048 bit)
priv:
pub: 
P:   
Q:   
G:   

$ ./util/wrap.pl ./apps/openssl genpkey -quiet -algorithm dh \
        -pkeyopt group:ffdhe2048 |
    ./util/wrap.pl ./apps/openssl pkey -noout -text | grep -v '^ '
DH Private-Key: (2048 bit)
private-key:
public-key:
GROUP: ffdhe2048

$ ./util/wrap.pl ./apps/openssl genpkey -quiet -algorithm ec \
        -pkeyopt ec_paramgen_curve:sm2 |
    ./util/wrap.pl ./apps/openssl pkey -noout -text | grep -v '^ '
Private-Key: (256 bit field, 128 bit security level)
priv:
pub:
ASN1 OID: SM2

$ ./util/wrap.pl ./apps/openssl genpkey -quiet -algorithm x25519 |
    ./util/wrap.pl ./apps/openssl pkey -noout -text | grep -v '^ '
X25519 Private-Key:
priv:
pub:

$ ./util/wrap.pl ./apps/openssl genpkey -quiet -algorithm ed25519 |
    ./util/wrap.pl ./apps/openssl pkey -noout -text | grep -v '^ '
ED25519 Private-Key:
priv:
pub:

$ ./util/wrap.pl ./apps/openssl genpkey -quiet -algorithm ml-kem-512 |
    ./util/wrap.pl ./apps/openssl pkey -noout -text | grep -v '^ '
ML-KEM-512 Private-Key:
seed:
dk:
ek:

$ ./util/wrap.pl ./apps/openssl genpkey -quiet -algorithm ml-dsa-44 |
    ./util/wrap.pl ./apps/openssl pkey -noout -text | grep -v '^ '
ML-DSA-44 Private-Key:
seed:
priv:
pub:

$ ./util/wrap.pl ./apps/openssl genpkey -quiet -algorithm slh-dsa-sha2-128f |
    ./util/wrap.pl ./apps/openssl pkey -noout -text | grep -v '^ '
SLH-DSA-SHA2-128f Private-Key:
priv:
pub:

Comment on lines -655 to -670
/*
* The following estimates are based on the values published
* in Table 2 of "NIST Special Publication 800-57 Part 1 Revision 4"
* at http://dx.doi.org/10.6028/NIST.SP.800-57pt1r4 .
*
* Note that the above reference explicitly categorizes algorithms in a
* discrete set of values {80, 112, 128, 192, 256}, and that it is
* relevant only for NIST approved Elliptic Curves, while OpenSSL
* applies the same logic also to other curves.
*
* Classifications produced by other standardazing bodies might differ,
* so the results provided for "bits of security" by this provider are
* to be considered merely indicative, and it is the users'
* responsibility to compare these values against the normative
* references that may be relevant for their intent and purposes.
*/
Copy link
Member

Choose a reason for hiding this comment

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

I would put the first paragraph of this comment into EC_GROUP_security_bits ... which is where the code is now moved to be in a single location ... a good cleanup - but the comment is useful (to me at least). I would drop the last paragraph however - that looks more like something for end user documentation rather than a code comment which is not going to be seen by any user of the capability ...

t-j-h
t-j-h previously approved these changes Jan 4, 2026
Copy link
Member

@t-j-h t-j-h left a comment

Choose a reason for hiding this comment

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

The commit text should be adjusted to note it is adding a parameter to report the field degree (and then using it to change the text output).

Note I think the current output is not useful for users (it is not what the user would immediately think it might be and it is wrong more than it is right for user usage).

@t-j-h t-j-h added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Jan 4, 2026
@t-j-h
Copy link
Member

t-j-h commented Jan 4, 2026

Note I do not think this should be merged as yet even though it has the necessary approvals - but I am not placing any hold as this follows our current process (only two approvals required).

There should be broader discussion on this change as we don't want to merge a change and then back it out if the consensus view differs.

I suggest anyone interested in this carefully read through the summary of what the current output is and how it is not what the user would expect and it not particularly useful. This change returns something the user can related to (the degree which is in the name) and also the security bits which is an addition I think we should place in all of the output formats to encourage awareness and use of that value.

Expose the EC field degree as a gettable parameter for both provided
and legacy EC keys.  In the latter case, drop a spurious assertion,
since even in debug builds an application may try to get an unknown
parameter, and this should return an error rather than abort.

In the EC `TEXT` encoding format, instead of reporting the bit count of
the group order, report the field degree (which matches the size number
in the curve's name when present) and also the symmetric-equivalent
security-bits (adjusted down the the standard numbers (80, 112, 128,
192, 256).

Along the way, add a missing getter method for the EC_GROUP security
bits.
@vdukhovni vdukhovni dismissed stale reviews from t-j-h and beldmit via a7ae7a7 January 4, 2026 03:01
@vdukhovni vdukhovni changed the title Adjust ECDSA -text reporting of curve bits Expose and report EC curve field degrees Jan 4, 2026
Copy link
Member

@t-j-h t-j-h left a comment

Choose a reason for hiding this comment

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

Still approved - changes are cosmetic only - so leaving approved.

Copy link
Member

@mbroz mbroz left a comment

Choose a reason for hiding this comment

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

Just reading through the whole story...

Definitely it should avoid changing any existing value in output, so if current text output is explicitely changed to "%d bit field, %d bit security level" it is IMO the best option.

@openssl-machine
Copy link
Collaborator

24 hours has passed since 'approval: done' was set, but as this PR has been updated in that time the label 'approval: ready to merge' is not being automatically set. Please review the updates and set the label manually.

@github-project-automation github-project-automation bot moved this from Waiting Review to Waiting Merge in Development Board Jan 5, 2026
@kroeckx
Copy link
Member

kroeckx commented Jan 5, 2026

So I'm wondering if we should do the same for something like RSA keys. That currently returns something like: "Private-Key: (2048 bit, 2 primes)"

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.

LGTM.

I'm okay with the output text change. It's breaking but that's what major versions are for and this is an improvement.

@t8m t8m added triaged: feature The issue/pr requests/adds a feature tests: exempted The PR is exempt from requirements for testing labels Jan 12, 2026
@jogme
Copy link
Contributor

jogme commented Jan 13, 2026

I guess this can be set ready for merge as the last approval was a week ago.

@jogme jogme 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 Jan 13, 2026
openssl-machine pushed a commit that referenced this pull request Jan 15, 2026
Expose the EC field degree as a gettable parameter for both provided
and legacy EC keys.  In the latter case, drop a spurious assertion,
since even in debug builds an application may try to get an unknown
parameter, and this should return an error rather than abort.

In the EC `TEXT` encoding format, instead of reporting the bit count of
the group order, report the field degree (which matches the size number
in the curve's name when present) and also the symmetric-equivalent
security-bits (adjusted down the the standard numbers (80, 112, 128,
192, 256).

Along the way, add a missing getter method for the EC_GROUP security
bits.

Reviewed-by: Kurt Roeckx <[email protected]>
Reviewed-by: Tim Hudson <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Saša Nedvědický <[email protected]>
MergeDate: Thu Jan 15 16:10:26 2026
(Merged from #29539)
@Sashan
Copy link
Contributor

Sashan commented Jan 15, 2026

pushed to master branch as e57f7941af

@Sashan Sashan closed this Jan 15, 2026
@github-project-automation github-project-automation bot moved this from Waiting Merge to Done in Development Board Jan 15, 2026
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 severity: ABI change This pull request contains ABI changes severity: fips change The pull request changes FIPS provider sources tests: exempted The PR is exempt from requirements for testing triaged: feature The issue/pr requests/adds a feature

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Better rounding of ECDSA key bit counts reported with -text key outputs?