This commit is contained in:
2018-06-05 08:17:23 +09:00
parent f03e5e0d15
commit 5aee3a55b9
17 changed files with 859 additions and 1059 deletions
+15 -11
View File
@@ -17,7 +17,7 @@
#include "internal/evp_int.h"
#if !defined(OPENSSL_NO_SM2)
# include <openssl/sm2.h>
# include "internal/sm2.h"
#endif
/* EC pkey context structure */
@@ -126,7 +126,7 @@ static int pkey_ec_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
#if defined(OPENSSL_NO_SM2)
return -1;
#else
ret = SM2_sign(type, tbs, tbslen, sig, &sltmp, ec);
ret = sm2_sign(type, tbs, tbslen, sig, &sltmp, ec);
#endif
} else {
ret = ECDSA_sign(type, tbs, tbslen, sig, &sltmp, ec);
@@ -156,7 +156,7 @@ static int pkey_ec_verify(EVP_PKEY_CTX *ctx,
#if defined(OPENSSL_NO_SM2)
ret = -1;
#else
ret = SM2_verify(type, tbs, tbslen, sig, siglen, ec);
ret = sm2_verify(type, tbs, tbslen, sig, siglen, ec);
#endif
} else {
ret = ECDSA_verify(type, tbs, tbslen, sig, siglen, ec);
@@ -223,12 +223,14 @@ static int pkey_ecies_encrypt(EVP_PKEY_CTX *ctx,
md_type = NID_sm3;
if (out == NULL) {
*outlen = SM2_ciphertext_size(ec, EVP_get_digestbynid(md_type),
inlen);
ret = 1;
if (!sm2_ciphertext_size(ec, EVP_get_digestbynid(md_type), inlen,
outlen))
ret = -1;
else
ret = 1;
}
else {
ret = SM2_encrypt(ec, EVP_get_digestbynid(md_type),
ret = sm2_encrypt(ec, EVP_get_digestbynid(md_type),
in, inlen, out, outlen);
}
# endif
@@ -261,12 +263,14 @@ static int pkey_ecies_decrypt(EVP_PKEY_CTX *ctx,
md_type = NID_sm3;
if (out == NULL) {
*outlen = SM2_plaintext_size(ec, EVP_get_digestbynid(md_type),
inlen);
ret = 1;
if (!sm2_plaintext_size(ec, EVP_get_digestbynid(md_type), inlen,
outlen))
ret = -1;
else
ret = 1;
}
else {
ret = SM2_decrypt(ec, EVP_get_digestbynid(md_type),
ret = sm2_decrypt(ec, EVP_get_digestbynid(md_type),
in, inlen, out, outlen);
}
# endif