mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-08-10 07:53:57 +08:00
more sm. tests
This commit is contained in:
@@ -68,15 +68,20 @@ int SM2_CIPHERTEXT_VALUE_size(const EC_GROUP *group,
|
||||
EC_KEY *ec_key = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
|
||||
if (!(ec_key = EC_KEY_new())) {
|
||||
SM2err(SM2_F_SM2_CIPHERTEXT_VALUE_SIZE, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (!EC_KEY_set_group(ec_key, group)) {
|
||||
SM2err(SM2_F_SM2_CIPHERTEXT_VALUE_SIZE, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (!EC_KEY_generate_key(ec_key)) {
|
||||
SM2err(SM2_F_SM2_CIPHERTEXT_VALUE_SIZE, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
len += EC_POINT_point2oct(group, EC_KEY_get0_public_key(ec_key),
|
||||
params->point_form, NULL, 0, NULL);
|
||||
len += mlen;
|
||||
@@ -107,11 +112,13 @@ int SM2_CIPHERTEXT_VALUE_encode(const SM2_CIPHERTEXT_VALUE *cv,
|
||||
size_t ptlen, cvlen;
|
||||
|
||||
if (!bn_ctx) {
|
||||
SM2err(SM2_F_SM2_CIPHERTEXT_VALUE_ENCODE, SM2_R_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(ptlen = EC_POINT_point2oct(ec_group, cv->ephem_point,
|
||||
params->point_form, NULL, 0, bn_ctx))) {
|
||||
SM2err(SM2_F_SM2_CIPHERTEXT_VALUE_ENCODE, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
cvlen = ptlen + cv->ciphertext_size + cv->mactag_size;
|
||||
@@ -122,11 +129,13 @@ int SM2_CIPHERTEXT_VALUE_encode(const SM2_CIPHERTEXT_VALUE *cv,
|
||||
goto end;
|
||||
|
||||
} else if (*buflen < cvlen) {
|
||||
SM2err(SM2_F_SM2_CIPHERTEXT_VALUE_ENCODE, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!(ptlen = EC_POINT_point2oct(ec_group, cv->ephem_point,
|
||||
params->point_form, buf, *buflen, bn_ctx))) {
|
||||
SM2err(SM2_F_SM2_CIPHERTEXT_VALUE_ENCODE, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
buf += ptlen;
|
||||
@@ -158,17 +167,17 @@ SM2_CIPHERTEXT_VALUE *SM2_CIPHERTEXT_VALUE_decode(
|
||||
}
|
||||
|
||||
if (!(fixlen = SM2_CIPHERTEXT_VALUE_size(ec_group, params, 0))) {
|
||||
fprintf(stderr, "%s %d\n", __FILE__, __LINE__);
|
||||
SM2err(SM2_F_SM2_CIPHERTEXT_VALUE_DECODE, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (buflen <= fixlen) {
|
||||
fprintf(stderr, "%s %d\n", __FILE__, __LINE__);
|
||||
SM2err(SM2_F_SM2_CIPHERTEXT_VALUE_DECODE, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!(ret = OPENSSL_malloc(sizeof(SM2_CIPHERTEXT_VALUE)))) {
|
||||
fprintf(stderr, "%s %d\n", __FILE__, __LINE__);
|
||||
SM2err(SM2_F_SM2_CIPHERTEXT_VALUE_DECODE, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -176,14 +185,13 @@ SM2_CIPHERTEXT_VALUE *SM2_CIPHERTEXT_VALUE_decode(
|
||||
ret->ciphertext_size = buflen - fixlen;
|
||||
ret->ciphertext = OPENSSL_malloc(ret->ciphertext_size);
|
||||
if (!ret->ephem_point || !ret->ciphertext) {
|
||||
fprintf(stderr, "%s %d\n", __FILE__, __LINE__);
|
||||
SM2err(SM2_F_SM2_CIPHERTEXT_VALUE_DECODE, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
ptlen = fixlen - SM2_ENC_PARAMS_mactag_size(params);
|
||||
if (!EC_POINT_oct2point(ec_group, ret->ephem_point, buf, ptlen, bn_ctx)) {
|
||||
fprintf(stderr, "%s %d\n", __FILE__, __LINE__);
|
||||
ERR_print_errors_fp(stdout);
|
||||
SM2err(SM2_F_SM2_CIPHERTEXT_VALUE_DECODE, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -242,8 +250,9 @@ end:
|
||||
}
|
||||
|
||||
int SM2_encrypt(const SM2_ENC_PARAMS *params,
|
||||
unsigned char *out, size_t *outlen,
|
||||
const unsigned char *in, size_t inlen,
|
||||
unsigned char *out, size_t *outlen, EC_KEY *ec_key)
|
||||
EC_KEY *ec_key)
|
||||
{
|
||||
int ret = 0;
|
||||
const EC_GROUP *ec_group = EC_KEY_get0_group(ec_key);
|
||||
@@ -251,6 +260,7 @@ int SM2_encrypt(const SM2_ENC_PARAMS *params,
|
||||
int len;
|
||||
|
||||
if (!(len = SM2_CIPHERTEXT_VALUE_size(ec_group, params, inlen))) {
|
||||
SM2err(SM2_F_SM2_ENCRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -263,9 +273,11 @@ int SM2_encrypt(const SM2_ENC_PARAMS *params,
|
||||
}
|
||||
|
||||
if (!(cv = SM2_do_encrypt(params, in, inlen, ec_key))) {
|
||||
SM2err(SM2_F_SM2_ENCRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (!SM2_CIPHERTEXT_VALUE_encode(cv, ec_group, params, out, outlen)) {
|
||||
SM2err(SM2_F_SM2_ENCRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -293,6 +305,7 @@ SM2_CIPHERTEXT_VALUE *SM2_do_encrypt(const SM2_ENC_PARAMS *params,
|
||||
int nbytes;
|
||||
unsigned char dgst[EVP_MAX_MD_SIZE];
|
||||
unsigned int dgstlen;
|
||||
int mactag_size;
|
||||
size_t len;
|
||||
int i;
|
||||
|
||||
@@ -305,6 +318,7 @@ SM2_CIPHERTEXT_VALUE *SM2_do_encrypt(const SM2_ENC_PARAMS *params,
|
||||
|
||||
/* init ciphertext_value */
|
||||
if (!(cv = OPENSSL_malloc(sizeof(SM2_CIPHERTEXT_VALUE)))) {
|
||||
SM2err(SM2_F_SM2_DO_ENCRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
bzero(cv, sizeof(SM2_CIPHERTEXT_VALUE));
|
||||
@@ -312,6 +326,7 @@ SM2_CIPHERTEXT_VALUE *SM2_do_encrypt(const SM2_ENC_PARAMS *params,
|
||||
cv->ciphertext = OPENSSL_malloc(inlen);
|
||||
cv->ciphertext_size = inlen;
|
||||
if (!cv->ephem_point || !cv->ciphertext) {
|
||||
SM2err(SM2_F_SM2_DO_ENCRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -322,14 +337,17 @@ SM2_CIPHERTEXT_VALUE *SM2_do_encrypt(const SM2_ENC_PARAMS *params,
|
||||
bn_ctx = BN_CTX_new();
|
||||
md_ctx = EVP_MD_CTX_create();
|
||||
if (!point || !n || !h || !k || !bn_ctx || !md_ctx) {
|
||||
SM2err(SM2_F_SM2_DO_ENCRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* init ec domain parameters */
|
||||
if (!EC_GROUP_get_order(ec_group, n, bn_ctx)) {
|
||||
SM2err(SM2_F_SM2_DO_ENCRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (!EC_GROUP_get_cofactor(ec_group, h, bn_ctx)) {
|
||||
SM2err(SM2_F_SM2_DO_ENCRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
nbytes = (EC_GROUP_get_degree(ec_group) + 7) / 8;
|
||||
@@ -344,23 +362,28 @@ SM2_CIPHERTEXT_VALUE *SM2_do_encrypt(const SM2_ENC_PARAMS *params,
|
||||
|
||||
/* A2: C1 = [k]G = (x1, y1) */
|
||||
if (!EC_POINT_mul(ec_group, cv->ephem_point, k, NULL, NULL, bn_ctx)) {
|
||||
SM2err(SM2_F_SM2_DO_ENCRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* A3: check [h]P_B != O */
|
||||
if (!EC_POINT_mul(ec_group, point, NULL, pub_key, h, bn_ctx)) {
|
||||
SM2err(SM2_F_SM2_DO_ENCRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (EC_POINT_is_at_infinity(ec_group, point)) {
|
||||
SM2err(SM2_F_SM2_DO_ENCRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* A4: compute ECDH [k]P_B = (x2, y2) */
|
||||
if (!EC_POINT_mul(ec_group, point, NULL, pub_key, k, bn_ctx)) {
|
||||
SM2err(SM2_F_SM2_DO_ENCRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (!(len = EC_POINT_point2oct(ec_group, point,
|
||||
POINT_CONVERSION_UNCOMPRESSED, buf, sizeof(buf), bn_ctx))) {
|
||||
SM2err(SM2_F_SM2_DO_ENCRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
OPENSSL_assert(len == nbytes * 2 + 1);
|
||||
@@ -387,31 +410,38 @@ SM2_CIPHERTEXT_VALUE *SM2_do_encrypt(const SM2_ENC_PARAMS *params,
|
||||
cv->ciphertext[i] ^= in[i];
|
||||
}
|
||||
|
||||
if (params->mactag_size) {
|
||||
mactag_size = SM2_ENC_PARAMS_mactag_size(params);
|
||||
if (mactag_size) {
|
||||
|
||||
/* A7: C3 = Hash(x2 || M || y2) */
|
||||
if (!EVP_DigestInit_ex(md_ctx, params->mac_md, NULL)) {
|
||||
SM2err(SM2_F_SM2_DO_ENCRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (!EVP_DigestUpdate(md_ctx, buf + 1, nbytes)) {
|
||||
SM2err(SM2_F_SM2_DO_ENCRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (!EVP_DigestUpdate(md_ctx, in, inlen)) {
|
||||
SM2err(SM2_F_SM2_DO_ENCRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (!EVP_DigestUpdate(md_ctx, buf + 1 + nbytes, nbytes)) {
|
||||
SM2err(SM2_F_SM2_DO_ENCRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (!EVP_DigestFinal_ex(md_ctx, dgst, &dgstlen)) {
|
||||
SM2err(SM2_F_SM2_DO_ENCRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* GmSSL specific: reduce mactag size */
|
||||
if (params->mactag_size > dgstlen) {
|
||||
if (mactag_size > dgstlen) {
|
||||
SM2err(SM2_F_SM2_DO_ENCRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
cv->mactag_size = params->mactag_size;
|
||||
cv->mactag_size = mactag_size;
|
||||
memcpy(cv->mactag, dgst, cv->mactag_size);
|
||||
}
|
||||
|
||||
@@ -434,8 +464,9 @@ end:
|
||||
}
|
||||
|
||||
int SM2_decrypt(const SM2_ENC_PARAMS *params,
|
||||
unsigned char *out, size_t *outlen,
|
||||
const unsigned char *in, size_t inlen,
|
||||
unsigned char *out, size_t *outlen, EC_KEY *ec_key)
|
||||
EC_KEY *ec_key)
|
||||
{
|
||||
int ret = 0;
|
||||
const EC_GROUP *ec_group = EC_KEY_get0_group(ec_key);
|
||||
@@ -443,11 +474,11 @@ int SM2_decrypt(const SM2_ENC_PARAMS *params,
|
||||
int len;
|
||||
|
||||
if (!(len = SM2_CIPHERTEXT_VALUE_size(ec_group, params, 0))) {
|
||||
fprintf(stderr, "%s %d\n", __FILE__, __LINE__);
|
||||
SM2err(SM2_F_SM2_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (inlen <= len) {
|
||||
fprintf(stderr, "%s %d\n", __FILE__, __LINE__);
|
||||
SM2err(SM2_F_SM2_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -455,16 +486,16 @@ int SM2_decrypt(const SM2_ENC_PARAMS *params,
|
||||
*outlen = inlen - len;
|
||||
return 1;
|
||||
} else if (*outlen < inlen - len) {
|
||||
fprintf(stderr, "%s %d\n", __FILE__, __LINE__);
|
||||
SM2err(SM2_F_SM2_DECRYPT, SM2_R_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(cv = SM2_CIPHERTEXT_VALUE_decode(ec_group, params, in, inlen))) {
|
||||
fprintf(stderr, "%s %d\n", __FILE__, __LINE__);
|
||||
SM2err(SM2_F_SM2_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (!SM2_do_decrypt(params, cv, out, outlen, ec_key)) {
|
||||
fprintf(stderr, "%s %d\n", __FILE__, __LINE__);
|
||||
SM2err(SM2_F_SM2_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -490,14 +521,17 @@ int SM2_do_decrypt(const SM2_ENC_PARAMS *params,
|
||||
unsigned char buf[(OPENSSL_ECC_MAX_FIELD_BITS + 7)/4 + 1];
|
||||
unsigned char mac[EVP_MAX_MD_SIZE];
|
||||
unsigned int maclen;
|
||||
int mactag_size;
|
||||
int nbytes;
|
||||
size_t size;
|
||||
int i;
|
||||
|
||||
if (!ec_group || !pri_key) {
|
||||
SM2err(SM2_F_SM2_DO_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (!kdf) {
|
||||
SM2err(SM2_F_SM2_DO_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -506,6 +540,7 @@ int SM2_do_decrypt(const SM2_ENC_PARAMS *params,
|
||||
return 1;
|
||||
}
|
||||
if (*outlen < cv->ciphertext_size) {
|
||||
SM2err(SM2_F_SM2_DO_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -516,32 +551,39 @@ int SM2_do_decrypt(const SM2_ENC_PARAMS *params,
|
||||
bn_ctx = BN_CTX_new();
|
||||
md_ctx = EVP_MD_CTX_create();
|
||||
if (!point || !n || !h || !bn_ctx || !md_ctx) {
|
||||
SM2err(SM2_F_SM2_DO_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* init ec domain parameters */
|
||||
if (!EC_GROUP_get_order(ec_group, n, bn_ctx)) {
|
||||
SM2err(SM2_F_SM2_DO_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (!EC_GROUP_get_cofactor(ec_group, h, bn_ctx)) {
|
||||
SM2err(SM2_F_SM2_DO_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
nbytes = (EC_GROUP_get_degree(ec_group) + 7) / 8;
|
||||
|
||||
/* B2: check [h]C1 != O */
|
||||
if (!EC_POINT_mul(ec_group, point, NULL, cv->ephem_point, h, bn_ctx)) {
|
||||
SM2err(SM2_F_SM2_DO_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (EC_POINT_is_at_infinity(ec_group, point)) {
|
||||
SM2err(SM2_F_SM2_DO_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* B3: compute ECDH [d]C1 = (x2, y2) */
|
||||
if (!EC_POINT_mul(ec_group, point, NULL, cv->ephem_point, pri_key, bn_ctx)) {
|
||||
SM2err(SM2_F_SM2_DO_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (!(size = EC_POINT_point2oct(ec_group, point,
|
||||
POINT_CONVERSION_UNCOMPRESSED, buf, sizeof(buf), bn_ctx))) {
|
||||
SM2err(SM2_F_SM2_DO_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
OPENSSL_assert(size == 1 + nbytes * 2);
|
||||
@@ -558,31 +600,39 @@ int SM2_do_decrypt(const SM2_ENC_PARAMS *params,
|
||||
}
|
||||
*outlen = cv->ciphertext_size;
|
||||
|
||||
if (params->mactag_size) {
|
||||
mactag_size = SM2_ENC_PARAMS_mactag_size(params);
|
||||
if (mactag_size) {
|
||||
|
||||
/* B6: check Hash(x2 || M || y2) == C3 */
|
||||
if (!EVP_DigestInit_ex(md_ctx, params->mac_md, NULL)) {
|
||||
SM2err(SM2_F_SM2_DO_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (!EVP_DigestUpdate(md_ctx, buf + 1, nbytes)) {
|
||||
SM2err(SM2_F_SM2_DO_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (!EVP_DigestUpdate(md_ctx, out, *outlen)) {
|
||||
SM2err(SM2_F_SM2_DO_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (!EVP_DigestUpdate(md_ctx, buf + 1 + nbytes, nbytes)) {
|
||||
SM2err(SM2_F_SM2_DO_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (!EVP_DigestFinal_ex(md_ctx, mac, &maclen)) {
|
||||
SM2err(SM2_F_SM2_DO_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* GmSSL specific */
|
||||
if (params->mactag_size > maclen) {
|
||||
if (mactag_size > maclen) {
|
||||
SM2err(SM2_F_SM2_DO_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
if (cv->mactag_size != params->mactag_size ||
|
||||
if (cv->mactag_size != mactag_size ||
|
||||
memcmp(mac, cv->mactag, cv->mactag_size)) {
|
||||
SM2err(SM2_F_SM2_DO_DECRYPT, SM2_R_ERROR);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
@@ -610,41 +660,41 @@ int SM2_ENC_PARAMS_init_with_recommended(SM2_ENC_PARAMS *params)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SM2_encrypt_with_recommended(const unsigned char *in, size_t inlen,
|
||||
unsigned char *out, size_t *outlen, EC_KEY *ec_key)
|
||||
int SM2_encrypt_with_recommended(unsigned char *out, size_t *outlen,
|
||||
const unsigned char *in, size_t inlen, EC_KEY *ec_key)
|
||||
{
|
||||
SM2_ENC_PARAMS params;
|
||||
SM2_ENC_PARAMS_init_with_recommended(¶ms);
|
||||
return SM2_encrypt(¶ms, in, inlen, out, outlen, ec_key);
|
||||
return SM2_encrypt(¶ms, out, outlen, in, inlen, ec_key);
|
||||
}
|
||||
|
||||
int SM2_decrypt_with_recommended(const unsigned char *in, size_t inlen,
|
||||
unsigned char *out, size_t *outlen, EC_KEY *ec_key)
|
||||
int SM2_decrypt_with_recommended(unsigned char *out, size_t *outlen,
|
||||
const unsigned char *in, size_t inlen, EC_KEY *ec_key)
|
||||
{
|
||||
SM2_ENC_PARAMS params;
|
||||
SM2_ENC_PARAMS_init_with_recommended(¶ms);
|
||||
return SM2_decrypt(¶ms, in, inlen, out, outlen, ec_key);
|
||||
return SM2_decrypt(¶ms, out, outlen, in, inlen, ec_key);
|
||||
}
|
||||
|
||||
int SM2_encrypt_elgamal(const unsigned char *in, size_t inlen,
|
||||
unsigned char *out, size_t *outlen, EC_KEY *ec_key)
|
||||
int SM2_encrypt_elgamal(unsigned char *out, size_t *outlen,
|
||||
const unsigned char *in, size_t inlen, EC_KEY *ec_key)
|
||||
{
|
||||
SM2_ENC_PARAMS params;
|
||||
params.kdf_md = EVP_sm3();
|
||||
params.mac_md = EVP_sm3();
|
||||
params.mactag_size = 0;
|
||||
params.point_form = POINT_CONVERSION_COMPRESSED;
|
||||
return SM2_encrypt(¶ms, in, inlen, out, outlen, ec_key);
|
||||
return SM2_encrypt(¶ms, out, outlen, in, inlen, ec_key);
|
||||
}
|
||||
|
||||
int SM2_decrypt_elgamal(const unsigned char *in, size_t inlen,
|
||||
unsigned char *out, size_t *outlen, EC_KEY *ec_key)
|
||||
int SM2_decrypt_elgamal(unsigned char *out, size_t *outlen,
|
||||
const unsigned char *in, size_t inlen, EC_KEY *ec_key)
|
||||
{
|
||||
SM2_ENC_PARAMS params;
|
||||
params.kdf_md = EVP_sm3();
|
||||
params.mac_md = EVP_sm3();
|
||||
params.mactag_size = 0;
|
||||
params.point_form = POINT_CONVERSION_COMPRESSED;
|
||||
return SM2_decrypt(¶ms, in, inlen, out, outlen, ec_key);
|
||||
return SM2_decrypt(¶ms, out, outlen, in, inlen, ec_key);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user