/* Provenance: openssl/openssl pkey_sm2_decrypt (fixed). * repo: openssl/openssl * commit: 59f5e75f3bced8fc0e130d72a3f582cf7b480b46 * parent: 8c74c9d1ade0fbdab5b815ddb747351b8b839641 * commit_url: https://github.com/openssl/openssl/commit/59f5e75f3bced8fc0e130d72a3f582cf7b480b46 * cve: CVE-2021-3711 * license: OpenSSL License * function: pkey_sm2_decrypt * relpath: crypto/sm2/sm2_pmeth.c */ static int pkey_sm2_decrypt(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, const unsigned char *in, size_t inlen) { EC_KEY *ec = ctx->pkey->pkey.ec; SM2_PKEY_CTX *dctx = ctx->data; const EVP_MD *md = (dctx->md == NULL) ? EVP_sm3() : dctx->md; if (out == NULL) { if (!sm2_plaintext_size(in, inlen, outlen)) return -1; else return 1; } return sm2_decrypt(ec, md, in, inlen, out, outlen); }