Merge pull request #7967 from douzzer/20240910-configure-enable-all-asm-and-sp-cleanup

20240910-configure-enable-all-asm-and-sp-cleanup
This commit is contained in:
Sean Parkinson
2024-09-13 09:18:37 +10:00
committed by GitHub
11 changed files with 939 additions and 930 deletions

View File

@@ -316,7 +316,6 @@ then
fi fi
AC_SUBST([ENABLED_ASM]) AC_SUBST([ENABLED_ASM])
# Default math is SP Math all and not fast math # Default math is SP Math all and not fast math
# FIPS v1 and v2 must use fast math # FIPS v1 and v2 must use fast math
DEF_SP_MATH="yes" DEF_SP_MATH="yes"
@@ -759,14 +758,14 @@ fi
# fastmath # fastmath
AC_ARG_ENABLE([fastmath], AC_ARG_ENABLE([fastmath],
[AS_HELP_STRING([--enable-fastmath],[Enable fast math ops (default: disabled)])], [AS_HELP_STRING([--enable-fastmath],[Enable legacy Tom's Fast Math back end (default: disabled)])],
[ ENABLED_FASTMATH=$enableval ], [ ENABLED_FASTMATH=$enableval ],
[ ENABLED_FASTMATH=$DEF_FAST_MATH ] [ ENABLED_FASTMATH=$DEF_FAST_MATH ]
) )
# fast HUGE math # fast HUGE math
AC_ARG_ENABLE([fasthugemath], AC_ARG_ENABLE([fasthugemath],
[AS_HELP_STRING([--enable-fasthugemath],[Enable fast math + huge code (default: disabled)])], [AS_HELP_STRING([--enable-fasthugemath],[Enable legacy Tom's Fast Math + huge code (default: disabled)])],
[ ENABLED_FASTHUGEMATH=$enableval ], [ ENABLED_FASTHUGEMATH=$enableval ],
[ ENABLED_FASTHUGEMATH=no ] [ ENABLED_FASTHUGEMATH=no ]
) )
@@ -790,6 +789,69 @@ then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_X86_BUILD" AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_X86_BUILD"
fi fi
AC_ARG_ENABLE([leanpsk],
[AS_HELP_STRING([--enable-leanpsk],[Enable Lean PSK build (default: disabled)])],
[ ENABLED_LEANPSK=$enableval ],
[ ENABLED_LEANPSK=no ]
)
if test "$ENABLED_LEANPSK" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_LEANPSK -DWOLFSSL_STATIC_PSK -DHAVE_NULL_CIPHER -DSINGLE_THREADED -DNO_AES -DNO_FILESYSTEM -DNO_RSA -DNO_DSA -DNO_DH -DNO_PWDBASED -DNO_MD4 -DNO_MD5 -DNO_ERROR_STRINGS -DNO_OLD_TLS -DNO_RC4 -DNO_WRITEV -DNO_DEV_RANDOM -DWOLFSSL_USER_IO -DNO_SHA"
ENABLED_SLOWMATH="no"
ENABLED_SINGLETHREADED="yes"
enable_lowresource=yes
fi
# ASN
# disabling ASN implicitly disables certs, RSA, DSA, and ECC,
# and also disables MPI unless DH is enabled.
# turn off ASN if leanpsk on
if test "$ENABLED_LEANPSK" = "yes"
then
enable_asn=no
fi
AC_ARG_ENABLE([asn],
[AS_HELP_STRING([--enable-asn],[Enable ASN (default: enabled)])],
[ ENABLED_ASN=$enableval ],
[ ENABLED_ASN=yes ]
)
for v in `echo $ENABLED_ASN | tr "," " "`
do
case $v in
all)
# Enable all ASN features
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ASN_ALL"
ENABLED_ASN=yes
;;
template | yes)
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ASN_TEMPLATE"
ENABLED_ASN=yes
;;
original)
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ASN_ORIGINAL"
;;
nocrypt)
AM_CFLAGS="$AM_CFLAGS -DNO_ASN_CRYPT"
enable_pwdbased=no
;;
no)
AM_CFLAGS="$AM_CFLAGS -DNO_ASN -DNO_ASN_CRYPT"
enable_pwdbased=no
;;
*)
AC_MSG_ERROR([Invalid asn option. Valid are: all, template/yes, original, nocrypt or no. Seen: $ENABLED_ASN.])
break;;
esac
done
# if sp-math-all is not set, then enable fast math # if sp-math-all is not set, then enable fast math
if test "x$ENABLED_FASTMATH" = "xyes" && test "$enable_sp_math_all" = "" && test "$enable_sp_math" = "" if test "x$ENABLED_FASTMATH" = "xyes" && test "$enable_sp_math_all" = "" && test "$enable_sp_math" = ""
then then
@@ -841,6 +903,8 @@ AC_ARG_ENABLE([all],
) )
if test "$ENABLED_ALL" = "yes" if test "$ENABLED_ALL" = "yes"
then then
enable_all_crypto=yes
test "$enable_dtls" = "" && enable_dtls=yes test "$enable_dtls" = "" && enable_dtls=yes
if test "x$FIPS_VERSION" != "xv1" if test "x$FIPS_VERSION" != "xv1"
then then
@@ -848,61 +912,6 @@ then
test "$enable_rsapss" = "" && enable_rsapss=yes test "$enable_rsapss" = "" && enable_rsapss=yes
fi fi
# this set is also enabled by enable-all-crypto:
test "$enable_atomicuser" = "" && enable_atomicuser=yes
test "$enable_aesgcm" = "" && enable_aesgcm=yes
test "$enable_aesgcm_stream" = "" && test "$enable_aesgcm" = "yes" && enable_aesgcm_stream=yes
test "$enable_aesccm" = "" && enable_aesccm=yes
test "$enable_aesctr" = "" && enable_aesctr=yes
test "$enable_aeseax" = "" && enable_aeseax=yes
test "$enable_aesofb" = "" && enable_aesofb=yes
test "$enable_aescfb" = "" && enable_aescfb=yes
test "$enable_aescbc_length_checks" = "" && enable_aescbc_length_checks=yes
test "$enable_camellia" = "" && enable_camellia=yes
test "$enable_ripemd" = "" && enable_ripemd=yes
test "$enable_sha224" = "" && enable_sha224=yes
test "$enable_sha512" = "" && enable_sha512=yes
test "$enable_sha3" = "" && enable_sha3=yes
test "$enable_shake128" = "" && enable_shake128=yes
test "$enable_shake256" = "" && enable_shake256=yes
test "$enable_sessioncerts" = "" && enable_sessioncerts=yes
test "$enable_keygen" = "" && enable_keygen=yes
test "$enable_certgen" = "" && enable_certgen=yes
test "$enable_certreq" = "" && enable_certreq=yes
test "$enable_certext" = "" && enable_certext=yes
test "$enable_sep" = "" && enable_sep=yes
test "$enable_hkdf" = "" && enable_hkdf=yes
test "$enable_curve25519" = "" && enable_curve25519=yes
test "$enable_curve448" = "" && enable_curve448=yes
test "$enable_fpecc" = "" && test "$enable_ecc" != "no" && enable_fpecc=yes
test "$enable_eccencrypt" = "" && test "$enable_ecc" != "no" && enable_eccencrypt=yes
test "$enable_psk" = "" && enable_psk=yes
test "$enable_cmac" = "" && enable_cmac=yes
test "$enable_siphash" = "" && enable_siphash=yes
test "$enable_ocsp" = "" && enable_ocsp=yes
test "$enable_ocspstapling" = "" && test "$enable_ocsp" != "no" && enable_ocspstapling=yes
test "$enable_ocspstapling2" = "" && test "$enable_ocsp" != "no" && enable_ocspstapling2=yes
test "$enable_crl" = "" && enable_crl=yes
test "$enable_supportedcurves" = "" && enable_supportedcurves=yes
test "$enable_tlsx" = "" && enable_tlsx=yes
test "$enable_pwdbased" = "" && enable_pwdbased=yes
test "$enable_aeskeywrap" = "" && enable_aeskeywrap=yes
test "$enable_x963kdf" = "" && enable_x963kdf=yes
test "$enable_scrypt" = "" && test "$enable_hmac" != "no" && enable_scrypt=yes
test "$enable_indef" = "" && enable_indef=yes
test "$enable_enckeys" = "" && enable_enckeys=yes
test "$enable_hashflags" = "" && enable_hashflags=yes
test "$enable_defaultdhparams" = "" && enable_defaultdhparams=yes
test "$enable_base64encode" = "" && enable_base64encode=yes
test "$enable_base16" = "" && enable_base16=yes
test "$enable_arc4" = "" && enable_arc4=yes
test "$enable_blake2" = "" && enable_blake2=yes
test "$enable_blake2s" = "" && enable_blake2s=yes
test "$enable_md2" = "" && enable_md2=yes
test "$enable_md4" = "" && enable_md4=yes
test "$enable_anon" = "" && enable_anon=yes
test "$enable_ssh" = "" && test "$enable_hmac" != "no" && enable_ssh=yes
test "$enable_savesession" = "" && enable_savesession=yes test "$enable_savesession" = "" && enable_savesession=yes
test "$enable_savecert" = "" && enable_savecert=yes test "$enable_savecert" = "" && enable_savecert=yes
test "$enable_postauth" = "" && enable_postauth=yes test "$enable_postauth" = "" && enable_postauth=yes
@@ -918,25 +927,16 @@ then
test "$enable_session_ticket" = "" && enable_session_ticket=yes test "$enable_session_ticket" = "" && enable_session_ticket=yes
test "$enable_earlydata" = "" && enable_earlydata=yes test "$enable_earlydata" = "" && enable_earlydata=yes
test "$enable_ech" = "" && enable_ech=yes test "$enable_ech" = "" && enable_ech=yes
test "$enable_srtp" = "" && enable_srtp=yes
test "$enable_rpk" = "" && enable_rpk=yes test "$enable_rpk" = "" && enable_rpk=yes
if test "$ENABLED_LINUXKM_DEFAULTS" != "yes" if test "$ENABLED_LINUXKM_DEFAULTS" != "yes"
then then
test "$enable_compkey" = "" && enable_compkey=yes
test "$enable_quic" = "" && test "$enable_cryptonly" != "yes" && enable_quic=yes test "$enable_quic" = "" && test "$enable_cryptonly" != "yes" && enable_quic=yes
AM_CFLAGS="$AM_CFLAGS -DHAVE_CRL_IO -DHAVE_IO_TIMEOUT" AM_CFLAGS="$AM_CFLAGS -DHAVE_CRL_IO -DHAVE_IO_TIMEOUT"
fi fi
# sp-math is incompatible with opensslextra, ECC custom curves, and DSA.
if test "$ENABLED_SP_MATH" = "no" if test "$ENABLED_SP_MATH" = "no"
then then
test "$enable_dsa" = "" && test "$enable_sha" != "no" && enable_dsa=yes
if test "$ENABLED_FIPS" = "no" || test "$HAVE_FIPS_VERSION" -le 5; then
test "$enable_ecccustcurves" = "" && enable_ecccustcurves=yes
test "$enable_brainpool" = "" && enable_brainpool=yes
fi
test "$enable_srp" = "" && enable_srp=yes
# linuxkm is incompatible with opensslextra and its dependents. # linuxkm is incompatible with opensslextra and its dependents.
if test "$ENABLED_LINUXKM_DEFAULTS" != "yes" if test "$ENABLED_LINUXKM_DEFAULTS" != "yes"
then then
@@ -965,17 +965,8 @@ then
if test "$ENABLED_FIPS" = "no" if test "$ENABLED_FIPS" = "no"
then then
test "$enable_cryptocb" = "" && enable_cryptocb=yes
test "$enable_pkcallbacks" = "" && enable_pkcallbacks=yes
test "$enable_xchacha" = "" && test "$enable_chacha" != "no" && enable_xchacha=yes
test "$enable_scep" = "" && enable_scep=yes test "$enable_scep" = "" && enable_scep=yes
test "$enable_pkcs7" = "" && enable_pkcs7=yes
test "$enable_nullcipher" = "" && enable_nullcipher=yes
test "$enable_mcast" = "" && enable_mcast=yes test "$enable_mcast" = "" && enable_mcast=yes
test "$enable_ed25519" = "" && enable_ed25519=yes
test "$enable_ed25519_stream" = "" && test "$enable_ed25519" != "no" && enable_ed25519_stream=yes
test "$enable_ed448" = "" && enable_ed448=yes
test "$enable_ed448_stream" = "" && test "$enable_ed448" != "no" && enable_ed448_stream=yes
if test "$ENABLED_LINUXKM_DEFAULTS" != "yes" if test "$ENABLED_LINUXKM_DEFAULTS" != "yes"
then then
@@ -983,43 +974,15 @@ then
test "$enable_stunnel" = "" && enable_stunnel=yes test "$enable_stunnel" = "" && enable_stunnel=yes
test "$enable_curl" = "" && enable_curl=yes test "$enable_curl" = "" && enable_curl=yes
test "$enable_tcpdump" = "" && enable_tcpdump=yes test "$enable_tcpdump" = "" && enable_tcpdump=yes
test "$enable_eccsi" = "" && test "$enable_ecc" != "no" && enable_eccsi=yes
test "$enable_sakke" = "" && test "$enable_ecc" != "no" && enable_sakke=yes
fi fi
fi fi
if test "$ENABLED_FIPS" = "no" || test "$HAVE_FIPS_VERSION" -ge 6 || test "$FIPS_VERSION" = "v5-dev"; then if test "$ENABLED_FIPS" = "no" || test "$HAVE_FIPS_VERSION" -ge 6
test "$enable_aesxts" = "" && enable_aesxts=yes then
test "$enable_aesxts_stream" = "" && test "$enable_aesxts" = "yes" && (test "$enable_armasm" = "" || test "$enable_armasm" = "no") && enable_aesxts_stream=yes test "$enable_srtp" = "" && enable_srtp=yes
test "$enable_aessiv" = "" && enable_aessiv=yes
fi fi
if test "$ENABLED_FIPS" = "no" || test "$HAVE_FIPS_VERSION" -le 5; then AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DER_LOAD -DKEEP_OUR_CERT -DKEEP_PEER_CERT"
test "$enable_des3" = "" && enable_des3=yes
fi
# Enable DH const table speedups (eliminates `-lm` math lib dependency)
AM_CFLAGS="$AM_CFLAGS -DHAVE_FFDHE_2048 -DHAVE_FFDHE_3072"
DEFAULT_MAX_CLASSIC_ASYM_KEY_BITS=4096
# Enable multiple attribute additions such as DC
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_MULTI_ATTRIB"
# Enable AES Decrypt, AES ECB
AM_CFLAGS="$AM_CFLAGS -DHAVE_AES_DECRYPT -DHAVE_AES_ECB"
# Enable Alt Names, DER Load, Keep Certs, CRL IO with Timeout
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ALT_NAMES -DWOLFSSL_DER_LOAD -DKEEP_OUR_CERT -DKEEP_PEER_CERT"
# Enable DH Extra
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DH_EXTRA"
# Enable deterministic ECC signing API with variant
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ECDSA_DETERMINISTIC_K_VARIANT"
# Store issuer name components when parsing certificates.
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_HAVE_ISSUER_NAMES"
# Certificate extensions and alt. names for FPKI use # Certificate extensions and alt. names for FPKI use
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SUBJ_DIR_ATTR -DWOLFSSL_FPKI -DWOLFSSL_SUBJ_INFO_ACC" AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SUBJ_DIR_ATTR -DWOLFSSL_FPKI -DWOLFSSL_SUBJ_INFO_ACC"
@@ -1032,6 +995,100 @@ then
fi fi
# Auto-selected activation of all applicable asm accelerations
# Enable asm automatically only if the compiler advertises itself as full Gnu C.
if "$CC" $AM_CFLAGS $CPPFLAGS $CFLAGS -x c - -o /dev/null >/dev/null 2>&1 <<' EOF'
#include <stdlib.h>
int main(int argc, char **argv) {
(void)argc; (void)argv;
#ifdef __STRICT_ANSI__
#error __STRICT_ANSI__
#endif
#ifndef __GNUC__
#error !__GNUC__
#endif
return 0;
}
EOF
then
HAVE_GNUC=yes
fi
if test "$enable_all_crypto" = "yes" &&
test "$ENABLED_LINUXKM_DEFAULTS" = "no" &&
test "$ENABLED_ASM" != "no" &&
test "$HAVE_GNUC" = "yes" &&
test "$enable_sp_asm" != "no" &&
test "$enable_intelasm" != "no" &&
test "$enable_armasm" != "no"
then
DEFAULT_ENABLED_ALL_ASM=yes
else
DEFAULT_ENABLED_ALL_ASM=no
fi
AC_ARG_ENABLE([all-asm],
[AS_HELP_STRING([--enable-all-asm],[Enable all applicable assembly accelerations (default: disabled)])],
[ ENABLED_ALL_ASM=$enableval ],
[ ENABLED_ALL_ASM=$DEFAULT_ENABLED_ALL_ASM ]
)
if test "$ENABLED_ALL_ASM" != "no"
then
if test "$ENABLED_ASM" = "no"
then
AC_MSG_ERROR([--enable-all-asm is incompatible with --disable-asm])
fi
if test "$enable_sp_asm" = "no"
then
AC_MSG_ERROR([--enable-all-asm is incompatible with --disable-sp-asm])
fi
if test "$enable_intelasm" = "no"
then
AC_MSG_ERROR([--enable-all-asm is incompatible with --disable-intelasm])
fi
if test "$enable_armasm" = "no"
then
AC_MSG_ERROR([--enable-all-asm is incompatible with --disable-armasm])
fi
case "$host_cpu" in
*x86_64*|*amd64*)
if test "$enable_intelasm" = ""
then
enable_intelasm=yes
fi
if test "$ENABLED_SP" != "no"
then
ENABLED_SP_ASM=yes
if test "$ENABLED_SP" = ""
then
ENABLED_SP=yes
fi
fi
;;
*aarch64*)
if test "$enable_armasm" = ""
then
enable_armasm=yes
fi
if test "$ENABLED_SP" != "no"
then
ENABLED_SP_ASM=yes
if test "$ENABLED_SP" = ""
then
ENABLED_SP=yes
fi
fi
;;
esac
fi
# ALL CRYPTO FEATURES # ALL CRYPTO FEATURES
AC_ARG_ENABLE([all-crypto], AC_ARG_ENABLE([all-crypto],
[AS_HELP_STRING([--enable-all-crypto],[Enable all wolfcrypt algorithms (default: disabled)])], [AS_HELP_STRING([--enable-all-crypto],[Enable all wolfcrypt algorithms (default: disabled)])],
@@ -1042,7 +1099,6 @@ if test "$ENABLED_ALL_CRYPT" = "yes"
then then
test "$enable_atomicuser" = "" && enable_atomicuser=yes test "$enable_atomicuser" = "" && enable_atomicuser=yes
test "$enable_aesgcm" = "" && enable_aesgcm=yes test "$enable_aesgcm" = "" && enable_aesgcm=yes
test "$enable_aesgcm_stream" = "" && test "$enable_aesgcm" = "yes" && enable_aesgcm_stream=yes
test "$enable_aesccm" = "" && enable_aesccm=yes test "$enable_aesccm" = "" && enable_aesccm=yes
test "$enable_aesctr" = "" && enable_aesctr=yes test "$enable_aesctr" = "" && enable_aesctr=yes
test "$enable_aeseax" = "" && enable_aeseax=yes test "$enable_aeseax" = "" && enable_aeseax=yes
@@ -1054,8 +1110,6 @@ then
test "$enable_sha224" = "" && enable_sha224=yes test "$enable_sha224" = "" && enable_sha224=yes
test "$enable_sha512" = "" && enable_sha512=yes test "$enable_sha512" = "" && enable_sha512=yes
test "$enable_sha3" = "" && enable_sha3=yes test "$enable_sha3" = "" && enable_sha3=yes
test "$enable_shake128" = "" && enable_shake128=yes
test "$enable_shake256" = "" && enable_shake256=yes
test "$enable_sessioncerts" = "" && enable_sessioncerts=yes test "$enable_sessioncerts" = "" && enable_sessioncerts=yes
test "$enable_keygen" = "" && enable_keygen=yes test "$enable_keygen" = "" && enable_keygen=yes
test "$enable_certgen" = "" && enable_certgen=yes test "$enable_certgen" = "" && enable_certgen=yes
@@ -1093,13 +1147,8 @@ then
test "$enable_md4" = "" && enable_md4=yes test "$enable_md4" = "" && enable_md4=yes
test "$enable_anon" = "" && enable_anon=yes test "$enable_anon" = "" && enable_anon=yes
test "$enable_ssh" = "" && test "$enable_hmac" != "no" && enable_ssh=yes test "$enable_ssh" = "" && test "$enable_hmac" != "no" && enable_ssh=yes
test "$enable_srtp_kdf" = "" && enable_srtp_kdf=yes
if test "$ENABLED_LINUXKM_DEFAULTS" != "yes"
then
test "$enable_compkey" = "" && enable_compkey=yes
fi
# sp-math is incompatible with opensslextra, ECC custom curves, and DSA.
if test "$ENABLED_SP_MATH" = "no" if test "$ENABLED_SP_MATH" = "no"
then then
test "$enable_dsa" = "" && test "$enable_sha" != "no" && enable_dsa=yes test "$enable_dsa" = "" && test "$enable_sha" != "no" && enable_dsa=yes
@@ -1129,25 +1178,30 @@ then
fi fi
fi fi
if test "$ENABLED_FIPS" = "no" || test "$HAVE_FIPS_VERSION" -ge 6 || test "$FIPS_VERSION" = "v5-dev"; then if test "$ENABLED_FIPS" = "no" || test "$HAVE_FIPS_VERSION" -ge 6
then
test "$enable_aesgcm_stream" = "" && test "$enable_aesgcm" = "yes" && enable_aesgcm_stream=yes
test "$enable_aesxts" = "" && enable_aesxts=yes test "$enable_aesxts" = "" && enable_aesxts=yes
test "$enable_aesxts_stream" = "" && test "$enable_aesxts" = "yes" && (test "$enable_armasm" = "" || test "$enable_armasm" = "no") && enable_aesxts_stream=yes test "$enable_aesxts_stream" = "" && test "$enable_aesxts" = "yes" && (test "$enable_armasm" = "" || test "$enable_armasm" = "no") && enable_aesxts_stream=yes
test "$enable_aessiv" = "" && enable_aessiv=yes test "$enable_aessiv" = "" && enable_aessiv=yes
test "$enable_shake128" = "" && enable_shake128=yes
test "$enable_shake256" = "" && enable_shake256=yes
test "$enable_compkey" = "" && test "$ENABLED_LINUXKM_DEFAULTS" != "yes" && enable_compkey=yes
test "$enable_srtp_kdf" = "" && enable_srtp_kdf=yes
fi fi
if test "$ENABLED_FIPS" = "no" || test "$HAVE_FIPS_VERSION" -le 5; then if test "$ENABLED_FIPS" = "no" || test "$HAVE_FIPS_VERSION" -le 5; then
test "$enable_des3" = "" && enable_des3=yes test "$enable_des3" = "" && enable_des3=yes
fi fi
# Enable AES Decrypt, AES ECB, Alt Names, DER Load AM_CFLAGS="$AM_CFLAGS -DHAVE_AES_DECRYPT -DHAVE_AES_ECB -DWOLFSSL_ALT_NAMES"
AM_CFLAGS="$AM_CFLAGS -DHAVE_AES_DECRYPT -DHAVE_AES_ECB -DWOLFSSL_ALT_NAMES -DWOLFSSL_DER_LOAD"
# Enable DH const table speedups (eliminates `-lm` math lib dependency) # Enable DH const table speedups (eliminates `-lm` math lib dependency)
AM_CFLAGS="$AM_CFLAGS -DHAVE_FFDHE_2048 -DHAVE_FFDHE_3072" AM_CFLAGS="$AM_CFLAGS -DHAVE_FFDHE_2048 -DHAVE_FFDHE_3072"
DEFAULT_MAX_CLASSIC_ASYM_KEY_BITS=4096 DEFAULT_MAX_CLASSIC_ASYM_KEY_BITS=4096
# Enable multiple attribute additions such as DC # Enable all parsing features for ASN */
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_MULTI_ATTRIB" AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ASN_ALL"
# Enable DH Extra # Enable DH Extra
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DH_EXTRA" AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DH_EXTRA"
@@ -2300,21 +2354,6 @@ then
DEFAULT_MAX_CLASSIC_ASYM_KEY_BITS=4096 DEFAULT_MAX_CLASSIC_ASYM_KEY_BITS=4096
fi fi
# lean psk build
AC_ARG_ENABLE([leanpsk],
[AS_HELP_STRING([--enable-leanpsk],[Enable Lean PSK build (default: disabled)])],
[ ENABLED_LEANPSK=$enableval ],
[ ENABLED_LEANPSK=no ]
)
if test "$ENABLED_LEANPSK" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_LEANPSK -DWOLFSSL_STATIC_PSK -DHAVE_NULL_CIPHER -DSINGLE_THREADED -DNO_AES -DNO_FILESYSTEM -DNO_RSA -DNO_DSA -DNO_DH -DNO_PWDBASED -DNO_MD4 -DNO_MD5 -DNO_ERROR_STRINGS -DNO_OLD_TLS -DNO_RC4 -DNO_WRITEV -DNO_DEV_RANDOM -DWOLFSSL_USER_IO -DNO_SHA"
ENABLED_SLOWMATH="no"
ENABLED_SINGLETHREADED="yes"
enable_lowresource=yes
fi
# lean TLS build (TLS 1.2 client only (no client auth), ECC256, AES128 and SHA256 w/o Shamir) # lean TLS build (TLS 1.2 client only (no client auth), ECC256, AES128 and SHA256 w/o Shamir)
AC_ARG_ENABLE([leantls], AC_ARG_ENABLE([leantls],
@@ -4034,7 +4073,8 @@ AC_ARG_ENABLE([compkey],
[ ENABLED_COMPKEY=no ] [ ENABLED_COMPKEY=no ]
) )
if test "$ENABLED_WPAS" = "yes" || test "$ENABLED_OPENSSLALL" = "yes" if (test "$ENABLED_WPAS" = "yes" || test "$ENABLED_OPENSSLALL" = "yes") &&
(test "$HAVE_FIPS_VERSION" != "5" || test "$FIPS_VERSION" = "v5-dev")
then then
ENABLED_COMPKEY=yes ENABLED_COMPKEY=yes
fi fi
@@ -4753,54 +4793,6 @@ then
fi fi
# ASN
# turn off asn, which means no certs, no rsa, no dsa, no ecc,
# and no big int (unless dh is on)
# turn off ASN if leanpsk on
if test "$ENABLED_LEANPSK" = "yes"
then
enable_asn=no
fi
AC_ARG_ENABLE([asn],
[AS_HELP_STRING([--enable-asn],[Enable ASN (default: enabled)])],
[ ENABLED_ASN=$enableval ],
[ ENABLED_ASN=yes ]
)
for v in `echo $ENABLED_ASN | tr "," " "`
do
case $v in
all)
# Enable all ASN features
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ASN_ALL"
ENABLED_ASN=yes
;;
template | yes)
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ASN_TEMPLATE"
ENABLED_ASN=yes
;;
original)
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ASN_ORIGINAL"
ENABLED_ASN=yes
;;
nocrypt)
AM_CFLAGS="$AM_CFLAGS -DNO_ASN_CRYPT"
enable_pwdbased=no
;;
no)
AM_CFLAGS="$AM_CFLAGS -DNO_ASN -DNO_ASN_CRYPT"
enable_pwdbased=no
ENABLED_ASN=no
;;
*)
AC_MSG_ERROR([Invalid asn option. Valid are: all, template/yes, original, nocrypt or no. Seen: $ENABLED_ASN.])
break;;
esac
done
if test "$ENABLED_RSA" = "yes" && test "$ENABLED_RSAVFY" = "no" && \ if test "$ENABLED_RSA" = "yes" && test "$ENABLED_RSAVFY" = "no" && \
test "$ENABLED_ASN" = "no" && test "$ENABLED_LOWRESOURCE" = "no" test "$ENABLED_ASN" = "no" && test "$ENABLED_LOWRESOURCE" = "no"
then then
@@ -5305,7 +5297,8 @@ AS_CASE([$FIPS_VERSION],
AS_IF([test "x$ENABLED_ECCCUSTCURVES" != "xno" && AS_IF([test "x$ENABLED_ECCCUSTCURVES" != "xno" &&
test "$FIPS_VERSION" != "dev"], test "$FIPS_VERSION" != "dev"],
[ENABLED_ECCCUSTCURVES="no"]) [AC_MSG_WARN([Forcing off ecccustcurves for FIPS ${FIPS_VERSION}.])
ENABLED_ECCCUSTCURVES="no"])
# Hashing section # Hashing section
AS_IF([test "x$ENABLED_SHA3" != "xyes" && AS_IF([test "x$ENABLED_SHA3" != "xyes" &&
@@ -5388,7 +5381,8 @@ AS_CASE([$FIPS_VERSION],
# Old TLS requires MD5 + HMAC, which is not allowed under FIPS 140-3 # Old TLS requires MD5 + HMAC, which is not allowed under FIPS 140-3
AS_IF([test "$ENABLED_OLD_TLS" != "no"], AS_IF([test "$ENABLED_OLD_TLS" != "no"],
[ENABLED_OLD_TLS="no"; AM_CFLAGS="$AM_CFLAGS -DNO_OLD_TLS"]) [AC_MSG_WARN([Forcing off oldtls for FIPS ${FIPS_VERSION}.])
ENABLED_OLD_TLS="no"; AM_CFLAGS="$AM_CFLAGS -DNO_OLD_TLS"])
], ],
[v5*], [ # FIPS 140-3 [v5*], [ # FIPS 140-3
@@ -5432,7 +5426,8 @@ AS_CASE([$FIPS_VERSION],
AS_IF([test "$ENABLED_COMPKEY" = "yes" && AS_IF([test "$ENABLED_COMPKEY" = "yes" &&
(test "$FIPS_VERSION" != "v5-dev" || test "$enable_compkey" != "yes")], (test "$FIPS_VERSION" != "v5-dev" || test "$enable_compkey" != "yes")],
[ENABLED_COMPKEY="no"]) [AC_MSG_WARN([Forcing off compkey for FIPS ${FIPS_VERSION}.])
ENABLED_COMPKEY="no"])
AS_IF([test "$ENABLED_SHA224" != "yes" && AS_IF([test "$ENABLED_SHA224" != "yes" &&
(test "$FIPS_VERSION" != "v5-dev" || test "$enable_sha224" != "no")], (test "$FIPS_VERSION" != "v5-dev" || test "$enable_sha224" != "no")],
@@ -5449,12 +5444,14 @@ AS_CASE([$FIPS_VERSION],
# Shake128 is a SHA-3 algorithm outside the v5 FIPS algorithm list # Shake128 is a SHA-3 algorithm outside the v5 FIPS algorithm list
AS_IF([test "$ENABLED_SHAKE128" != "no" && AS_IF([test "$ENABLED_SHAKE128" != "no" &&
(test "$FIPS_VERSION" != "v5-dev" || test "$enable_shake128" != "yes")], (test "$FIPS_VERSION" != "v5-dev" || test "$enable_shake128" != "yes")],
[ENABLED_SHAKE128=no; AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_NO_SHAKE128"]) [AC_MSG_WARN([Forcing off shake128 for FIPS ${FIPS_VERSION}.])
ENABLED_SHAKE128=no; AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_NO_SHAKE128"])
# Shake256 is a SHA-3 algorithm outside the v5 FIPS algorithm list # Shake256 is a SHA-3 algorithm outside the v5 FIPS algorithm list
AS_IF([test "$ENABLED_SHAKE256" != "no" && AS_IF([test "$ENABLED_SHAKE256" != "no" &&
(test "$FIPS_VERSION" != "v5-dev" || test "$enable_shake256" != "yes")], (test "$FIPS_VERSION" != "v5-dev" || test "$enable_shake256" != "yes")],
[ENABLED_SHAKE256=no; AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_NO_SHAKE256"]) [AC_MSG_WARN([Forcing off shake256 for FIPS ${FIPS_VERSION}.])
ENABLED_SHAKE256=no; AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_NO_SHAKE256"])
# SHA512-224 and SHA512-256 are SHA-2 algorithms outside the v5 FIPS algorithm list # SHA512-224 and SHA512-256 are SHA-2 algorithms outside the v5 FIPS algorithm list
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_NOSHA512_224 -DWOLFSSL_NOSHA512_256" AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_NOSHA512_224 -DWOLFSSL_NOSHA512_256"
@@ -5465,7 +5462,8 @@ AS_CASE([$FIPS_VERSION],
AS_IF([test "$ENABLED_AESXTS" = "yes" && AS_IF([test "$ENABLED_AESXTS" = "yes" &&
(test "$FIPS_VERSION" != "v5-dev" || test "$enable_aesxts" != "yes")], (test "$FIPS_VERSION" != "v5-dev" || test "$enable_aesxts" != "yes")],
[ENABLED_AESXTS="no"]) [AC_MSG_WARN([Forcing off aesxts for FIPS ${FIPS_VERSION}.])
ENABLED_AESXTS="no"])
AS_IF([test "$ENABLED_RSAPSS" != "yes" && AS_IF([test "$ENABLED_RSAPSS" != "yes" &&
(test "$FIPS_VERSION" != "v5-dev" || test "$enable_rsapss" != "no")], (test "$FIPS_VERSION" != "v5-dev" || test "$enable_rsapss" != "no")],
@@ -5504,17 +5502,29 @@ AS_CASE([$FIPS_VERSION],
# AES-GCM streaming isn't part of the v5 FIPS suite. # AES-GCM streaming isn't part of the v5 FIPS suite.
AS_IF([test "$ENABLED_AESGCM_STREAM" = "yes" && AS_IF([test "$ENABLED_AESGCM_STREAM" = "yes" &&
(test "$FIPS_VERSION" != "v5-dev" || test "$enable_aesgcm_stream" != "yes")], (test "$FIPS_VERSION" != "v5-dev" || test "$enable_aesgcm_stream" != "yes")],
[ENABLED_AESGCM_STREAM="no"]) [AC_MSG_WARN([Forcing off aesgcm-stream for FIPS ${FIPS_VERSION}.])
ENABLED_AESGCM_STREAM="no"])
# Old TLS requires MD5 + HMAC, which is not allowed under FIPS 140-3 # Old TLS requires MD5 + HMAC, which is not allowed under FIPS 140-3
AS_IF([test "$ENABLED_OLD_TLS" != "no"], AS_IF([test "$ENABLED_OLD_TLS" != "no"],
[ENABLED_OLD_TLS="no"; AM_CFLAGS="$AM_CFLAGS -DNO_OLD_TLS"]) [AC_MSG_WARN([Forcing off oldtls for FIPS ${FIPS_VERSION}.])
ENABLED_OLD_TLS="no"; AM_CFLAGS="$AM_CFLAGS -DNO_OLD_TLS"])
AS_IF([test $HAVE_FIPS_VERSION_MINOR -ge 2], AS_IF([test $HAVE_FIPS_VERSION_MINOR -ge 2],
[AS_IF([test "x$ENABLED_AESOFB" = "xno" && [AS_IF([test "x$ENABLED_AESOFB" = "xno" &&
(test "$FIPS_VERSION" != "v5-dev" || test "$enable_aesofb" != "no")], (test "$FIPS_VERSION" != "v5-dev" || test "$enable_aesofb" != "no")],
[ENABLED_AESOFB="yes"; AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_AES_OFB"])]) [ENABLED_AESOFB="yes"; AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_AES_OFB"])])
AS_IF([test "$ENABLED_SRTP" != "no" &&
(test "$FIPS_VERSION" != "v5-dev" || test "$enable_srtp" != "yes")],
[AC_MSG_WARN([Forcing off srtp for FIPS ${FIPS_VERSION}.])
ENABLED_SRTP="no"])
AS_IF([test "$ENABLED_SRTP_KDF" != "no" &&
(test "$FIPS_VERSION" != "v5-dev" || test "$enable_srtp_kdf" != "yes")],
[AC_MSG_WARN([Forcing off srtp-kdf for FIPS ${FIPS_VERSION}.])
ENABLED_SRTP_KDF="no"])
AS_IF([(test "$ENABLED_AESCCM" = "yes" && test "$HAVE_AESCCM_PORT" != "yes") || AS_IF([(test "$ENABLED_AESCCM" = "yes" && test "$HAVE_AESCCM_PORT" != "yes") ||
(test "$ENABLED_AESCTR" = "yes" && test "$HAVE_AESCTR_PORT" != "yes") || (test "$ENABLED_AESCTR" = "yes" && test "$HAVE_AESCTR_PORT" != "yes") ||
(test "$ENABLED_AESGCM" = "yes" && test "$HAVE_AESGCM_PORT" != "yes") || (test "$ENABLED_AESGCM" = "yes" && test "$HAVE_AESGCM_PORT" != "yes") ||
@@ -8421,7 +8431,7 @@ then
if test "x$ENABLED_HEAPMATH" = "xyes" if test "x$ENABLED_HEAPMATH" = "xyes"
then then
AC_MSG_ERROR([please use --enable-fastmath if enabling staticmemory.]) AC_MSG_ERROR([--enable-heapmath is incompatible with --enable-staticmemory.])
fi fi
if test "$ENABLED_LOWRESOURCE" = "yes" && test "$ENABLED_RSA" = "no" if test "$ENABLED_LOWRESOURCE" = "yes" && test "$ENABLED_RSA" = "no"
then then
@@ -8886,7 +8896,7 @@ fi
# determine if we have key validation mechanism # determine if we have key validation mechanism
if test "x$ENABLED_ECC" != "xno" || test "x$ENABLED_RSA" = "xyes" if test "x$ENABLED_ECC" != "xno" || test "x$ENABLED_RSA" = "xyes"
then then
if test "x$ENABLED_ASN" = "xyes" if test "$ENABLED_ASN" != "no" && test "$ENABLED_ASN" != "nocrypt"
then then
ENABLED_PKI="yes" ENABLED_PKI="yes"
fi fi
@@ -9816,7 +9826,7 @@ AM_CONDITIONAL([BUILD_FASTMATH],[test "x$ENABLED_FASTMATH" = "xyes" || test "x$E
AM_CONDITIONAL([BUILD_HEAPMATH],[test "x$ENABLED_HEAPMATH" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"]) AM_CONDITIONAL([BUILD_HEAPMATH],[test "x$ENABLED_HEAPMATH" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([BUILD_EXAMPLE_SERVERS],[test "x$ENABLED_EXAMPLES" = "xyes" && test "x$ENABLED_LEANTLS" = "xno"]) AM_CONDITIONAL([BUILD_EXAMPLE_SERVERS],[test "x$ENABLED_EXAMPLES" = "xyes" && test "x$ENABLED_LEANTLS" = "xno"])
AM_CONDITIONAL([BUILD_EXAMPLE_CLIENTS],[test "x$ENABLED_EXAMPLES" = "xyes"]) AM_CONDITIONAL([BUILD_EXAMPLE_CLIENTS],[test "x$ENABLED_EXAMPLES" = "xyes"])
AM_CONDITIONAL([BUILD_EXAMPLE_ASN1],[test "x$ENABLED_EXAMPLES" = "xyes"] && [test "x$ENABLED_ASN_PRINT" = "xyes"] && [test "x$ENABLED_ASN" = "xyes"]) AM_CONDITIONAL([BUILD_EXAMPLE_ASN1],[test "x$ENABLED_EXAMPLES" = "xyes" && test "x$ENABLED_ASN_PRINT" = "xyes" && test "$ENABLED_ASN" != "no"])
AM_CONDITIONAL([BUILD_TESTS],[test "x$ENABLED_EXAMPLES" = "xyes"]) AM_CONDITIONAL([BUILD_TESTS],[test "x$ENABLED_EXAMPLES" = "xyes"])
AM_CONDITIONAL([BUILD_THREADED_EXAMPLES],[test "x$ENABLED_SINGLETHREADED" = "xno" && test "x$ENABLED_EXAMPLES" = "xyes" && test "x$ENABLED_LEANTLS" = "xno"]) AM_CONDITIONAL([BUILD_THREADED_EXAMPLES],[test "x$ENABLED_SINGLETHREADED" = "xno" && test "x$ENABLED_EXAMPLES" = "xyes" && test "x$ENABLED_LEANTLS" = "xno"])
AM_CONDITIONAL([BUILD_WOLFCRYPT_TESTS],[test "x$ENABLED_CRYPT_TESTS" = "xyes"]) AM_CONDITIONAL([BUILD_WOLFCRYPT_TESTS],[test "x$ENABLED_CRYPT_TESTS" = "xyes"])

View File

@@ -36028,7 +36028,7 @@ static int DecodeSingleResponse(byte* source, word32* ioIndex, word32 size,
*ioIndex = idx; *ioIndex = idx;
return 0; return 0;
#else #else /* WOLFSSL_ASN_TEMPLATE */
DECL_ASNGETDATA(dataASN, singleResponseASN_Length); DECL_ASNGETDATA(dataASN, singleResponseASN_Length);
int ret = 0; int ret = 0;
word32 ocspDigestSize = OCSP_DIGEST_SIZE; word32 ocspDigestSize = OCSP_DIGEST_SIZE;
@@ -36038,10 +36038,6 @@ static int DecodeSingleResponse(byte* source, word32* ioIndex, word32 size,
word32 issuerKeyHashLen; word32 issuerKeyHashLen;
word32 thisDateLen; word32 thisDateLen;
word32 nextDateLen; word32 nextDateLen;
#if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || \
defined(WOLFSSL_HAPROXY) || defined(HAVE_LIGHTY)
WOLFSSL_ASN1_TIME *at;
#endif
(void)wrapperSz; (void)wrapperSz;
@@ -36119,19 +36115,20 @@ static int DecodeSingleResponse(byte* source, word32* ioIndex, word32 size,
if (!XVALIDATE_DATE(cs->thisDate, ASN_GENERALIZED_TIME, ASN_BEFORE)) { if (!XVALIDATE_DATE(cs->thisDate, ASN_GENERALIZED_TIME, ASN_BEFORE)) {
ret = ASN_BEFORE_DATE_E; ret = ASN_BEFORE_DATE_E;
} }
#endif /* !NO_ASN_TIME_CHECK && !WOLFSSL_NO_OCSP_DATE_CHECK */
} }
#ifdef WOLFSSL_OCSP_PARSE_STATUS
if (ret == 0) { if (ret == 0) {
#endif
#ifdef WOLFSSL_OCSP_PARSE_STATUS
/* Store ASN.1 version of thisDate. */ /* Store ASN.1 version of thisDate. */
WOLFSSL_ASN1_TIME *at;
cs->thisDateAsn = GetASNItem_Addr( cs->thisDateAsn = GetASNItem_Addr(
dataASN[SINGLERESPONSEASN_IDX_THISUPDATE_GT], source); dataASN[SINGLERESPONSEASN_IDX_THISUPDATE_GT], source);
at = &cs->thisDateParsed; at = &cs->thisDateParsed;
at->type = ASN_GENERALIZED_TIME; at->type = ASN_GENERALIZED_TIME;
XMEMCPY(at->data, cs->thisDate, thisDateLen); XMEMCPY(at->data, cs->thisDate, thisDateLen);
at->length = (int)thisDateLen; at->length = (int)thisDateLen;
#endif
} }
#endif
if ((ret == 0) && if ((ret == 0) &&
(dataASN[SINGLERESPONSEASN_IDX_NEXTUPDATE_GT].tag != 0)) { (dataASN[SINGLERESPONSEASN_IDX_NEXTUPDATE_GT].tag != 0)) {
/* Store the nextDate format - only one possible. */ /* Store the nextDate format - only one possible. */
@@ -36141,20 +36138,22 @@ static int DecodeSingleResponse(byte* source, word32* ioIndex, word32 size,
if (!XVALIDATE_DATE(cs->nextDate, ASN_GENERALIZED_TIME, ASN_AFTER)) { if (!XVALIDATE_DATE(cs->nextDate, ASN_GENERALIZED_TIME, ASN_AFTER)) {
ret = ASN_AFTER_DATE_E; ret = ASN_AFTER_DATE_E;
} }
#endif /* !NO_ASN_TIME_CHECK && !WOLFSSL_NO_OCSP_DATE_CHECK */
} }
#ifdef WOLFSSL_OCSP_PARSE_STATUS
if ((ret == 0) && if ((ret == 0) &&
(dataASN[SINGLERESPONSEASN_IDX_NEXTUPDATE_GT].tag != 0)) { (dataASN[SINGLERESPONSEASN_IDX_NEXTUPDATE_GT].tag != 0))
#endif {
#ifdef WOLFSSL_OCSP_PARSE_STATUS
/* Store ASN.1 version of thisDate. */ /* Store ASN.1 version of thisDate. */
WOLFSSL_ASN1_TIME *at;
cs->nextDateAsn = GetASNItem_Addr( cs->nextDateAsn = GetASNItem_Addr(
dataASN[SINGLERESPONSEASN_IDX_NEXTUPDATE_GT], source); dataASN[SINGLERESPONSEASN_IDX_NEXTUPDATE_GT], source);
at = &cs->nextDateParsed; at = &cs->nextDateParsed;
at->type = ASN_GENERALIZED_TIME; at->type = ASN_GENERALIZED_TIME;
XMEMCPY(at->data, cs->nextDate, nextDateLen); XMEMCPY(at->data, cs->nextDate, nextDateLen);
at->length = (int)nextDateLen; at->length = (int)nextDateLen;
#endif
} }
#endif
if (ret == 0) { if (ret == 0) {
/* OcspEntry now used. */ /* OcspEntry now used. */
single->used = 1; single->used = 1;
@@ -36162,7 +36161,7 @@ static int DecodeSingleResponse(byte* source, word32* ioIndex, word32 size,
FREE_ASNGETDATA(dataASN, NULL); FREE_ASNGETDATA(dataASN, NULL);
return ret; return ret;
#endif #endif /* WOLFSSL_ASN_TEMPLATE */
} }
#ifdef WOLFSSL_ASN_TEMPLATE #ifdef WOLFSSL_ASN_TEMPLATE

View File

@@ -805,29 +805,29 @@ int wc_SipHash(const unsigned char* key, const unsigned char* in, word32 inSz,
#else #else
#define SipRoundV(v0, v1, v2, v3) \ #define SipRoundV(v0, v1, v2, v3) \
v0 += v1; \ (v0) += (v1); \
v2 += v3; \ (v2) += (v3); \
v1 = rotlFixed64(v1, 13); \ (v1) = rotlFixed64(v1, 13); \
v3 = rotlFixed64(v3, 16); \ (v3) = rotlFixed64(v3, 16); \
v1 ^= v0; \ (v1) ^= (v0); \
v3 ^= v2; \ (v3) ^= (v2); \
v0 = rotlFixed64(v0, 32); \ (v0) = rotlFixed64(v0, 32); \
v2 += v1; \ (v2) += (v1); \
v0 += v3; \ (v0) += (v3); \
v1 = rotlFixed64(v1, 17); \ (v1) = rotlFixed64(v1, 17); \
v3 = rotlFixed64(v3, 21); \ (v3) = rotlFixed64(v3, 21); \
v1 ^= v2; \ (v1) ^= (v2); \
v3 ^= v0; \ (v3) ^= (v0); \
v2 = rotlFixed64(v2, 32); (v2) = rotlFixed64(v2, 32);
#define SipHashCompressV(v0, v1, v2, v3, m) \ #define SipHashCompressV(v0, v1, v2, v3, m) \
do { \ do { \
int i; \ int i; \
v3 ^= m; \ (v3) ^= (m); \
for (i = 0; i < WOLFSSL_SIPHASH_CROUNDS; i++) { \ for (i = 0; i < WOLFSSL_SIPHASH_CROUNDS; i++) { \
SipRoundV(v0, v1, v2, v3); \ SipRoundV(v0, v1, v2, v3); \
} \ } \
v0 ^= m; \ (v0) ^= (m); \
} \ } \
while (0) while (0)
@@ -839,7 +839,7 @@ int wc_SipHash(const unsigned char* key, const unsigned char* in, word32 inSz,
for (i = 0; i < WOLFSSL_SIPHASH_DROUNDS; i++) { \ for (i = 0; i < WOLFSSL_SIPHASH_DROUNDS; i++) { \
SipRoundV(v0, v1, v2, v3); \ SipRoundV(v0, v1, v2, v3); \
} \ } \
n = v0 ^ v1 ^ v2 ^ v3; \ n = (v0) ^ (v1) ^ (v2) ^ (v3); \
SET_U64(out, n); \ SET_U64(out, n); \
} \ } \
while (0) while (0)

View File

@@ -67,7 +67,7 @@
do { \ do { \
int ii; \ int ii; \
fprintf(stderr, name "=0x"); \ fprintf(stderr, name "=0x"); \
for (ii = ((bits + 31) / 32) - 1; ii >= 0; ii--) \ for (ii = (((bits) + 31) / 32) - 1; ii >= 0; ii--) \
fprintf(stderr, SP_PRINT_FMT, (var)[ii]); \ fprintf(stderr, SP_PRINT_FMT, (var)[ii]); \
fprintf(stderr, "\n"); \ fprintf(stderr, "\n"); \
} while (0) } while (0)
@@ -12022,7 +12022,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[32], 0, sizeof(sp_digit) * 32U); XMEMSET(&r[32], 0, sizeof(sp_digit) * 32U);
sp_2048_mont_reduce_32(r, m, mp); sp_2048_mont_reduce_32(r, m, mp);
mask = 0 - (sp_2048_cmp_32(r, m) >= 0); mask = (sp_digit)0 - (sp_2048_cmp_32(r, m) >= 0);
sp_2048_cond_sub_32(r, r, m, mask); sp_2048_cond_sub_32(r, r, m, mask);
} }
@@ -12190,7 +12190,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[32], 0, sizeof(sp_digit) * 32U); XMEMSET(&r[32], 0, sizeof(sp_digit) * 32U);
sp_2048_mont_reduce_32(r, m, mp); sp_2048_mont_reduce_32(r, m, mp);
mask = 0 - (sp_2048_cmp_32(r, m) >= 0); mask = (sp_digit)0 - (sp_2048_cmp_32(r, m) >= 0);
sp_2048_cond_sub_32(r, r, m, mask); sp_2048_cond_sub_32(r, r, m, mask);
} }
@@ -16781,7 +16781,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U); XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U);
sp_2048_mont_reduce_64(r, m, mp); sp_2048_mont_reduce_64(r, m, mp);
mask = 0 - (sp_2048_cmp_64(r, m) >= 0); mask = (sp_digit)0 - (sp_2048_cmp_64(r, m) >= 0);
sp_2048_cond_sub_64(r, r, m, mask); sp_2048_cond_sub_64(r, r, m, mask);
} }
@@ -16932,7 +16932,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U); XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U);
sp_2048_mont_reduce_64(r, m, mp); sp_2048_mont_reduce_64(r, m, mp);
mask = 0 - (sp_2048_cmp_64(r, m) >= 0); mask = (sp_digit)0 - (sp_2048_cmp_64(r, m) >= 0);
sp_2048_cond_sub_64(r, r, m, mask); sp_2048_cond_sub_64(r, r, m, mask);
} }
@@ -18112,7 +18112,7 @@ static int sp_2048_mod_exp_2_64(sp_digit* r, const sp_digit* e, int bits,
XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U); XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U);
sp_2048_mont_reduce_64(r, m, mp); sp_2048_mont_reduce_64(r, m, mp);
mask = 0 - (sp_2048_cmp_64(r, m) >= 0); mask = (sp_digit)0 - (sp_2048_cmp_64(r, m) >= 0);
sp_2048_cond_sub_64(r, r, m, mask); sp_2048_cond_sub_64(r, r, m, mask);
} }
@@ -37393,7 +37393,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[48], 0, sizeof(sp_digit) * 48U); XMEMSET(&r[48], 0, sizeof(sp_digit) * 48U);
sp_3072_mont_reduce_48(r, m, mp); sp_3072_mont_reduce_48(r, m, mp);
mask = 0 - (sp_3072_cmp_48(r, m) >= 0); mask = (sp_digit)0 - (sp_3072_cmp_48(r, m) >= 0);
sp_3072_cond_sub_48(r, r, m, mask); sp_3072_cond_sub_48(r, r, m, mask);
} }
@@ -37561,7 +37561,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[48], 0, sizeof(sp_digit) * 48U); XMEMSET(&r[48], 0, sizeof(sp_digit) * 48U);
sp_3072_mont_reduce_48(r, m, mp); sp_3072_mont_reduce_48(r, m, mp);
mask = 0 - (sp_3072_cmp_48(r, m) >= 0); mask = (sp_digit)0 - (sp_3072_cmp_48(r, m) >= 0);
sp_3072_cond_sub_48(r, r, m, mask); sp_3072_cond_sub_48(r, r, m, mask);
} }
@@ -44022,7 +44022,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[96], 0, sizeof(sp_digit) * 96U); XMEMSET(&r[96], 0, sizeof(sp_digit) * 96U);
sp_3072_mont_reduce_96(r, m, mp); sp_3072_mont_reduce_96(r, m, mp);
mask = 0 - (sp_3072_cmp_96(r, m) >= 0); mask = (sp_digit)0 - (sp_3072_cmp_96(r, m) >= 0);
sp_3072_cond_sub_96(r, r, m, mask); sp_3072_cond_sub_96(r, r, m, mask);
} }
@@ -44173,7 +44173,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[96], 0, sizeof(sp_digit) * 96U); XMEMSET(&r[96], 0, sizeof(sp_digit) * 96U);
sp_3072_mont_reduce_96(r, m, mp); sp_3072_mont_reduce_96(r, m, mp);
mask = 0 - (sp_3072_cmp_96(r, m) >= 0); mask = (sp_digit)0 - (sp_3072_cmp_96(r, m) >= 0);
sp_3072_cond_sub_96(r, r, m, mask); sp_3072_cond_sub_96(r, r, m, mask);
} }
@@ -45601,7 +45601,7 @@ static int sp_3072_mod_exp_2_96(sp_digit* r, const sp_digit* e, int bits,
XMEMSET(&r[96], 0, sizeof(sp_digit) * 96U); XMEMSET(&r[96], 0, sizeof(sp_digit) * 96U);
sp_3072_mont_reduce_96(r, m, mp); sp_3072_mont_reduce_96(r, m, mp);
mask = 0 - (sp_3072_cmp_96(r, m) >= 0); mask = (sp_digit)0 - (sp_3072_cmp_96(r, m) >= 0);
sp_3072_cond_sub_96(r, r, m, mask); sp_3072_cond_sub_96(r, r, m, mask);
} }
@@ -59437,7 +59437,7 @@ static int sp_4096_mod_exp_128(sp_digit* r, const sp_digit* a, const sp_digit* e
XMEMSET(&r[128], 0, sizeof(sp_digit) * 128U); XMEMSET(&r[128], 0, sizeof(sp_digit) * 128U);
sp_4096_mont_reduce_128(r, m, mp); sp_4096_mont_reduce_128(r, m, mp);
mask = 0 - (sp_4096_cmp_128(r, m) >= 0); mask = (sp_digit)0 - (sp_4096_cmp_128(r, m) >= 0);
sp_4096_cond_sub_128(r, r, m, mask); sp_4096_cond_sub_128(r, r, m, mask);
} }
@@ -59588,7 +59588,7 @@ static int sp_4096_mod_exp_128(sp_digit* r, const sp_digit* a, const sp_digit* e
XMEMSET(&r[128], 0, sizeof(sp_digit) * 128U); XMEMSET(&r[128], 0, sizeof(sp_digit) * 128U);
sp_4096_mont_reduce_128(r, m, mp); sp_4096_mont_reduce_128(r, m, mp);
mask = 0 - (sp_4096_cmp_128(r, m) >= 0); mask = (sp_digit)0 - (sp_4096_cmp_128(r, m) >= 0);
sp_4096_cond_sub_128(r, r, m, mask); sp_4096_cond_sub_128(r, r, m, mask);
} }
@@ -61264,7 +61264,7 @@ static int sp_4096_mod_exp_2_128(sp_digit* r, const sp_digit* e, int bits,
XMEMSET(&r[128], 0, sizeof(sp_digit) * 128U); XMEMSET(&r[128], 0, sizeof(sp_digit) * 128U);
sp_4096_mont_reduce_128(r, m, mp); sp_4096_mont_reduce_128(r, m, mp);
mask = 0 - (sp_4096_cmp_128(r, m) >= 0); mask = (sp_digit)0 - (sp_4096_cmp_128(r, m) >= 0);
sp_4096_cond_sub_128(r, r, m, mask); sp_4096_cond_sub_128(r, r, m, mask);
} }
@@ -72463,7 +72463,7 @@ static void sp_256_map_8(sp_point_256* r, const sp_point_256* p,
sp_256_mont_reduce_8(r->x, p256_mod, p256_mp_mod); sp_256_mont_reduce_8(r->x, p256_mod, p256_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_256_cmp_8(r->x, p256_mod); n = sp_256_cmp_8(r->x, p256_mod);
sp_256_cond_sub_8(r->x, r->x, p256_mod, ~(n >> 31)); sp_256_cond_sub_8(r->x, r->x, p256_mod, (sp_digit)~(n >> 31));
sp_256_norm_8(r->x); sp_256_norm_8(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -72472,7 +72472,7 @@ static void sp_256_map_8(sp_point_256* r, const sp_point_256* p,
sp_256_mont_reduce_8(r->y, p256_mod, p256_mp_mod); sp_256_mont_reduce_8(r->y, p256_mod, p256_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_256_cmp_8(r->y, p256_mod); n = sp_256_cmp_8(r->y, p256_mod);
sp_256_cond_sub_8(r->y, r->y, p256_mod, ~(n >> 31)); sp_256_cond_sub_8(r->y, r->y, p256_mod, (sp_digit)~(n >> 31));
sp_256_norm_8(r->y); sp_256_norm_8(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -73088,8 +73088,8 @@ static void sp_256_proj_point_add_8(sp_point_256* r,
sp_256_mont_sub_8(y, y, t5, p256_mod); sp_256_mont_sub_8(y, y, t5, p256_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -73106,7 +73106,7 @@ static void sp_256_proj_point_add_8(sp_point_256* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -73280,8 +73280,8 @@ static int sp_256_proj_point_add_8_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -73298,7 +73298,7 @@ static int sp_256_proj_point_add_8_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -73353,7 +73353,7 @@ static void sp_256_get_point_16_8(sp_point_256* r, const sp_point_256* table,
r->z[6] = 0; r->z[6] = 0;
r->z[7] = 0; r->z[7] = 0;
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -73751,8 +73751,8 @@ static void sp_256_proj_point_add_qz1_8(sp_point_256* r,
sp_256_mont_sub_8(y, t3, t1, p256_mod); sp_256_mont_sub_8(y, t3, t1, p256_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -73769,7 +73769,7 @@ static void sp_256_proj_point_add_qz1_8(sp_point_256* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -73896,7 +73896,7 @@ static void sp_256_get_entry_16_8(sp_point_256* r,
r->y[6] = 0; r->y[6] = 0;
r->y[7] = 0; r->y[7] = 0;
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -74317,7 +74317,7 @@ static void sp_256_get_entry_256_8(sp_point_256* r,
r->y[6] = 0; r->y[6] = 0;
r->y[7] = 0; r->y[7] = 0;
for (i = 1; i < 256; i++) { for (i = 1; i < 256; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -88818,18 +88818,18 @@ static int sp_384_mod_mul_norm_12(sp_digit* r, const sp_digit* a, const sp_digit
t[10] += t[9] >> 32; t[9] &= 0xffffffff; t[10] += t[9] >> 32; t[9] &= 0xffffffff;
t[11] += t[10] >> 32; t[10] &= 0xffffffff; t[11] += t[10] >> 32; t[10] &= 0xffffffff;
r[0] = t[0]; r[0] = (sp_digit)t[0];
r[1] = t[1]; r[1] = (sp_digit)t[1];
r[2] = t[2]; r[2] = (sp_digit)t[2];
r[3] = t[3]; r[3] = (sp_digit)t[3];
r[4] = t[4]; r[4] = (sp_digit)t[4];
r[5] = t[5]; r[5] = (sp_digit)t[5];
r[6] = t[6]; r[6] = (sp_digit)t[6];
r[7] = t[7]; r[7] = (sp_digit)t[7];
r[8] = t[8]; r[8] = (sp_digit)t[8];
r[9] = t[9]; r[9] = (sp_digit)t[9];
r[10] = t[10]; r[10] = (sp_digit)t[10];
r[11] = t[11]; r[11] = (sp_digit)t[11];
} }
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
@@ -90136,7 +90136,7 @@ static void sp_384_map_12(sp_point_384* r, const sp_point_384* p,
sp_384_mont_reduce_12(r->x, p384_mod, p384_mp_mod); sp_384_mont_reduce_12(r->x, p384_mod, p384_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_384_cmp_12(r->x, p384_mod); n = sp_384_cmp_12(r->x, p384_mod);
sp_384_cond_sub_12(r->x, r->x, p384_mod, ~(n >> 31)); sp_384_cond_sub_12(r->x, r->x, p384_mod, (sp_digit)~(n >> 31));
sp_384_norm_12(r->x); sp_384_norm_12(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -90145,7 +90145,7 @@ static void sp_384_map_12(sp_point_384* r, const sp_point_384* p,
sp_384_mont_reduce_12(r->y, p384_mod, p384_mp_mod); sp_384_mont_reduce_12(r->y, p384_mod, p384_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_384_cmp_12(r->y, p384_mod); n = sp_384_cmp_12(r->y, p384_mod);
sp_384_cond_sub_12(r->y, r->y, p384_mod, ~(n >> 31)); sp_384_cond_sub_12(r->y, r->y, p384_mod, (sp_digit)~(n >> 31));
sp_384_norm_12(r->y); sp_384_norm_12(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -90789,8 +90789,8 @@ static void sp_384_proj_point_add_12(sp_point_384* r,
sp_384_mont_sub_12(y, y, t5, p384_mod); sp_384_mont_sub_12(y, y, t5, p384_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -90807,7 +90807,7 @@ static void sp_384_proj_point_add_12(sp_point_384* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -90981,8 +90981,8 @@ static int sp_384_proj_point_add_12_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -90999,7 +90999,7 @@ static int sp_384_proj_point_add_12_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -91066,7 +91066,7 @@ static void sp_384_get_point_16_12(sp_point_384* r, const sp_point_384* table,
r->z[10] = 0; r->z[10] = 0;
r->z[11] = 0; r->z[11] = 0;
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -91476,8 +91476,8 @@ static void sp_384_proj_point_add_qz1_12(sp_point_384* r,
sp_384_mont_sub_12(y, t3, t1, p384_mod); sp_384_mont_sub_12(y, t3, t1, p384_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -91494,7 +91494,7 @@ static void sp_384_proj_point_add_qz1_12(sp_point_384* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -91629,7 +91629,7 @@ static void sp_384_get_entry_16_12(sp_point_384* r,
r->y[10] = 0; r->y[10] = 0;
r->y[11] = 0; r->y[11] = 0;
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -92066,7 +92066,7 @@ static void sp_384_get_entry_256_12(sp_point_384* r,
r->y[10] = 0; r->y[10] = 0;
r->y[11] = 0; r->y[11] = 0;
for (i = 1; i < 256; i++) { for (i = 1; i < 256; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -117158,7 +117158,7 @@ static void sp_521_map_17(sp_point_521* r, const sp_point_521* p,
sp_521_mont_reduce_17(r->x, p521_mod, p521_mp_mod); sp_521_mont_reduce_17(r->x, p521_mod, p521_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_521_cmp_17(r->x, p521_mod); n = sp_521_cmp_17(r->x, p521_mod);
sp_521_cond_sub_17(r->x, r->x, p521_mod, ~(n >> 31)); sp_521_cond_sub_17(r->x, r->x, p521_mod, (sp_digit)~(n >> 31));
sp_521_norm_17(r->x); sp_521_norm_17(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -117167,7 +117167,7 @@ static void sp_521_map_17(sp_point_521* r, const sp_point_521* p,
sp_521_mont_reduce_17(r->y, p521_mod, p521_mp_mod); sp_521_mont_reduce_17(r->y, p521_mod, p521_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_521_cmp_17(r->y, p521_mod); n = sp_521_cmp_17(r->y, p521_mod);
sp_521_cond_sub_17(r->y, r->y, p521_mod, ~(n >> 31)); sp_521_cond_sub_17(r->y, r->y, p521_mod, (sp_digit)~(n >> 31));
sp_521_norm_17(r->y); sp_521_norm_17(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -117911,8 +117911,8 @@ static void sp_521_proj_point_add_17(sp_point_521* r,
sp_521_mont_sub_17(y, y, t5, p521_mod); sp_521_mont_sub_17(y, y, t5, p521_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -117929,7 +117929,7 @@ static void sp_521_proj_point_add_17(sp_point_521* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -118103,8 +118103,8 @@ static int sp_521_proj_point_add_17_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -118121,7 +118121,7 @@ static int sp_521_proj_point_add_17_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -118203,7 +118203,7 @@ static void sp_521_get_point_16_17(sp_point_521* r, const sp_point_521* table,
r->z[15] = 0; r->z[15] = 0;
r->z[16] = 0; r->z[16] = 0;
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -118632,8 +118632,8 @@ static void sp_521_proj_point_add_qz1_17(sp_point_521* r,
sp_521_mont_sub_17(y, t3, t1, p521_mod); sp_521_mont_sub_17(y, t3, t1, p521_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -118650,7 +118650,7 @@ static void sp_521_proj_point_add_qz1_17(sp_point_521* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -118795,7 +118795,7 @@ static void sp_521_get_entry_16_17(sp_point_521* r,
r->y[15] = 0; r->y[15] = 0;
r->y[16] = 0; r->y[16] = 0;
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -119252,7 +119252,7 @@ static void sp_521_get_entry_256_17(sp_point_521* r,
r->y[15] = 0; r->y[15] = 0;
r->y[16] = 0; r->y[16] = 0;
for (i = 1; i < 256; i++) { for (i = 1; i < 256; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -146392,7 +146392,7 @@ static void sp_1024_map_32(sp_point_1024* r, const sp_point_1024* p,
sp_1024_mont_reduce_32(r->x, p1024_mod, p1024_mp_mod); sp_1024_mont_reduce_32(r->x, p1024_mod, p1024_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_1024_cmp_32(r->x, p1024_mod); n = sp_1024_cmp_32(r->x, p1024_mod);
sp_1024_cond_sub_32(r->x, r->x, p1024_mod, ~(n >> 31)); sp_1024_cond_sub_32(r->x, r->x, p1024_mod, (sp_digit)~(n >> 31));
sp_1024_norm_32(r->x); sp_1024_norm_32(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -146401,7 +146401,7 @@ static void sp_1024_map_32(sp_point_1024* r, const sp_point_1024* p,
sp_1024_mont_reduce_32(r->y, p1024_mod, p1024_mp_mod); sp_1024_mont_reduce_32(r->y, p1024_mod, p1024_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_1024_cmp_32(r->y, p1024_mod); n = sp_1024_cmp_32(r->y, p1024_mod);
sp_1024_cond_sub_32(r->y, r->y, p1024_mod, ~(n >> 31)); sp_1024_cond_sub_32(r->y, r->y, p1024_mod, (sp_digit)~(n >> 31));
sp_1024_norm_32(r->y); sp_1024_norm_32(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -147847,8 +147847,8 @@ static void sp_1024_proj_point_add_32(sp_point_1024* r,
sp_1024_mont_sub_32(y, y, t5, p1024_mod); sp_1024_mont_sub_32(y, y, t5, p1024_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -147865,7 +147865,7 @@ static void sp_1024_proj_point_add_32(sp_point_1024* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -148039,8 +148039,8 @@ static int sp_1024_proj_point_add_32_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -148057,7 +148057,7 @@ static int sp_1024_proj_point_add_32_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -148398,8 +148398,8 @@ static void sp_1024_proj_point_add_qz1_32(sp_point_1024* r,
sp_1024_mont_sub_32(y, t3, t1, p1024_mod); sp_1024_mont_sub_32(y, t3, t1, p1024_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -148416,7 +148416,7 @@ static void sp_1024_proj_point_add_qz1_32(sp_point_1024* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -156541,7 +156541,7 @@ static int sp_1024_ecc_is_point_32(const sp_point_1024* point,
n = sp_1024_cmp_32(t1, p1024_mod); n = sp_1024_cmp_32(t1, p1024_mod);
sp_1024_cond_sub_32(t1, t1, p1024_mod, ~(n >> 31)); sp_1024_cond_sub_32(t1, t1, p1024_mod, (sp_digit)~(n >> 31));
sp_1024_norm_32(t1); sp_1024_norm_32(t1);
if (!sp_1024_iszero_32(t1)) { if (!sp_1024_iszero_32(t1)) {
err = MP_VAL; err = MP_VAL;

View File

@@ -67,7 +67,7 @@
do { \ do { \
int ii; \ int ii; \
fprintf(stderr, name "=0x"); \ fprintf(stderr, name "=0x"); \
for (ii = ((bits + 63) / 64) - 1; ii >= 0; ii--) \ for (ii = (((bits) + 63) / 64) - 1; ii >= 0; ii--) \
fprintf(stderr, SP_PRINT_FMT, (var)[ii]); \ fprintf(stderr, SP_PRINT_FMT, (var)[ii]); \
fprintf(stderr, "\n"); \ fprintf(stderr, "\n"); \
} while (0) } while (0)
@@ -4164,7 +4164,7 @@ static int sp_2048_mod_exp_16(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[16], 0, sizeof(sp_digit) * 16U); XMEMSET(&r[16], 0, sizeof(sp_digit) * 16U);
sp_2048_mont_reduce_16(r, m, mp); sp_2048_mont_reduce_16(r, m, mp);
mask = 0 - (sp_2048_cmp_16(r, m) >= 0); mask = (sp_digit)0 - (sp_2048_cmp_16(r, m) >= 0);
sp_2048_cond_sub_16(r, r, m, mask); sp_2048_cond_sub_16(r, r, m, mask);
} }
@@ -4332,7 +4332,7 @@ static int sp_2048_mod_exp_16(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[16], 0, sizeof(sp_digit) * 16U); XMEMSET(&r[16], 0, sizeof(sp_digit) * 16U);
sp_2048_mont_reduce_16(r, m, mp); sp_2048_mont_reduce_16(r, m, mp);
mask = 0 - (sp_2048_cmp_16(r, m) >= 0); mask = (sp_digit)0 - (sp_2048_cmp_16(r, m) >= 0);
sp_2048_cond_sub_16(r, r, m, mask); sp_2048_cond_sub_16(r, r, m, mask);
} }
@@ -5788,7 +5788,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[32], 0, sizeof(sp_digit) * 32U); XMEMSET(&r[32], 0, sizeof(sp_digit) * 32U);
sp_2048_mont_reduce_32(r, m, mp); sp_2048_mont_reduce_32(r, m, mp);
mask = 0 - (sp_2048_cmp_32(r, m) >= 0); mask = (sp_digit)0 - (sp_2048_cmp_32(r, m) >= 0);
sp_2048_cond_sub_32(r, r, m, mask); sp_2048_cond_sub_32(r, r, m, mask);
} }
@@ -5989,7 +5989,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[32], 0, sizeof(sp_digit) * 32U); XMEMSET(&r[32], 0, sizeof(sp_digit) * 32U);
sp_2048_mont_reduce_32(r, m, mp); sp_2048_mont_reduce_32(r, m, mp);
mask = 0 - (sp_2048_cmp_32(r, m) >= 0); mask = (sp_digit)0 - (sp_2048_cmp_32(r, m) >= 0);
sp_2048_cond_sub_32(r, r, m, mask); sp_2048_cond_sub_32(r, r, m, mask);
} }
@@ -6832,7 +6832,7 @@ static int sp_2048_mod_exp_2_32(sp_digit* r, const sp_digit* e, int bits,
XMEMSET(&r[32], 0, sizeof(sp_digit) * 32U); XMEMSET(&r[32], 0, sizeof(sp_digit) * 32U);
sp_2048_mont_reduce_32(r, m, mp); sp_2048_mont_reduce_32(r, m, mp);
mask = 0 - (sp_2048_cmp_32(r, m) >= 0); mask = (sp_digit)0 - (sp_2048_cmp_32(r, m) >= 0);
sp_2048_cond_sub_32(r, r, m, mask); sp_2048_cond_sub_32(r, r, m, mask);
} }
@@ -13349,7 +13349,7 @@ static int sp_3072_mod_exp_24(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[24], 0, sizeof(sp_digit) * 24U); XMEMSET(&r[24], 0, sizeof(sp_digit) * 24U);
sp_3072_mont_reduce_24(r, m, mp); sp_3072_mont_reduce_24(r, m, mp);
mask = 0 - (sp_3072_cmp_24(r, m) >= 0); mask = (sp_digit)0 - (sp_3072_cmp_24(r, m) >= 0);
sp_3072_cond_sub_24(r, r, m, mask); sp_3072_cond_sub_24(r, r, m, mask);
} }
@@ -13517,7 +13517,7 @@ static int sp_3072_mod_exp_24(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[24], 0, sizeof(sp_digit) * 24U); XMEMSET(&r[24], 0, sizeof(sp_digit) * 24U);
sp_3072_mont_reduce_24(r, m, mp); sp_3072_mont_reduce_24(r, m, mp);
mask = 0 - (sp_3072_cmp_24(r, m) >= 0); mask = (sp_digit)0 - (sp_3072_cmp_24(r, m) >= 0);
sp_3072_cond_sub_24(r, r, m, mask); sp_3072_cond_sub_24(r, r, m, mask);
} }
@@ -15339,7 +15339,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[48], 0, sizeof(sp_digit) * 48U); XMEMSET(&r[48], 0, sizeof(sp_digit) * 48U);
sp_3072_mont_reduce_48(r, m, mp); sp_3072_mont_reduce_48(r, m, mp);
mask = 0 - (sp_3072_cmp_48(r, m) >= 0); mask = (sp_digit)0 - (sp_3072_cmp_48(r, m) >= 0);
sp_3072_cond_sub_48(r, r, m, mask); sp_3072_cond_sub_48(r, r, m, mask);
} }
@@ -15490,7 +15490,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[48], 0, sizeof(sp_digit) * 48U); XMEMSET(&r[48], 0, sizeof(sp_digit) * 48U);
sp_3072_mont_reduce_48(r, m, mp); sp_3072_mont_reduce_48(r, m, mp);
mask = 0 - (sp_3072_cmp_48(r, m) >= 0); mask = (sp_digit)0 - (sp_3072_cmp_48(r, m) >= 0);
sp_3072_cond_sub_48(r, r, m, mask); sp_3072_cond_sub_48(r, r, m, mask);
} }
@@ -16429,7 +16429,7 @@ static int sp_3072_mod_exp_2_48(sp_digit* r, const sp_digit* e, int bits,
XMEMSET(&r[48], 0, sizeof(sp_digit) * 48U); XMEMSET(&r[48], 0, sizeof(sp_digit) * 48U);
sp_3072_mont_reduce_48(r, m, mp); sp_3072_mont_reduce_48(r, m, mp);
mask = 0 - (sp_3072_cmp_48(r, m) >= 0); mask = (sp_digit)0 - (sp_3072_cmp_48(r, m) >= 0);
sp_3072_cond_sub_48(r, r, m, mask); sp_3072_cond_sub_48(r, r, m, mask);
} }
@@ -20446,7 +20446,7 @@ static int sp_4096_mod_exp_64(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U); XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U);
sp_4096_mont_reduce_64(r, m, mp); sp_4096_mont_reduce_64(r, m, mp);
mask = 0 - (sp_4096_cmp_64(r, m) >= 0); mask = (sp_digit)0 - (sp_4096_cmp_64(r, m) >= 0);
sp_4096_cond_sub_64(r, r, m, mask); sp_4096_cond_sub_64(r, r, m, mask);
} }
@@ -20597,7 +20597,7 @@ static int sp_4096_mod_exp_64(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U); XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U);
sp_4096_mont_reduce_64(r, m, mp); sp_4096_mont_reduce_64(r, m, mp);
mask = 0 - (sp_4096_cmp_64(r, m) >= 0); mask = (sp_digit)0 - (sp_4096_cmp_64(r, m) >= 0);
sp_4096_cond_sub_64(r, r, m, mask); sp_4096_cond_sub_64(r, r, m, mask);
} }
@@ -21632,7 +21632,7 @@ static int sp_4096_mod_exp_2_64(sp_digit* r, const sp_digit* e, int bits,
XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U); XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U);
sp_4096_mont_reduce_64(r, m, mp); sp_4096_mont_reduce_64(r, m, mp);
mask = 0 - (sp_4096_cmp_64(r, m) >= 0); mask = (sp_digit)0 - (sp_4096_cmp_64(r, m) >= 0);
sp_4096_cond_sub_64(r, r, m, mask); sp_4096_cond_sub_64(r, r, m, mask);
} }
@@ -22103,14 +22103,14 @@ static int sp_256_mod_mul_norm_4(sp_digit* r, const sp_digit* a, const sp_digit*
(void)m; (void)m;
a32[0] = a[0] & 0xffffffff; a32[0] = (int64_t)(a[0] & 0xffffffff);
a32[1] = a[0] >> 32; a32[1] = (int64_t)(a[0] >> 32);
a32[2] = a[1] & 0xffffffff; a32[2] = (int64_t)(a[1] & 0xffffffff);
a32[3] = a[1] >> 32; a32[3] = (int64_t)(a[1] >> 32);
a32[4] = a[2] & 0xffffffff; a32[4] = (int64_t)(a[2] & 0xffffffff);
a32[5] = a[2] >> 32; a32[5] = (int64_t)(a[2] >> 32);
a32[6] = a[3] & 0xffffffff; a32[6] = (int64_t)(a[3] & 0xffffffff);
a32[7] = a[3] >> 32; a32[7] = (int64_t)(a[3] >> 32);
/* 1 1 0 -1 -1 -1 -1 0 */ /* 1 1 0 -1 -1 -1 -1 0 */
t[0] = 0 + a32[0] + a32[1] - a32[3] - a32[4] - a32[5] - a32[6]; t[0] = 0 + a32[0] + a32[1] - a32[3] - a32[4] - a32[5] - a32[6];
@@ -22160,10 +22160,10 @@ static int sp_256_mod_mul_norm_4(sp_digit* r, const sp_digit* a, const sp_digit*
t[5] += t[4] >> 32; t[4] &= 0xffffffff; t[5] += t[4] >> 32; t[4] &= 0xffffffff;
t[6] += t[5] >> 32; t[5] &= 0xffffffff; t[6] += t[5] >> 32; t[5] &= 0xffffffff;
t[7] += t[6] >> 32; t[6] &= 0xffffffff; t[7] += t[6] >> 32; t[6] &= 0xffffffff;
r[0] = (t[1] << 32) | t[0]; r[0] = (sp_digit)((t[1] << 32) | t[0]);
r[1] = (t[3] << 32) | t[2]; r[1] = (sp_digit)((t[3] << 32) | t[2]);
r[2] = (t[5] << 32) | t[4]; r[2] = (sp_digit)((t[5] << 32) | t[4]);
r[3] = (t[7] << 32) | t[6]; r[3] = (sp_digit)((t[7] << 32) | t[6]);
return MP_OKAY; return MP_OKAY;
} }
@@ -23044,7 +23044,7 @@ static void sp_256_map_4(sp_point_256* r, const sp_point_256* p,
sp_256_mont_reduce_4(r->x, p256_mod, p256_mp_mod); sp_256_mont_reduce_4(r->x, p256_mod, p256_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_256_cmp_4(r->x, p256_mod); n = sp_256_cmp_4(r->x, p256_mod);
sp_256_cond_sub_4(r->x, r->x, p256_mod, ~(n >> 63)); sp_256_cond_sub_4(r->x, r->x, p256_mod, (sp_digit)~(n >> 63));
sp_256_norm_4(r->x); sp_256_norm_4(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -23053,7 +23053,7 @@ static void sp_256_map_4(sp_point_256* r, const sp_point_256* p,
sp_256_mont_reduce_4(r->y, p256_mod, p256_mp_mod); sp_256_mont_reduce_4(r->y, p256_mod, p256_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_256_cmp_4(r->y, p256_mod); n = sp_256_cmp_4(r->y, p256_mod);
sp_256_cond_sub_4(r->y, r->y, p256_mod, ~(n >> 63)); sp_256_cond_sub_4(r->y, r->y, p256_mod, (sp_digit)~(n >> 63));
sp_256_norm_4(r->y); sp_256_norm_4(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -24239,7 +24239,7 @@ static void sp_256_ecc_recode_6_4(const sp_digit* k, ecc_recode_256* v)
n = k[j]; n = k[j];
o = 0; o = 0;
for (i=0; i<43; i++) { for (i=0; i<43; i++) {
y = (int8_t)n; y = (uint8_t)(int8_t)n;
if (o + 6 < 64) { if (o + 6 < 64) {
y &= 0x3f; y &= 0x3f;
n >>= 6; n >>= 6;
@@ -27322,7 +27322,7 @@ static void sp_256_ecc_recode_7_4(const sp_digit* k, ecc_recode_256* v)
n = k[j]; n = k[j];
o = 0; o = 0;
for (i=0; i<37; i++) { for (i=0; i<37; i++) {
y = (int8_t)n; y = (uint8_t)(int8_t)n;
if (o + 7 < 64) { if (o + 7 < 64) {
y &= 0x7f; y &= 0x7f;
n >>= 7; n >>= 7;
@@ -43344,18 +43344,18 @@ static int sp_384_mod_mul_norm_6(sp_digit* r, const sp_digit* a, const sp_digit*
if (err == MP_OKAY) { if (err == MP_OKAY) {
a32 = t + 12; a32 = t + 12;
a32[0] = a[0] & 0xffffffff; a32[0] = (int64_t)(a[0] & 0xffffffff);
a32[1] = a[0] >> 32; a32[1] = (int64_t)(a[0] >> 32);
a32[2] = a[1] & 0xffffffff; a32[2] = (int64_t)(a[1] & 0xffffffff);
a32[3] = a[1] >> 32; a32[3] = (int64_t)(a[1] >> 32);
a32[4] = a[2] & 0xffffffff; a32[4] = (int64_t)(a[2] & 0xffffffff);
a32[5] = a[2] >> 32; a32[5] = (int64_t)(a[2] >> 32);
a32[6] = a[3] & 0xffffffff; a32[6] = (int64_t)(a[3] & 0xffffffff);
a32[7] = a[3] >> 32; a32[7] = (int64_t)(a[3] >> 32);
a32[8] = a[4] & 0xffffffff; a32[8] = (int64_t)(a[4] & 0xffffffff);
a32[9] = a[4] >> 32; a32[9] = (int64_t)(a[4] >> 32);
a32[10] = a[5] & 0xffffffff; a32[10] = (int64_t)(a[5] & 0xffffffff);
a32[11] = a[5] >> 32; a32[11] = (int64_t)(a[5] >> 32);
/* 1 0 0 0 0 0 0 0 1 1 0 -1 */ /* 1 0 0 0 0 0 0 0 1 1 0 -1 */
t[0] = 0 + a32[0] + a32[8] + a32[9] - a32[11]; t[0] = 0 + a32[0] + a32[8] + a32[9] - a32[11];
@@ -43410,12 +43410,12 @@ static int sp_384_mod_mul_norm_6(sp_digit* r, const sp_digit* a, const sp_digit*
t[10] += t[9] >> 32; t[9] &= 0xffffffff; t[10] += t[9] >> 32; t[9] &= 0xffffffff;
t[11] += t[10] >> 32; t[10] &= 0xffffffff; t[11] += t[10] >> 32; t[10] &= 0xffffffff;
r[0] = (t[1] << 32) | t[0]; r[0] = (sp_digit)((t[1] << 32) | t[0]);
r[1] = (t[3] << 32) | t[2]; r[1] = (sp_digit)((t[3] << 32) | t[2]);
r[2] = (t[5] << 32) | t[4]; r[2] = (sp_digit)((t[5] << 32) | t[4]);
r[3] = (t[7] << 32) | t[6]; r[3] = (sp_digit)((t[7] << 32) | t[6]);
r[4] = (t[9] << 32) | t[8]; r[4] = (sp_digit)((t[9] << 32) | t[8]);
r[5] = (t[11] << 32) | t[10]; r[5] = (sp_digit)((t[11] << 32) | t[10]);
} }
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
@@ -44198,7 +44198,7 @@ static void sp_384_map_6(sp_point_384* r, const sp_point_384* p,
sp_384_mont_reduce_6(r->x, p384_mod, p384_mp_mod); sp_384_mont_reduce_6(r->x, p384_mod, p384_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_384_cmp_6(r->x, p384_mod); n = sp_384_cmp_6(r->x, p384_mod);
sp_384_cond_sub_6(r->x, r->x, p384_mod, ~(n >> 63)); sp_384_cond_sub_6(r->x, r->x, p384_mod, (sp_digit)~(n >> 63));
sp_384_norm_6(r->x); sp_384_norm_6(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -44207,7 +44207,7 @@ static void sp_384_map_6(sp_point_384* r, const sp_point_384* p,
sp_384_mont_reduce_6(r->y, p384_mod, p384_mp_mod); sp_384_mont_reduce_6(r->y, p384_mod, p384_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_384_cmp_6(r->y, p384_mod); n = sp_384_cmp_6(r->y, p384_mod);
sp_384_cond_sub_6(r->y, r->y, p384_mod, ~(n >> 63)); sp_384_cond_sub_6(r->y, r->y, p384_mod, (sp_digit)~(n >> 63));
sp_384_norm_6(r->y); sp_384_norm_6(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -44777,8 +44777,8 @@ static void sp_384_proj_point_add_6(sp_point_384* r,
sp_384_mont_sub_6(y, y, t5, p384_mod); sp_384_mont_sub_6(y, y, t5, p384_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -44795,7 +44795,7 @@ static void sp_384_proj_point_add_6(sp_point_384* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -44969,8 +44969,8 @@ static int sp_384_proj_point_add_6_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -44987,7 +44987,7 @@ static int sp_384_proj_point_add_6_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -45201,7 +45201,7 @@ static void sp_384_ecc_recode_6_6(const sp_digit* k, ecc_recode_384* v)
n = k[j]; n = k[j];
o = 0; o = 0;
for (i=0; i<65; i++) { for (i=0; i<65; i++) {
y = (int8_t)n; y = (uint8_t)(int8_t)n;
if (o + 6 < 64) { if (o + 6 < 64) {
y &= 0x3f; y &= 0x3f;
n >>= 6; n >>= 6;
@@ -45507,8 +45507,8 @@ static void sp_384_proj_point_add_qz1_6(sp_point_384* r,
sp_384_mont_sub_6(y, t3, t1, p384_mod); sp_384_mont_sub_6(y, t3, t1, p384_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -45525,7 +45525,7 @@ static void sp_384_proj_point_add_qz1_6(sp_point_384* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -48248,7 +48248,7 @@ static void sp_384_ecc_recode_7_6(const sp_digit* k, ecc_recode_384* v)
n = k[j]; n = k[j];
o = 0; o = 0;
for (i=0; i<55; i++) { for (i=0; i<55; i++) {
y = (int8_t)n; y = (uint8_t)(int8_t)n;
if (o + 7 < 64) { if (o + 7 < 64) {
y &= 0x7f; y &= 0x7f;
n >>= 7; n >>= 7;
@@ -72377,7 +72377,7 @@ static void sp_521_map_9(sp_point_521* r, const sp_point_521* p,
sp_521_mont_reduce_9(r->x, p521_mod, p521_mp_mod); sp_521_mont_reduce_9(r->x, p521_mod, p521_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_521_cmp_9(r->x, p521_mod); n = sp_521_cmp_9(r->x, p521_mod);
sp_521_cond_sub_9(r->x, r->x, p521_mod, ~(n >> 63)); sp_521_cond_sub_9(r->x, r->x, p521_mod, (sp_digit)~(n >> 63));
sp_521_norm_9(r->x); sp_521_norm_9(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -72386,7 +72386,7 @@ static void sp_521_map_9(sp_point_521* r, const sp_point_521* p,
sp_521_mont_reduce_9(r->y, p521_mod, p521_mp_mod); sp_521_mont_reduce_9(r->y, p521_mod, p521_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_521_cmp_9(r->y, p521_mod); n = sp_521_cmp_9(r->y, p521_mod);
sp_521_cond_sub_9(r->y, r->y, p521_mod, ~(n >> 63)); sp_521_cond_sub_9(r->y, r->y, p521_mod, (sp_digit)~(n >> 63));
sp_521_norm_9(r->y); sp_521_norm_9(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -73134,8 +73134,8 @@ static void sp_521_proj_point_add_9(sp_point_521* r,
sp_521_mont_sub_9(y, y, t5, p521_mod); sp_521_mont_sub_9(y, y, t5, p521_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -73152,7 +73152,7 @@ static void sp_521_proj_point_add_9(sp_point_521* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -73326,8 +73326,8 @@ static int sp_521_proj_point_add_9_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -73344,7 +73344,7 @@ static int sp_521_proj_point_add_9_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -73558,7 +73558,7 @@ static void sp_521_ecc_recode_6_9(const sp_digit* k, ecc_recode_521* v)
n = k[j]; n = k[j];
o = 0; o = 0;
for (i=0; i<87; i++) { for (i=0; i<87; i++) {
y = (int8_t)n; y = (uint8_t)(int8_t)n;
if (o + 6 < 64) { if (o + 6 < 64) {
y &= 0x3f; y &= 0x3f;
n >>= 6; n >>= 6;
@@ -73891,8 +73891,8 @@ static void sp_521_proj_point_add_qz1_9(sp_point_521* r,
sp_521_mont_sub_9(y, t3, t1, p521_mod); sp_521_mont_sub_9(y, t3, t1, p521_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -73909,7 +73909,7 @@ static void sp_521_proj_point_add_qz1_9(sp_point_521* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -77304,7 +77304,7 @@ static void sp_521_ecc_recode_7_9(const sp_digit* k, ecc_recode_521* v)
n = k[j]; n = k[j];
o = 0; o = 0;
for (i=0; i<75; i++) { for (i=0; i<75; i++) {
y = (int8_t)n; y = (uint8_t)(int8_t)n;
if (o + 7 < 64) { if (o + 7 < 64) {
y &= 0x7f; y &= 0x7f;
n >>= 7; n >>= 7;
@@ -116168,7 +116168,7 @@ static void sp_1024_map_16(sp_point_1024* r, const sp_point_1024* p,
sp_1024_mont_reduce_16(r->x, p1024_mod, p1024_mp_mod); sp_1024_mont_reduce_16(r->x, p1024_mod, p1024_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_1024_cmp_16(r->x, p1024_mod); n = sp_1024_cmp_16(r->x, p1024_mod);
sp_1024_cond_sub_16(r->x, r->x, p1024_mod, ~(n >> 63)); sp_1024_cond_sub_16(r->x, r->x, p1024_mod, (sp_digit)~(n >> 63));
sp_1024_norm_16(r->x); sp_1024_norm_16(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -116177,7 +116177,7 @@ static void sp_1024_map_16(sp_point_1024* r, const sp_point_1024* p,
sp_1024_mont_reduce_16(r->y, p1024_mod, p1024_mp_mod); sp_1024_mont_reduce_16(r->y, p1024_mod, p1024_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_1024_cmp_16(r->y, p1024_mod); n = sp_1024_cmp_16(r->y, p1024_mod);
sp_1024_cond_sub_16(r->y, r->y, p1024_mod, ~(n >> 63)); sp_1024_cond_sub_16(r->y, r->y, p1024_mod, (sp_digit)~(n >> 63));
sp_1024_norm_16(r->y); sp_1024_norm_16(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -117213,8 +117213,8 @@ static void sp_1024_proj_point_add_16(sp_point_1024* r,
sp_1024_mont_sub_16(y, y, t5, p1024_mod); sp_1024_mont_sub_16(y, y, t5, p1024_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -117231,7 +117231,7 @@ static void sp_1024_proj_point_add_16(sp_point_1024* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -117405,8 +117405,8 @@ static int sp_1024_proj_point_add_16_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -117423,7 +117423,7 @@ static int sp_1024_proj_point_add_16_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -117645,7 +117645,7 @@ static void sp_1024_ecc_recode_7_16(const sp_digit* k, ecc_recode_1024* v)
n = k[j]; n = k[j];
o = 0; o = 0;
for (i=0; i<147; i++) { for (i=0; i<147; i++) {
y = (int8_t)n; y = (uint8_t)(int8_t)n;
if (o + 7 < 64) { if (o + 7 < 64) {
y &= 0x7f; y &= 0x7f;
n >>= 7; n >>= 7;
@@ -117884,8 +117884,8 @@ static void sp_1024_proj_point_add_qz1_16(sp_point_1024* r,
sp_1024_mont_sub_16(y, t3, t1, p1024_mod); sp_1024_mont_sub_16(y, t3, t1, p1024_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -117902,7 +117902,7 @@ static void sp_1024_proj_point_add_qz1_16(sp_point_1024* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -125273,7 +125273,7 @@ static int sp_1024_ecc_is_point_16(const sp_point_1024* point,
n = sp_1024_cmp_16(t1, p1024_mod); n = sp_1024_cmp_16(t1, p1024_mod);
sp_1024_cond_sub_16(t1, t1, p1024_mod, ~(n >> 63)); sp_1024_cond_sub_16(t1, t1, p1024_mod, (sp_digit)~(n >> 63));
sp_1024_norm_16(t1); sp_1024_norm_16(t1);
if (!sp_1024_iszero_16(t1)) { if (!sp_1024_iszero_16(t1)) {
err = MP_VAL; err = MP_VAL;

View File

@@ -67,7 +67,7 @@
do { \ do { \
int ii; \ int ii; \
fprintf(stderr, name "=0x"); \ fprintf(stderr, name "=0x"); \
for (ii = ((bits + 31) / 32) - 1; ii >= 0; ii--) \ for (ii = (((bits) + 31) / 32) - 1; ii >= 0; ii--) \
fprintf(stderr, SP_PRINT_FMT, (var)[ii]); \ fprintf(stderr, SP_PRINT_FMT, (var)[ii]); \
fprintf(stderr, "\n"); \ fprintf(stderr, "\n"); \
} while (0) } while (0)
@@ -24134,7 +24134,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[32], 0, sizeof(sp_digit) * 32U); XMEMSET(&r[32], 0, sizeof(sp_digit) * 32U);
sp_2048_mont_reduce_32(r, m, mp); sp_2048_mont_reduce_32(r, m, mp);
mask = 0 - (sp_2048_cmp_32(r, m) >= 0); mask = (sp_digit)0 - (sp_2048_cmp_32(r, m) >= 0);
sp_2048_cond_sub_32(r, r, m, mask); sp_2048_cond_sub_32(r, r, m, mask);
} }
@@ -24302,7 +24302,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[32], 0, sizeof(sp_digit) * 32U); XMEMSET(&r[32], 0, sizeof(sp_digit) * 32U);
sp_2048_mont_reduce_32(r, m, mp); sp_2048_mont_reduce_32(r, m, mp);
mask = 0 - (sp_2048_cmp_32(r, m) >= 0); mask = (sp_digit)0 - (sp_2048_cmp_32(r, m) >= 0);
sp_2048_cond_sub_32(r, r, m, mask); sp_2048_cond_sub_32(r, r, m, mask);
} }
@@ -27713,7 +27713,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U); XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U);
sp_2048_mont_reduce_64(r, m, mp); sp_2048_mont_reduce_64(r, m, mp);
mask = 0 - (sp_2048_cmp_64(r, m) >= 0); mask = (sp_digit)0 - (sp_2048_cmp_64(r, m) >= 0);
sp_2048_cond_sub_64(r, r, m, mask); sp_2048_cond_sub_64(r, r, m, mask);
} }
@@ -27864,7 +27864,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U); XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U);
sp_2048_mont_reduce_64(r, m, mp); sp_2048_mont_reduce_64(r, m, mp);
mask = 0 - (sp_2048_cmp_64(r, m) >= 0); mask = (sp_digit)0 - (sp_2048_cmp_64(r, m) >= 0);
sp_2048_cond_sub_64(r, r, m, mask); sp_2048_cond_sub_64(r, r, m, mask);
} }
@@ -30127,7 +30127,7 @@ static int sp_2048_mod_exp_2_64(sp_digit* r, const sp_digit* e, int bits,
XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U); XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U);
sp_2048_mont_reduce_64(r, m, mp); sp_2048_mont_reduce_64(r, m, mp);
mask = 0 - (sp_2048_cmp_64(r, m) >= 0); mask = (sp_digit)0 - (sp_2048_cmp_64(r, m) >= 0);
sp_2048_cond_sub_64(r, r, m, mask); sp_2048_cond_sub_64(r, r, m, mask);
} }
@@ -75590,7 +75590,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[48], 0, sizeof(sp_digit) * 48U); XMEMSET(&r[48], 0, sizeof(sp_digit) * 48U);
sp_3072_mont_reduce_48(r, m, mp); sp_3072_mont_reduce_48(r, m, mp);
mask = 0 - (sp_3072_cmp_48(r, m) >= 0); mask = (sp_digit)0 - (sp_3072_cmp_48(r, m) >= 0);
sp_3072_cond_sub_48(r, r, m, mask); sp_3072_cond_sub_48(r, r, m, mask);
} }
@@ -75758,7 +75758,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[48], 0, sizeof(sp_digit) * 48U); XMEMSET(&r[48], 0, sizeof(sp_digit) * 48U);
sp_3072_mont_reduce_48(r, m, mp); sp_3072_mont_reduce_48(r, m, mp);
mask = 0 - (sp_3072_cmp_48(r, m) >= 0); mask = (sp_digit)0 - (sp_3072_cmp_48(r, m) >= 0);
sp_3072_cond_sub_48(r, r, m, mask); sp_3072_cond_sub_48(r, r, m, mask);
} }
@@ -80000,7 +80000,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[96], 0, sizeof(sp_digit) * 96U); XMEMSET(&r[96], 0, sizeof(sp_digit) * 96U);
sp_3072_mont_reduce_96(r, m, mp); sp_3072_mont_reduce_96(r, m, mp);
mask = 0 - (sp_3072_cmp_96(r, m) >= 0); mask = (sp_digit)0 - (sp_3072_cmp_96(r, m) >= 0);
sp_3072_cond_sub_96(r, r, m, mask); sp_3072_cond_sub_96(r, r, m, mask);
} }
@@ -80151,7 +80151,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[96], 0, sizeof(sp_digit) * 96U); XMEMSET(&r[96], 0, sizeof(sp_digit) * 96U);
sp_3072_mont_reduce_96(r, m, mp); sp_3072_mont_reduce_96(r, m, mp);
mask = 0 - (sp_3072_cmp_96(r, m) >= 0); mask = (sp_digit)0 - (sp_3072_cmp_96(r, m) >= 0);
sp_3072_cond_sub_96(r, r, m, mask); sp_3072_cond_sub_96(r, r, m, mask);
} }
@@ -83212,7 +83212,7 @@ static int sp_3072_mod_exp_2_96(sp_digit* r, const sp_digit* e, int bits,
XMEMSET(&r[96], 0, sizeof(sp_digit) * 96U); XMEMSET(&r[96], 0, sizeof(sp_digit) * 96U);
sp_3072_mont_reduce_96(r, m, mp); sp_3072_mont_reduce_96(r, m, mp);
mask = 0 - (sp_3072_cmp_96(r, m) >= 0); mask = (sp_digit)0 - (sp_3072_cmp_96(r, m) >= 0);
sp_3072_cond_sub_96(r, r, m, mask); sp_3072_cond_sub_96(r, r, m, mask);
} }
@@ -92545,7 +92545,7 @@ static int sp_4096_mod_exp_128(sp_digit* r, const sp_digit* a, const sp_digit* e
XMEMSET(&r[128], 0, sizeof(sp_digit) * 128U); XMEMSET(&r[128], 0, sizeof(sp_digit) * 128U);
sp_4096_mont_reduce_128(r, m, mp); sp_4096_mont_reduce_128(r, m, mp);
mask = 0 - (sp_4096_cmp_128(r, m) >= 0); mask = (sp_digit)0 - (sp_4096_cmp_128(r, m) >= 0);
sp_4096_cond_sub_128(r, r, m, mask); sp_4096_cond_sub_128(r, r, m, mask);
} }
@@ -92696,7 +92696,7 @@ static int sp_4096_mod_exp_128(sp_digit* r, const sp_digit* a, const sp_digit* e
XMEMSET(&r[128], 0, sizeof(sp_digit) * 128U); XMEMSET(&r[128], 0, sizeof(sp_digit) * 128U);
sp_4096_mont_reduce_128(r, m, mp); sp_4096_mont_reduce_128(r, m, mp);
mask = 0 - (sp_4096_cmp_128(r, m) >= 0); mask = (sp_digit)0 - (sp_4096_cmp_128(r, m) >= 0);
sp_4096_cond_sub_128(r, r, m, mask); sp_4096_cond_sub_128(r, r, m, mask);
} }
@@ -96550,7 +96550,7 @@ static int sp_4096_mod_exp_2_128(sp_digit* r, const sp_digit* e, int bits,
XMEMSET(&r[128], 0, sizeof(sp_digit) * 128U); XMEMSET(&r[128], 0, sizeof(sp_digit) * 128U);
sp_4096_mont_reduce_128(r, m, mp); sp_4096_mont_reduce_128(r, m, mp);
mask = 0 - (sp_4096_cmp_128(r, m) >= 0); mask = (sp_digit)0 - (sp_4096_cmp_128(r, m) >= 0);
sp_4096_cond_sub_128(r, r, m, mask); sp_4096_cond_sub_128(r, r, m, mask);
} }
@@ -99135,7 +99135,7 @@ static void sp_256_map_8(sp_point_256* r, const sp_point_256* p,
sp_256_mont_reduce_8(r->x, p256_mod, p256_mp_mod); sp_256_mont_reduce_8(r->x, p256_mod, p256_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_256_cmp_8(r->x, p256_mod); n = sp_256_cmp_8(r->x, p256_mod);
sp_256_cond_sub_8(r->x, r->x, p256_mod, ~(n >> 31)); sp_256_cond_sub_8(r->x, r->x, p256_mod, (sp_digit)~(n >> 31));
sp_256_norm_8(r->x); sp_256_norm_8(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -99144,7 +99144,7 @@ static void sp_256_map_8(sp_point_256* r, const sp_point_256* p,
sp_256_mont_reduce_8(r->y, p256_mod, p256_mp_mod); sp_256_mont_reduce_8(r->y, p256_mod, p256_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_256_cmp_8(r->y, p256_mod); n = sp_256_cmp_8(r->y, p256_mod);
sp_256_cond_sub_8(r->y, r->y, p256_mod, ~(n >> 31)); sp_256_cond_sub_8(r->y, r->y, p256_mod, (sp_digit)~(n >> 31));
sp_256_norm_8(r->y); sp_256_norm_8(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -100590,8 +100590,8 @@ static void sp_256_proj_point_add_8(sp_point_256* r,
sp_256_mont_sub_8(y, y, t5, p256_mod); sp_256_mont_sub_8(y, y, t5, p256_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -100608,7 +100608,7 @@ static void sp_256_proj_point_add_8(sp_point_256* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -100782,8 +100782,8 @@ static int sp_256_proj_point_add_8_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -100800,7 +100800,7 @@ static int sp_256_proj_point_add_8_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -100855,7 +100855,7 @@ static void sp_256_get_point_16_8(sp_point_256* r, const sp_point_256* table,
r->z[6] = 0; r->z[6] = 0;
r->z[7] = 0; r->z[7] = 0;
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -101253,8 +101253,8 @@ static void sp_256_proj_point_add_qz1_8(sp_point_256* r,
sp_256_mont_sub_8(y, t3, t1, p256_mod); sp_256_mont_sub_8(y, t3, t1, p256_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -101271,7 +101271,7 @@ static void sp_256_proj_point_add_qz1_8(sp_point_256* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -101398,7 +101398,7 @@ static void sp_256_get_entry_16_8(sp_point_256* r,
r->y[6] = 0; r->y[6] = 0;
r->y[7] = 0; r->y[7] = 0;
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -101819,7 +101819,7 @@ static void sp_256_get_entry_256_8(sp_point_256* r,
r->y[6] = 0; r->y[6] = 0;
r->y[7] = 0; r->y[7] = 0;
for (i = 1; i < 256; i++) { for (i = 1; i < 256; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -109228,18 +109228,18 @@ static int sp_384_mod_mul_norm_12(sp_digit* r, const sp_digit* a, const sp_digit
t[10] += t[9] >> 32; t[9] &= 0xffffffff; t[10] += t[9] >> 32; t[9] &= 0xffffffff;
t[11] += t[10] >> 32; t[10] &= 0xffffffff; t[11] += t[10] >> 32; t[10] &= 0xffffffff;
r[0] = t[0]; r[0] = (sp_digit)t[0];
r[1] = t[1]; r[1] = (sp_digit)t[1];
r[2] = t[2]; r[2] = (sp_digit)t[2];
r[3] = t[3]; r[3] = (sp_digit)t[3];
r[4] = t[4]; r[4] = (sp_digit)t[4];
r[5] = t[5]; r[5] = (sp_digit)t[5];
r[6] = t[6]; r[6] = (sp_digit)t[6];
r[7] = t[7]; r[7] = (sp_digit)t[7];
r[8] = t[8]; r[8] = (sp_digit)t[8];
r[9] = t[9]; r[9] = (sp_digit)t[9];
r[10] = t[10]; r[10] = (sp_digit)t[10];
r[11] = t[11]; r[11] = (sp_digit)t[11];
} }
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
@@ -110516,7 +110516,7 @@ static void sp_384_map_12(sp_point_384* r, const sp_point_384* p,
sp_384_mont_reduce_12(r->x, p384_mod, p384_mp_mod); sp_384_mont_reduce_12(r->x, p384_mod, p384_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_384_cmp_12(r->x, p384_mod); n = sp_384_cmp_12(r->x, p384_mod);
sp_384_cond_sub_12(r->x, r->x, p384_mod, ~(n >> 31)); sp_384_cond_sub_12(r->x, r->x, p384_mod, (sp_digit)~(n >> 31));
sp_384_norm_12(r->x); sp_384_norm_12(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -110525,7 +110525,7 @@ static void sp_384_map_12(sp_point_384* r, const sp_point_384* p,
sp_384_mont_reduce_12(r->y, p384_mod, p384_mp_mod); sp_384_mont_reduce_12(r->y, p384_mod, p384_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_384_cmp_12(r->y, p384_mod); n = sp_384_cmp_12(r->y, p384_mod);
sp_384_cond_sub_12(r->y, r->y, p384_mod, ~(n >> 31)); sp_384_cond_sub_12(r->y, r->y, p384_mod, (sp_digit)~(n >> 31));
sp_384_norm_12(r->y); sp_384_norm_12(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -111398,8 +111398,8 @@ static void sp_384_proj_point_add_12(sp_point_384* r,
sp_384_mont_sub_12(y, y, t5, p384_mod); sp_384_mont_sub_12(y, y, t5, p384_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -111416,7 +111416,7 @@ static void sp_384_proj_point_add_12(sp_point_384* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -111590,8 +111590,8 @@ static int sp_384_proj_point_add_12_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -111608,7 +111608,7 @@ static int sp_384_proj_point_add_12_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -111675,7 +111675,7 @@ static void sp_384_get_point_16_12(sp_point_384* r, const sp_point_384* table,
r->z[10] = 0; r->z[10] = 0;
r->z[11] = 0; r->z[11] = 0;
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -112085,8 +112085,8 @@ static void sp_384_proj_point_add_qz1_12(sp_point_384* r,
sp_384_mont_sub_12(y, t3, t1, p384_mod); sp_384_mont_sub_12(y, t3, t1, p384_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -112103,7 +112103,7 @@ static void sp_384_proj_point_add_qz1_12(sp_point_384* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -112238,7 +112238,7 @@ static void sp_384_get_entry_16_12(sp_point_384* r,
r->y[10] = 0; r->y[10] = 0;
r->y[11] = 0; r->y[11] = 0;
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -112675,7 +112675,7 @@ static void sp_384_get_entry_256_12(sp_point_384* r,
r->y[10] = 0; r->y[10] = 0;
r->y[11] = 0; r->y[11] = 0;
for (i = 1; i < 256; i++) { for (i = 1; i < 256; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -122778,7 +122778,7 @@ static void sp_521_map_17(sp_point_521* r, const sp_point_521* p,
sp_521_mont_reduce_17(r->x, p521_mod, p521_mp_mod); sp_521_mont_reduce_17(r->x, p521_mod, p521_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_521_cmp_17(r->x, p521_mod); n = sp_521_cmp_17(r->x, p521_mod);
sp_521_cond_sub_17(r->x, r->x, p521_mod, ~(n >> 31)); sp_521_cond_sub_17(r->x, r->x, p521_mod, (sp_digit)~(n >> 31));
sp_521_norm_17(r->x); sp_521_norm_17(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -122787,7 +122787,7 @@ static void sp_521_map_17(sp_point_521* r, const sp_point_521* p,
sp_521_mont_reduce_17(r->y, p521_mod, p521_mp_mod); sp_521_mont_reduce_17(r->y, p521_mod, p521_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_521_cmp_17(r->y, p521_mod); n = sp_521_cmp_17(r->y, p521_mod);
sp_521_cond_sub_17(r->y, r->y, p521_mod, ~(n >> 31)); sp_521_cond_sub_17(r->y, r->y, p521_mod, (sp_digit)~(n >> 31));
sp_521_norm_17(r->y); sp_521_norm_17(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -124968,8 +124968,8 @@ static void sp_521_proj_point_add_17(sp_point_521* r,
sp_521_mont_sub_17(y, y, t5, p521_mod); sp_521_mont_sub_17(y, y, t5, p521_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -124986,7 +124986,7 @@ static void sp_521_proj_point_add_17(sp_point_521* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -125160,8 +125160,8 @@ static int sp_521_proj_point_add_17_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -125178,7 +125178,7 @@ static int sp_521_proj_point_add_17_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -125260,7 +125260,7 @@ static void sp_521_get_point_16_17(sp_point_521* r, const sp_point_521* table,
r->z[15] = 0; r->z[15] = 0;
r->z[16] = 0; r->z[16] = 0;
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -125689,8 +125689,8 @@ static void sp_521_proj_point_add_qz1_17(sp_point_521* r,
sp_521_mont_sub_17(y, t3, t1, p521_mod); sp_521_mont_sub_17(y, t3, t1, p521_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -125707,7 +125707,7 @@ static void sp_521_proj_point_add_qz1_17(sp_point_521* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -125852,7 +125852,7 @@ static void sp_521_get_entry_16_17(sp_point_521* r,
r->y[15] = 0; r->y[15] = 0;
r->y[16] = 0; r->y[16] = 0;
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -126309,7 +126309,7 @@ static void sp_521_get_entry_256_17(sp_point_521* r,
r->y[15] = 0; r->y[15] = 0;
r->y[16] = 0; r->y[16] = 0;
for (i = 1; i < 256; i++) { for (i = 1; i < 256; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -203834,7 +203834,7 @@ static void sp_1024_map_32(sp_point_1024* r, const sp_point_1024* p,
sp_1024_mont_reduce_32(r->x, p1024_mod, p1024_mp_mod); sp_1024_mont_reduce_32(r->x, p1024_mod, p1024_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_1024_cmp_32(r->x, p1024_mod); n = sp_1024_cmp_32(r->x, p1024_mod);
sp_1024_cond_sub_32(r->x, r->x, p1024_mod, ~(n >> 31)); sp_1024_cond_sub_32(r->x, r->x, p1024_mod, (sp_digit)~(n >> 31));
sp_1024_norm_32(r->x); sp_1024_norm_32(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -203843,7 +203843,7 @@ static void sp_1024_map_32(sp_point_1024* r, const sp_point_1024* p,
sp_1024_mont_reduce_32(r->y, p1024_mod, p1024_mp_mod); sp_1024_mont_reduce_32(r->y, p1024_mod, p1024_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_1024_cmp_32(r->y, p1024_mod); n = sp_1024_cmp_32(r->y, p1024_mod);
sp_1024_cond_sub_32(r->y, r->y, p1024_mod, ~(n >> 31)); sp_1024_cond_sub_32(r->y, r->y, p1024_mod, (sp_digit)~(n >> 31));
sp_1024_norm_32(r->y); sp_1024_norm_32(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -209838,8 +209838,8 @@ static void sp_1024_proj_point_add_32(sp_point_1024* r,
sp_1024_mont_sub_32(y, y, t5, p1024_mod); sp_1024_mont_sub_32(y, y, t5, p1024_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -209856,7 +209856,7 @@ static void sp_1024_proj_point_add_32(sp_point_1024* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -210030,8 +210030,8 @@ static int sp_1024_proj_point_add_32_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -210048,7 +210048,7 @@ static int sp_1024_proj_point_add_32_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -210389,8 +210389,8 @@ static void sp_1024_proj_point_add_qz1_32(sp_point_1024* r,
sp_1024_mont_sub_32(y, t3, t1, p1024_mod); sp_1024_mont_sub_32(y, t3, t1, p1024_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -210407,7 +210407,7 @@ static void sp_1024_proj_point_add_qz1_32(sp_point_1024* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -218532,7 +218532,7 @@ static int sp_1024_ecc_is_point_32(const sp_point_1024* point,
n = sp_1024_cmp_32(t1, p1024_mod); n = sp_1024_cmp_32(t1, p1024_mod);
sp_1024_cond_sub_32(t1, t1, p1024_mod, ~(n >> 31)); sp_1024_cond_sub_32(t1, t1, p1024_mod, (sp_digit)~(n >> 31));
sp_1024_norm_32(t1); sp_1024_norm_32(t1);
if (!sp_1024_iszero_32(t1)) { if (!sp_1024_iszero_32(t1)) {
err = MP_VAL; err = MP_VAL;

View File

@@ -71,13 +71,13 @@
#define SP_PRINT_NUM(var, name, total, words, bits) \ #define SP_PRINT_NUM(var, name, total, words, bits) \
do { \ do { \
int ii; \ int ii; \
byte nb[(bits + 7) / 8]; \ byte nb[((bits) + 7) / 8]; \
sp_digit _s[words]; \ sp_digit _s[words]; \
XMEMCPY(_s, var, sizeof(_s)); \ XMEMCPY(_s, var, sizeof(_s)); \
sp_##total##_norm_##words(_s); \ sp_##total##_norm_##words(_s); \
sp_##total##_to_bin_##words(_s, nb); \ sp_##total##_to_bin_##words(_s, nb); \
fprintf(stderr, name "=0x"); \ fprintf(stderr, name "=0x"); \
for (ii=0; ii<(bits + 7) / 8; ii++) \ for (ii=0; ii<((bits) + 7) / 8; ii++) \
fprintf(stderr, "%02x", nb[ii]); \ fprintf(stderr, "%02x", nb[ii]); \
fprintf(stderr, "\n"); \ fprintf(stderr, "\n"); \
} while (0) } while (0)
@@ -2217,7 +2217,7 @@ static int sp_2048_mod_exp_36(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_2048_mont_reduce_36(t[0], m, mp); sp_2048_mont_reduce_36(t[0], m, mp);
n = sp_2048_cmp_36(t[0], m); n = sp_2048_cmp_36(t[0], m);
sp_2048_cond_sub_36(t[0], t[0], m, ~(n >> 31)); sp_2048_cond_sub_36(t[0], t[0], m, (sp_digit)~(n >> 31));
XMEMCPY(r, t[0], sizeof(*r) * 36 * 2); XMEMCPY(r, t[0], sizeof(*r) * 36 * 2);
} }
@@ -2307,7 +2307,7 @@ static int sp_2048_mod_exp_36(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_2048_mont_reduce_36(t[0], m, mp); sp_2048_mont_reduce_36(t[0], m, mp);
n = sp_2048_cmp_36(t[0], m); n = sp_2048_cmp_36(t[0], m);
sp_2048_cond_sub_36(t[0], t[0], m, ~(n >> 31)); sp_2048_cond_sub_36(t[0], t[0], m, (sp_digit)~(n >> 31));
XMEMCPY(r, t[0], sizeof(*r) * 36 * 2); XMEMCPY(r, t[0], sizeof(*r) * 36 * 2);
} }
@@ -2452,7 +2452,7 @@ static int sp_2048_mod_exp_36(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_2048_mont_reduce_36(rt, m, mp); sp_2048_mont_reduce_36(rt, m, mp);
n = sp_2048_cmp_36(rt, m); n = sp_2048_cmp_36(rt, m);
sp_2048_cond_sub_36(rt, rt, m, ~(n >> 31)); sp_2048_cond_sub_36(rt, rt, m, (sp_digit)~(n >> 31));
XMEMCPY(r, rt, sizeof(sp_digit) * 72); XMEMCPY(r, rt, sizeof(sp_digit) * 72);
} }
@@ -3278,7 +3278,7 @@ static int sp_2048_mod_exp_72(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_2048_mont_reduce_72(t[0], m, mp); sp_2048_mont_reduce_72(t[0], m, mp);
n = sp_2048_cmp_72(t[0], m); n = sp_2048_cmp_72(t[0], m);
sp_2048_cond_sub_72(t[0], t[0], m, ~(n >> 31)); sp_2048_cond_sub_72(t[0], t[0], m, (sp_digit)~(n >> 31));
XMEMCPY(r, t[0], sizeof(*r) * 72 * 2); XMEMCPY(r, t[0], sizeof(*r) * 72 * 2);
} }
@@ -3368,7 +3368,7 @@ static int sp_2048_mod_exp_72(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_2048_mont_reduce_72(t[0], m, mp); sp_2048_mont_reduce_72(t[0], m, mp);
n = sp_2048_cmp_72(t[0], m); n = sp_2048_cmp_72(t[0], m);
sp_2048_cond_sub_72(t[0], t[0], m, ~(n >> 31)); sp_2048_cond_sub_72(t[0], t[0], m, (sp_digit)~(n >> 31));
XMEMCPY(r, t[0], sizeof(*r) * 72 * 2); XMEMCPY(r, t[0], sizeof(*r) * 72 * 2);
} }
@@ -3496,7 +3496,7 @@ static int sp_2048_mod_exp_72(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_2048_mont_reduce_72(rt, m, mp); sp_2048_mont_reduce_72(rt, m, mp);
n = sp_2048_cmp_72(rt, m); n = sp_2048_cmp_72(rt, m);
sp_2048_cond_sub_72(rt, rt, m, ~(n >> 31)); sp_2048_cond_sub_72(rt, rt, m, (sp_digit)~(n >> 31));
XMEMCPY(r, rt, sizeof(sp_digit) * 144); XMEMCPY(r, rt, sizeof(sp_digit) * 144);
} }
@@ -4601,7 +4601,7 @@ static int sp_2048_mod_exp_2_72(sp_digit* r, const sp_digit* e, int bits, const
sp_2048_mont_reduce_72(r, m, mp); sp_2048_mont_reduce_72(r, m, mp);
n = sp_2048_cmp_72(r, m); n = sp_2048_cmp_72(r, m);
sp_2048_cond_sub_72(r, r, m, ~(n >> 31)); sp_2048_cond_sub_72(r, r, m, (sp_digit)~(n >> 31));
} }
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
@@ -5891,7 +5891,7 @@ static int sp_3072_mod_exp_53(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_3072_mont_reduce_53(t[0], m, mp); sp_3072_mont_reduce_53(t[0], m, mp);
n = sp_3072_cmp_53(t[0], m); n = sp_3072_cmp_53(t[0], m);
sp_3072_cond_sub_53(t[0], t[0], m, ~(n >> 31)); sp_3072_cond_sub_53(t[0], t[0], m, (sp_digit)~(n >> 31));
XMEMCPY(r, t[0], sizeof(*r) * 53 * 2); XMEMCPY(r, t[0], sizeof(*r) * 53 * 2);
} }
@@ -5981,7 +5981,7 @@ static int sp_3072_mod_exp_53(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_3072_mont_reduce_53(t[0], m, mp); sp_3072_mont_reduce_53(t[0], m, mp);
n = sp_3072_cmp_53(t[0], m); n = sp_3072_cmp_53(t[0], m);
sp_3072_cond_sub_53(t[0], t[0], m, ~(n >> 31)); sp_3072_cond_sub_53(t[0], t[0], m, (sp_digit)~(n >> 31));
XMEMCPY(r, t[0], sizeof(*r) * 53 * 2); XMEMCPY(r, t[0], sizeof(*r) * 53 * 2);
} }
@@ -6126,7 +6126,7 @@ static int sp_3072_mod_exp_53(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_3072_mont_reduce_53(rt, m, mp); sp_3072_mont_reduce_53(rt, m, mp);
n = sp_3072_cmp_53(rt, m); n = sp_3072_cmp_53(rt, m);
sp_3072_cond_sub_53(rt, rt, m, ~(n >> 31)); sp_3072_cond_sub_53(rt, rt, m, (sp_digit)~(n >> 31));
XMEMCPY(r, rt, sizeof(sp_digit) * 106); XMEMCPY(r, rt, sizeof(sp_digit) * 106);
} }
@@ -6727,7 +6727,7 @@ static int sp_3072_mod_exp_106(sp_digit* r, const sp_digit* a, const sp_digit* e
sp_3072_mont_reduce_106(t[0], m, mp); sp_3072_mont_reduce_106(t[0], m, mp);
n = sp_3072_cmp_106(t[0], m); n = sp_3072_cmp_106(t[0], m);
sp_3072_cond_sub_106(t[0], t[0], m, ~(n >> 31)); sp_3072_cond_sub_106(t[0], t[0], m, (sp_digit)~(n >> 31));
XMEMCPY(r, t[0], sizeof(*r) * 106 * 2); XMEMCPY(r, t[0], sizeof(*r) * 106 * 2);
} }
@@ -6817,7 +6817,7 @@ static int sp_3072_mod_exp_106(sp_digit* r, const sp_digit* a, const sp_digit* e
sp_3072_mont_reduce_106(t[0], m, mp); sp_3072_mont_reduce_106(t[0], m, mp);
n = sp_3072_cmp_106(t[0], m); n = sp_3072_cmp_106(t[0], m);
sp_3072_cond_sub_106(t[0], t[0], m, ~(n >> 31)); sp_3072_cond_sub_106(t[0], t[0], m, (sp_digit)~(n >> 31));
XMEMCPY(r, t[0], sizeof(*r) * 106 * 2); XMEMCPY(r, t[0], sizeof(*r) * 106 * 2);
} }
@@ -6945,7 +6945,7 @@ static int sp_3072_mod_exp_106(sp_digit* r, const sp_digit* a, const sp_digit* e
sp_3072_mont_reduce_106(rt, m, mp); sp_3072_mont_reduce_106(rt, m, mp);
n = sp_3072_cmp_106(rt, m); n = sp_3072_cmp_106(rt, m);
sp_3072_cond_sub_106(rt, rt, m, ~(n >> 31)); sp_3072_cond_sub_106(rt, rt, m, (sp_digit)~(n >> 31));
XMEMCPY(r, rt, sizeof(sp_digit) * 212); XMEMCPY(r, rt, sizeof(sp_digit) * 212);
} }
@@ -7898,7 +7898,7 @@ static int sp_3072_mod_exp_2_106(sp_digit* r, const sp_digit* e, int bits, const
sp_3072_mont_reduce_106(r, m, mp); sp_3072_mont_reduce_106(r, m, mp);
n = sp_3072_cmp_106(r, m); n = sp_3072_cmp_106(r, m);
sp_3072_cond_sub_106(r, r, m, ~(n >> 31)); sp_3072_cond_sub_106(r, r, m, (sp_digit)~(n >> 31));
} }
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
@@ -9914,7 +9914,7 @@ static int sp_3072_mod_exp_56(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_3072_mont_reduce_56(t[0], m, mp); sp_3072_mont_reduce_56(t[0], m, mp);
n = sp_3072_cmp_56(t[0], m); n = sp_3072_cmp_56(t[0], m);
sp_3072_cond_sub_56(t[0], t[0], m, ~(n >> 31)); sp_3072_cond_sub_56(t[0], t[0], m, (sp_digit)~(n >> 31));
XMEMCPY(r, t[0], sizeof(*r) * 56 * 2); XMEMCPY(r, t[0], sizeof(*r) * 56 * 2);
} }
@@ -10004,7 +10004,7 @@ static int sp_3072_mod_exp_56(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_3072_mont_reduce_56(t[0], m, mp); sp_3072_mont_reduce_56(t[0], m, mp);
n = sp_3072_cmp_56(t[0], m); n = sp_3072_cmp_56(t[0], m);
sp_3072_cond_sub_56(t[0], t[0], m, ~(n >> 31)); sp_3072_cond_sub_56(t[0], t[0], m, (sp_digit)~(n >> 31));
XMEMCPY(r, t[0], sizeof(*r) * 56 * 2); XMEMCPY(r, t[0], sizeof(*r) * 56 * 2);
} }
@@ -10149,7 +10149,7 @@ static int sp_3072_mod_exp_56(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_3072_mont_reduce_56(rt, m, mp); sp_3072_mont_reduce_56(rt, m, mp);
n = sp_3072_cmp_56(rt, m); n = sp_3072_cmp_56(rt, m);
sp_3072_cond_sub_56(rt, rt, m, ~(n >> 31)); sp_3072_cond_sub_56(rt, rt, m, (sp_digit)~(n >> 31));
XMEMCPY(r, rt, sizeof(sp_digit) * 112); XMEMCPY(r, rt, sizeof(sp_digit) * 112);
} }
@@ -10832,7 +10832,7 @@ static int sp_3072_mod_exp_112(sp_digit* r, const sp_digit* a, const sp_digit* e
sp_3072_mont_reduce_112(t[0], m, mp); sp_3072_mont_reduce_112(t[0], m, mp);
n = sp_3072_cmp_112(t[0], m); n = sp_3072_cmp_112(t[0], m);
sp_3072_cond_sub_112(t[0], t[0], m, ~(n >> 31)); sp_3072_cond_sub_112(t[0], t[0], m, (sp_digit)~(n >> 31));
XMEMCPY(r, t[0], sizeof(*r) * 112 * 2); XMEMCPY(r, t[0], sizeof(*r) * 112 * 2);
} }
@@ -10922,7 +10922,7 @@ static int sp_3072_mod_exp_112(sp_digit* r, const sp_digit* a, const sp_digit* e
sp_3072_mont_reduce_112(t[0], m, mp); sp_3072_mont_reduce_112(t[0], m, mp);
n = sp_3072_cmp_112(t[0], m); n = sp_3072_cmp_112(t[0], m);
sp_3072_cond_sub_112(t[0], t[0], m, ~(n >> 31)); sp_3072_cond_sub_112(t[0], t[0], m, (sp_digit)~(n >> 31));
XMEMCPY(r, t[0], sizeof(*r) * 112 * 2); XMEMCPY(r, t[0], sizeof(*r) * 112 * 2);
} }
@@ -11050,7 +11050,7 @@ static int sp_3072_mod_exp_112(sp_digit* r, const sp_digit* a, const sp_digit* e
sp_3072_mont_reduce_112(rt, m, mp); sp_3072_mont_reduce_112(rt, m, mp);
n = sp_3072_cmp_112(rt, m); n = sp_3072_cmp_112(rt, m);
sp_3072_cond_sub_112(rt, rt, m, ~(n >> 31)); sp_3072_cond_sub_112(rt, rt, m, (sp_digit)~(n >> 31));
XMEMCPY(r, rt, sizeof(sp_digit) * 224); XMEMCPY(r, rt, sizeof(sp_digit) * 224);
} }
@@ -12226,7 +12226,7 @@ static int sp_3072_mod_exp_2_112(sp_digit* r, const sp_digit* e, int bits, const
sp_3072_mont_reduce_112(r, m, mp); sp_3072_mont_reduce_112(r, m, mp);
n = sp_3072_cmp_112(r, m); n = sp_3072_cmp_112(r, m);
sp_3072_cond_sub_112(r, r, m, ~(n >> 31)); sp_3072_cond_sub_112(r, r, m, (sp_digit)~(n >> 31));
} }
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
@@ -13526,7 +13526,7 @@ static int sp_4096_mod_exp_71(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_4096_mont_reduce_71(t[0], m, mp); sp_4096_mont_reduce_71(t[0], m, mp);
n = sp_4096_cmp_71(t[0], m); n = sp_4096_cmp_71(t[0], m);
sp_4096_cond_sub_71(t[0], t[0], m, ~(n >> 31)); sp_4096_cond_sub_71(t[0], t[0], m, (sp_digit)~(n >> 31));
XMEMCPY(r, t[0], sizeof(*r) * 71 * 2); XMEMCPY(r, t[0], sizeof(*r) * 71 * 2);
} }
@@ -13616,7 +13616,7 @@ static int sp_4096_mod_exp_71(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_4096_mont_reduce_71(t[0], m, mp); sp_4096_mont_reduce_71(t[0], m, mp);
n = sp_4096_cmp_71(t[0], m); n = sp_4096_cmp_71(t[0], m);
sp_4096_cond_sub_71(t[0], t[0], m, ~(n >> 31)); sp_4096_cond_sub_71(t[0], t[0], m, (sp_digit)~(n >> 31));
XMEMCPY(r, t[0], sizeof(*r) * 71 * 2); XMEMCPY(r, t[0], sizeof(*r) * 71 * 2);
} }
@@ -13761,7 +13761,7 @@ static int sp_4096_mod_exp_71(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_4096_mont_reduce_71(rt, m, mp); sp_4096_mont_reduce_71(rt, m, mp);
n = sp_4096_cmp_71(rt, m); n = sp_4096_cmp_71(rt, m);
sp_4096_cond_sub_71(rt, rt, m, ~(n >> 31)); sp_4096_cond_sub_71(rt, rt, m, (sp_digit)~(n >> 31));
XMEMCPY(r, rt, sizeof(sp_digit) * 142); XMEMCPY(r, rt, sizeof(sp_digit) * 142);
} }
@@ -14363,7 +14363,7 @@ static int sp_4096_mod_exp_142(sp_digit* r, const sp_digit* a, const sp_digit* e
sp_4096_mont_reduce_142(t[0], m, mp); sp_4096_mont_reduce_142(t[0], m, mp);
n = sp_4096_cmp_142(t[0], m); n = sp_4096_cmp_142(t[0], m);
sp_4096_cond_sub_142(t[0], t[0], m, ~(n >> 31)); sp_4096_cond_sub_142(t[0], t[0], m, (sp_digit)~(n >> 31));
XMEMCPY(r, t[0], sizeof(*r) * 142 * 2); XMEMCPY(r, t[0], sizeof(*r) * 142 * 2);
} }
@@ -14453,7 +14453,7 @@ static int sp_4096_mod_exp_142(sp_digit* r, const sp_digit* a, const sp_digit* e
sp_4096_mont_reduce_142(t[0], m, mp); sp_4096_mont_reduce_142(t[0], m, mp);
n = sp_4096_cmp_142(t[0], m); n = sp_4096_cmp_142(t[0], m);
sp_4096_cond_sub_142(t[0], t[0], m, ~(n >> 31)); sp_4096_cond_sub_142(t[0], t[0], m, (sp_digit)~(n >> 31));
XMEMCPY(r, t[0], sizeof(*r) * 142 * 2); XMEMCPY(r, t[0], sizeof(*r) * 142 * 2);
} }
@@ -14581,7 +14581,7 @@ static int sp_4096_mod_exp_142(sp_digit* r, const sp_digit* a, const sp_digit* e
sp_4096_mont_reduce_142(rt, m, mp); sp_4096_mont_reduce_142(rt, m, mp);
n = sp_4096_cmp_142(rt, m); n = sp_4096_cmp_142(rt, m);
sp_4096_cond_sub_142(rt, rt, m, ~(n >> 31)); sp_4096_cond_sub_142(rt, rt, m, (sp_digit)~(n >> 31));
XMEMCPY(r, rt, sizeof(sp_digit) * 284); XMEMCPY(r, rt, sizeof(sp_digit) * 284);
} }
@@ -15534,7 +15534,7 @@ static int sp_4096_mod_exp_2_142(sp_digit* r, const sp_digit* e, int bits, const
sp_4096_mont_reduce_142(r, m, mp); sp_4096_mont_reduce_142(r, m, mp);
n = sp_4096_cmp_142(r, m); n = sp_4096_cmp_142(r, m);
sp_4096_cond_sub_142(r, r, m, ~(n >> 31)); sp_4096_cond_sub_142(r, r, m, (sp_digit)~(n >> 31));
} }
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
@@ -17430,7 +17430,7 @@ static int sp_4096_mod_exp_81(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_4096_mont_reduce_81(t[0], m, mp); sp_4096_mont_reduce_81(t[0], m, mp);
n = sp_4096_cmp_81(t[0], m); n = sp_4096_cmp_81(t[0], m);
sp_4096_cond_sub_81(t[0], t[0], m, ~(n >> 31)); sp_4096_cond_sub_81(t[0], t[0], m, (sp_digit)~(n >> 31));
XMEMCPY(r, t[0], sizeof(*r) * 81 * 2); XMEMCPY(r, t[0], sizeof(*r) * 81 * 2);
} }
@@ -17520,7 +17520,7 @@ static int sp_4096_mod_exp_81(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_4096_mont_reduce_81(t[0], m, mp); sp_4096_mont_reduce_81(t[0], m, mp);
n = sp_4096_cmp_81(t[0], m); n = sp_4096_cmp_81(t[0], m);
sp_4096_cond_sub_81(t[0], t[0], m, ~(n >> 31)); sp_4096_cond_sub_81(t[0], t[0], m, (sp_digit)~(n >> 31));
XMEMCPY(r, t[0], sizeof(*r) * 81 * 2); XMEMCPY(r, t[0], sizeof(*r) * 81 * 2);
} }
@@ -17665,7 +17665,7 @@ static int sp_4096_mod_exp_81(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_4096_mont_reduce_81(rt, m, mp); sp_4096_mont_reduce_81(rt, m, mp);
n = sp_4096_cmp_81(rt, m); n = sp_4096_cmp_81(rt, m);
sp_4096_cond_sub_81(rt, rt, m, ~(n >> 31)); sp_4096_cond_sub_81(rt, rt, m, (sp_digit)~(n >> 31));
XMEMCPY(r, rt, sizeof(sp_digit) * 162); XMEMCPY(r, rt, sizeof(sp_digit) * 162);
} }
@@ -18335,7 +18335,7 @@ static int sp_4096_mod_exp_162(sp_digit* r, const sp_digit* a, const sp_digit* e
sp_4096_mont_reduce_162(t[0], m, mp); sp_4096_mont_reduce_162(t[0], m, mp);
n = sp_4096_cmp_162(t[0], m); n = sp_4096_cmp_162(t[0], m);
sp_4096_cond_sub_162(t[0], t[0], m, ~(n >> 31)); sp_4096_cond_sub_162(t[0], t[0], m, (sp_digit)~(n >> 31));
XMEMCPY(r, t[0], sizeof(*r) * 162 * 2); XMEMCPY(r, t[0], sizeof(*r) * 162 * 2);
} }
@@ -18425,7 +18425,7 @@ static int sp_4096_mod_exp_162(sp_digit* r, const sp_digit* a, const sp_digit* e
sp_4096_mont_reduce_162(t[0], m, mp); sp_4096_mont_reduce_162(t[0], m, mp);
n = sp_4096_cmp_162(t[0], m); n = sp_4096_cmp_162(t[0], m);
sp_4096_cond_sub_162(t[0], t[0], m, ~(n >> 31)); sp_4096_cond_sub_162(t[0], t[0], m, (sp_digit)~(n >> 31));
XMEMCPY(r, t[0], sizeof(*r) * 162 * 2); XMEMCPY(r, t[0], sizeof(*r) * 162 * 2);
} }
@@ -18553,7 +18553,7 @@ static int sp_4096_mod_exp_162(sp_digit* r, const sp_digit* a, const sp_digit* e
sp_4096_mont_reduce_162(rt, m, mp); sp_4096_mont_reduce_162(rt, m, mp);
n = sp_4096_cmp_162(rt, m); n = sp_4096_cmp_162(rt, m);
sp_4096_cond_sub_162(rt, rt, m, ~(n >> 31)); sp_4096_cond_sub_162(rt, rt, m, (sp_digit)~(n >> 31));
XMEMCPY(r, rt, sizeof(sp_digit) * 324); XMEMCPY(r, rt, sizeof(sp_digit) * 324);
} }
@@ -19829,7 +19829,7 @@ static int sp_4096_mod_exp_2_162(sp_digit* r, const sp_digit* e, int bits, const
sp_4096_mont_reduce_162(r, m, mp); sp_4096_mont_reduce_162(r, m, mp);
n = sp_4096_cmp_162(r, m); n = sp_4096_cmp_162(r, m);
sp_4096_cond_sub_162(r, r, m, ~(n >> 31)); sp_4096_cond_sub_162(r, r, m, (sp_digit)~(n >> 31));
} }
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
@@ -21044,7 +21044,7 @@ static void sp_256_map_9(sp_point_256* r, const sp_point_256* p,
sp_256_mont_reduce_9(r->x, p256_mod, p256_mp_mod); sp_256_mont_reduce_9(r->x, p256_mod, p256_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_256_cmp_9(r->x, p256_mod); n = sp_256_cmp_9(r->x, p256_mod);
sp_256_cond_sub_9(r->x, r->x, p256_mod, ~(n >> 28)); sp_256_cond_sub_9(r->x, r->x, p256_mod, (sp_digit)~(n >> 28));
sp_256_norm_9(r->x); sp_256_norm_9(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -21053,7 +21053,7 @@ static void sp_256_map_9(sp_point_256* r, const sp_point_256* p,
sp_256_mont_reduce_9(r->y, p256_mod, p256_mp_mod); sp_256_mont_reduce_9(r->y, p256_mod, p256_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_256_cmp_9(r->y, p256_mod); n = sp_256_cmp_9(r->y, p256_mod);
sp_256_cond_sub_9(r->y, r->y, p256_mod, ~(n >> 28)); sp_256_cond_sub_9(r->y, r->y, p256_mod, (sp_digit)~(n >> 28));
sp_256_norm_9(r->y); sp_256_norm_9(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -21508,8 +21508,8 @@ static void sp_256_proj_point_add_9(sp_point_256* r,
sp_256_mont_sub_9(y, y, t5, p256_mod); sp_256_mont_sub_9(y, y, t5, p256_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -21526,7 +21526,7 @@ static void sp_256_proj_point_add_9(sp_point_256* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -21700,8 +21700,8 @@ static int sp_256_proj_point_add_9_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -21718,7 +21718,7 @@ static int sp_256_proj_point_add_9_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -22427,7 +22427,7 @@ static void sp_256_ecc_recode_6_9(const sp_digit* k, ecc_recode_256* v)
n = k[j]; n = k[j];
o = 0; o = 0;
for (i=0; i<43; i++) { for (i=0; i<43; i++) {
y = (int8_t)n; y = (uint8_t)(int8_t)n;
if (o + 6 < 29) { if (o + 6 < 29) {
y &= 0x3f; y &= 0x3f;
n >>= 6; n >>= 6;
@@ -22494,7 +22494,7 @@ static void sp_256_get_point_33_9(sp_point_256* r, const sp_point_256* table,
r->z[7] = 0; r->z[7] = 0;
r->z[8] = 0; r->z[8] = 0;
for (i = 1; i < 33; i++) { for (i = 1; i < 33; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -22728,8 +22728,8 @@ static void sp_256_proj_point_add_qz1_9(sp_point_256* r,
sp_256_mont_sub_9(y, t3, t1, p256_mod); sp_256_mont_sub_9(y, t3, t1, p256_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -22746,7 +22746,7 @@ static void sp_256_proj_point_add_qz1_9(sp_point_256* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -22896,7 +22896,7 @@ static void sp_256_get_entry_256_9(sp_point_256* r,
r->y[7] = 0; r->y[7] = 0;
r->y[8] = 0; r->y[8] = 0;
for (i = 1; i < 256; i++) { for (i = 1; i < 256; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -28443,7 +28443,7 @@ static void sp_384_map_15(sp_point_384* r, const sp_point_384* p,
sp_384_mont_reduce_15(r->x, p384_mod, p384_mp_mod); sp_384_mont_reduce_15(r->x, p384_mod, p384_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_384_cmp_15(r->x, p384_mod); n = sp_384_cmp_15(r->x, p384_mod);
sp_384_cond_sub_15(r->x, r->x, p384_mod, ~(n >> 25)); sp_384_cond_sub_15(r->x, r->x, p384_mod, (sp_digit)~(n >> 25));
sp_384_norm_15(r->x); sp_384_norm_15(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -28452,7 +28452,7 @@ static void sp_384_map_15(sp_point_384* r, const sp_point_384* p,
sp_384_mont_reduce_15(r->y, p384_mod, p384_mp_mod); sp_384_mont_reduce_15(r->y, p384_mod, p384_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_384_cmp_15(r->y, p384_mod); n = sp_384_cmp_15(r->y, p384_mod);
sp_384_cond_sub_15(r->y, r->y, p384_mod, ~(n >> 25)); sp_384_cond_sub_15(r->y, r->y, p384_mod, (sp_digit)~(n >> 25));
sp_384_norm_15(r->y); sp_384_norm_15(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -28921,8 +28921,8 @@ static void sp_384_proj_point_add_15(sp_point_384* r,
sp_384_mont_sub_15(y, y, t5, p384_mod); sp_384_mont_sub_15(y, y, t5, p384_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -28939,7 +28939,7 @@ static void sp_384_proj_point_add_15(sp_point_384* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -29113,8 +29113,8 @@ static int sp_384_proj_point_add_15_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -29131,7 +29131,7 @@ static int sp_384_proj_point_add_15_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -29896,7 +29896,7 @@ static void sp_384_ecc_recode_6_15(const sp_digit* k, ecc_recode_384* v)
n = k[j]; n = k[j];
o = 0; o = 0;
for (i=0; i<65; i++) { for (i=0; i<65; i++) {
y = (int8_t)n; y = (uint8_t)(int8_t)n;
if (o + 6 < 26) { if (o + 6 < 26) {
y &= 0x3f; y &= 0x3f;
n >>= 6; n >>= 6;
@@ -29981,7 +29981,7 @@ static void sp_384_get_point_33_15(sp_point_384* r, const sp_point_384* table,
r->z[13] = 0; r->z[13] = 0;
r->z[14] = 0; r->z[14] = 0;
for (i = 1; i < 33; i++) { for (i = 1; i < 33; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -30233,8 +30233,8 @@ static void sp_384_proj_point_add_qz1_15(sp_point_384* r,
sp_384_mont_sub_15(y, t3, t1, p384_mod); sp_384_mont_sub_15(y, t3, t1, p384_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -30251,7 +30251,7 @@ static void sp_384_proj_point_add_qz1_15(sp_point_384* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -30413,7 +30413,7 @@ static void sp_384_get_entry_256_15(sp_point_384* r,
r->y[13] = 0; r->y[13] = 0;
r->y[14] = 0; r->y[14] = 0;
for (i = 1; i < 256; i++) { for (i = 1; i < 256; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -36088,7 +36088,7 @@ static void sp_521_map_21(sp_point_521* r, const sp_point_521* p,
sp_521_mont_reduce_21(r->x, p521_mod, p521_mp_mod); sp_521_mont_reduce_21(r->x, p521_mod, p521_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_521_cmp_21(r->x, p521_mod); n = sp_521_cmp_21(r->x, p521_mod);
sp_521_cond_sub_21(r->x, r->x, p521_mod, ~(n >> 24)); sp_521_cond_sub_21(r->x, r->x, p521_mod, (sp_digit)~(n >> 24));
sp_521_norm_21(r->x); sp_521_norm_21(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -36097,7 +36097,7 @@ static void sp_521_map_21(sp_point_521* r, const sp_point_521* p,
sp_521_mont_reduce_21(r->y, p521_mod, p521_mp_mod); sp_521_mont_reduce_21(r->y, p521_mod, p521_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_521_cmp_21(r->y, p521_mod); n = sp_521_cmp_21(r->y, p521_mod);
sp_521_cond_sub_21(r->y, r->y, p521_mod, ~(n >> 24)); sp_521_cond_sub_21(r->y, r->y, p521_mod, (sp_digit)~(n >> 24));
sp_521_norm_21(r->y); sp_521_norm_21(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -36577,8 +36577,8 @@ static void sp_521_proj_point_add_21(sp_point_521* r,
sp_521_mont_sub_21(y, y, t5, p521_mod); sp_521_mont_sub_21(y, y, t5, p521_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -36595,7 +36595,7 @@ static void sp_521_proj_point_add_21(sp_point_521* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -36769,8 +36769,8 @@ static int sp_521_proj_point_add_21_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -36787,7 +36787,7 @@ static int sp_521_proj_point_add_21_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -37415,7 +37415,7 @@ static void sp_521_ecc_recode_6_21(const sp_digit* k, ecc_recode_521* v)
n = k[j]; n = k[j];
o = 0; o = 0;
for (i=0; i<87; i++) { for (i=0; i<87; i++) {
y = (int8_t)n; y = (uint8_t)(int8_t)n;
if (o + 6 < 25) { if (o + 6 < 25) {
y &= 0x3f; y &= 0x3f;
n >>= 6; n >>= 6;
@@ -37518,7 +37518,7 @@ static void sp_521_get_point_33_21(sp_point_521* r, const sp_point_521* table,
r->z[19] = 0; r->z[19] = 0;
r->z[20] = 0; r->z[20] = 0;
for (i = 1; i < 33; i++) { for (i = 1; i < 33; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -37788,8 +37788,8 @@ static void sp_521_proj_point_add_qz1_21(sp_point_521* r,
sp_521_mont_sub_21(y, t3, t1, p521_mod); sp_521_mont_sub_21(y, t3, t1, p521_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -37806,7 +37806,7 @@ static void sp_521_proj_point_add_qz1_21(sp_point_521* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -37980,7 +37980,7 @@ static void sp_521_get_entry_256_21(sp_point_521* r,
r->y[19] = 0; r->y[19] = 0;
r->y[20] = 0; r->y[20] = 0;
for (i = 1; i < 256; i++) { for (i = 1; i < 256; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -44894,7 +44894,7 @@ static void sp_1024_map_42(sp_point_1024* r, const sp_point_1024* p,
sp_1024_mont_reduce_42(r->x, p1024_mod, p1024_mp_mod); sp_1024_mont_reduce_42(r->x, p1024_mod, p1024_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_1024_cmp_42(r->x, p1024_mod); n = sp_1024_cmp_42(r->x, p1024_mod);
sp_1024_cond_sub_42(r->x, r->x, p1024_mod, ~(n >> 24)); sp_1024_cond_sub_42(r->x, r->x, p1024_mod, (sp_digit)~(n >> 24));
sp_1024_norm_42(r->x); sp_1024_norm_42(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -44903,7 +44903,7 @@ static void sp_1024_map_42(sp_point_1024* r, const sp_point_1024* p,
sp_1024_mont_reduce_42(r->y, p1024_mod, p1024_mp_mod); sp_1024_mont_reduce_42(r->y, p1024_mod, p1024_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_1024_cmp_42(r->y, p1024_mod); n = sp_1024_cmp_42(r->y, p1024_mod);
sp_1024_cond_sub_42(r->y, r->y, p1024_mod, ~(n >> 24)); sp_1024_cond_sub_42(r->y, r->y, p1024_mod, (sp_digit)~(n >> 24));
sp_1024_norm_42(r->y); sp_1024_norm_42(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -45362,8 +45362,8 @@ static void sp_1024_proj_point_add_42(sp_point_1024* r,
sp_1024_mont_sub_42(y, y, t5, p1024_mod); sp_1024_mont_sub_42(y, y, t5, p1024_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -45380,7 +45380,7 @@ static void sp_1024_proj_point_add_42(sp_point_1024* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -45554,8 +45554,8 @@ static int sp_1024_proj_point_add_42_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -45572,7 +45572,7 @@ static int sp_1024_proj_point_add_42_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -46232,7 +46232,7 @@ static void sp_1024_ecc_recode_7_42(const sp_digit* k, ecc_recode_1024* v)
n = k[j]; n = k[j];
o = 0; o = 0;
for (i=0; i<147; i++) { for (i=0; i<147; i++) {
y = (int8_t)n; y = (uint8_t)(int8_t)n;
if (o + 7 < 25) { if (o + 7 < 25) {
y &= 0x7f; y &= 0x7f;
n >>= 7; n >>= 7;
@@ -46465,8 +46465,8 @@ static void sp_1024_proj_point_add_qz1_42(sp_point_1024* r,
sp_1024_mont_sub_42(y, t3, t1, p1024_mod); sp_1024_mont_sub_42(y, t3, t1, p1024_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -46483,7 +46483,7 @@ static void sp_1024_proj_point_add_qz1_42(sp_point_1024* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -54577,7 +54577,7 @@ static int sp_1024_ecc_is_point_42(const sp_point_1024* point,
n = sp_1024_cmp_42(t1, p1024_mod); n = sp_1024_cmp_42(t1, p1024_mod);
sp_1024_cond_sub_42(t1, t1, p1024_mod, ~(n >> 24)); sp_1024_cond_sub_42(t1, t1, p1024_mod, (sp_digit)~(n >> 24));
sp_1024_norm_42(t1); sp_1024_norm_42(t1);
if (!sp_1024_iszero_42(t1)) { if (!sp_1024_iszero_42(t1)) {
err = MP_VAL; err = MP_VAL;

View File

@@ -71,13 +71,13 @@
#define SP_PRINT_NUM(var, name, total, words, bits) \ #define SP_PRINT_NUM(var, name, total, words, bits) \
do { \ do { \
int ii; \ int ii; \
byte nb[(bits + 7) / 8]; \ byte nb[((bits) + 7) / 8]; \
sp_digit _s[words]; \ sp_digit _s[words]; \
XMEMCPY(_s, var, sizeof(_s)); \ XMEMCPY(_s, var, sizeof(_s)); \
sp_##total##_norm_##words(_s); \ sp_##total##_norm_##words(_s); \
sp_##total##_to_bin_##words(_s, nb); \ sp_##total##_to_bin_##words(_s, nb); \
fprintf(stderr, name "=0x"); \ fprintf(stderr, name "=0x"); \
for (ii=0; ii<(bits + 7) / 8; ii++) \ for (ii=0; ii<((bits) + 7) / 8; ii++) \
fprintf(stderr, "%02x", nb[ii]); \ fprintf(stderr, "%02x", nb[ii]); \
fprintf(stderr, "\n"); \ fprintf(stderr, "\n"); \
} while (0) } while (0)
@@ -1129,7 +1129,7 @@ static int sp_2048_mod_exp_17(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_2048_mont_reduce_17(t[0], m, mp); sp_2048_mont_reduce_17(t[0], m, mp);
n = sp_2048_cmp_17(t[0], m); n = sp_2048_cmp_17(t[0], m);
sp_2048_cond_sub_17(t[0], t[0], m, ~(n >> 63)); sp_2048_cond_sub_17(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 17 * 2); XMEMCPY(r, t[0], sizeof(*r) * 17 * 2);
} }
@@ -1219,7 +1219,7 @@ static int sp_2048_mod_exp_17(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_2048_mont_reduce_17(t[0], m, mp); sp_2048_mont_reduce_17(t[0], m, mp);
n = sp_2048_cmp_17(t[0], m); n = sp_2048_cmp_17(t[0], m);
sp_2048_cond_sub_17(t[0], t[0], m, ~(n >> 63)); sp_2048_cond_sub_17(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 17 * 2); XMEMCPY(r, t[0], sizeof(*r) * 17 * 2);
} }
@@ -1364,7 +1364,7 @@ static int sp_2048_mod_exp_17(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_2048_mont_reduce_17(rt, m, mp); sp_2048_mont_reduce_17(rt, m, mp);
n = sp_2048_cmp_17(rt, m); n = sp_2048_cmp_17(rt, m);
sp_2048_cond_sub_17(rt, rt, m, ~(n >> 63)); sp_2048_cond_sub_17(rt, rt, m, (sp_digit)~(n >> 63));
XMEMCPY(r, rt, sizeof(sp_digit) * 34); XMEMCPY(r, rt, sizeof(sp_digit) * 34);
} }
@@ -1951,7 +1951,7 @@ static int sp_2048_mod_exp_34(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_2048_mont_reduce_34(t[0], m, mp); sp_2048_mont_reduce_34(t[0], m, mp);
n = sp_2048_cmp_34(t[0], m); n = sp_2048_cmp_34(t[0], m);
sp_2048_cond_sub_34(t[0], t[0], m, ~(n >> 63)); sp_2048_cond_sub_34(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 34 * 2); XMEMCPY(r, t[0], sizeof(*r) * 34 * 2);
} }
@@ -2041,7 +2041,7 @@ static int sp_2048_mod_exp_34(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_2048_mont_reduce_34(t[0], m, mp); sp_2048_mont_reduce_34(t[0], m, mp);
n = sp_2048_cmp_34(t[0], m); n = sp_2048_cmp_34(t[0], m);
sp_2048_cond_sub_34(t[0], t[0], m, ~(n >> 63)); sp_2048_cond_sub_34(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 34 * 2); XMEMCPY(r, t[0], sizeof(*r) * 34 * 2);
} }
@@ -2169,7 +2169,7 @@ static int sp_2048_mod_exp_34(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_2048_mont_reduce_34(rt, m, mp); sp_2048_mont_reduce_34(rt, m, mp);
n = sp_2048_cmp_34(rt, m); n = sp_2048_cmp_34(rt, m);
sp_2048_cond_sub_34(rt, rt, m, ~(n >> 63)); sp_2048_cond_sub_34(rt, rt, m, (sp_digit)~(n >> 63));
XMEMCPY(r, rt, sizeof(sp_digit) * 68); XMEMCPY(r, rt, sizeof(sp_digit) * 68);
} }
@@ -3123,7 +3123,7 @@ static int sp_2048_mod_exp_2_34(sp_digit* r, const sp_digit* e, int bits, const
sp_2048_mont_reduce_34(r, m, mp); sp_2048_mont_reduce_34(r, m, mp);
n = sp_2048_cmp_34(r, m); n = sp_2048_cmp_34(r, m);
sp_2048_cond_sub_34(r, r, m, ~(n >> 63)); sp_2048_cond_sub_34(r, r, m, (sp_digit)~(n >> 63));
} }
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
@@ -4653,7 +4653,7 @@ static int sp_2048_mod_exp_18(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_2048_mont_reduce_18(t[0], m, mp); sp_2048_mont_reduce_18(t[0], m, mp);
n = sp_2048_cmp_18(t[0], m); n = sp_2048_cmp_18(t[0], m);
sp_2048_cond_sub_18(t[0], t[0], m, ~(n >> 63)); sp_2048_cond_sub_18(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 18 * 2); XMEMCPY(r, t[0], sizeof(*r) * 18 * 2);
} }
@@ -4743,7 +4743,7 @@ static int sp_2048_mod_exp_18(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_2048_mont_reduce_18(t[0], m, mp); sp_2048_mont_reduce_18(t[0], m, mp);
n = sp_2048_cmp_18(t[0], m); n = sp_2048_cmp_18(t[0], m);
sp_2048_cond_sub_18(t[0], t[0], m, ~(n >> 63)); sp_2048_cond_sub_18(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 18 * 2); XMEMCPY(r, t[0], sizeof(*r) * 18 * 2);
} }
@@ -4888,7 +4888,7 @@ static int sp_2048_mod_exp_18(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_2048_mont_reduce_18(rt, m, mp); sp_2048_mont_reduce_18(rt, m, mp);
n = sp_2048_cmp_18(rt, m); n = sp_2048_cmp_18(rt, m);
sp_2048_cond_sub_18(rt, rt, m, ~(n >> 63)); sp_2048_cond_sub_18(rt, rt, m, (sp_digit)~(n >> 63));
XMEMCPY(r, rt, sizeof(sp_digit) * 36); XMEMCPY(r, rt, sizeof(sp_digit) * 36);
} }
@@ -5538,7 +5538,7 @@ static int sp_2048_mod_exp_36(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_2048_mont_reduce_36(t[0], m, mp); sp_2048_mont_reduce_36(t[0], m, mp);
n = sp_2048_cmp_36(t[0], m); n = sp_2048_cmp_36(t[0], m);
sp_2048_cond_sub_36(t[0], t[0], m, ~(n >> 63)); sp_2048_cond_sub_36(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 36 * 2); XMEMCPY(r, t[0], sizeof(*r) * 36 * 2);
} }
@@ -5628,7 +5628,7 @@ static int sp_2048_mod_exp_36(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_2048_mont_reduce_36(t[0], m, mp); sp_2048_mont_reduce_36(t[0], m, mp);
n = sp_2048_cmp_36(t[0], m); n = sp_2048_cmp_36(t[0], m);
sp_2048_cond_sub_36(t[0], t[0], m, ~(n >> 63)); sp_2048_cond_sub_36(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 36 * 2); XMEMCPY(r, t[0], sizeof(*r) * 36 * 2);
} }
@@ -5756,7 +5756,7 @@ static int sp_2048_mod_exp_36(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_2048_mont_reduce_36(rt, m, mp); sp_2048_mont_reduce_36(rt, m, mp);
n = sp_2048_cmp_36(rt, m); n = sp_2048_cmp_36(rt, m);
sp_2048_cond_sub_36(rt, rt, m, ~(n >> 63)); sp_2048_cond_sub_36(rt, rt, m, (sp_digit)~(n >> 63));
XMEMCPY(r, rt, sizeof(sp_digit) * 72); XMEMCPY(r, rt, sizeof(sp_digit) * 72);
} }
@@ -6781,7 +6781,7 @@ static int sp_2048_mod_exp_2_36(sp_digit* r, const sp_digit* e, int bits, const
sp_2048_mont_reduce_36(r, m, mp); sp_2048_mont_reduce_36(r, m, mp);
n = sp_2048_cmp_36(r, m); n = sp_2048_cmp_36(r, m);
sp_2048_cond_sub_36(r, r, m, ~(n >> 63)); sp_2048_cond_sub_36(r, r, m, (sp_digit)~(n >> 63));
} }
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
@@ -7984,7 +7984,7 @@ static int sp_3072_mod_exp_26(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_3072_mont_reduce_26(t[0], m, mp); sp_3072_mont_reduce_26(t[0], m, mp);
n = sp_3072_cmp_26(t[0], m); n = sp_3072_cmp_26(t[0], m);
sp_3072_cond_sub_26(t[0], t[0], m, ~(n >> 63)); sp_3072_cond_sub_26(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 26 * 2); XMEMCPY(r, t[0], sizeof(*r) * 26 * 2);
} }
@@ -8074,7 +8074,7 @@ static int sp_3072_mod_exp_26(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_3072_mont_reduce_26(t[0], m, mp); sp_3072_mont_reduce_26(t[0], m, mp);
n = sp_3072_cmp_26(t[0], m); n = sp_3072_cmp_26(t[0], m);
sp_3072_cond_sub_26(t[0], t[0], m, ~(n >> 63)); sp_3072_cond_sub_26(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 26 * 2); XMEMCPY(r, t[0], sizeof(*r) * 26 * 2);
} }
@@ -8219,7 +8219,7 @@ static int sp_3072_mod_exp_26(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_3072_mont_reduce_26(rt, m, mp); sp_3072_mont_reduce_26(rt, m, mp);
n = sp_3072_cmp_26(rt, m); n = sp_3072_cmp_26(rt, m);
sp_3072_cond_sub_26(rt, rt, m, ~(n >> 63)); sp_3072_cond_sub_26(rt, rt, m, (sp_digit)~(n >> 63));
XMEMCPY(r, rt, sizeof(sp_digit) * 52); XMEMCPY(r, rt, sizeof(sp_digit) * 52);
} }
@@ -8812,7 +8812,7 @@ static int sp_3072_mod_exp_52(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_3072_mont_reduce_52(t[0], m, mp); sp_3072_mont_reduce_52(t[0], m, mp);
n = sp_3072_cmp_52(t[0], m); n = sp_3072_cmp_52(t[0], m);
sp_3072_cond_sub_52(t[0], t[0], m, ~(n >> 63)); sp_3072_cond_sub_52(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 52 * 2); XMEMCPY(r, t[0], sizeof(*r) * 52 * 2);
} }
@@ -8902,7 +8902,7 @@ static int sp_3072_mod_exp_52(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_3072_mont_reduce_52(t[0], m, mp); sp_3072_mont_reduce_52(t[0], m, mp);
n = sp_3072_cmp_52(t[0], m); n = sp_3072_cmp_52(t[0], m);
sp_3072_cond_sub_52(t[0], t[0], m, ~(n >> 63)); sp_3072_cond_sub_52(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 52 * 2); XMEMCPY(r, t[0], sizeof(*r) * 52 * 2);
} }
@@ -9030,7 +9030,7 @@ static int sp_3072_mod_exp_52(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_3072_mont_reduce_52(rt, m, mp); sp_3072_mont_reduce_52(rt, m, mp);
n = sp_3072_cmp_52(rt, m); n = sp_3072_cmp_52(rt, m);
sp_3072_cond_sub_52(rt, rt, m, ~(n >> 63)); sp_3072_cond_sub_52(rt, rt, m, (sp_digit)~(n >> 63));
XMEMCPY(r, rt, sizeof(sp_digit) * 104); XMEMCPY(r, rt, sizeof(sp_digit) * 104);
} }
@@ -9984,7 +9984,7 @@ static int sp_3072_mod_exp_2_52(sp_digit* r, const sp_digit* e, int bits, const
sp_3072_mont_reduce_52(r, m, mp); sp_3072_mont_reduce_52(r, m, mp);
n = sp_3072_cmp_52(r, m); n = sp_3072_cmp_52(r, m);
sp_3072_cond_sub_52(r, r, m, ~(n >> 63)); sp_3072_cond_sub_52(r, r, m, (sp_digit)~(n >> 63));
} }
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
@@ -11652,7 +11652,7 @@ static int sp_3072_mod_exp_27(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_3072_mont_reduce_27(t[0], m, mp); sp_3072_mont_reduce_27(t[0], m, mp);
n = sp_3072_cmp_27(t[0], m); n = sp_3072_cmp_27(t[0], m);
sp_3072_cond_sub_27(t[0], t[0], m, ~(n >> 63)); sp_3072_cond_sub_27(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 27 * 2); XMEMCPY(r, t[0], sizeof(*r) * 27 * 2);
} }
@@ -11742,7 +11742,7 @@ static int sp_3072_mod_exp_27(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_3072_mont_reduce_27(t[0], m, mp); sp_3072_mont_reduce_27(t[0], m, mp);
n = sp_3072_cmp_27(t[0], m); n = sp_3072_cmp_27(t[0], m);
sp_3072_cond_sub_27(t[0], t[0], m, ~(n >> 63)); sp_3072_cond_sub_27(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 27 * 2); XMEMCPY(r, t[0], sizeof(*r) * 27 * 2);
} }
@@ -11887,7 +11887,7 @@ static int sp_3072_mod_exp_27(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_3072_mont_reduce_27(rt, m, mp); sp_3072_mont_reduce_27(rt, m, mp);
n = sp_3072_cmp_27(rt, m); n = sp_3072_cmp_27(rt, m);
sp_3072_cond_sub_27(rt, rt, m, ~(n >> 63)); sp_3072_cond_sub_27(rt, rt, m, (sp_digit)~(n >> 63));
XMEMCPY(r, rt, sizeof(sp_digit) * 54); XMEMCPY(r, rt, sizeof(sp_digit) * 54);
} }
@@ -12548,7 +12548,7 @@ static int sp_3072_mod_exp_54(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_3072_mont_reduce_54(t[0], m, mp); sp_3072_mont_reduce_54(t[0], m, mp);
n = sp_3072_cmp_54(t[0], m); n = sp_3072_cmp_54(t[0], m);
sp_3072_cond_sub_54(t[0], t[0], m, ~(n >> 63)); sp_3072_cond_sub_54(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 54 * 2); XMEMCPY(r, t[0], sizeof(*r) * 54 * 2);
} }
@@ -12638,7 +12638,7 @@ static int sp_3072_mod_exp_54(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_3072_mont_reduce_54(t[0], m, mp); sp_3072_mont_reduce_54(t[0], m, mp);
n = sp_3072_cmp_54(t[0], m); n = sp_3072_cmp_54(t[0], m);
sp_3072_cond_sub_54(t[0], t[0], m, ~(n >> 63)); sp_3072_cond_sub_54(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 54 * 2); XMEMCPY(r, t[0], sizeof(*r) * 54 * 2);
} }
@@ -12766,7 +12766,7 @@ static int sp_3072_mod_exp_54(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_3072_mont_reduce_54(rt, m, mp); sp_3072_mont_reduce_54(rt, m, mp);
n = sp_3072_cmp_54(rt, m); n = sp_3072_cmp_54(rt, m);
sp_3072_cond_sub_54(rt, rt, m, ~(n >> 63)); sp_3072_cond_sub_54(rt, rt, m, (sp_digit)~(n >> 63));
XMEMCPY(r, rt, sizeof(sp_digit) * 108); XMEMCPY(r, rt, sizeof(sp_digit) * 108);
} }
@@ -13827,7 +13827,7 @@ static int sp_3072_mod_exp_2_54(sp_digit* r, const sp_digit* e, int bits, const
sp_3072_mont_reduce_54(r, m, mp); sp_3072_mont_reduce_54(r, m, mp);
n = sp_3072_cmp_54(r, m); n = sp_3072_cmp_54(r, m);
sp_3072_cond_sub_54(r, r, m, ~(n >> 63)); sp_3072_cond_sub_54(r, r, m, (sp_digit)~(n >> 63));
} }
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
@@ -15036,7 +15036,7 @@ static int sp_4096_mod_exp_35(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_4096_mont_reduce_35(t[0], m, mp); sp_4096_mont_reduce_35(t[0], m, mp);
n = sp_4096_cmp_35(t[0], m); n = sp_4096_cmp_35(t[0], m);
sp_4096_cond_sub_35(t[0], t[0], m, ~(n >> 63)); sp_4096_cond_sub_35(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 35 * 2); XMEMCPY(r, t[0], sizeof(*r) * 35 * 2);
} }
@@ -15126,7 +15126,7 @@ static int sp_4096_mod_exp_35(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_4096_mont_reduce_35(t[0], m, mp); sp_4096_mont_reduce_35(t[0], m, mp);
n = sp_4096_cmp_35(t[0], m); n = sp_4096_cmp_35(t[0], m);
sp_4096_cond_sub_35(t[0], t[0], m, ~(n >> 63)); sp_4096_cond_sub_35(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 35 * 2); XMEMCPY(r, t[0], sizeof(*r) * 35 * 2);
} }
@@ -15271,7 +15271,7 @@ static int sp_4096_mod_exp_35(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_4096_mont_reduce_35(rt, m, mp); sp_4096_mont_reduce_35(rt, m, mp);
n = sp_4096_cmp_35(rt, m); n = sp_4096_cmp_35(rt, m);
sp_4096_cond_sub_35(rt, rt, m, ~(n >> 63)); sp_4096_cond_sub_35(rt, rt, m, (sp_digit)~(n >> 63));
XMEMCPY(r, rt, sizeof(sp_digit) * 70); XMEMCPY(r, rt, sizeof(sp_digit) * 70);
} }
@@ -15859,7 +15859,7 @@ static int sp_4096_mod_exp_70(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_4096_mont_reduce_70(t[0], m, mp); sp_4096_mont_reduce_70(t[0], m, mp);
n = sp_4096_cmp_70(t[0], m); n = sp_4096_cmp_70(t[0], m);
sp_4096_cond_sub_70(t[0], t[0], m, ~(n >> 63)); sp_4096_cond_sub_70(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 70 * 2); XMEMCPY(r, t[0], sizeof(*r) * 70 * 2);
} }
@@ -15949,7 +15949,7 @@ static int sp_4096_mod_exp_70(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_4096_mont_reduce_70(t[0], m, mp); sp_4096_mont_reduce_70(t[0], m, mp);
n = sp_4096_cmp_70(t[0], m); n = sp_4096_cmp_70(t[0], m);
sp_4096_cond_sub_70(t[0], t[0], m, ~(n >> 63)); sp_4096_cond_sub_70(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 70 * 2); XMEMCPY(r, t[0], sizeof(*r) * 70 * 2);
} }
@@ -16077,7 +16077,7 @@ static int sp_4096_mod_exp_70(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_4096_mont_reduce_70(rt, m, mp); sp_4096_mont_reduce_70(rt, m, mp);
n = sp_4096_cmp_70(rt, m); n = sp_4096_cmp_70(rt, m);
sp_4096_cond_sub_70(rt, rt, m, ~(n >> 63)); sp_4096_cond_sub_70(rt, rt, m, (sp_digit)~(n >> 63));
XMEMCPY(r, rt, sizeof(sp_digit) * 140); XMEMCPY(r, rt, sizeof(sp_digit) * 140);
} }
@@ -17031,7 +17031,7 @@ static int sp_4096_mod_exp_2_70(sp_digit* r, const sp_digit* e, int bits, const
sp_4096_mont_reduce_70(r, m, mp); sp_4096_mont_reduce_70(r, m, mp);
n = sp_4096_cmp_70(r, m); n = sp_4096_cmp_70(r, m);
sp_4096_cond_sub_70(r, r, m, ~(n >> 63)); sp_4096_cond_sub_70(r, r, m, (sp_digit)~(n >> 63));
} }
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
@@ -18754,7 +18754,7 @@ static int sp_4096_mod_exp_39(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_4096_mont_reduce_39(t[0], m, mp); sp_4096_mont_reduce_39(t[0], m, mp);
n = sp_4096_cmp_39(t[0], m); n = sp_4096_cmp_39(t[0], m);
sp_4096_cond_sub_39(t[0], t[0], m, ~(n >> 63)); sp_4096_cond_sub_39(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 39 * 2); XMEMCPY(r, t[0], sizeof(*r) * 39 * 2);
} }
@@ -18844,7 +18844,7 @@ static int sp_4096_mod_exp_39(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_4096_mont_reduce_39(t[0], m, mp); sp_4096_mont_reduce_39(t[0], m, mp);
n = sp_4096_cmp_39(t[0], m); n = sp_4096_cmp_39(t[0], m);
sp_4096_cond_sub_39(t[0], t[0], m, ~(n >> 63)); sp_4096_cond_sub_39(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 39 * 2); XMEMCPY(r, t[0], sizeof(*r) * 39 * 2);
} }
@@ -18989,7 +18989,7 @@ static int sp_4096_mod_exp_39(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_4096_mont_reduce_39(rt, m, mp); sp_4096_mont_reduce_39(rt, m, mp);
n = sp_4096_cmp_39(rt, m); n = sp_4096_cmp_39(rt, m);
sp_4096_cond_sub_39(rt, rt, m, ~(n >> 63)); sp_4096_cond_sub_39(rt, rt, m, (sp_digit)~(n >> 63));
XMEMCPY(r, rt, sizeof(sp_digit) * 78); XMEMCPY(r, rt, sizeof(sp_digit) * 78);
} }
@@ -19651,7 +19651,7 @@ static int sp_4096_mod_exp_78(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_4096_mont_reduce_78(t[0], m, mp); sp_4096_mont_reduce_78(t[0], m, mp);
n = sp_4096_cmp_78(t[0], m); n = sp_4096_cmp_78(t[0], m);
sp_4096_cond_sub_78(t[0], t[0], m, ~(n >> 63)); sp_4096_cond_sub_78(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 78 * 2); XMEMCPY(r, t[0], sizeof(*r) * 78 * 2);
} }
@@ -19741,7 +19741,7 @@ static int sp_4096_mod_exp_78(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_4096_mont_reduce_78(t[0], m, mp); sp_4096_mont_reduce_78(t[0], m, mp);
n = sp_4096_cmp_78(t[0], m); n = sp_4096_cmp_78(t[0], m);
sp_4096_cond_sub_78(t[0], t[0], m, ~(n >> 63)); sp_4096_cond_sub_78(t[0], t[0], m, (sp_digit)~(n >> 63));
XMEMCPY(r, t[0], sizeof(*r) * 78 * 2); XMEMCPY(r, t[0], sizeof(*r) * 78 * 2);
} }
@@ -19869,7 +19869,7 @@ static int sp_4096_mod_exp_78(sp_digit* r, const sp_digit* a, const sp_digit* e,
sp_4096_mont_reduce_78(rt, m, mp); sp_4096_mont_reduce_78(rt, m, mp);
n = sp_4096_cmp_78(rt, m); n = sp_4096_cmp_78(rt, m);
sp_4096_cond_sub_78(rt, rt, m, ~(n >> 63)); sp_4096_cond_sub_78(rt, rt, m, (sp_digit)~(n >> 63));
XMEMCPY(r, rt, sizeof(sp_digit) * 156); XMEMCPY(r, rt, sizeof(sp_digit) * 156);
} }
@@ -20978,7 +20978,7 @@ static int sp_4096_mod_exp_2_78(sp_digit* r, const sp_digit* e, int bits, const
sp_4096_mont_reduce_78(r, m, mp); sp_4096_mont_reduce_78(r, m, mp);
n = sp_4096_cmp_78(r, m); n = sp_4096_cmp_78(r, m);
sp_4096_cond_sub_78(r, r, m, ~(n >> 63)); sp_4096_cond_sub_78(r, r, m, (sp_digit)~(n >> 63));
} }
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
@@ -22013,7 +22013,7 @@ static void sp_256_map_5(sp_point_256* r, const sp_point_256* p,
sp_256_mont_reduce_5(r->x, p256_mod, p256_mp_mod); sp_256_mont_reduce_5(r->x, p256_mod, p256_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_256_cmp_5(r->x, p256_mod); n = sp_256_cmp_5(r->x, p256_mod);
sp_256_cond_sub_5(r->x, r->x, p256_mod, ~(n >> 51)); sp_256_cond_sub_5(r->x, r->x, p256_mod, (sp_digit)~(n >> 51));
sp_256_norm_5(r->x); sp_256_norm_5(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -22022,7 +22022,7 @@ static void sp_256_map_5(sp_point_256* r, const sp_point_256* p,
sp_256_mont_reduce_5(r->y, p256_mod, p256_mp_mod); sp_256_mont_reduce_5(r->y, p256_mod, p256_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_256_cmp_5(r->y, p256_mod); n = sp_256_cmp_5(r->y, p256_mod);
sp_256_cond_sub_5(r->y, r->y, p256_mod, ~(n >> 51)); sp_256_cond_sub_5(r->y, r->y, p256_mod, (sp_digit)~(n >> 51));
sp_256_norm_5(r->y); sp_256_norm_5(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -22467,8 +22467,8 @@ static void sp_256_proj_point_add_5(sp_point_256* r,
sp_256_mont_sub_5(y, y, t5, p256_mod); sp_256_mont_sub_5(y, y, t5, p256_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -22485,7 +22485,7 @@ static void sp_256_proj_point_add_5(sp_point_256* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -22659,8 +22659,8 @@ static int sp_256_proj_point_add_5_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -22677,7 +22677,7 @@ static int sp_256_proj_point_add_5_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -23363,7 +23363,7 @@ static void sp_256_ecc_recode_6_5(const sp_digit* k, ecc_recode_256* v)
n = k[j]; n = k[j];
o = 0; o = 0;
for (i=0; i<43; i++) { for (i=0; i<43; i++) {
y = (int8_t)n; y = (uint8_t)(int8_t)n;
if (o + 6 < 52) { if (o + 6 < 52) {
y &= 0x3f; y &= 0x3f;
n >>= 6; n >>= 6;
@@ -23418,7 +23418,7 @@ static void sp_256_get_point_33_5(sp_point_256* r, const sp_point_256* table,
r->z[3] = 0; r->z[3] = 0;
r->z[4] = 0; r->z[4] = 0;
for (i = 1; i < 33; i++) { for (i = 1; i < 33; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -23640,8 +23640,8 @@ static void sp_256_proj_point_add_qz1_5(sp_point_256* r,
sp_256_mont_sub_5(y, t3, t1, p256_mod); sp_256_mont_sub_5(y, t3, t1, p256_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -23658,7 +23658,7 @@ static void sp_256_proj_point_add_qz1_5(sp_point_256* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -23800,7 +23800,7 @@ static void sp_256_get_entry_256_5(sp_point_256* r,
r->y[3] = 0; r->y[3] = 0;
r->y[4] = 0; r->y[4] = 0;
for (i = 1; i < 256; i++) { for (i = 1; i < 256; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -28908,7 +28908,7 @@ static void sp_384_map_7(sp_point_384* r, const sp_point_384* p,
sp_384_mont_reduce_7(r->x, p384_mod, p384_mp_mod); sp_384_mont_reduce_7(r->x, p384_mod, p384_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_384_cmp_7(r->x, p384_mod); n = sp_384_cmp_7(r->x, p384_mod);
sp_384_cond_sub_7(r->x, r->x, p384_mod, ~(n >> 54)); sp_384_cond_sub_7(r->x, r->x, p384_mod, (sp_digit)~(n >> 54));
sp_384_norm_7(r->x); sp_384_norm_7(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -28917,7 +28917,7 @@ static void sp_384_map_7(sp_point_384* r, const sp_point_384* p,
sp_384_mont_reduce_7(r->y, p384_mod, p384_mp_mod); sp_384_mont_reduce_7(r->y, p384_mod, p384_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_384_cmp_7(r->y, p384_mod); n = sp_384_cmp_7(r->y, p384_mod);
sp_384_cond_sub_7(r->y, r->y, p384_mod, ~(n >> 54)); sp_384_cond_sub_7(r->y, r->y, p384_mod, (sp_digit)~(n >> 54));
sp_384_norm_7(r->y); sp_384_norm_7(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -29367,8 +29367,8 @@ static void sp_384_proj_point_add_7(sp_point_384* r,
sp_384_mont_sub_7(y, y, t5, p384_mod); sp_384_mont_sub_7(y, y, t5, p384_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -29385,7 +29385,7 @@ static void sp_384_proj_point_add_7(sp_point_384* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -29559,8 +29559,8 @@ static int sp_384_proj_point_add_7_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -29577,7 +29577,7 @@ static int sp_384_proj_point_add_7_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -30299,7 +30299,7 @@ static void sp_384_ecc_recode_6_7(const sp_digit* k, ecc_recode_384* v)
n = k[j]; n = k[j];
o = 0; o = 0;
for (i=0; i<65; i++) { for (i=0; i<65; i++) {
y = (int8_t)n; y = (uint8_t)(int8_t)n;
if (o + 6 < 55) { if (o + 6 < 55) {
y &= 0x3f; y &= 0x3f;
n >>= 6; n >>= 6;
@@ -30360,7 +30360,7 @@ static void sp_384_get_point_33_7(sp_point_384* r, const sp_point_384* table,
r->z[5] = 0; r->z[5] = 0;
r->z[6] = 0; r->z[6] = 0;
for (i = 1; i < 33; i++) { for (i = 1; i < 33; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -30588,8 +30588,8 @@ static void sp_384_proj_point_add_qz1_7(sp_point_384* r,
sp_384_mont_sub_7(y, t3, t1, p384_mod); sp_384_mont_sub_7(y, t3, t1, p384_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -30606,7 +30606,7 @@ static void sp_384_proj_point_add_qz1_7(sp_point_384* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -30752,7 +30752,7 @@ static void sp_384_get_entry_256_7(sp_point_384* r,
r->y[5] = 0; r->y[5] = 0;
r->y[6] = 0; r->y[6] = 0;
for (i = 1; i < 256; i++) { for (i = 1; i < 256; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -36418,7 +36418,7 @@ static void sp_521_map_9(sp_point_521* r, const sp_point_521* p,
sp_521_mont_reduce_9(r->x, p521_mod, p521_mp_mod); sp_521_mont_reduce_9(r->x, p521_mod, p521_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_521_cmp_9(r->x, p521_mod); n = sp_521_cmp_9(r->x, p521_mod);
sp_521_cond_sub_9(r->x, r->x, p521_mod, ~(n >> 57)); sp_521_cond_sub_9(r->x, r->x, p521_mod, (sp_digit)~(n >> 57));
sp_521_norm_9(r->x); sp_521_norm_9(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -36427,7 +36427,7 @@ static void sp_521_map_9(sp_point_521* r, const sp_point_521* p,
sp_521_mont_reduce_9(r->y, p521_mod, p521_mp_mod); sp_521_mont_reduce_9(r->y, p521_mod, p521_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_521_cmp_9(r->y, p521_mod); n = sp_521_cmp_9(r->y, p521_mod);
sp_521_cond_sub_9(r->y, r->y, p521_mod, ~(n >> 57)); sp_521_cond_sub_9(r->y, r->y, p521_mod, (sp_digit)~(n >> 57));
sp_521_norm_9(r->y); sp_521_norm_9(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -36882,8 +36882,8 @@ static void sp_521_proj_point_add_9(sp_point_521* r,
sp_521_mont_sub_9(y, y, t5, p521_mod); sp_521_mont_sub_9(y, y, t5, p521_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -36900,7 +36900,7 @@ static void sp_521_proj_point_add_9(sp_point_521* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -37074,8 +37074,8 @@ static int sp_521_proj_point_add_9_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -37092,7 +37092,7 @@ static int sp_521_proj_point_add_9_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -37696,7 +37696,7 @@ static void sp_521_ecc_recode_6_9(const sp_digit* k, ecc_recode_521* v)
n = k[j]; n = k[j];
o = 0; o = 0;
for (i=0; i<87; i++) { for (i=0; i<87; i++) {
y = (int8_t)n; y = (uint8_t)(int8_t)n;
if (o + 6 < 58) { if (o + 6 < 58) {
y &= 0x3f; y &= 0x3f;
n >>= 6; n >>= 6;
@@ -37763,7 +37763,7 @@ static void sp_521_get_point_33_9(sp_point_521* r, const sp_point_521* table,
r->z[7] = 0; r->z[7] = 0;
r->z[8] = 0; r->z[8] = 0;
for (i = 1; i < 33; i++) { for (i = 1; i < 33; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -37997,8 +37997,8 @@ static void sp_521_proj_point_add_qz1_9(sp_point_521* r,
sp_521_mont_sub_9(y, t3, t1, p521_mod); sp_521_mont_sub_9(y, t3, t1, p521_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -38015,7 +38015,7 @@ static void sp_521_proj_point_add_qz1_9(sp_point_521* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -38165,7 +38165,7 @@ static void sp_521_get_entry_256_9(sp_point_521* r,
r->y[7] = 0; r->y[7] = 0;
r->y[8] = 0; r->y[8] = 0;
for (i = 1; i < 256; i++) { for (i = 1; i < 256; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -44320,7 +44320,7 @@ static void sp_1024_map_18(sp_point_1024* r, const sp_point_1024* p,
sp_1024_mont_reduce_18(r->x, p1024_mod, p1024_mp_mod); sp_1024_mont_reduce_18(r->x, p1024_mod, p1024_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_1024_cmp_18(r->x, p1024_mod); n = sp_1024_cmp_18(r->x, p1024_mod);
sp_1024_cond_sub_18(r->x, r->x, p1024_mod, ~(n >> 56)); sp_1024_cond_sub_18(r->x, r->x, p1024_mod, (sp_digit)~(n >> 56));
sp_1024_norm_18(r->x); sp_1024_norm_18(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -44329,7 +44329,7 @@ static void sp_1024_map_18(sp_point_1024* r, const sp_point_1024* p,
sp_1024_mont_reduce_18(r->y, p1024_mod, p1024_mp_mod); sp_1024_mont_reduce_18(r->y, p1024_mod, p1024_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_1024_cmp_18(r->y, p1024_mod); n = sp_1024_cmp_18(r->y, p1024_mod);
sp_1024_cond_sub_18(r->y, r->y, p1024_mod, ~(n >> 56)); sp_1024_cond_sub_18(r->y, r->y, p1024_mod, (sp_digit)~(n >> 56));
sp_1024_norm_18(r->y); sp_1024_norm_18(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -44753,8 +44753,8 @@ static void sp_1024_proj_point_add_18(sp_point_1024* r,
sp_1024_mont_sub_18(y, y, t5, p1024_mod); sp_1024_mont_sub_18(y, y, t5, p1024_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -44771,7 +44771,7 @@ static void sp_1024_proj_point_add_18(sp_point_1024* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -44945,8 +44945,8 @@ static int sp_1024_proj_point_add_18_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -44963,7 +44963,7 @@ static int sp_1024_proj_point_add_18_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -45575,7 +45575,7 @@ static void sp_1024_ecc_recode_7_18(const sp_digit* k, ecc_recode_1024* v)
n = k[j]; n = k[j];
o = 0; o = 0;
for (i=0; i<147; i++) { for (i=0; i<147; i++) {
y = (int8_t)n; y = (uint8_t)(int8_t)n;
if (o + 7 < 57) { if (o + 7 < 57) {
y &= 0x7f; y &= 0x7f;
n >>= 7; n >>= 7;
@@ -45808,8 +45808,8 @@ static void sp_1024_proj_point_add_qz1_18(sp_point_1024* r,
sp_1024_mont_sub_18(y, t3, t1, p1024_mod); sp_1024_mont_sub_18(y, t3, t1, p1024_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -45826,7 +45826,7 @@ static void sp_1024_proj_point_add_qz1_18(sp_point_1024* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -53150,7 +53150,7 @@ static int sp_1024_ecc_is_point_18(const sp_point_1024* point,
n = sp_1024_cmp_18(t1, p1024_mod); n = sp_1024_cmp_18(t1, p1024_mod);
sp_1024_cond_sub_18(t1, t1, p1024_mod, ~(n >> 56)); sp_1024_cond_sub_18(t1, t1, p1024_mod, (sp_digit)~(n >> 56));
sp_1024_norm_18(t1); sp_1024_norm_18(t1);
if (!sp_1024_iszero_18(t1)) { if (!sp_1024_iszero_18(t1)) {
err = MP_VAL; err = MP_VAL;

View File

@@ -67,7 +67,7 @@
do { \ do { \
int ii; \ int ii; \
fprintf(stderr, name "=0x"); \ fprintf(stderr, name "=0x"); \
for (ii = ((bits + 31) / 32) - 1; ii >= 0; ii--) \ for (ii = (((bits) + 31) / 32) - 1; ii >= 0; ii--) \
fprintf(stderr, SP_PRINT_FMT, (var)[ii]); \ fprintf(stderr, SP_PRINT_FMT, (var)[ii]); \
fprintf(stderr, "\n"); \ fprintf(stderr, "\n"); \
} while (0) } while (0)
@@ -5345,7 +5345,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[32], 0, sizeof(sp_digit) * 32U); XMEMSET(&r[32], 0, sizeof(sp_digit) * 32U);
sp_2048_mont_reduce_32(r, m, mp); sp_2048_mont_reduce_32(r, m, mp);
mask = 0 - (sp_2048_cmp_32(r, m) >= 0); mask = (sp_digit)0 - (sp_2048_cmp_32(r, m) >= 0);
sp_2048_cond_sub_32(r, r, m, mask); sp_2048_cond_sub_32(r, r, m, mask);
} }
@@ -5513,7 +5513,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[32], 0, sizeof(sp_digit) * 32U); XMEMSET(&r[32], 0, sizeof(sp_digit) * 32U);
sp_2048_mont_reduce_32(r, m, mp); sp_2048_mont_reduce_32(r, m, mp);
mask = 0 - (sp_2048_cmp_32(r, m) >= 0); mask = (sp_digit)0 - (sp_2048_cmp_32(r, m) >= 0);
sp_2048_cond_sub_32(r, r, m, mask); sp_2048_cond_sub_32(r, r, m, mask);
} }
@@ -8462,7 +8462,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U); XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U);
sp_2048_mont_reduce_64(r, m, mp); sp_2048_mont_reduce_64(r, m, mp);
mask = 0 - (sp_2048_cmp_64(r, m) >= 0); mask = (sp_digit)0 - (sp_2048_cmp_64(r, m) >= 0);
sp_2048_cond_sub_64(r, r, m, mask); sp_2048_cond_sub_64(r, r, m, mask);
} }
@@ -8613,7 +8613,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U); XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U);
sp_2048_mont_reduce_64(r, m, mp); sp_2048_mont_reduce_64(r, m, mp);
mask = 0 - (sp_2048_cmp_64(r, m) >= 0); mask = (sp_digit)0 - (sp_2048_cmp_64(r, m) >= 0);
sp_2048_cond_sub_64(r, r, m, mask); sp_2048_cond_sub_64(r, r, m, mask);
} }
@@ -9821,7 +9821,7 @@ static int sp_2048_mod_exp_2_64(sp_digit* r, const sp_digit* e, int bits,
XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U); XMEMSET(&r[64], 0, sizeof(sp_digit) * 64U);
sp_2048_mont_reduce_64(r, m, mp); sp_2048_mont_reduce_64(r, m, mp);
mask = 0 - (sp_2048_cmp_64(r, m) >= 0); mask = (sp_digit)0 - (sp_2048_cmp_64(r, m) >= 0);
sp_2048_cond_sub_64(r, r, m, mask); sp_2048_cond_sub_64(r, r, m, mask);
} }
@@ -17020,7 +17020,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[48], 0, sizeof(sp_digit) * 48U); XMEMSET(&r[48], 0, sizeof(sp_digit) * 48U);
sp_3072_mont_reduce_48(r, m, mp); sp_3072_mont_reduce_48(r, m, mp);
mask = 0 - (sp_3072_cmp_48(r, m) >= 0); mask = (sp_digit)0 - (sp_3072_cmp_48(r, m) >= 0);
sp_3072_cond_sub_48(r, r, m, mask); sp_3072_cond_sub_48(r, r, m, mask);
} }
@@ -17188,7 +17188,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[48], 0, sizeof(sp_digit) * 48U); XMEMSET(&r[48], 0, sizeof(sp_digit) * 48U);
sp_3072_mont_reduce_48(r, m, mp); sp_3072_mont_reduce_48(r, m, mp);
mask = 0 - (sp_3072_cmp_48(r, m) >= 0); mask = (sp_digit)0 - (sp_3072_cmp_48(r, m) >= 0);
sp_3072_cond_sub_48(r, r, m, mask); sp_3072_cond_sub_48(r, r, m, mask);
} }
@@ -21073,7 +21073,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[96], 0, sizeof(sp_digit) * 96U); XMEMSET(&r[96], 0, sizeof(sp_digit) * 96U);
sp_3072_mont_reduce_96(r, m, mp); sp_3072_mont_reduce_96(r, m, mp);
mask = 0 - (sp_3072_cmp_96(r, m) >= 0); mask = (sp_digit)0 - (sp_3072_cmp_96(r, m) >= 0);
sp_3072_cond_sub_96(r, r, m, mask); sp_3072_cond_sub_96(r, r, m, mask);
} }
@@ -21224,7 +21224,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, const sp_digit* a, const sp_digit* e,
XMEMSET(&r[96], 0, sizeof(sp_digit) * 96U); XMEMSET(&r[96], 0, sizeof(sp_digit) * 96U);
sp_3072_mont_reduce_96(r, m, mp); sp_3072_mont_reduce_96(r, m, mp);
mask = 0 - (sp_3072_cmp_96(r, m) >= 0); mask = (sp_digit)0 - (sp_3072_cmp_96(r, m) >= 0);
sp_3072_cond_sub_96(r, r, m, mask); sp_3072_cond_sub_96(r, r, m, mask);
} }
@@ -22680,7 +22680,7 @@ static int sp_3072_mod_exp_2_96(sp_digit* r, const sp_digit* e, int bits,
XMEMSET(&r[96], 0, sizeof(sp_digit) * 96U); XMEMSET(&r[96], 0, sizeof(sp_digit) * 96U);
sp_3072_mont_reduce_96(r, m, mp); sp_3072_mont_reduce_96(r, m, mp);
mask = 0 - (sp_3072_cmp_96(r, m) >= 0); mask = (sp_digit)0 - (sp_3072_cmp_96(r, m) >= 0);
sp_3072_cond_sub_96(r, r, m, mask); sp_3072_cond_sub_96(r, r, m, mask);
} }
@@ -29456,7 +29456,7 @@ static int sp_4096_mod_exp_128(sp_digit* r, const sp_digit* a, const sp_digit* e
XMEMSET(&r[128], 0, sizeof(sp_digit) * 128U); XMEMSET(&r[128], 0, sizeof(sp_digit) * 128U);
sp_4096_mont_reduce_128(r, m, mp); sp_4096_mont_reduce_128(r, m, mp);
mask = 0 - (sp_4096_cmp_128(r, m) >= 0); mask = (sp_digit)0 - (sp_4096_cmp_128(r, m) >= 0);
sp_4096_cond_sub_128(r, r, m, mask); sp_4096_cond_sub_128(r, r, m, mask);
} }
@@ -29607,7 +29607,7 @@ static int sp_4096_mod_exp_128(sp_digit* r, const sp_digit* a, const sp_digit* e
XMEMSET(&r[128], 0, sizeof(sp_digit) * 128U); XMEMSET(&r[128], 0, sizeof(sp_digit) * 128U);
sp_4096_mont_reduce_128(r, m, mp); sp_4096_mont_reduce_128(r, m, mp);
mask = 0 - (sp_4096_cmp_128(r, m) >= 0); mask = (sp_digit)0 - (sp_4096_cmp_128(r, m) >= 0);
sp_4096_cond_sub_128(r, r, m, mask); sp_4096_cond_sub_128(r, r, m, mask);
} }
@@ -31311,7 +31311,7 @@ static int sp_4096_mod_exp_2_128(sp_digit* r, const sp_digit* e, int bits,
XMEMSET(&r[128], 0, sizeof(sp_digit) * 128U); XMEMSET(&r[128], 0, sizeof(sp_digit) * 128U);
sp_4096_mont_reduce_128(r, m, mp); sp_4096_mont_reduce_128(r, m, mp);
mask = 0 - (sp_4096_cmp_128(r, m) >= 0); mask = (sp_digit)0 - (sp_4096_cmp_128(r, m) >= 0);
sp_4096_cond_sub_128(r, r, m, mask); sp_4096_cond_sub_128(r, r, m, mask);
} }
@@ -35522,7 +35522,7 @@ static void sp_256_map_8(sp_point_256* r, const sp_point_256* p,
sp_256_mont_reduce_8(r->x, p256_mod, p256_mp_mod); sp_256_mont_reduce_8(r->x, p256_mod, p256_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_256_cmp_8(r->x, p256_mod); n = sp_256_cmp_8(r->x, p256_mod);
sp_256_cond_sub_8(r->x, r->x, p256_mod, ~(n >> 31)); sp_256_cond_sub_8(r->x, r->x, p256_mod, (sp_digit)~(n >> 31));
sp_256_norm_8(r->x); sp_256_norm_8(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -35531,7 +35531,7 @@ static void sp_256_map_8(sp_point_256* r, const sp_point_256* p,
sp_256_mont_reduce_8(r->y, p256_mod, p256_mp_mod); sp_256_mont_reduce_8(r->y, p256_mod, p256_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_256_cmp_8(r->y, p256_mod); n = sp_256_cmp_8(r->y, p256_mod);
sp_256_cond_sub_8(r->y, r->y, p256_mod, ~(n >> 31)); sp_256_cond_sub_8(r->y, r->y, p256_mod, (sp_digit)~(n >> 31));
sp_256_norm_8(r->y); sp_256_norm_8(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -36173,8 +36173,8 @@ static void sp_256_proj_point_add_8(sp_point_256* r,
sp_256_mont_sub_8(y, y, t5, p256_mod); sp_256_mont_sub_8(y, y, t5, p256_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -36191,7 +36191,7 @@ static void sp_256_proj_point_add_8(sp_point_256* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -36365,8 +36365,8 @@ static int sp_256_proj_point_add_8_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -36383,7 +36383,7 @@ static int sp_256_proj_point_add_8_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -36438,7 +36438,7 @@ static void sp_256_get_point_16_8(sp_point_256* r, const sp_point_256* table,
r->z[6] = 0; r->z[6] = 0;
r->z[7] = 0; r->z[7] = 0;
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -36836,8 +36836,8 @@ static void sp_256_proj_point_add_qz1_8(sp_point_256* r,
sp_256_mont_sub_8(y, t3, t1, p256_mod); sp_256_mont_sub_8(y, t3, t1, p256_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -36854,7 +36854,7 @@ static void sp_256_proj_point_add_qz1_8(sp_point_256* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -36981,7 +36981,7 @@ static void sp_256_get_entry_16_8(sp_point_256* r,
r->y[6] = 0; r->y[6] = 0;
r->y[7] = 0; r->y[7] = 0;
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -37402,7 +37402,7 @@ static void sp_256_get_entry_256_8(sp_point_256* r,
r->y[6] = 0; r->y[6] = 0;
r->y[7] = 0; r->y[7] = 0;
for (i = 1; i < 256; i++) { for (i = 1; i < 256; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -44461,18 +44461,18 @@ static int sp_384_mod_mul_norm_12(sp_digit* r, const sp_digit* a, const sp_digit
t[10] += t[9] >> 32; t[9] &= 0xffffffff; t[10] += t[9] >> 32; t[9] &= 0xffffffff;
t[11] += t[10] >> 32; t[10] &= 0xffffffff; t[11] += t[10] >> 32; t[10] &= 0xffffffff;
r[0] = t[0]; r[0] = (sp_digit)t[0];
r[1] = t[1]; r[1] = (sp_digit)t[1];
r[2] = t[2]; r[2] = (sp_digit)t[2];
r[3] = t[3]; r[3] = (sp_digit)t[3];
r[4] = t[4]; r[4] = (sp_digit)t[4];
r[5] = t[5]; r[5] = (sp_digit)t[5];
r[6] = t[6]; r[6] = (sp_digit)t[6];
r[7] = t[7]; r[7] = (sp_digit)t[7];
r[8] = t[8]; r[8] = (sp_digit)t[8];
r[9] = t[9]; r[9] = (sp_digit)t[9];
r[10] = t[10]; r[10] = (sp_digit)t[10];
r[11] = t[11]; r[11] = (sp_digit)t[11];
} }
#ifdef WOLFSSL_SP_SMALL_STACK #ifdef WOLFSSL_SP_SMALL_STACK
@@ -45447,7 +45447,7 @@ static void sp_384_map_12(sp_point_384* r, const sp_point_384* p,
sp_384_mont_reduce_12(r->x, p384_mod, p384_mp_mod); sp_384_mont_reduce_12(r->x, p384_mod, p384_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_384_cmp_12(r->x, p384_mod); n = sp_384_cmp_12(r->x, p384_mod);
sp_384_cond_sub_12(r->x, r->x, p384_mod, ~(n >> 31)); sp_384_cond_sub_12(r->x, r->x, p384_mod, (sp_digit)~(n >> 31));
sp_384_norm_12(r->x); sp_384_norm_12(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -45456,7 +45456,7 @@ static void sp_384_map_12(sp_point_384* r, const sp_point_384* p,
sp_384_mont_reduce_12(r->y, p384_mod, p384_mp_mod); sp_384_mont_reduce_12(r->y, p384_mod, p384_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_384_cmp_12(r->y, p384_mod); n = sp_384_cmp_12(r->y, p384_mod);
sp_384_cond_sub_12(r->y, r->y, p384_mod, ~(n >> 31)); sp_384_cond_sub_12(r->y, r->y, p384_mod, (sp_digit)~(n >> 31));
sp_384_norm_12(r->y); sp_384_norm_12(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -46174,8 +46174,8 @@ static void sp_384_proj_point_add_12(sp_point_384* r,
sp_384_mont_sub_12(y, y, t5, p384_mod); sp_384_mont_sub_12(y, y, t5, p384_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -46192,7 +46192,7 @@ static void sp_384_proj_point_add_12(sp_point_384* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -46366,8 +46366,8 @@ static int sp_384_proj_point_add_12_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -46384,7 +46384,7 @@ static int sp_384_proj_point_add_12_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -46451,7 +46451,7 @@ static void sp_384_get_point_16_12(sp_point_384* r, const sp_point_384* table,
r->z[10] = 0; r->z[10] = 0;
r->z[11] = 0; r->z[11] = 0;
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -46861,8 +46861,8 @@ static void sp_384_proj_point_add_qz1_12(sp_point_384* r,
sp_384_mont_sub_12(y, t3, t1, p384_mod); sp_384_mont_sub_12(y, t3, t1, p384_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -46879,7 +46879,7 @@ static void sp_384_proj_point_add_qz1_12(sp_point_384* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -47014,7 +47014,7 @@ static void sp_384_get_entry_16_12(sp_point_384* r,
r->y[10] = 0; r->y[10] = 0;
r->y[11] = 0; r->y[11] = 0;
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -47451,7 +47451,7 @@ static void sp_384_get_entry_256_12(sp_point_384* r,
r->y[10] = 0; r->y[10] = 0;
r->y[11] = 0; r->y[11] = 0;
for (i = 1; i < 256; i++) { for (i = 1; i < 256; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -57534,7 +57534,7 @@ static void sp_521_map_17(sp_point_521* r, const sp_point_521* p,
sp_521_mont_reduce_17(r->x, p521_mod, p521_mp_mod); sp_521_mont_reduce_17(r->x, p521_mod, p521_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_521_cmp_17(r->x, p521_mod); n = sp_521_cmp_17(r->x, p521_mod);
sp_521_cond_sub_17(r->x, r->x, p521_mod, ~(n >> 31)); sp_521_cond_sub_17(r->x, r->x, p521_mod, (sp_digit)~(n >> 31));
sp_521_norm_17(r->x); sp_521_norm_17(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -57543,7 +57543,7 @@ static void sp_521_map_17(sp_point_521* r, const sp_point_521* p,
sp_521_mont_reduce_17(r->y, p521_mod, p521_mp_mod); sp_521_mont_reduce_17(r->y, p521_mod, p521_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_521_cmp_17(r->y, p521_mod); n = sp_521_cmp_17(r->y, p521_mod);
sp_521_cond_sub_17(r->y, r->y, p521_mod, ~(n >> 31)); sp_521_cond_sub_17(r->y, r->y, p521_mod, (sp_digit)~(n >> 31));
sp_521_norm_17(r->y); sp_521_norm_17(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -58309,8 +58309,8 @@ static void sp_521_proj_point_add_17(sp_point_521* r,
sp_521_mont_sub_17(y, y, t5, p521_mod); sp_521_mont_sub_17(y, y, t5, p521_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -58327,7 +58327,7 @@ static void sp_521_proj_point_add_17(sp_point_521* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -58501,8 +58501,8 @@ static int sp_521_proj_point_add_17_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -58519,7 +58519,7 @@ static int sp_521_proj_point_add_17_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -58601,7 +58601,7 @@ static void sp_521_get_point_16_17(sp_point_521* r, const sp_point_521* table,
r->z[15] = 0; r->z[15] = 0;
r->z[16] = 0; r->z[16] = 0;
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -59030,8 +59030,8 @@ static void sp_521_proj_point_add_qz1_17(sp_point_521* r,
sp_521_mont_sub_17(y, t3, t1, p521_mod); sp_521_mont_sub_17(y, t3, t1, p521_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -59048,7 +59048,7 @@ static void sp_521_proj_point_add_qz1_17(sp_point_521* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -59193,7 +59193,7 @@ static void sp_521_get_entry_16_17(sp_point_521* r,
r->y[15] = 0; r->y[15] = 0;
r->y[16] = 0; r->y[16] = 0;
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -59650,7 +59650,7 @@ static void sp_521_get_entry_256_17(sp_point_521* r,
r->y[15] = 0; r->y[15] = 0;
r->y[16] = 0; r->y[16] = 0;
for (i = 1; i < 256; i++) { for (i = 1; i < 256; i++) {
mask = 0 - (i == idx); mask = (sp_digit)0 - (i == idx);
r->x[0] |= mask & table[i].x[0]; r->x[0] |= mask & table[i].x[0];
r->x[1] |= mask & table[i].x[1]; r->x[1] |= mask & table[i].x[1];
r->x[2] |= mask & table[i].x[2]; r->x[2] |= mask & table[i].x[2];
@@ -71659,7 +71659,7 @@ static void sp_1024_map_32(sp_point_1024* r, const sp_point_1024* p,
sp_1024_mont_reduce_32(r->x, p1024_mod, p1024_mp_mod); sp_1024_mont_reduce_32(r->x, p1024_mod, p1024_mp_mod);
/* Reduce x to less than modulus */ /* Reduce x to less than modulus */
n = sp_1024_cmp_32(r->x, p1024_mod); n = sp_1024_cmp_32(r->x, p1024_mod);
sp_1024_cond_sub_32(r->x, r->x, p1024_mod, ~(n >> 31)); sp_1024_cond_sub_32(r->x, r->x, p1024_mod, (sp_digit)~(n >> 31));
sp_1024_norm_32(r->x); sp_1024_norm_32(r->x);
/* y /= z^3 */ /* y /= z^3 */
@@ -71668,7 +71668,7 @@ static void sp_1024_map_32(sp_point_1024* r, const sp_point_1024* p,
sp_1024_mont_reduce_32(r->y, p1024_mod, p1024_mp_mod); sp_1024_mont_reduce_32(r->y, p1024_mod, p1024_mp_mod);
/* Reduce y to less than modulus */ /* Reduce y to less than modulus */
n = sp_1024_cmp_32(r->y, p1024_mod); n = sp_1024_cmp_32(r->y, p1024_mod);
sp_1024_cond_sub_32(r->y, r->y, p1024_mod, ~(n >> 31)); sp_1024_cond_sub_32(r->y, r->y, p1024_mod, (sp_digit)~(n >> 31));
sp_1024_norm_32(r->y); sp_1024_norm_32(r->y);
XMEMSET(r->z, 0, sizeof(r->z) / 2); XMEMSET(r->z, 0, sizeof(r->z) / 2);
@@ -73166,8 +73166,8 @@ static void sp_1024_proj_point_add_32(sp_point_1024* r,
sp_1024_mont_sub_32(y, y, t5, p1024_mod); sp_1024_mont_sub_32(y, y, t5, p1024_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -73184,7 +73184,7 @@ static void sp_1024_proj_point_add_32(sp_point_1024* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -73358,8 +73358,8 @@ static int sp_1024_proj_point_add_32_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r,
{ {
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -73376,7 +73376,7 @@ static int sp_1024_proj_point_add_32_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r,
(ctx->z[i] & maskt); (ctx->z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
ctx->state = 25; ctx->state = 25;
break; break;
@@ -73717,8 +73717,8 @@ static void sp_1024_proj_point_add_qz1_32(sp_point_1024* r,
sp_1024_mont_sub_32(y, t3, t1, p1024_mod); sp_1024_mont_sub_32(y, t3, t1, p1024_mod);
{ {
int i; int i;
sp_digit maskp = 0 - (q->infinity & (!p->infinity)); sp_digit maskp = (sp_digit)(0 - (q->infinity & (!p->infinity)));
sp_digit maskq = 0 - (p->infinity & (!q->infinity)); sp_digit maskq = (sp_digit)(0 - (p->infinity & (!q->infinity)));
sp_digit maskt = ~(maskp | maskq); sp_digit maskt = ~(maskp | maskq);
sp_digit inf = (sp_digit)(p->infinity & q->infinity); sp_digit inf = (sp_digit)(p->infinity & q->infinity);
@@ -73735,7 +73735,7 @@ static void sp_1024_proj_point_add_qz1_32(sp_point_1024* r,
(z[i] & maskt); (z[i] & maskt);
} }
r->z[0] |= inf; r->z[0] |= inf;
r->infinity = (word32)inf; r->infinity = (int)inf;
} }
} }
} }
@@ -81860,7 +81860,7 @@ static int sp_1024_ecc_is_point_32(const sp_point_1024* point,
n = sp_1024_cmp_32(t1, p1024_mod); n = sp_1024_cmp_32(t1, p1024_mod);
sp_1024_cond_sub_32(t1, t1, p1024_mod, ~(n >> 31)); sp_1024_cond_sub_32(t1, t1, p1024_mod, (sp_digit)~(n >> 31));
sp_1024_norm_32(t1); sp_1024_norm_32(t1);
if (!sp_1024_iszero_32(t1)) { if (!sp_1024_iszero_32(t1)) {
err = MP_VAL; err = MP_VAL;

View File

@@ -9390,7 +9390,7 @@ static int _sp_mul(const sp_int* a, const sp_int* b, sp_int* r)
#ifdef SP_WORD_OVERFLOW #ifdef SP_WORD_OVERFLOW
o = 0; o = 0;
#endif #endif
for (k = 1; k <= (a->used - 1) + (b->used - 1); k++) { for (k = 1; (int)k <= ((int)a->used - 1) + ((int)b->used - 1); k++) {
i = k - (sp_size_t)(b->used - 1); i = k - (sp_size_t)(b->used - 1);
i &= (sp_size_t)(((unsigned int)i >> (sizeof(i) * 8 - 1)) - 1U); i &= (sp_size_t)(((unsigned int)i >> (sizeof(i) * 8 - 1)) - 1U);
j = (int)(k - i); j = (int)(k - i);

File diff suppressed because it is too large Load Diff