mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-08-07 21:53:41 +08:00
fix bug sm2test(enc) fail
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -174,3 +174,5 @@ cscope.*
|
|||||||
# auto create by Configure
|
# auto create by Configure
|
||||||
crypto/opensslconf.h
|
crypto/opensslconf.h
|
||||||
tool/c_rehash
|
tool/c_rehash
|
||||||
|
# exec file
|
||||||
|
apps/gmssl
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
#include <openssl/engine.h>
|
#include <openssl/engine.h>
|
||||||
#include "./sm2.h"
|
#include <openssl/sm2.h>
|
||||||
|
|
||||||
RAND_METHOD fake_rand;
|
RAND_METHOD fake_rand;
|
||||||
const RAND_METHOD *old_rand;
|
const RAND_METHOD *old_rand;
|
||||||
@@ -336,7 +336,15 @@ int test_sm2_enc(const EC_GROUP *group,
|
|||||||
}
|
}
|
||||||
|
|
||||||
buflen = sizeof(buf);
|
buflen = sizeof(buf);
|
||||||
if (!SM2_encrypt_with_recommended(buf, &buflen,
|
if (!SM2_encrypt_with_recommended(NULL, &buflen,
|
||||||
|
(const unsigned char *)M, strlen(M), ec_key)) {
|
||||||
|
fprintf(stderr, "error: %s %d\n", __FILE__, __LINE__);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
if(buflen > sizeof(buf)){
|
||||||
|
fprintf(stderr, "error: %s %d\n", __FILE__, __LINE__);
|
||||||
|
goto end;
|
||||||
|
}else if (!SM2_encrypt_with_recommended(buf, &buflen,
|
||||||
(const unsigned char *)M, strlen(M), ec_key)) {
|
(const unsigned char *)M, strlen(M), ec_key)) {
|
||||||
fprintf(stderr, "error: %s %d\n", __FILE__, __LINE__);
|
fprintf(stderr, "error: %s %d\n", __FILE__, __LINE__);
|
||||||
goto end;
|
goto end;
|
||||||
@@ -354,7 +362,15 @@ int test_sm2_enc(const EC_GROUP *group,
|
|||||||
fprintf(stderr, "error: %s %d\n", __FILE__, __LINE__);
|
fprintf(stderr, "error: %s %d\n", __FILE__, __LINE__);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
if (!SM2_decrypt_with_recommended(msg, &msglen, buf, buflen, ec_key)) {
|
|
||||||
|
if (!SM2_decrypt_with_recommended(NULL, &msglen, buf, buflen, ec_key)) {
|
||||||
|
fprintf(stderr, "error: %s %d\n", __FILE__, __LINE__);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
if(msglen > sizeof(msg)){
|
||||||
|
fprintf(stderr, "error: %s %d\n", __FILE__, __LINE__);
|
||||||
|
goto end;
|
||||||
|
} else if (!SM2_decrypt_with_recommended(msg, &msglen, buf, buflen, ec_key)) {
|
||||||
fprintf(stderr, "error: %s %d\n", __FILE__, __LINE__);
|
fprintf(stderr, "error: %s %d\n", __FILE__, __LINE__);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user