summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsthen <>2014-04-14 14:50:09 +0000
committersthen <>2014-04-14 14:50:09 +0000
commitc03306dde55b9ef0d2073f1376f36b96f84c0679 (patch)
tree2983dd43dc8ad4f271e515467509c9f79a24ab1a /src
parent95692a60ee0169e369d59f82504e36ff376e13ba (diff)
downloadopenbsd-c03306dde55b9ef0d2073f1376f36b96f84c0679.tar.gz
openbsd-c03306dde55b9ef0d2073f1376f36b96f84c0679.tar.bz2
openbsd-c03306dde55b9ef0d2073f1376f36b96f84c0679.zip
replace PTR_SIZE_INT (only used for VMS) with uintptr_t, tweaks from jca@,
makes sense to beck@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/bn/bn.h18
-rw-r--r--src/lib/libcrypto/bn/bn_mont.c2
-rw-r--r--src/lib/libcrypto/bn/bn_nist.c66
-rw-r--r--src/lib/libcrypto/cryptlib.h1
-rw-r--r--src/lib/libssl/src/crypto/bn/bn.h18
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_mont.c2
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_nist.c66
-rw-r--r--src/lib/libssl/src/crypto/cryptlib.h1
8 files changed, 66 insertions, 108 deletions
diff --git a/src/lib/libcrypto/bn/bn.h b/src/lib/libcrypto/bn/bn.h
index 21a1a3fe35..2e3fab98db 100644
--- a/src/lib/libcrypto/bn/bn.h
+++ b/src/lib/libcrypto/bn/bn.h
@@ -253,24 +253,6 @@ extern "C" {
253#define BN_HEX_FMT2 "%08X" 253#define BN_HEX_FMT2 "%08X"
254#endif 254#endif
255 255
256/* 2011-02-22 SMS.
257 * In various places, a size_t variable or a type cast to size_t was
258 * used to perform integer-only operations on pointers. This failed on
259 * VMS with 64-bit pointers (CC /POINTER_SIZE = 64) because size_t is
260 * still only 32 bits. What's needed in these cases is an integer type
261 * with the same size as a pointer, which size_t is not certain to be.
262 * The only fix here is VMS-specific.
263 */
264#if defined(OPENSSL_SYS_VMS)
265# if __INITIAL_POINTER_SIZE == 64
266# define PTR_SIZE_INT long long
267# else /* __INITIAL_POINTER_SIZE == 64 */
268# define PTR_SIZE_INT int
269# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
270#else /* defined(OPENSSL_SYS_VMS) */
271# define PTR_SIZE_INT size_t
272#endif /* defined(OPENSSL_SYS_VMS) [else] */
273
274#define BN_DEFAULT_BITS 1280 256#define BN_DEFAULT_BITS 1280
275 257
276#define BN_FLG_MALLOCED 0x01 258#define BN_FLG_MALLOCED 0x01
diff --git a/src/lib/libcrypto/bn/bn_mont.c b/src/lib/libcrypto/bn/bn_mont.c
index 427b5cf4df..a6713ae5b1 100644
--- a/src/lib/libcrypto/bn/bn_mont.c
+++ b/src/lib/libcrypto/bn/bn_mont.c
@@ -247,7 +247,7 @@ static int BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont)
247 * trick unconditional memcpy below to perform in-place 247 * trick unconditional memcpy below to perform in-place
248 * "refresh" instead of actual copy. */ 248 * "refresh" instead of actual copy. */
249 m=(0-(size_t)v); 249 m=(0-(size_t)v);
250 nrp=(BN_ULONG *)(((PTR_SIZE_INT)rp&~m)|((PTR_SIZE_INT)ap&m)); 250 nrp=(BN_ULONG *)(((uintptr_t)rp&~m)|((uintptr_t)ap&m));
251 251
252 for (i=0,nl-=4; i<nl; i+=4) 252 for (i=0,nl-=4; i<nl; i+=4)
253 { 253 {
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,
364 } buf; 364 } buf;
365 BN_ULONG c_d[BN_NIST_192_TOP], 365 BN_ULONG c_d[BN_NIST_192_TOP],
366 *res; 366 *res;
367 PTR_SIZE_INT mask; 367 uintptr_t mask;
368 static const BIGNUM _bignum_nist_p_192_sqr = { 368 static const BIGNUM _bignum_nist_p_192_sqr = {
369 (BN_ULONG *)_nist_p_192_sqr, 369 (BN_ULONG *)_nist_p_192_sqr,
370 sizeof(_nist_p_192_sqr)/sizeof(_nist_p_192_sqr[0]), 370 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,
448 * 'tmp=result-modulus; if (!carry || !borrow) result=tmp;' 448 * 'tmp=result-modulus; if (!carry || !borrow) result=tmp;'
449 * this is what happens below, but without explicit if:-) a. 449 * this is what happens below, but without explicit if:-) a.
450 */ 450 */
451 mask = 0-(PTR_SIZE_INT)bn_sub_words(c_d,r_d,_nist_p_192[0],BN_NIST_192_TOP); 451 mask = 0-(uintptr_t)bn_sub_words(c_d,r_d,_nist_p_192[0],BN_NIST_192_TOP);
452 mask &= 0-(PTR_SIZE_INT)carry; 452 mask &= 0-(uintptr_t)carry;
453 res = c_d; 453 res = c_d;
454 res = (BN_ULONG *) 454 res = (BN_ULONG *)
455 (((PTR_SIZE_INT)res&~mask) | ((PTR_SIZE_INT)r_d&mask)); 455 (((uintptr_t)res&~mask) | ((uintptr_t)r_d&mask));
456 nist_cp_bn(r_d, res, BN_NIST_192_TOP); 456 nist_cp_bn(r_d, res, BN_NIST_192_TOP);
457 r->top = BN_NIST_192_TOP; 457 r->top = BN_NIST_192_TOP;
458 bn_correct_top(r); 458 bn_correct_top(r);
@@ -485,8 +485,8 @@ int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
485 } buf; 485 } buf;
486 BN_ULONG c_d[BN_NIST_224_TOP], 486 BN_ULONG c_d[BN_NIST_224_TOP],
487 *res; 487 *res;
488 PTR_SIZE_INT mask; 488 uintptr_t mask;
489 union { bn_addsub_f f; PTR_SIZE_INT p; } u; 489 union { bn_addsub_f f; uintptr_t p; } u;
490 static const BIGNUM _bignum_nist_p_224_sqr = { 490 static const BIGNUM _bignum_nist_p_224_sqr = {
491 (BN_ULONG *)_nist_p_224_sqr, 491 (BN_ULONG *)_nist_p_224_sqr,
492 sizeof(_nist_p_224_sqr)/sizeof(_nist_p_224_sqr[0]), 492 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,
599 * to be compared to the modulus and conditionally 599 * to be compared to the modulus and conditionally
600 * adjusted by *subtracting* the latter. */ 600 * adjusted by *subtracting* the latter. */
601 carry = (int)bn_add_words(r_d,r_d,_nist_p_224[-carry-1],BN_NIST_224_TOP); 601 carry = (int)bn_add_words(r_d,r_d,_nist_p_224[-carry-1],BN_NIST_224_TOP);
602 mask = 0-(PTR_SIZE_INT)carry; 602 mask = 0-(uintptr_t)carry;
603 u.p = ((PTR_SIZE_INT)bn_sub_words&mask) | 603 u.p = ((uintptr_t)bn_sub_words&mask) |
604 ((PTR_SIZE_INT)bn_add_words&~mask); 604 ((uintptr_t)bn_add_words&~mask);
605 } 605 }
606 else 606 else
607 carry = 1; 607 carry = 1;
608 608
609 /* otherwise it's effectively same as in BN_nist_mod_192... */ 609 /* otherwise it's effectively same as in BN_nist_mod_192... */
610 mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_224[0],BN_NIST_224_TOP); 610 mask = 0-(uintptr_t)(*u.f)(c_d,r_d,_nist_p_224[0],BN_NIST_224_TOP);
611 mask &= 0-(PTR_SIZE_INT)carry; 611 mask &= 0-(uintptr_t)carry;
612 res = c_d; 612 res = c_d;
613 res = (BN_ULONG *)(((PTR_SIZE_INT)res&~mask) | 613 res = (BN_ULONG *)(((uintptr_t)res&~mask) | ((uintptr_t)r_d&mask));
614 ((PTR_SIZE_INT)r_d&mask));
615 nist_cp_bn(r_d, res, BN_NIST_224_TOP); 614 nist_cp_bn(r_d, res, BN_NIST_224_TOP);
616 r->top = BN_NIST_224_TOP; 615 r->top = BN_NIST_224_TOP;
617 bn_correct_top(r); 616 bn_correct_top(r);
@@ -643,8 +642,8 @@ int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
643 } buf; 642 } buf;
644 BN_ULONG c_d[BN_NIST_256_TOP], 643 BN_ULONG c_d[BN_NIST_256_TOP],
645 *res; 644 *res;
646 PTR_SIZE_INT mask; 645 uintptr_t mask;
647 union { bn_addsub_f f; PTR_SIZE_INT p; } u; 646 union { bn_addsub_f f; uintptr_t p; } u;
648 static const BIGNUM _bignum_nist_p_256_sqr = { 647 static const BIGNUM _bignum_nist_p_256_sqr = {
649 (BN_ULONG *)_nist_p_256_sqr, 648 (BN_ULONG *)_nist_p_256_sqr,
650 sizeof(_nist_p_256_sqr)/sizeof(_nist_p_256_sqr[0]), 649 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,
800 else if (carry < 0) 799 else if (carry < 0)
801 { 800 {
802 carry = (int)bn_add_words(r_d,r_d,_nist_p_256[-carry-1],BN_NIST_256_TOP); 801 carry = (int)bn_add_words(r_d,r_d,_nist_p_256[-carry-1],BN_NIST_256_TOP);
803 mask = 0-(PTR_SIZE_INT)carry; 802 mask = 0-(uintptr_t)carry;
804 u.p = ((PTR_SIZE_INT)bn_sub_words&mask) | 803 u.p = ((uintptr_t)bn_sub_words&mask) |
805 ((PTR_SIZE_INT)bn_add_words&~mask); 804 ((uintptr_t)bn_add_words&~mask);
806 } 805 }
807 else 806 else
808 carry = 1; 807 carry = 1;
809 808
810 mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_256[0],BN_NIST_256_TOP); 809 mask = 0-(uintptr_t)(*u.f)(c_d,r_d,_nist_p_256[0],BN_NIST_256_TOP);
811 mask &= 0-(PTR_SIZE_INT)carry; 810 mask &= 0-(uintptr_t)carry;
812 res = c_d; 811 res = c_d;
813 res = (BN_ULONG *)(((PTR_SIZE_INT)res&~mask) | 812 res = (BN_ULONG *)(((uintptr_t)res&~mask) | ((uintptr_t)r_d&mask));
814 ((PTR_SIZE_INT)r_d&mask));
815 nist_cp_bn(r_d, res, BN_NIST_256_TOP); 813 nist_cp_bn(r_d, res, BN_NIST_256_TOP);
816 r->top = BN_NIST_256_TOP; 814 r->top = BN_NIST_256_TOP;
817 bn_correct_top(r); 815 bn_correct_top(r);
@@ -847,8 +845,8 @@ int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
847 } buf; 845 } buf;
848 BN_ULONG c_d[BN_NIST_384_TOP], 846 BN_ULONG c_d[BN_NIST_384_TOP],
849 *res; 847 *res;
850 PTR_SIZE_INT mask; 848 uintptr_t mask;
851 union { bn_addsub_f f; PTR_SIZE_INT p; } u; 849 union { bn_addsub_f f; uintptr_t p; } u;
852 static const BIGNUM _bignum_nist_p_384_sqr = { 850 static const BIGNUM _bignum_nist_p_384_sqr = {
853 (BN_ULONG *)_nist_p_384_sqr, 851 (BN_ULONG *)_nist_p_384_sqr,
854 sizeof(_nist_p_384_sqr)/sizeof(_nist_p_384_sqr[0]), 852 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,
1022 else if (carry < 0) 1020 else if (carry < 0)
1023 { 1021 {
1024 carry = (int)bn_add_words(r_d,r_d,_nist_p_384[-carry-1],BN_NIST_384_TOP); 1022 carry = (int)bn_add_words(r_d,r_d,_nist_p_384[-carry-1],BN_NIST_384_TOP);
1025 mask = 0-(PTR_SIZE_INT)carry; 1023 mask = 0-(uintptr_t)carry;
1026 u.p = ((PTR_SIZE_INT)bn_sub_words&mask) | 1024 u.p = ((uintptr_t)bn_sub_words&mask) |
1027 ((PTR_SIZE_INT)bn_add_words&~mask); 1025 ((uintptr_t)bn_add_words&~mask);
1028 } 1026 }
1029 else 1027 else
1030 carry = 1; 1028 carry = 1;
1031 1029
1032 mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_384[0],BN_NIST_384_TOP); 1030 mask = 0-(uintptr_t)(*u.f)(c_d,r_d,_nist_p_384[0],BN_NIST_384_TOP);
1033 mask &= 0-(PTR_SIZE_INT)carry; 1031 mask &= 0-(uintptr_t)carry;
1034 res = c_d; 1032 res = c_d;
1035 res = (BN_ULONG *)(((PTR_SIZE_INT)res&~mask) | 1033 res = (BN_ULONG *)(((uintptr_t)res&~mask) | ((uintptr_t)r_d&mask));
1036 ((PTR_SIZE_INT)r_d&mask));
1037 nist_cp_bn(r_d, res, BN_NIST_384_TOP); 1034 nist_cp_bn(r_d, res, BN_NIST_384_TOP);
1038 r->top = BN_NIST_384_TOP; 1035 r->top = BN_NIST_384_TOP;
1039 bn_correct_top(r); 1036 bn_correct_top(r);
@@ -1052,7 +1049,7 @@ int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
1052 BN_ULONG *r_d, *a_d = a->d, 1049 BN_ULONG *r_d, *a_d = a->d,
1053 t_d[BN_NIST_521_TOP], 1050 t_d[BN_NIST_521_TOP],
1054 val,tmp,*res; 1051 val,tmp,*res;
1055 PTR_SIZE_INT mask; 1052 uintptr_t mask;
1056 static const BIGNUM _bignum_nist_p_521_sqr = { 1053 static const BIGNUM _bignum_nist_p_521_sqr = {
1057 (BN_ULONG *)_nist_p_521_sqr, 1054 (BN_ULONG *)_nist_p_521_sqr,
1058 sizeof(_nist_p_521_sqr)/sizeof(_nist_p_521_sqr[0]), 1055 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,
1097 r_d[i] &= BN_NIST_521_TOP_MASK; 1094 r_d[i] &= BN_NIST_521_TOP_MASK;
1098 1095
1099 bn_add_words(r_d,r_d,t_d,BN_NIST_521_TOP); 1096 bn_add_words(r_d,r_d,t_d,BN_NIST_521_TOP);
1100 mask = 0-(PTR_SIZE_INT)bn_sub_words(t_d,r_d,_nist_p_521,BN_NIST_521_TOP); 1097 mask = 0-(uintptr_t)bn_sub_words(t_d,r_d,_nist_p_521,BN_NIST_521_TOP);
1101 res = t_d; 1098 res = t_d;
1102 res = (BN_ULONG *)(((PTR_SIZE_INT)res&~mask) | 1099 res = (BN_ULONG *)(((uintptr_t)res&~mask) | ((uintptr_t)r_d&mask));
1103 ((PTR_SIZE_INT)r_d&mask));
1104 nist_cp_bn(r_d,res,BN_NIST_521_TOP); 1100 nist_cp_bn(r_d,res,BN_NIST_521_TOP);
1105 r->top = BN_NIST_521_TOP; 1101 r->top = BN_NIST_521_TOP;
1106 bn_correct_top(r); 1102 bn_correct_top(r);
diff --git a/src/lib/libcrypto/cryptlib.h b/src/lib/libcrypto/cryptlib.h
index a99f3d4614..d1d7cfe80a 100644
--- a/src/lib/libcrypto/cryptlib.h
+++ b/src/lib/libcrypto/cryptlib.h
@@ -59,6 +59,7 @@
59#ifndef HEADER_CRYPTLIB_H 59#ifndef HEADER_CRYPTLIB_H
60#define HEADER_CRYPTLIB_H 60#define HEADER_CRYPTLIB_H
61 61
62#include <stdint.h>
62#include <stdlib.h> 63#include <stdlib.h>
63#include <string.h> 64#include <string.h>
64 65
diff --git a/src/lib/libssl/src/crypto/bn/bn.h b/src/lib/libssl/src/crypto/bn/bn.h
index 21a1a3fe35..2e3fab98db 100644
--- a/src/lib/libssl/src/crypto/bn/bn.h
+++ b/src/lib/libssl/src/crypto/bn/bn.h
@@ -253,24 +253,6 @@ extern "C" {
253#define BN_HEX_FMT2 "%08X" 253#define BN_HEX_FMT2 "%08X"
254#endif 254#endif
255 255
256/* 2011-02-22 SMS.
257 * In various places, a size_t variable or a type cast to size_t was
258 * used to perform integer-only operations on pointers. This failed on
259 * VMS with 64-bit pointers (CC /POINTER_SIZE = 64) because size_t is
260 * still only 32 bits. What's needed in these cases is an integer type
261 * with the same size as a pointer, which size_t is not certain to be.
262 * The only fix here is VMS-specific.
263 */
264#if defined(OPENSSL_SYS_VMS)
265# if __INITIAL_POINTER_SIZE == 64
266# define PTR_SIZE_INT long long
267# else /* __INITIAL_POINTER_SIZE == 64 */
268# define PTR_SIZE_INT int
269# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
270#else /* defined(OPENSSL_SYS_VMS) */
271# define PTR_SIZE_INT size_t
272#endif /* defined(OPENSSL_SYS_VMS) [else] */
273
274#define BN_DEFAULT_BITS 1280 256#define BN_DEFAULT_BITS 1280
275 257
276#define BN_FLG_MALLOCED 0x01 258#define BN_FLG_MALLOCED 0x01
diff --git a/src/lib/libssl/src/crypto/bn/bn_mont.c b/src/lib/libssl/src/crypto/bn/bn_mont.c
index 427b5cf4df..a6713ae5b1 100644
--- a/src/lib/libssl/src/crypto/bn/bn_mont.c
+++ b/src/lib/libssl/src/crypto/bn/bn_mont.c
@@ -247,7 +247,7 @@ static int BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont)
247 * trick unconditional memcpy below to perform in-place 247 * trick unconditional memcpy below to perform in-place
248 * "refresh" instead of actual copy. */ 248 * "refresh" instead of actual copy. */
249 m=(0-(size_t)v); 249 m=(0-(size_t)v);
250 nrp=(BN_ULONG *)(((PTR_SIZE_INT)rp&~m)|((PTR_SIZE_INT)ap&m)); 250 nrp=(BN_ULONG *)(((uintptr_t)rp&~m)|((uintptr_t)ap&m));
251 251
252 for (i=0,nl-=4; i<nl; i+=4) 252 for (i=0,nl-=4; i<nl; i+=4)
253 { 253 {
diff --git a/src/lib/libssl/src/crypto/bn/bn_nist.c b/src/lib/libssl/src/crypto/bn/bn_nist.c
index e22968d4a3..1e4cf833dc 100644
--- a/src/lib/libssl/src/crypto/bn/bn_nist.c
+++ b/src/lib/libssl/src/crypto/bn/bn_nist.c
@@ -364,7 +364,7 @@ int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
364 } buf; 364 } buf;
365 BN_ULONG c_d[BN_NIST_192_TOP], 365 BN_ULONG c_d[BN_NIST_192_TOP],
366 *res; 366 *res;
367 PTR_SIZE_INT mask; 367 uintptr_t mask;
368 static const BIGNUM _bignum_nist_p_192_sqr = { 368 static const BIGNUM _bignum_nist_p_192_sqr = {
369 (BN_ULONG *)_nist_p_192_sqr, 369 (BN_ULONG *)_nist_p_192_sqr,
370 sizeof(_nist_p_192_sqr)/sizeof(_nist_p_192_sqr[0]), 370 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,
448 * 'tmp=result-modulus; if (!carry || !borrow) result=tmp;' 448 * 'tmp=result-modulus; if (!carry || !borrow) result=tmp;'
449 * this is what happens below, but without explicit if:-) a. 449 * this is what happens below, but without explicit if:-) a.
450 */ 450 */
451 mask = 0-(PTR_SIZE_INT)bn_sub_words(c_d,r_d,_nist_p_192[0],BN_NIST_192_TOP); 451 mask = 0-(uintptr_t)bn_sub_words(c_d,r_d,_nist_p_192[0],BN_NIST_192_TOP);
452 mask &= 0-(PTR_SIZE_INT)carry; 452 mask &= 0-(uintptr_t)carry;
453 res = c_d; 453 res = c_d;
454 res = (BN_ULONG *) 454 res = (BN_ULONG *)
455 (((PTR_SIZE_INT)res&~mask) | ((PTR_SIZE_INT)r_d&mask)); 455 (((uintptr_t)res&~mask) | ((uintptr_t)r_d&mask));
456 nist_cp_bn(r_d, res, BN_NIST_192_TOP); 456 nist_cp_bn(r_d, res, BN_NIST_192_TOP);
457 r->top = BN_NIST_192_TOP; 457 r->top = BN_NIST_192_TOP;
458 bn_correct_top(r); 458 bn_correct_top(r);
@@ -485,8 +485,8 @@ int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
485 } buf; 485 } buf;
486 BN_ULONG c_d[BN_NIST_224_TOP], 486 BN_ULONG c_d[BN_NIST_224_TOP],
487 *res; 487 *res;
488 PTR_SIZE_INT mask; 488 uintptr_t mask;
489 union { bn_addsub_f f; PTR_SIZE_INT p; } u; 489 union { bn_addsub_f f; uintptr_t p; } u;
490 static const BIGNUM _bignum_nist_p_224_sqr = { 490 static const BIGNUM _bignum_nist_p_224_sqr = {
491 (BN_ULONG *)_nist_p_224_sqr, 491 (BN_ULONG *)_nist_p_224_sqr,
492 sizeof(_nist_p_224_sqr)/sizeof(_nist_p_224_sqr[0]), 492 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,
599 * to be compared to the modulus and conditionally 599 * to be compared to the modulus and conditionally
600 * adjusted by *subtracting* the latter. */ 600 * adjusted by *subtracting* the latter. */
601 carry = (int)bn_add_words(r_d,r_d,_nist_p_224[-carry-1],BN_NIST_224_TOP); 601 carry = (int)bn_add_words(r_d,r_d,_nist_p_224[-carry-1],BN_NIST_224_TOP);
602 mask = 0-(PTR_SIZE_INT)carry; 602 mask = 0-(uintptr_t)carry;
603 u.p = ((PTR_SIZE_INT)bn_sub_words&mask) | 603 u.p = ((uintptr_t)bn_sub_words&mask) |
604 ((PTR_SIZE_INT)bn_add_words&~mask); 604 ((uintptr_t)bn_add_words&~mask);
605 } 605 }
606 else 606 else
607 carry = 1; 607 carry = 1;
608 608
609 /* otherwise it's effectively same as in BN_nist_mod_192... */ 609 /* otherwise it's effectively same as in BN_nist_mod_192... */
610 mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_224[0],BN_NIST_224_TOP); 610 mask = 0-(uintptr_t)(*u.f)(c_d,r_d,_nist_p_224[0],BN_NIST_224_TOP);
611 mask &= 0-(PTR_SIZE_INT)carry; 611 mask &= 0-(uintptr_t)carry;
612 res = c_d; 612 res = c_d;
613 res = (BN_ULONG *)(((PTR_SIZE_INT)res&~mask) | 613 res = (BN_ULONG *)(((uintptr_t)res&~mask) | ((uintptr_t)r_d&mask));
614 ((PTR_SIZE_INT)r_d&mask));
615 nist_cp_bn(r_d, res, BN_NIST_224_TOP); 614 nist_cp_bn(r_d, res, BN_NIST_224_TOP);
616 r->top = BN_NIST_224_TOP; 615 r->top = BN_NIST_224_TOP;
617 bn_correct_top(r); 616 bn_correct_top(r);
@@ -643,8 +642,8 @@ int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
643 } buf; 642 } buf;
644 BN_ULONG c_d[BN_NIST_256_TOP], 643 BN_ULONG c_d[BN_NIST_256_TOP],
645 *res; 644 *res;
646 PTR_SIZE_INT mask; 645 uintptr_t mask;
647 union { bn_addsub_f f; PTR_SIZE_INT p; } u; 646 union { bn_addsub_f f; uintptr_t p; } u;
648 static const BIGNUM _bignum_nist_p_256_sqr = { 647 static const BIGNUM _bignum_nist_p_256_sqr = {
649 (BN_ULONG *)_nist_p_256_sqr, 648 (BN_ULONG *)_nist_p_256_sqr,
650 sizeof(_nist_p_256_sqr)/sizeof(_nist_p_256_sqr[0]), 649 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,
800 else if (carry < 0) 799 else if (carry < 0)
801 { 800 {
802 carry = (int)bn_add_words(r_d,r_d,_nist_p_256[-carry-1],BN_NIST_256_TOP); 801 carry = (int)bn_add_words(r_d,r_d,_nist_p_256[-carry-1],BN_NIST_256_TOP);
803 mask = 0-(PTR_SIZE_INT)carry; 802 mask = 0-(uintptr_t)carry;
804 u.p = ((PTR_SIZE_INT)bn_sub_words&mask) | 803 u.p = ((uintptr_t)bn_sub_words&mask) |
805 ((PTR_SIZE_INT)bn_add_words&~mask); 804 ((uintptr_t)bn_add_words&~mask);
806 } 805 }
807 else 806 else
808 carry = 1; 807 carry = 1;
809 808
810 mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_256[0],BN_NIST_256_TOP); 809 mask = 0-(uintptr_t)(*u.f)(c_d,r_d,_nist_p_256[0],BN_NIST_256_TOP);
811 mask &= 0-(PTR_SIZE_INT)carry; 810 mask &= 0-(uintptr_t)carry;
812 res = c_d; 811 res = c_d;
813 res = (BN_ULONG *)(((PTR_SIZE_INT)res&~mask) | 812 res = (BN_ULONG *)(((uintptr_t)res&~mask) | ((uintptr_t)r_d&mask));
814 ((PTR_SIZE_INT)r_d&mask));
815 nist_cp_bn(r_d, res, BN_NIST_256_TOP); 813 nist_cp_bn(r_d, res, BN_NIST_256_TOP);
816 r->top = BN_NIST_256_TOP; 814 r->top = BN_NIST_256_TOP;
817 bn_correct_top(r); 815 bn_correct_top(r);
@@ -847,8 +845,8 @@ int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
847 } buf; 845 } buf;
848 BN_ULONG c_d[BN_NIST_384_TOP], 846 BN_ULONG c_d[BN_NIST_384_TOP],
849 *res; 847 *res;
850 PTR_SIZE_INT mask; 848 uintptr_t mask;
851 union { bn_addsub_f f; PTR_SIZE_INT p; } u; 849 union { bn_addsub_f f; uintptr_t p; } u;
852 static const BIGNUM _bignum_nist_p_384_sqr = { 850 static const BIGNUM _bignum_nist_p_384_sqr = {
853 (BN_ULONG *)_nist_p_384_sqr, 851 (BN_ULONG *)_nist_p_384_sqr,
854 sizeof(_nist_p_384_sqr)/sizeof(_nist_p_384_sqr[0]), 852 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,
1022 else if (carry < 0) 1020 else if (carry < 0)
1023 { 1021 {
1024 carry = (int)bn_add_words(r_d,r_d,_nist_p_384[-carry-1],BN_NIST_384_TOP); 1022 carry = (int)bn_add_words(r_d,r_d,_nist_p_384[-carry-1],BN_NIST_384_TOP);
1025 mask = 0-(PTR_SIZE_INT)carry; 1023 mask = 0-(uintptr_t)carry;
1026 u.p = ((PTR_SIZE_INT)bn_sub_words&mask) | 1024 u.p = ((uintptr_t)bn_sub_words&mask) |
1027 ((PTR_SIZE_INT)bn_add_words&~mask); 1025 ((uintptr_t)bn_add_words&~mask);
1028 } 1026 }
1029 else 1027 else
1030 carry = 1; 1028 carry = 1;
1031 1029
1032 mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_384[0],BN_NIST_384_TOP); 1030 mask = 0-(uintptr_t)(*u.f)(c_d,r_d,_nist_p_384[0],BN_NIST_384_TOP);
1033 mask &= 0-(PTR_SIZE_INT)carry; 1031 mask &= 0-(uintptr_t)carry;
1034 res = c_d; 1032 res = c_d;
1035 res = (BN_ULONG *)(((PTR_SIZE_INT)res&~mask) | 1033 res = (BN_ULONG *)(((uintptr_t)res&~mask) | ((uintptr_t)r_d&mask));
1036 ((PTR_SIZE_INT)r_d&mask));
1037 nist_cp_bn(r_d, res, BN_NIST_384_TOP); 1034 nist_cp_bn(r_d, res, BN_NIST_384_TOP);
1038 r->top = BN_NIST_384_TOP; 1035 r->top = BN_NIST_384_TOP;
1039 bn_correct_top(r); 1036 bn_correct_top(r);
@@ -1052,7 +1049,7 @@ int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
1052 BN_ULONG *r_d, *a_d = a->d, 1049 BN_ULONG *r_d, *a_d = a->d,
1053 t_d[BN_NIST_521_TOP], 1050 t_d[BN_NIST_521_TOP],
1054 val,tmp,*res; 1051 val,tmp,*res;
1055 PTR_SIZE_INT mask; 1052 uintptr_t mask;
1056 static const BIGNUM _bignum_nist_p_521_sqr = { 1053 static const BIGNUM _bignum_nist_p_521_sqr = {
1057 (BN_ULONG *)_nist_p_521_sqr, 1054 (BN_ULONG *)_nist_p_521_sqr,
1058 sizeof(_nist_p_521_sqr)/sizeof(_nist_p_521_sqr[0]), 1055 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,
1097 r_d[i] &= BN_NIST_521_TOP_MASK; 1094 r_d[i] &= BN_NIST_521_TOP_MASK;
1098 1095
1099 bn_add_words(r_d,r_d,t_d,BN_NIST_521_TOP); 1096 bn_add_words(r_d,r_d,t_d,BN_NIST_521_TOP);
1100 mask = 0-(PTR_SIZE_INT)bn_sub_words(t_d,r_d,_nist_p_521,BN_NIST_521_TOP); 1097 mask = 0-(uintptr_t)bn_sub_words(t_d,r_d,_nist_p_521,BN_NIST_521_TOP);
1101 res = t_d; 1098 res = t_d;
1102 res = (BN_ULONG *)(((PTR_SIZE_INT)res&~mask) | 1099 res = (BN_ULONG *)(((uintptr_t)res&~mask) | ((uintptr_t)r_d&mask));
1103 ((PTR_SIZE_INT)r_d&mask));
1104 nist_cp_bn(r_d,res,BN_NIST_521_TOP); 1100 nist_cp_bn(r_d,res,BN_NIST_521_TOP);
1105 r->top = BN_NIST_521_TOP; 1101 r->top = BN_NIST_521_TOP;
1106 bn_correct_top(r); 1102 bn_correct_top(r);
diff --git a/src/lib/libssl/src/crypto/cryptlib.h b/src/lib/libssl/src/crypto/cryptlib.h
index a99f3d4614..d1d7cfe80a 100644
--- a/src/lib/libssl/src/crypto/cryptlib.h
+++ b/src/lib/libssl/src/crypto/cryptlib.h
@@ -59,6 +59,7 @@
59#ifndef HEADER_CRYPTLIB_H 59#ifndef HEADER_CRYPTLIB_H
60#define HEADER_CRYPTLIB_H 60#define HEADER_CRYPTLIB_H
61 61
62#include <stdint.h>
62#include <stdlib.h> 63#include <stdlib.h>
63#include <string.h> 64#include <string.h>
64 65