From c03306dde55b9ef0d2073f1376f36b96f84c0679 Mon Sep 17 00:00:00 2001 From: sthen <> Date: Mon, 14 Apr 2014 14:50:09 +0000 Subject: replace PTR_SIZE_INT (only used for VMS) with uintptr_t, tweaks from jca@, makes sense to beck@ --- src/lib/libcrypto/bn/bn_nist.c | 66 ++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 35 deletions(-) (limited to 'src/lib/libcrypto/bn/bn_nist.c') diff --git a/src/lib/libcrypto/bn/bn_nist.c b/src/lib/libcrypto/bn/bn_nist.c index e22968d4a3..1e4cf833dc 100644 --- a/src/lib/libcrypto/bn/bn_nist.c +++ b/src/lib/libcrypto/bn/bn_nist.c @@ -364,7 +364,7 @@ int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, } buf; BN_ULONG c_d[BN_NIST_192_TOP], *res; - PTR_SIZE_INT mask; + uintptr_t mask; static const BIGNUM _bignum_nist_p_192_sqr = { (BN_ULONG *)_nist_p_192_sqr, sizeof(_nist_p_192_sqr)/sizeof(_nist_p_192_sqr[0]), @@ -448,11 +448,11 @@ int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, * 'tmp=result-modulus; if (!carry || !borrow) result=tmp;' * this is what happens below, but without explicit if:-) a. */ - mask = 0-(PTR_SIZE_INT)bn_sub_words(c_d,r_d,_nist_p_192[0],BN_NIST_192_TOP); - mask &= 0-(PTR_SIZE_INT)carry; + mask = 0-(uintptr_t)bn_sub_words(c_d,r_d,_nist_p_192[0],BN_NIST_192_TOP); + mask &= 0-(uintptr_t)carry; res = c_d; res = (BN_ULONG *) - (((PTR_SIZE_INT)res&~mask) | ((PTR_SIZE_INT)r_d&mask)); + (((uintptr_t)res&~mask) | ((uintptr_t)r_d&mask)); nist_cp_bn(r_d, res, BN_NIST_192_TOP); r->top = BN_NIST_192_TOP; bn_correct_top(r); @@ -485,8 +485,8 @@ int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, } buf; BN_ULONG c_d[BN_NIST_224_TOP], *res; - PTR_SIZE_INT mask; - union { bn_addsub_f f; PTR_SIZE_INT p; } u; + uintptr_t mask; + union { bn_addsub_f f; uintptr_t p; } u; static const BIGNUM _bignum_nist_p_224_sqr = { (BN_ULONG *)_nist_p_224_sqr, sizeof(_nist_p_224_sqr)/sizeof(_nist_p_224_sqr[0]), @@ -599,19 +599,18 @@ int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, * to be compared to the modulus and conditionally * adjusted by *subtracting* the latter. */ carry = (int)bn_add_words(r_d,r_d,_nist_p_224[-carry-1],BN_NIST_224_TOP); - mask = 0-(PTR_SIZE_INT)carry; - u.p = ((PTR_SIZE_INT)bn_sub_words&mask) | - ((PTR_SIZE_INT)bn_add_words&~mask); + mask = 0-(uintptr_t)carry; + u.p = ((uintptr_t)bn_sub_words&mask) | + ((uintptr_t)bn_add_words&~mask); } else carry = 1; /* otherwise it's effectively same as in BN_nist_mod_192... */ - mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_224[0],BN_NIST_224_TOP); - mask &= 0-(PTR_SIZE_INT)carry; + mask = 0-(uintptr_t)(*u.f)(c_d,r_d,_nist_p_224[0],BN_NIST_224_TOP); + mask &= 0-(uintptr_t)carry; res = c_d; - res = (BN_ULONG *)(((PTR_SIZE_INT)res&~mask) | - ((PTR_SIZE_INT)r_d&mask)); + res = (BN_ULONG *)(((uintptr_t)res&~mask) | ((uintptr_t)r_d&mask)); nist_cp_bn(r_d, res, BN_NIST_224_TOP); r->top = BN_NIST_224_TOP; bn_correct_top(r); @@ -643,8 +642,8 @@ int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, } buf; BN_ULONG c_d[BN_NIST_256_TOP], *res; - PTR_SIZE_INT mask; - union { bn_addsub_f f; PTR_SIZE_INT p; } u; + uintptr_t mask; + union { bn_addsub_f f; uintptr_t p; } u; static const BIGNUM _bignum_nist_p_256_sqr = { (BN_ULONG *)_nist_p_256_sqr, sizeof(_nist_p_256_sqr)/sizeof(_nist_p_256_sqr[0]), @@ -800,18 +799,17 @@ int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, else if (carry < 0) { carry = (int)bn_add_words(r_d,r_d,_nist_p_256[-carry-1],BN_NIST_256_TOP); - mask = 0-(PTR_SIZE_INT)carry; - u.p = ((PTR_SIZE_INT)bn_sub_words&mask) | - ((PTR_SIZE_INT)bn_add_words&~mask); + mask = 0-(uintptr_t)carry; + u.p = ((uintptr_t)bn_sub_words&mask) | + ((uintptr_t)bn_add_words&~mask); } else carry = 1; - mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_256[0],BN_NIST_256_TOP); - mask &= 0-(PTR_SIZE_INT)carry; + mask = 0-(uintptr_t)(*u.f)(c_d,r_d,_nist_p_256[0],BN_NIST_256_TOP); + mask &= 0-(uintptr_t)carry; res = c_d; - res = (BN_ULONG *)(((PTR_SIZE_INT)res&~mask) | - ((PTR_SIZE_INT)r_d&mask)); + res = (BN_ULONG *)(((uintptr_t)res&~mask) | ((uintptr_t)r_d&mask)); nist_cp_bn(r_d, res, BN_NIST_256_TOP); r->top = BN_NIST_256_TOP; bn_correct_top(r); @@ -847,8 +845,8 @@ int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, } buf; BN_ULONG c_d[BN_NIST_384_TOP], *res; - PTR_SIZE_INT mask; - union { bn_addsub_f f; PTR_SIZE_INT p; } u; + uintptr_t mask; + union { bn_addsub_f f; uintptr_t p; } u; static const BIGNUM _bignum_nist_p_384_sqr = { (BN_ULONG *)_nist_p_384_sqr, sizeof(_nist_p_384_sqr)/sizeof(_nist_p_384_sqr[0]), @@ -1022,18 +1020,17 @@ int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, else if (carry < 0) { carry = (int)bn_add_words(r_d,r_d,_nist_p_384[-carry-1],BN_NIST_384_TOP); - mask = 0-(PTR_SIZE_INT)carry; - u.p = ((PTR_SIZE_INT)bn_sub_words&mask) | - ((PTR_SIZE_INT)bn_add_words&~mask); + mask = 0-(uintptr_t)carry; + u.p = ((uintptr_t)bn_sub_words&mask) | + ((uintptr_t)bn_add_words&~mask); } else carry = 1; - mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_384[0],BN_NIST_384_TOP); - mask &= 0-(PTR_SIZE_INT)carry; + mask = 0-(uintptr_t)(*u.f)(c_d,r_d,_nist_p_384[0],BN_NIST_384_TOP); + mask &= 0-(uintptr_t)carry; res = c_d; - res = (BN_ULONG *)(((PTR_SIZE_INT)res&~mask) | - ((PTR_SIZE_INT)r_d&mask)); + res = (BN_ULONG *)(((uintptr_t)res&~mask) | ((uintptr_t)r_d&mask)); nist_cp_bn(r_d, res, BN_NIST_384_TOP); r->top = BN_NIST_384_TOP; bn_correct_top(r); @@ -1052,7 +1049,7 @@ int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_ULONG *r_d, *a_d = a->d, t_d[BN_NIST_521_TOP], val,tmp,*res; - PTR_SIZE_INT mask; + uintptr_t mask; static const BIGNUM _bignum_nist_p_521_sqr = { (BN_ULONG *)_nist_p_521_sqr, sizeof(_nist_p_521_sqr)/sizeof(_nist_p_521_sqr[0]), @@ -1097,10 +1094,9 @@ int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, r_d[i] &= BN_NIST_521_TOP_MASK; bn_add_words(r_d,r_d,t_d,BN_NIST_521_TOP); - mask = 0-(PTR_SIZE_INT)bn_sub_words(t_d,r_d,_nist_p_521,BN_NIST_521_TOP); + mask = 0-(uintptr_t)bn_sub_words(t_d,r_d,_nist_p_521,BN_NIST_521_TOP); res = t_d; - res = (BN_ULONG *)(((PTR_SIZE_INT)res&~mask) | - ((PTR_SIZE_INT)r_d&mask)); + res = (BN_ULONG *)(((uintptr_t)res&~mask) | ((uintptr_t)r_d&mask)); nist_cp_bn(r_d,res,BN_NIST_521_TOP); r->top = BN_NIST_521_TOP; bn_correct_top(r); -- cgit v1.2.3-55-g6feb