FreeRTOS-Plus/ThirdParty/WolfSSL-FIPS-Ready/wolfcrypt/src/evp.c
/* Finalize an EVP_DigestSign/Verify operation - common part only.
 * Finalize a digest for RSA and ECC keys, or HMAC for HMAC key.
 * Copies the digest so that you can keep updating.
 */
Finalize an EVP_DigestSign/Verify operation - common part only.
Finalize an EVP_DigestSign / Verify operation - common part only .
static int wolfssl_evp_digest_pk_final(WOLFSSL_EVP_MD_CTX *ctx,
                                       unsigned char *md, unsigned int* mdlen)
{
    int  ret;
    if (ctx->pctx == NULL) {
        Hmac hmacCopy;
        if (!ctx->isHMAC)
            return WOLFSSL_FAILURE;
        if (wolfSSL_HmacCopy(&hmacCopy, &ctx->hash.hmac) != WOLFSSL_SUCCESS)
            return WOLFSSL_FAILURE;
        ret = wc_HmacFinal(&hmacCopy, md) == 0;
        wc_HmacFree(&hmacCopy);
        return ret;
    }
    else {
        WOLFSSL_EVP_MD_CTX ctxCopy;
        if (wolfSSL_EVP_MD_CTX_copy_ex(&ctxCopy, ctx) != WOLFSSL_SUCCESS)
            return WOLFSSL_FAILURE;
        ret = wolfSSL_EVP_DigestFinal(&ctxCopy, md, mdlen);
        wolfSSL_EVP_MD_CTX_cleanup(&ctxCopy);
        return ret;
    }
}
static int wolfssl_evp_digest_pk_final ( WOLFSSL_EVP_MD_CTX * ctx , unsigned char * md , unsigned int * mdlen ) { int ret ; if ( ctx -> pctx == NULL ) { Hmac hmacCopy ; if ( ! ctx -> isHMAC ) return WOLFSSL_FAILURE ; if ( wolfSSL_HmacCopy ( & hmacCopy , & ctx -> hash . hmac ) != WOLFSSL_SUCCESS ) return WOLFSSL_FAILURE ; ret = wc_HmacFinal ( & hmacCopy , md ) == 0 ; wc_HmacFree ( & hmacCopy ) ; return ret ; } else { WOLFSSL_EVP_MD_CTX ctxCopy ; if ( wolfSSL_EVP_MD_CTX_copy_ex ( & ctxCopy , ctx ) != WOLFSSL_SUCCESS ) return WOLFSSL_FAILURE ; ret = wolfSSL_EVP_DigestFinal ( & ctxCopy , md , mdlen ) ; wolfSSL_EVP_MD_CTX_cleanup ( & ctxCopy ) ; return ret ; } }
Finalize an EVP_DigestSign/Verify operation - common part only.
Finalize an EVP_DigestSign / Verify operation - common part only .