Skip to content

Commit

Permalink
Merge pull request #3586 from tmael/cc310_tests
Browse files Browse the repository at this point in the history
Fix Cryptocell and revert test.c use of static const
  • Loading branch information
dgarske authored Dec 23, 2020
2 parents 90b14e2 + f06361d commit 9c87f97
Show file tree
Hide file tree
Showing 4 changed files with 499 additions and 493 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ AC_ARG_ENABLE([linuxkm-defaults],

if test "$ENABLED_LINUXKM_DEFAULTS" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DH_CONST -DWOLFSSL_SP_MOD_WORD_RP -DWOLFSSL_OLD_PRIME_CHECK -DWOLFSSL_SP_DIV_64 -DWOLFSSL_SP_DIV_WORD_HALF"
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DH_CONST -DWOLFSSL_SP_MOD_WORD_RP -DWOLFSSL_OLD_PRIME_CHECK -DWOLFSSL_SP_DIV_64 -DWOLFSSL_SP_DIV_WORD_HALF -DWOLFSSL_SMALL_STACK_STATIC"
fi

AC_ARG_WITH([linux-source],
Expand Down
17 changes: 8 additions & 9 deletions wolfcrypt/src/ecc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4911,16 +4911,15 @@ static int wc_ecc_sign_hash_hw(const byte* in, word32 inlen,
return WC_HW_E;
}
#elif defined(WOLFSSL_CRYPTOCELL)

/* truncate if hash is longer than key size */
if (msgLenInBytes > keysize) {
msgLenInBytes = keysize;
}
hash_mode = cc310_hashModeECC(msgLenInBytes);
if (hash_mode == CRYS_ECPKI_HASH_OpModeLast) {
hash_mode = cc310_hashModeECC(keysize);
hash_mode = CRYS_ECPKI_HASH_SHA256_mode;
}

/* truncate if hash is longer than key size */
if (msgLenInBytes > keysize) {
msgLenInBytes = keysize;
}

/* create signature from an input buffer using a private key*/
Expand Down Expand Up @@ -6390,15 +6389,15 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
return err;
}

/* truncate if hash is longer than key size */
if (msgLenInBytes > keySz) {
msgLenInBytes = keySz;
}
hash_mode = cc310_hashModeECC(msgLenInBytes);
if (hash_mode == CRYS_ECPKI_HASH_OpModeLast) {
/* hash_mode = */ cc310_hashModeECC(keySz);
hash_mode = CRYS_ECPKI_HASH_SHA256_mode;
}
/* truncate if hash is longer than key size */
if (msgLenInBytes > keySz) {
msgLenInBytes = keySz;
}

/* verify the signature using the public key */
err = CRYS_ECDSA_Verify(&sigCtxTemp,
Expand Down
Loading

0 comments on commit 9c87f97

Please sign in to comment.