diff options
| author | jsing <> | 2022-12-23 02:13:15 +0000 |
|---|---|---|
| committer | jsing <> | 2022-12-23 02:13:15 +0000 |
| commit | 2d6e4bd5f08b69b78eff6e6fa85bedebe55a1315 (patch) | |
| tree | efd5f0f35d3ee164f36c1353fb02450af11a28f2 /src | |
| parent | 640b0c4a9328313aab9b02da2a11bea759092ce1 (diff) | |
| download | openbsd-2d6e4bd5f08b69b78eff6e6fa85bedebe55a1315.tar.gz openbsd-2d6e4bd5f08b69b78eff6e6fa85bedebe55a1315.tar.bz2 openbsd-2d6e4bd5f08b69b78eff6e6fa85bedebe55a1315.zip | |
Add regress coverage for shifts of zero bits.
Diffstat (limited to 'src')
| -rw-r--r-- | src/regress/lib/libcrypto/bn/bn_shift.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/regress/lib/libcrypto/bn/bn_shift.c b/src/regress/lib/libcrypto/bn/bn_shift.c index fd5184523b..743a911cbe 100644 --- a/src/regress/lib/libcrypto/bn/bn_shift.c +++ b/src/regress/lib/libcrypto/bn/bn_shift.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_shift.c,v 1.4 2022/12/23 02:12:11 jsing Exp $ */ | 1 | /* $OpenBSD: bn_shift.c,v 1.5 2022/12/23 02:13:15 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2022 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2022 Joel Sing <jsing@openbsd.org> |
| 4 | * | 4 | * |
| @@ -233,6 +233,43 @@ test_bn_shift(void) | |||
| 233 | if (!check_shift_result(bn1)) | 233 | if (!check_shift_result(bn1)) |
| 234 | goto failure; | 234 | goto failure; |
| 235 | 235 | ||
| 236 | /* | ||
| 237 | * Shift of zero (equivalent to a copy). | ||
| 238 | */ | ||
| 239 | BN_zero(bn2); | ||
| 240 | if (!BN_lshift(bn2, bn1, 0)) { | ||
| 241 | fprintf(stderr, "FAIL: failed to BN_lshift()\n"); | ||
| 242 | goto failure; | ||
| 243 | } | ||
| 244 | |||
| 245 | if (!check_shift_result(bn2)) | ||
| 246 | goto failure; | ||
| 247 | |||
| 248 | if (!BN_lshift(bn2, bn2, 0)) { | ||
| 249 | fprintf(stderr, "FAIL: failed to BN_lshift()\n"); | ||
| 250 | goto failure; | ||
| 251 | } | ||
| 252 | |||
| 253 | if (!check_shift_result(bn2)) | ||
| 254 | goto failure; | ||
| 255 | |||
| 256 | BN_zero(bn2); | ||
| 257 | if (!BN_rshift(bn2, bn1, 0)) { | ||
| 258 | fprintf(stderr, "FAIL: failed to BN_rshift()\n"); | ||
| 259 | goto failure; | ||
| 260 | } | ||
| 261 | |||
| 262 | if (!check_shift_result(bn2)) | ||
| 263 | goto failure; | ||
| 264 | |||
| 265 | if (!BN_rshift(bn2, bn2, 0)) { | ||
| 266 | fprintf(stderr, "FAIL: failed to BN_rshift()\n"); | ||
| 267 | goto failure; | ||
| 268 | } | ||
| 269 | |||
| 270 | if (!check_shift_result(bn2)) | ||
| 271 | goto failure; | ||
| 272 | |||
| 236 | failed = 0; | 273 | failed = 0; |
| 237 | 274 | ||
| 238 | failure: | 275 | failure: |
