diff options
| author | jsing <> | 2023-03-07 06:05:06 +0000 |
|---|---|---|
| committer | jsing <> | 2023-03-07 06:05:06 +0000 |
| commit | a11e3f4bc655f7f0e41fc25cdf9ae62072074f19 (patch) | |
| tree | 07616c0d9912eae8d84dd75298d357b07b044da6 /src/lib/libc | |
| parent | 3ff8de87d297012e198b74040393e159cdec0992 (diff) | |
| download | openbsd-a11e3f4bc655f7f0e41fc25cdf9ae62072074f19.tar.gz openbsd-a11e3f4bc655f7f0e41fc25cdf9ae62072074f19.tar.bz2 openbsd-a11e3f4bc655f7f0e41fc25cdf9ae62072074f19.zip | |
Delete unused and unsafe bn_mul_mont() example code.
This came from bn_asm.c and did not even compile until recently.
ok beck@ tb@
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/bn/bn_mont.c | 55 |
1 files changed, 1 insertions, 54 deletions
diff --git a/src/lib/libcrypto/bn/bn_mont.c b/src/lib/libcrypto/bn/bn_mont.c index 15c9c4a00e..5dcd548f85 100644 --- a/src/lib/libcrypto/bn/bn_mont.c +++ b/src/lib/libcrypto/bn/bn_mont.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_mont.c,v 1.47 2023/02/28 12:29:57 jsing Exp $ */ | 1 | /* $OpenBSD: bn_mont.c,v 1.48 2023/03/07 06:05:06 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -303,59 +303,6 @@ BN_MONT_CTX_set_locked(BN_MONT_CTX **pmctx, int lock, const BIGNUM *mod, | |||
| 303 | return mctx; | 303 | return mctx; |
| 304 | } | 304 | } |
| 305 | 305 | ||
| 306 | #ifdef OPENSSL_NO_ASM | ||
| 307 | #ifdef OPENSSL_BN_ASM_MONT | ||
| 308 | int | ||
| 309 | bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, | ||
| 310 | const BN_ULONG *np, const BN_ULONG *n0p, int num) | ||
| 311 | { | ||
| 312 | BN_ULONG c0, c1, *tp, n0 = *n0p; | ||
| 313 | int i = 0, j; | ||
| 314 | |||
| 315 | tp = calloc(num + 2, sizeof(BN_ULONG)); | ||
| 316 | if (tp == NULL) | ||
| 317 | return 0; | ||
| 318 | |||
| 319 | for (i = 0; i < num; i++) { | ||
| 320 | c0 = bn_mul_add_words(tp, ap, num, bp[i]); | ||
| 321 | c1 = (tp[num] + c0) & BN_MASK2; | ||
| 322 | tp[num] = c1; | ||
| 323 | tp[num + 1] = (c1 < c0 ? 1 : 0); | ||
| 324 | |||
| 325 | c0 = bn_mul_add_words(tp, np, num, tp[0] * n0); | ||
| 326 | c1 = (tp[num] + c0) & BN_MASK2; | ||
| 327 | tp[num] = c1; | ||
| 328 | tp[num + 1] += (c1 < c0 ? 1 : 0); | ||
| 329 | for (j = 0; j <= num; j++) | ||
| 330 | tp[j] = tp[j + 1]; | ||
| 331 | } | ||
| 332 | |||
| 333 | if (tp[num] != 0 || tp[num - 1] >= np[num - 1]) { | ||
| 334 | c0 = bn_sub_words(rp, tp, np, num); | ||
| 335 | if (tp[num] != 0 || c0 == 0) { | ||
| 336 | goto out; | ||
| 337 | } | ||
| 338 | } | ||
| 339 | memcpy(rp, tp, num * sizeof(BN_ULONG)); | ||
| 340 | out: | ||
| 341 | freezero(tp, (num + 2) * sizeof(BN_ULONG)); | ||
| 342 | return 1; | ||
| 343 | } | ||
| 344 | #else /* !OPENSSL_BN_ASM_MONT */ | ||
| 345 | int | ||
| 346 | bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, | ||
| 347 | const BN_ULONG *np, const BN_ULONG *n0, int num) | ||
| 348 | { | ||
| 349 | /* | ||
| 350 | * Return value of 0 indicates that multiplication/convolution was not | ||
| 351 | * performed to signal the caller to fall down to alternative/original | ||
| 352 | * code-path. | ||
| 353 | */ | ||
| 354 | return 0; | ||
| 355 | } | ||
| 356 | #endif /* !OPENSSL_BN_ASM_MONT */ | ||
| 357 | #endif /* OPENSSL_NO_ASM */ | ||
| 358 | |||
| 359 | static int bn_montgomery_reduce(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mctx); | 306 | static int bn_montgomery_reduce(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mctx); |
| 360 | 307 | ||
| 361 | int | 308 | int |
