diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/bn/bn_nist.c | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/src/lib/libcrypto/bn/bn_nist.c b/src/lib/libcrypto/bn/bn_nist.c index 51b59020c7..6b51bb10f0 100644 --- a/src/lib/libcrypto/bn/bn_nist.c +++ b/src/lib/libcrypto/bn/bn_nist.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_nist.c,v 1.21 2022/07/30 18:03:36 jsing Exp $ */ | 1 | /* $OpenBSD: bn_nist.c,v 1.22 2022/07/31 14:38:38 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Nils Larsch for the OpenSSL project | 3 | * Written by Nils Larsch for the OpenSSL project |
| 4 | */ | 4 | */ |
| @@ -464,12 +464,13 @@ static void nist_cp_bn(BN_ULONG *dst, const BN_ULONG *src, int top) | |||
| 464 | int | 464 | int |
| 465 | BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) | 465 | BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) |
| 466 | { | 466 | { |
| 467 | int top = a->top, i; | ||
| 468 | int carry; | ||
| 469 | BN_ULONG *r_d, *a_d = a->d; | ||
| 470 | BN_ULONG bnbuf[BN_NIST_192_TOP] = { 0 }; | 467 | BN_ULONG bnbuf[BN_NIST_192_TOP] = { 0 }; |
| 471 | BN_ULONG c_d[BN_NIST_192_TOP], *res; | 468 | BN_ULONG c_d[BN_NIST_192_TOP] = { 0 }; |
| 469 | BN_ULONG *a_d = a->d; | ||
| 470 | BN_ULONG *r_d, *res; | ||
| 472 | uintptr_t mask; | 471 | uintptr_t mask; |
| 472 | int top = a->top; | ||
| 473 | int carry, i; | ||
| 473 | 474 | ||
| 474 | field = &_bignum_nist_p_192; /* just to make sure */ | 475 | field = &_bignum_nist_p_192; /* just to make sure */ |
| 475 | 476 | ||
| @@ -611,13 +612,14 @@ typedef BN_ULONG (*bn_addsub_f)(BN_ULONG *, const BN_ULONG *, | |||
| 611 | int | 612 | int |
| 612 | BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) | 613 | BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) |
| 613 | { | 614 | { |
| 614 | int top = a->top, i; | ||
| 615 | int carry; | ||
| 616 | BN_ULONG *r_d, *a_d = a->d; | ||
| 617 | BN_ULONG bnbuf[BN_NIST_224_TOP] = { 0 }; | 615 | BN_ULONG bnbuf[BN_NIST_224_TOP] = { 0 }; |
| 618 | BN_ULONG c_d[BN_NIST_224_TOP], *res; | 616 | BN_ULONG c_d[BN_NIST_224_TOP] = { 0 }; |
| 619 | uintptr_t mask; | 617 | BN_ULONG *a_d = a->d; |
| 618 | BN_ULONG *r_d, *res; | ||
| 620 | bn_addsub_f addsubf; | 619 | bn_addsub_f addsubf; |
| 620 | uintptr_t mask; | ||
| 621 | int top = a->top; | ||
| 622 | int carry, i; | ||
| 621 | 623 | ||
| 622 | field = &_bignum_nist_p_224; /* just to make sure */ | 624 | field = &_bignum_nist_p_224; /* just to make sure */ |
| 623 | 625 | ||
| @@ -794,13 +796,14 @@ BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) | |||
| 794 | int | 796 | int |
| 795 | BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) | 797 | BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) |
| 796 | { | 798 | { |
| 797 | int i, top = a->top; | ||
| 798 | int carry = 0; | ||
| 799 | BN_ULONG *a_d = a->d, *r_d; | ||
| 800 | BN_ULONG bnbuf[BN_NIST_256_TOP] = { 0 }; | 799 | BN_ULONG bnbuf[BN_NIST_256_TOP] = { 0 }; |
| 801 | BN_ULONG c_d[BN_NIST_256_TOP] = {0}, *res; | 800 | BN_ULONG c_d[BN_NIST_256_TOP] = { 0 }; |
| 802 | uintptr_t mask; | 801 | BN_ULONG *a_d = a->d; |
| 802 | BN_ULONG *r_d, *res; | ||
| 803 | bn_addsub_f addsubf; | 803 | bn_addsub_f addsubf; |
| 804 | uintptr_t mask; | ||
| 805 | int top = a->top; | ||
| 806 | int carry, i; | ||
| 804 | 807 | ||
| 805 | field = &_bignum_nist_p_256; /* just to make sure */ | 808 | field = &_bignum_nist_p_256; /* just to make sure */ |
| 806 | 809 | ||
| @@ -1025,13 +1028,14 @@ BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) | |||
| 1025 | int | 1028 | int |
| 1026 | BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) | 1029 | BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) |
| 1027 | { | 1030 | { |
| 1028 | int i, top = a->top; | ||
| 1029 | int carry = 0; | ||
| 1030 | BN_ULONG *r_d, *a_d = a->d; | ||
| 1031 | BN_ULONG bnbuf[BN_NIST_384_TOP] = { 0 }; | 1031 | BN_ULONG bnbuf[BN_NIST_384_TOP] = { 0 }; |
| 1032 | BN_ULONG c_d[BN_NIST_384_TOP], *res; | 1032 | BN_ULONG c_d[BN_NIST_384_TOP] = { 0 }; |
| 1033 | uintptr_t mask; | 1033 | BN_ULONG *a_d = a->d; |
| 1034 | BN_ULONG *r_d, *res; | ||
| 1034 | bn_addsub_f addsubf; | 1035 | bn_addsub_f addsubf; |
| 1036 | uintptr_t mask; | ||
| 1037 | int top = a->top; | ||
| 1038 | int carry, i; | ||
| 1035 | 1039 | ||
| 1036 | field = &_bignum_nist_p_384; /* just to make sure */ | 1040 | field = &_bignum_nist_p_384; /* just to make sure */ |
| 1037 | 1041 | ||
| @@ -1277,9 +1281,13 @@ BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) | |||
| 1277 | int | 1281 | int |
| 1278 | BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) | 1282 | BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) |
| 1279 | { | 1283 | { |
| 1280 | int top = a->top, i; | 1284 | BN_ULONG t_d[BN_NIST_521_TOP] = { 0 }; |
| 1281 | BN_ULONG *r_d, *a_d = a->d, t_d[BN_NIST_521_TOP], val, tmp, *res; | 1285 | BN_ULONG *a_d = a->d; |
| 1286 | BN_ULONG *r_d, *res; | ||
| 1287 | BN_ULONG tmp, val; | ||
| 1282 | uintptr_t mask; | 1288 | uintptr_t mask; |
| 1289 | int top = a->top; | ||
| 1290 | int i; | ||
| 1283 | 1291 | ||
| 1284 | field = &_bignum_nist_p_521; /* just to make sure */ | 1292 | field = &_bignum_nist_p_521; /* just to make sure */ |
| 1285 | 1293 | ||
