SM2 failed to generate public key from private key #24305
Labels
branch: master
Merge to master branch
branch: 3.0
Merge to openssl-3.0 branch
branch: 3.1
Merge to openssl-3.1
branch: 3.2
Merge to openssl-3.2
branch: 3.3
Merge to openssl-3.3
help wanted
triaged: bug
The issue/pr is/fixes a bug
Problem Description:
SM2 failed to generate public key from private key of 3.0 and 3.2.
command
1. generate sm2 private key file by OpenSSL commands of 3.0 and 3.2:
openssl ecparam -genkey -name SM2 -out sm2-private.key
2. failed to generate public key file with sm2 private key file
openssl ec -in sm2-private.key -pubout -out sm2-public.key
Preliminary analysis:
private key file
file generated by 1.1 as
-----BEGIN EC PARAMETERS-----
-----END EC PARAMETERS-----
-----BEGIN EC PRIVATE KEY-----
-----END EC PRIVATE KEY-----
file generated by 3.0 or 3.2 as
-----BEGIN SM2 PARAMETERS-----
-----END SM2 PARAMETERS-----
-----BEGIN SM2 PRIVATE KEY-----
-----END SM2 PRIVATE KEY-----
error in generating public key
read EC key
unable to enable public key encoding
4076A04EF87F0000:error:030000A3:digital envelope routines:EVP_PKEY_set_params:invalid key:crypto/evp/p_lib.c:2386:
analysis
Guess whether the high version is not compatible with the low version, or update the usage rules of related commands, because this group of commands is correct in version 1.1.
Tasks
The text was updated successfully, but these errors were encountered: