diff options
| -rw-r--r-- | src/lib/libcrypto/bn/bn_nist.c | 126 |
1 files changed, 65 insertions, 61 deletions
diff --git a/src/lib/libcrypto/bn/bn_nist.c b/src/lib/libcrypto/bn/bn_nist.c index 871b37cf89..51b59020c7 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.20 2022/05/07 07:47:24 jsing Exp $ */ | 1 | /* $OpenBSD: bn_nist.c,v 1.21 2022/07/30 18:03:36 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Nils Larsch for the OpenSSL project | 3 | * Written by Nils Larsch for the OpenSSL project |
| 4 | */ | 4 | */ |
| @@ -287,45 +287,84 @@ static const BN_ULONG _nist_p_521_sqr[] = { | |||
| 287 | #endif | 287 | #endif |
| 288 | 288 | ||
| 289 | static const BIGNUM _bignum_nist_p_192 = { | 289 | static const BIGNUM _bignum_nist_p_192 = { |
| 290 | (BN_ULONG *)_nist_p_192[0], | 290 | .d = (BN_ULONG *)_nist_p_192[0], |
| 291 | BN_NIST_192_TOP, | 291 | .top = BN_NIST_192_TOP, |
| 292 | BN_NIST_192_TOP, | 292 | .dmax = BN_NIST_192_TOP, |
| 293 | 0, | 293 | .neg = 0, |
| 294 | BN_FLG_STATIC_DATA | 294 | .flags = BN_FLG_STATIC_DATA, |
| 295 | }; | ||
| 296 | |||
| 297 | static const BIGNUM _bignum_nist_p_192_sqr = { | ||
| 298 | .d = (BN_ULONG *)_nist_p_192_sqr, | ||
| 299 | .top = sizeof(_nist_p_192_sqr) / sizeof(_nist_p_192_sqr[0]), | ||
| 300 | .dmax = sizeof(_nist_p_192_sqr) / sizeof(_nist_p_192_sqr[0]), | ||
| 301 | .neg = 0, | ||
| 302 | .flags = BN_FLG_STATIC_DATA, | ||
| 295 | }; | 303 | }; |
| 296 | 304 | ||
| 297 | static const BIGNUM _bignum_nist_p_224 = { | 305 | static const BIGNUM _bignum_nist_p_224 = { |
| 298 | (BN_ULONG *)_nist_p_224[0], | 306 | .d = (BN_ULONG *)_nist_p_224[0], |
| 299 | BN_NIST_224_TOP, | 307 | .top = BN_NIST_224_TOP, |
| 300 | BN_NIST_224_TOP, | 308 | .dmax = BN_NIST_224_TOP, |
| 301 | 0, | 309 | .neg = 0, |
| 302 | BN_FLG_STATIC_DATA | 310 | .flags = BN_FLG_STATIC_DATA, |
| 311 | }; | ||
| 312 | |||
| 313 | static const BIGNUM _bignum_nist_p_224_sqr = { | ||
| 314 | .d = (BN_ULONG *)_nist_p_224_sqr, | ||
| 315 | .top = sizeof(_nist_p_224_sqr) / sizeof(_nist_p_224_sqr[0]), | ||
| 316 | .dmax = sizeof(_nist_p_224_sqr) / sizeof(_nist_p_224_sqr[0]), | ||
| 317 | .neg = 0, | ||
| 318 | .flags = BN_FLG_STATIC_DATA, | ||
| 303 | }; | 319 | }; |
| 304 | 320 | ||
| 305 | static const BIGNUM _bignum_nist_p_256 = { | 321 | static const BIGNUM _bignum_nist_p_256 = { |
| 306 | (BN_ULONG *)_nist_p_256[0], | 322 | .d = (BN_ULONG *)_nist_p_256[0], |
| 307 | BN_NIST_256_TOP, | 323 | .top = BN_NIST_256_TOP, |
| 308 | BN_NIST_256_TOP, | 324 | .dmax = BN_NIST_256_TOP, |
| 309 | 0, | 325 | .neg = 0, |
| 310 | BN_FLG_STATIC_DATA | 326 | .flags = BN_FLG_STATIC_DATA, |
| 327 | }; | ||
| 328 | |||
| 329 | static const BIGNUM _bignum_nist_p_256_sqr = { | ||
| 330 | .d = (BN_ULONG *)_nist_p_256_sqr, | ||
| 331 | .top = sizeof(_nist_p_256_sqr) / sizeof(_nist_p_256_sqr[0]), | ||
| 332 | .dmax = sizeof(_nist_p_256_sqr) / sizeof(_nist_p_256_sqr[0]), | ||
| 333 | .neg = 0, | ||
| 334 | .flags = BN_FLG_STATIC_DATA, | ||
| 311 | }; | 335 | }; |
| 312 | 336 | ||
| 313 | static const BIGNUM _bignum_nist_p_384 = { | 337 | static const BIGNUM _bignum_nist_p_384 = { |
| 314 | (BN_ULONG *)_nist_p_384[0], | 338 | .d = (BN_ULONG *)_nist_p_384[0], |
| 315 | BN_NIST_384_TOP, | 339 | .top = BN_NIST_384_TOP, |
| 316 | BN_NIST_384_TOP, | 340 | .dmax = BN_NIST_384_TOP, |
| 317 | 0, | 341 | .neg = 0, |
| 318 | BN_FLG_STATIC_DATA | 342 | .flags = BN_FLG_STATIC_DATA, |
| 343 | }; | ||
| 344 | |||
| 345 | static const BIGNUM _bignum_nist_p_384_sqr = { | ||
| 346 | .d = (BN_ULONG *)_nist_p_384_sqr, | ||
| 347 | .top = sizeof(_nist_p_384_sqr) / sizeof(_nist_p_384_sqr[0]), | ||
| 348 | .dmax = sizeof(_nist_p_384_sqr) / sizeof(_nist_p_384_sqr[0]), | ||
| 349 | .neg = 0, | ||
| 350 | .flags = BN_FLG_STATIC_DATA, | ||
| 319 | }; | 351 | }; |
| 320 | 352 | ||
| 321 | static const BIGNUM _bignum_nist_p_521 = { | 353 | static const BIGNUM _bignum_nist_p_521 = { |
| 322 | (BN_ULONG *)_nist_p_521, | 354 | .d = (BN_ULONG *)_nist_p_521, |
| 323 | BN_NIST_521_TOP, | 355 | .top = BN_NIST_521_TOP, |
| 324 | BN_NIST_521_TOP, | 356 | .dmax = BN_NIST_521_TOP, |
| 325 | 0, | 357 | .neg = 0, |
| 326 | BN_FLG_STATIC_DATA | 358 | .flags = BN_FLG_STATIC_DATA, |
| 327 | }; | 359 | }; |
| 328 | 360 | ||
| 361 | static const BIGNUM _bignum_nist_p_521_sqr = { | ||
| 362 | .d = (BN_ULONG *)_nist_p_521_sqr, | ||
| 363 | .top = sizeof(_nist_p_521_sqr) / sizeof(_nist_p_521_sqr[0]), | ||
| 364 | .dmax = sizeof(_nist_p_521_sqr) / sizeof(_nist_p_521_sqr[0]), | ||
| 365 | .neg = 0, | ||
| 366 | .flags = BN_FLG_STATIC_DATA, | ||
| 367 | }; | ||
| 329 | 368 | ||
| 330 | const BIGNUM * | 369 | const BIGNUM * |
| 331 | BN_get0_nist_prime_192(void) | 370 | BN_get0_nist_prime_192(void) |
| @@ -431,13 +470,6 @@ BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) | |||
| 431 | BN_ULONG bnbuf[BN_NIST_192_TOP] = { 0 }; | 470 | BN_ULONG bnbuf[BN_NIST_192_TOP] = { 0 }; |
| 432 | BN_ULONG c_d[BN_NIST_192_TOP], *res; | 471 | BN_ULONG c_d[BN_NIST_192_TOP], *res; |
| 433 | uintptr_t mask; | 472 | uintptr_t mask; |
| 434 | static const BIGNUM _bignum_nist_p_192_sqr = { | ||
| 435 | (BN_ULONG *)_nist_p_192_sqr, | ||
| 436 | sizeof(_nist_p_192_sqr) / sizeof(_nist_p_192_sqr[0]), | ||
| 437 | sizeof(_nist_p_192_sqr) / sizeof(_nist_p_192_sqr[0]), | ||
| 438 | 0, | ||
| 439 | BN_FLG_STATIC_DATA | ||
| 440 | }; | ||
| 441 | 473 | ||
| 442 | field = &_bignum_nist_p_192; /* just to make sure */ | 474 | field = &_bignum_nist_p_192; /* just to make sure */ |
| 443 | 475 | ||
| @@ -586,13 +618,6 @@ BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) | |||
| 586 | BN_ULONG c_d[BN_NIST_224_TOP], *res; | 618 | BN_ULONG c_d[BN_NIST_224_TOP], *res; |
| 587 | uintptr_t mask; | 619 | uintptr_t mask; |
| 588 | bn_addsub_f addsubf; | 620 | bn_addsub_f addsubf; |
| 589 | static const BIGNUM _bignum_nist_p_224_sqr = { | ||
| 590 | (BN_ULONG *)_nist_p_224_sqr, | ||
| 591 | sizeof(_nist_p_224_sqr) / sizeof(_nist_p_224_sqr[0]), | ||
| 592 | sizeof(_nist_p_224_sqr) / sizeof(_nist_p_224_sqr[0]), | ||
| 593 | 0, | ||
| 594 | BN_FLG_STATIC_DATA | ||
| 595 | }; | ||
| 596 | 621 | ||
| 597 | field = &_bignum_nist_p_224; /* just to make sure */ | 622 | field = &_bignum_nist_p_224; /* just to make sure */ |
| 598 | 623 | ||
| @@ -776,13 +801,6 @@ BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) | |||
| 776 | BN_ULONG c_d[BN_NIST_256_TOP] = {0}, *res; | 801 | BN_ULONG c_d[BN_NIST_256_TOP] = {0}, *res; |
| 777 | uintptr_t mask; | 802 | uintptr_t mask; |
| 778 | bn_addsub_f addsubf; | 803 | bn_addsub_f addsubf; |
| 779 | static const BIGNUM _bignum_nist_p_256_sqr = { | ||
| 780 | (BN_ULONG *)_nist_p_256_sqr, | ||
| 781 | sizeof(_nist_p_256_sqr) / sizeof(_nist_p_256_sqr[0]), | ||
| 782 | sizeof(_nist_p_256_sqr) / sizeof(_nist_p_256_sqr[0]), | ||
| 783 | 0, | ||
| 784 | BN_FLG_STATIC_DATA | ||
| 785 | }; | ||
| 786 | 804 | ||
| 787 | field = &_bignum_nist_p_256; /* just to make sure */ | 805 | field = &_bignum_nist_p_256; /* just to make sure */ |
| 788 | 806 | ||
| @@ -1014,13 +1032,6 @@ BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) | |||
| 1014 | BN_ULONG c_d[BN_NIST_384_TOP], *res; | 1032 | BN_ULONG c_d[BN_NIST_384_TOP], *res; |
| 1015 | uintptr_t mask; | 1033 | uintptr_t mask; |
| 1016 | bn_addsub_f addsubf; | 1034 | bn_addsub_f addsubf; |
| 1017 | static const BIGNUM _bignum_nist_p_384_sqr = { | ||
| 1018 | (BN_ULONG *)_nist_p_384_sqr, | ||
| 1019 | sizeof(_nist_p_384_sqr) / sizeof(_nist_p_384_sqr[0]), | ||
| 1020 | sizeof(_nist_p_384_sqr) / sizeof(_nist_p_384_sqr[0]), | ||
| 1021 | 0, | ||
| 1022 | BN_FLG_STATIC_DATA | ||
| 1023 | }; | ||
| 1024 | 1035 | ||
| 1025 | field = &_bignum_nist_p_384; /* just to make sure */ | 1036 | field = &_bignum_nist_p_384; /* just to make sure */ |
| 1026 | 1037 | ||
| @@ -1269,13 +1280,6 @@ BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) | |||
| 1269 | int top = a->top, i; | 1280 | int top = a->top, i; |
| 1270 | BN_ULONG *r_d, *a_d = a->d, t_d[BN_NIST_521_TOP], val, tmp, *res; | 1281 | BN_ULONG *r_d, *a_d = a->d, t_d[BN_NIST_521_TOP], val, tmp, *res; |
| 1271 | uintptr_t mask; | 1282 | uintptr_t mask; |
| 1272 | static const BIGNUM _bignum_nist_p_521_sqr = { | ||
| 1273 | (BN_ULONG *)_nist_p_521_sqr, | ||
| 1274 | sizeof(_nist_p_521_sqr) / sizeof(_nist_p_521_sqr[0]), | ||
| 1275 | sizeof(_nist_p_521_sqr) / sizeof(_nist_p_521_sqr[0]), | ||
| 1276 | 0, | ||
| 1277 | BN_FLG_STATIC_DATA | ||
| 1278 | }; | ||
| 1279 | 1283 | ||
| 1280 | field = &_bignum_nist_p_521; /* just to make sure */ | 1284 | field = &_bignum_nist_p_521; /* just to make sure */ |
| 1281 | 1285 | ||
