diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2015-05-02 19:30:00 +0200 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2015-05-03 13:53:08 +0200 |
commit | b6eb9827a6866981c08cc9613ca8b4a648894fb1 (patch) | |
tree | c5a6351461d8be964bc1f31fa2e34c4ebb7cfafd /crypto/bn | |
parent | Remove obsolete make variables (diff) | |
download | openssl-b6eb9827a6866981c08cc9613ca8b4a648894fb1.tar.xz openssl-b6eb9827a6866981c08cc9613ca8b4a648894fb1.zip |
Add OSSL_NELEM macro.
Add OSSL_NELEM macro to e_os.h to determine the number of elements in an
array.
Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'crypto/bn')
-rw-r--r-- | crypto/bn/bn_dh.c | 5 | ||||
-rw-r--r-- | crypto/bn/bn_gf2m.c | 4 | ||||
-rw-r--r-- | crypto/bn/bn_nist.c | 20 | ||||
-rw-r--r-- | crypto/bn/bn_srp.c | 29 |
4 files changed, 30 insertions, 28 deletions
diff --git a/crypto/bn/bn_dh.c b/crypto/bn/bn_dh.c index 1c007bb901..cfd8c067a8 100644 --- a/crypto/bn/bn_dh.c +++ b/crypto/bn/bn_dh.c @@ -57,6 +57,7 @@ */ #include "bn_lcl.h" +#include "e_os.h" #ifndef OPENSSL_NO_DH /* DH parameters from RFC5114 */ @@ -247,8 +248,8 @@ static const BN_ULONG dh2048_256_q[] = { /* Macro to make a BIGNUM from static data */ # define make_dh_bn(x) const BIGNUM _bignum_##x = { (BN_ULONG *) x, \ - sizeof(x)/sizeof(BN_ULONG),\ - sizeof(x)/sizeof(BN_ULONG),\ + OSSL_NELEM(x),\ + OSSL_NELEM(x),\ 0, BN_FLG_STATIC_DATA }; diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c index 7c0d4afc71..c87c5d96f8 100644 --- a/crypto/bn/bn_gf2m.c +++ b/crypto/bn/bn_gf2m.c @@ -473,8 +473,8 @@ int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p) int arr[6]; bn_check_top(a); bn_check_top(p); - ret = BN_GF2m_poly2arr(p, arr, sizeof(arr) / sizeof(arr[0])); - if (!ret || ret > (int)(sizeof(arr) / sizeof(arr[0]))) { + ret = BN_GF2m_poly2arr(p, arr, OSSL_NELEM(arr)); + if (!ret || ret > (int)OSSL_NELEM(arr)) { BNerr(BN_F_BN_GF2M_MOD, BN_R_INVALID_LENGTH); return 0; } diff --git a/crypto/bn/bn_nist.c b/crypto/bn/bn_nist.c index 2c5596d173..af048d3a3b 100644 --- a/crypto/bn/bn_nist.c +++ b/crypto/bn/bn_nist.c @@ -379,8 +379,8 @@ int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, PTR_SIZE_INT 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]), - sizeof(_nist_p_192_sqr) / sizeof(_nist_p_192_sqr[0]), + OSSL_NELEM(_nist_p_192_sqr), + OSSL_NELEM(_nist_p_192_sqr), 0, BN_FLG_STATIC_DATA }; @@ -524,8 +524,8 @@ int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, } 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]), - sizeof(_nist_p_224_sqr) / sizeof(_nist_p_224_sqr[0]), + OSSL_NELEM(_nist_p_224_sqr), + OSSL_NELEM(_nist_p_224_sqr), 0, BN_FLG_STATIC_DATA }; @@ -705,8 +705,8 @@ int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, } 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]), - sizeof(_nist_p_256_sqr) / sizeof(_nist_p_256_sqr[0]), + OSSL_NELEM(_nist_p_256_sqr), + OSSL_NELEM(_nist_p_256_sqr), 0, BN_FLG_STATIC_DATA }; @@ -951,8 +951,8 @@ int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, } 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]), - sizeof(_nist_p_384_sqr) / sizeof(_nist_p_384_sqr[0]), + OSSL_NELEM(_nist_p_384_sqr), + OSSL_NELEM(_nist_p_384_sqr), 0, BN_FLG_STATIC_DATA }; @@ -1209,8 +1209,8 @@ int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, PTR_SIZE_INT 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]), - sizeof(_nist_p_521_sqr) / sizeof(_nist_p_521_sqr[0]), + OSSL_NELEM(_nist_p_521_sqr), + OSSL_NELEM(_nist_p_521_sqr), 0, BN_FLG_STATIC_DATA }; diff --git a/crypto/bn/bn_srp.c b/crypto/bn/bn_srp.c index 0a39f2f7c1..5dd31fc7bf 100644 --- a/crypto/bn/bn_srp.c +++ b/crypto/bn/bn_srp.c @@ -1,4 +1,5 @@ #include "bn_lcl.h" +#include "e_os.h" #ifndef OPENSSL_NO_SRP @@ -37,8 +38,8 @@ static const BN_ULONG bn_group_1024_value[] = { const BIGNUM bn_group_1024 = { (BN_ULONG *)bn_group_1024_value, - (sizeof bn_group_1024_value) / sizeof(BN_ULONG), - (sizeof bn_group_1024_value) / sizeof(BN_ULONG), + OSSL_NELEM(bn_group_1024_value), + OSSL_NELEM(bn_group_1024_value), 0, BN_FLG_STATIC_DATA }; @@ -72,8 +73,8 @@ static const BN_ULONG bn_group_1536_value[] = { const BIGNUM bn_group_1536 = { (BN_ULONG *)bn_group_1536_value, - (sizeof bn_group_1536_value) / sizeof(BN_ULONG), - (sizeof bn_group_1536_value) / sizeof(BN_ULONG), + OSSL_NELEM(bn_group_1536_value), + OSSL_NELEM(bn_group_1536_value), 0, BN_FLG_STATIC_DATA }; @@ -115,8 +116,8 @@ static const BN_ULONG bn_group_2048_value[] = { const BIGNUM bn_group_2048 = { (BN_ULONG *)bn_group_2048_value, - (sizeof bn_group_2048_value) / sizeof(BN_ULONG), - (sizeof bn_group_2048_value) / sizeof(BN_ULONG), + OSSL_NELEM(bn_group_2048_value), + OSSL_NELEM(bn_group_2048_value), 0, BN_FLG_STATIC_DATA }; @@ -174,8 +175,8 @@ static const BN_ULONG bn_group_3072_value[] = { const BIGNUM bn_group_3072 = { (BN_ULONG *)bn_group_3072_value, - (sizeof bn_group_3072_value) / sizeof(BN_ULONG), - (sizeof bn_group_3072_value) / sizeof(BN_ULONG), + OSSL_NELEM(bn_group_3072_value), + OSSL_NELEM(bn_group_3072_value), 0, BN_FLG_STATIC_DATA }; @@ -249,8 +250,8 @@ static const BN_ULONG bn_group_4096_value[] = { const BIGNUM bn_group_4096 = { (BN_ULONG *)bn_group_4096_value, - (sizeof bn_group_4096_value) / sizeof(BN_ULONG), - (sizeof bn_group_4096_value) / sizeof(BN_ULONG), + OSSL_NELEM(bn_group_4096_value), + OSSL_NELEM(bn_group_4096_value), 0, BN_FLG_STATIC_DATA }; @@ -356,8 +357,8 @@ static const BN_ULONG bn_group_6144_value[] = { const BIGNUM bn_group_6144 = { (BN_ULONG *)bn_group_6144_value, - (sizeof bn_group_6144_value) / sizeof(BN_ULONG), - (sizeof bn_group_6144_value) / sizeof(BN_ULONG), + OSSL_NELEM(bn_group_6144_value), + OSSL_NELEM(bn_group_6144_value), 0, BN_FLG_STATIC_DATA }; @@ -495,8 +496,8 @@ static const BN_ULONG bn_group_8192_value[] = { const BIGNUM bn_group_8192 = { (BN_ULONG *)bn_group_8192_value, - (sizeof bn_group_8192_value) / sizeof(BN_ULONG), - (sizeof bn_group_8192_value) / sizeof(BN_ULONG), + OSSL_NELEM(bn_group_8192_value), + OSSL_NELEM(bn_group_8192_value), 0, BN_FLG_STATIC_DATA }; |