Skip to content

Commit

Permalink
Simplify function call
Browse files Browse the repository at this point in the history
  • Loading branch information
Andras Fekete committed Oct 29, 2024
1 parent 708463a commit e2dcfaa
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions include/wolfprovider/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ enum wc_HashType wp_nid_to_wc_hash_type(int nid);
int wp_name_to_wc_mgf(OSSL_LIB_CTX* libCtx, const char* name,
const char* propQ);
int wp_mgf1_from_hash(int nid);
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
int wp_hash_copy(wc_HashAlg* src, wc_HashAlg* dst);
#else
int wp_hash_copy(wc_HashAlg* src, wc_HashAlg* dst, enum wc_HashType hashType);
#endif

int wp_cipher_from_params(const OSSL_PARAM params[], int* cipher,
const char** cipherName);
Expand Down
6 changes: 3 additions & 3 deletions src/wp_ecdsa_sig.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ typedef struct wp_EcdsaSigCtx {

/** wolfSSL hash object. */
wc_HashAlg hash;
#ifndef wc_Hashes
#if LIBWOLFSSL_VERSION_HEX < 0x05007004
/** Hash algorithm to use on data to be signed. */
enum wc_HashType hashType;
#endif
Expand Down Expand Up @@ -143,7 +143,7 @@ static wp_EcdsaSigCtx* wp_ecdsa_dupctx(wp_EcdsaSigCtx* srcCtx)
}

if (ok && (!wp_hash_copy(&srcCtx->hash, &dstCtx->hash
#ifndef wc_Hashes
#if LIBWOLFSSL_VERSION_HEX < 0x05007004
,srcCtx->hashType
#endif
))) {
Expand All @@ -154,7 +154,7 @@ static wp_EcdsaSigCtx* wp_ecdsa_dupctx(wp_EcdsaSigCtx* srcCtx)
}
if (ok) {
dstCtx->ecc = srcCtx->ecc;
#ifndef wc_Hashes
#if LIBWOLFSSL_VERSION_HEX < 0x05007004
dstCtx->hashType = srcCtx->hashType;
#endif
dstCtx->op = srcCtx->op;
Expand Down
4 changes: 2 additions & 2 deletions src/wp_ecx_sig.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ typedef struct wp_EcxSigCtx {

/** wolfSSL hash object. */
wc_HashAlg hash;
#ifndef wc_Hashes
#if LIBWOLFSSL_VERSION_HEX < 0x05007004
/** Hash algorithm to use on data to be signed. */
enum wc_HashType hashType;
#endif
Expand Down Expand Up @@ -150,7 +150,7 @@ static wp_EcxSigCtx* wp_ecx_dupctx(wp_EcxSigCtx* srcCtx)
}
if (ok) {
dstCtx->ecx = srcCtx->ecx;
#ifndef wc_Hashes
#if LIBWOLFSSL_VERSION_HEX < 0x05007004
dstCtx->hashType = srcCtx->hashType;
#endif
dstCtx->op = srcCtx->op;
Expand Down
4 changes: 4 additions & 0 deletions src/wp_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,11 @@ int wp_mgf1_from_hash(int nid)
* @return 1 on success.
* @return 0 on failure.
*/
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
int wp_hash_copy(wc_HashAlg* src, wc_HashAlg* dst)
#else
int wp_hash_copy(wc_HashAlg* src, wc_HashAlg* dst, enum wc_HashType hashType)
#endif
{
int ok = 1;
int rc = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/wp_rsa_sig.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ typedef struct wp_RsaSigCtx {

/** wolfSSL hash object. */
wc_HashAlg hash;
#ifndef wc_Hashes
#if LIBWOLFSSL_VERSION_HEX < 0x05007004
/** Hash algorithm to use on data to be signed. */
enum wc_HashType hashType;
#endif
Expand Down Expand Up @@ -326,7 +326,7 @@ static wp_RsaSigCtx* wp_rsa_ctx_dup(wp_RsaSigCtx* srcCtx)
}
if (ok) {
dstCtx->rsa = srcCtx->rsa;
#ifndef wc_Hashes
#if LIBWOLFSSL_VERSION_HEX < 0x05007004
dstCtx->hashType = srcCtx->hashType;
#endif
dstCtx->mgf = srcCtx->mgf;
Expand Down

0 comments on commit e2dcfaa

Please sign in to comment.