Update SM2 methods

The default `./config` will enable the X86_64 ASM implementation of SM2. Use `./config -DGMSSL_NO_TURBO enable-ec_nistp_64_gcc_128` will enable the fast C implementation of SM2. The  `./config -DGMSSL_NO_TURBO` will use the original implementation.
This commit is contained in:
Zhi Guan
2019-01-26 17:26:03 +08:00
parent 674cada9bc
commit 7d5c18379f
8 changed files with 5433 additions and 5420 deletions

View File

@@ -2,7 +2,7 @@ LIBS=../../libcrypto
SOURCE[../../libcrypto]=\
ec_lib.c ecp_smpl.c ecp_mont.c ecp_nist.c ec_cvt.c ec_mult.c \
ec_err.c ec_curve.c ec_check.c ec_print.c ec_asn1.c ec_key.c \
ec2_smpl.c ec2_mult.c ec_ameth.c ec_pmeth.c eck_prn.c \
ec2_smpl.c ec2_mult.c ec_ameth.c ec_pmeth.c eck_prn.c ecp_sm2p256.c \
ecp_nistp224.c ecp_nistp256.c ecp_nistp521.c ecp_nistputil.c \
ecp_oct.c ec2_oct.c ec_oct.c ec_kmeth.c ecdh_ossl.c ecdh_kdf.c \
ecdsa_ossl.c ecdsa_sign.c ecdsa_vrf.c curve25519.c ecx_meth.c \

View File

@@ -3129,7 +3129,7 @@ static const ec_list_element curve_list[] = {
"RFC 5639 curve over a 512 bit prime field"},
#ifndef OPENSSL_NO_SM2
{NID_sm2p256v1, &_EC_SM2_PRIME_256V1.h,
# if defined(ECP_NISTZ256_ASM) && BN_BITS2 == 64
# if defined(ECP_NISTZ256_ASM) && BN_BITS2 == 64 && !defined(GMSSL_NO_TURBO)
EC_GFp_sm2z256_method,
# elif !defined(OPENSSL_NO_EC_NISTP_64_GCC_128)
EC_GFp_sm2p256_method,

View File

@@ -241,7 +241,7 @@ struct ec_group_st {
enum {
PCT_none,
PCT_nistp224, PCT_nistp256, PCT_nistp521, PCT_nistz256,
//PCT_sm2p256,
PCT_sm2p256,
PCT_sm2z256,
PCT_ec
} pre_comp_type;
@@ -575,7 +575,12 @@ int ec_group_simple_order_bits(const EC_GROUP *group);
* \return EC_METHOD object
*/
const EC_METHOD *EC_GFp_nistz256_method(void);
#endif
#ifndef OPENSSL_NO_SM2
# if defined(ECP_NISTZ256_ASM) && BN_BITS2 == 64 && !defined(GMSSL_NO_TURBO)
const EC_METHOD *EC_GFp_sm2z256_method(void);
# endif
#endif
size_t ec_key_simple_priv2oct(const EC_KEY *eckey,