diff options
author | Jack Lloyd <jack.lloyd@ribose.com> | 2018-02-09 18:21:56 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2018-03-19 14:33:25 +0100 |
commit | 4e6647506331fc3b3ef5b23e5dbe188279ddd575 (patch) | |
tree | e2a18c599cf117e0475c56f22740c8882880901d /crypto/sm2 | |
parent | Support SM2 ECIES scheme via EVP (diff) | |
download | openssl-4e6647506331fc3b3ef5b23e5dbe188279ddd575.tar.xz openssl-4e6647506331fc3b3ef5b23e5dbe188279ddd575.zip |
Handle evp_tests assumption of EVP_PKEY_FLAG_AUTOARGLEN
Without actually using EVP_PKEY_FLAG_AUTOARGLEN
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4793)
Diffstat (limited to 'crypto/sm2')
-rw-r--r-- | crypto/sm2/sm2_crypt.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/crypto/sm2/sm2_crypt.c b/crypto/sm2/sm2_crypt.c index 7e7be9d04a..b308e5b2e5 100644 --- a/crypto/sm2/sm2_crypt.c +++ b/crypto/sm2/sm2_crypt.c @@ -57,10 +57,23 @@ static size_t EC_field_size(const EC_GROUP *group) return field_size; } +size_t SM2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len) +{ + const size_t field_size = EC_field_size(EC_KEY_get0_group(key)); + const size_t md_size = EVP_MD_size(digest); + + const size_t overhead = 10 + 2 * field_size + md_size; + if(msg_len <= overhead) + return 0; + + return msg_len - overhead; +} + size_t SM2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len) { - return 10 + 2 * EC_field_size(EC_KEY_get0_group(key)) + - EVP_MD_size(digest) + msg_len; + const size_t field_size = EC_field_size(EC_KEY_get0_group(key)); + const size_t md_size = EVP_MD_size(digest); + return 10 + 2 * field_size + md_size + msg_len; } int SM2_encrypt(const EC_KEY *key, |