diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/regress/lib/libcrypto/bn/bn_convert.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/regress/lib/libcrypto/bn/bn_convert.c b/src/regress/lib/libcrypto/bn/bn_convert.c index c787036cc4..65f014693d 100644 --- a/src/regress/lib/libcrypto/bn/bn_convert.c +++ b/src/regress/lib/libcrypto/bn/bn_convert.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_convert.c,v 1.5 2024/04/09 16:06:01 tb Exp $ */ | 1 | /* $OpenBSD: bn_convert.c,v 1.6 2024/04/17 08:51:11 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> |
| 4 | * | 4 | * |
| @@ -25,7 +25,6 @@ | |||
| 25 | * | 25 | * |
| 26 | * - BN_bn2binpad() | 26 | * - BN_bn2binpad() |
| 27 | * - BN_bn2lebinpad() | 27 | * - BN_bn2lebinpad() |
| 28 | * - BN_lebin2bn() | ||
| 29 | * - BN_print()/BN_print_fp() | 28 | * - BN_print()/BN_print_fp() |
| 30 | * | 29 | * |
| 31 | * - Invalid inputs to {asc,dec,hex,mpi}2bn | 30 | * - Invalid inputs to {asc,dec,hex,mpi}2bn |
| @@ -440,9 +439,10 @@ test_bn_convert(void) | |||
| 440 | const struct bn_convert_test *bct; | 439 | const struct bn_convert_test *bct; |
| 441 | uint8_t *mpi_out = NULL; | 440 | uint8_t *mpi_out = NULL; |
| 442 | char *out_str = NULL; | 441 | char *out_str = NULL; |
| 442 | uint8_t lebin[64]; | ||
| 443 | BIGNUM *bn = NULL; | 443 | BIGNUM *bn = NULL; |
| 444 | int mpi_len; | 444 | int mpi_len; |
| 445 | size_t i; | 445 | size_t i, j; |
| 446 | int failed = 1; | 446 | int failed = 1; |
| 447 | 447 | ||
| 448 | for (i = 0; i < N_BN_CONVERT_TESTS; i++) { | 448 | for (i = 0; i < N_BN_CONVERT_TESTS; i++) { |
| @@ -459,6 +459,20 @@ test_bn_convert(void) | |||
| 459 | bn) != 0) | 459 | bn) != 0) |
| 460 | goto failure; | 460 | goto failure; |
| 461 | 461 | ||
| 462 | for (j = 0; j < bct->bin_len; j++) | ||
| 463 | lebin[j] = bct->bin[bct->bin_len - j - 1]; | ||
| 464 | |||
| 465 | BN_free(bn); | ||
| 466 | if ((bn = BN_lebin2bn(lebin, bct->bin_len, NULL)) == NULL) { | ||
| 467 | fprintf(stderr, "FAIL: BN_lebin2bn() failed\n"); | ||
| 468 | goto failure; | ||
| 469 | } | ||
| 470 | BN_set_negative(bn, bct->neg); | ||
| 471 | |||
| 472 | if (check_bin_output(i, "BN_lebin2bn()", bct->bin, bct->bin_len, | ||
| 473 | bn) != 0) | ||
| 474 | goto failure; | ||
| 475 | |||
| 462 | free(out_str); | 476 | free(out_str); |
| 463 | if ((out_str = BN_bn2dec(bn)) == NULL) { | 477 | if ((out_str = BN_bn2dec(bn)) == NULL) { |
| 464 | fprintf(stderr, "FAIL: BN_bn2dec() failed\n"); | 478 | fprintf(stderr, "FAIL: BN_bn2dec() failed\n"); |
