FreeRTOS-Plus/ThirdParty/WolfSSL-FIPS-Ready/wolfcrypt/src/evp.c
/* Use a WOLFSSL_EVP_PKEY_CTX structure to encrypt data
 *
 * ctx    WOLFSSL_EVP_PKEY_CTX structure to use with encryption
 * out    buffer to hold encrypted data
 * outlen length of out buffer
 * in     data to be encrypted
 * inlen  length of in buffer
 *
 * Returns WOLFSSL_FAILURE on failure and WOLFSSL_SUCCESS on success
 */
Use a WOLFSSL_EVP_PKEY_CTX structure to encrypt data
ctx    WOLFSSL_EVP_PKEY_CTX structure to use with encryption
out    buffer to hold encrypted data
outlen length of out buffer
in     data to be encrypted
inlen  length of in buffer

Returns WOLFSSL_FAILURE on failure and WOLFSSL_SUCCESS on success
Use a WOLFSSL_EVP_PKEY_CTX structure to encrypt data ctx WOLFSSL_EVP_PKEY_CTX structure to use with encryption out buffer to hold encrypted data outlen length of out buffer in data to be encrypted inlen length of in buffer Returns WOLFSSL_FAILURE on failure and WOLFSSL_SUCCESS on success
int wolfSSL_EVP_PKEY_encrypt(WOLFSSL_EVP_PKEY_CTX *ctx,
                     unsigned char *out, size_t *outlen,
                     const unsigned char *in, size_t inlen)
{
    int len = 0;
    if (ctx == NULL) return WOLFSSL_FAILURE;
    WOLFSSL_ENTER("EVP_PKEY_encrypt");
    if (ctx->op != EVP_PKEY_OP_ENCRYPT) return WOLFSSL_FAILURE;
    (void)out;
    (void)outlen;
    (void)in;
    (void)inlen;
    (void)len;
    switch (ctx->pkey->type) {
#if !defined(NO_RSA) && !defined(HAVE_USER_RSA)
    case EVP_PKEY_RSA:
        len = wolfSSL_RSA_public_encrypt((int)inlen, (unsigned char *)in, out,
                  ctx->pkey->rsa, ctx->padding);
        if (len < 0)
            break;
        else {
            *outlen = len;
            return WOLFSSL_SUCCESS;
        }
#endif 
    case EVP_PKEY_EC:
        WOLFSSL_MSG("not implemented");
        FALL_THROUGH;
    default:
        break;
    }
    return WOLFSSL_FAILURE;
}
int wolfSSL_EVP_PKEY_encrypt ( WOLFSSL_EVP_PKEY_CTX * ctx , unsigned char * out , size_t * outlen , const unsigned char * in , size_t inlen ) { int len = 0 ; if ( ctx == NULL ) return WOLFSSL_FAILURE ; WOLFSSL_ENTER ( " " ) ; if ( ctx -> op != EVP_PKEY_OP_ENCRYPT ) return WOLFSSL_FAILURE ; ( void ) out ; ( void ) outlen ; ( void ) in ; ( void ) inlen ; ( void ) len ; switch ( ctx -> pkey -> type ) { #if ! defined ( NO_RSA ) && ! defined ( HAVE_USER_RSA ) case EVP_PKEY_RSA : len = wolfSSL_RSA_public_encrypt ( ( int ) inlen , ( unsigned char * ) in , out , ctx -> pkey -> rsa , ctx -> padding ) ; if ( len < 0 ) break ; else { * outlen = len ; return WOLFSSL_SUCCESS ; } #endif case EVP_PKEY_EC : WOLFSSL_MSG ( " " ) ; FALL_THROUGH ; default : break ; } return WOLFSSL_FAILURE ; }
Use a WOLFSSL_EVP_PKEY_CTX structure to encrypt data
 ctx    WOLFSSL_EVP_PKEY_CTX structure to use with encryption
 out    buffer to hold encrypted data
 outlen length of out buffer
 in     data to be encrypted
 inlen  length of in buffer
Use a WOLFSSL_EVP_PKEY_CTX structure to encrypt data ctx WOLFSSL_EVP_PKEY_CTX structure to use with encryption out buffer to hold encrypted data outlen length of out buffer in data to be encrypted inlen length of in buffer
/* NO_RSA */