summaryrefslogtreecommitdiffstats
path: root/crypto/ec/ec_pmeth.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2018-05-31 14:49:47 +0200
committerMatt Caswell <matt@openssl.org>2018-06-04 12:59:56 +0200
commite14d6cf691c9d8ad49df280b580b6836a67c6a19 (patch)
treecbf7b07a1abd22da9e711c3656ed599f5f7b7715 /crypto/ec/ec_pmeth.c
parentFurther work on SM2 error codes (diff)
downloadopenssl-e14d6cf691c9d8ad49df280b580b6836a67c6a19.tar.xz
openssl-e14d6cf691c9d8ad49df280b580b6836a67c6a19.zip
Improve use of the test framework in the SM2 internal tests
Also general clean up of those tests Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/6386)
Diffstat (limited to 'crypto/ec/ec_pmeth.c')
-rw-r--r--crypto/ec/ec_pmeth.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/crypto/ec/ec_pmeth.c b/crypto/ec/ec_pmeth.c
index eefe2d0cd5..50331d32c4 100644
--- a/crypto/ec/ec_pmeth.c
+++ b/crypto/ec/ec_pmeth.c
@@ -223,9 +223,11 @@ 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),
@@ -261,9 +263,11 @@ 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),