forked from wolfSSL/wolfssl
return value check in EVP_PKEY_encrypt
This commit is contained in:
committed by
Jacob Barthelmeh
parent
09eeafe4f0
commit
1b7f4ad1dd
@ -703,6 +703,7 @@ WOLFSSL_API int wolfSSL_EVP_PKEY_encrypt(WOLFSSL_EVP_PKEY_CTX *ctx,
|
|||||||
unsigned char *out, size_t *outlen,
|
unsigned char *out, size_t *outlen,
|
||||||
const unsigned char *in, size_t inlen)
|
const unsigned char *in, size_t inlen)
|
||||||
{
|
{
|
||||||
|
int len;
|
||||||
if (ctx == NULL)return 0;
|
if (ctx == NULL)return 0;
|
||||||
WOLFSSL_ENTER("EVP_PKEY_encrypt");
|
WOLFSSL_ENTER("EVP_PKEY_encrypt");
|
||||||
if(ctx->op != EVP_PKEY_OP_ENCRYPT)return 0;
|
if(ctx->op != EVP_PKEY_OP_ENCRYPT)return 0;
|
||||||
@ -711,13 +712,17 @@ WOLFSSL_API int wolfSSL_EVP_PKEY_encrypt(WOLFSSL_EVP_PKEY_CTX *ctx,
|
|||||||
(void)outlen;
|
(void)outlen;
|
||||||
(void)in;
|
(void)in;
|
||||||
(void)inlen;
|
(void)inlen;
|
||||||
|
(void)len;
|
||||||
switch(ctx->pkey->type){
|
switch(ctx->pkey->type){
|
||||||
#if !defined(NO_RSA) && !defined(HAVE_USER_RSA)
|
#if !defined(NO_RSA) && !defined(HAVE_USER_RSA)
|
||||||
case EVP_PKEY_RSA:
|
case EVP_PKEY_RSA:
|
||||||
*outlen = wolfSSL_RSA_public_encrypt((int)inlen, (unsigned char *)in, out,
|
len = wolfSSL_RSA_public_encrypt((int)inlen, (unsigned char *)in, out,
|
||||||
ctx->pkey->rsa, ctx->padding);
|
ctx->pkey->rsa, ctx->padding);
|
||||||
return (int)*outlen;
|
if(len < 0)return 0;
|
||||||
|
else {
|
||||||
|
*outlen = len ;
|
||||||
|
return len;
|
||||||
|
}
|
||||||
#endif /* NO_RSA */
|
#endif /* NO_RSA */
|
||||||
|
|
||||||
case EVP_PKEY_EC:
|
case EVP_PKEY_EC:
|
||||||
|
Reference in New Issue
Block a user