summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2022-12-23 02:13:15 +0000
committerjsing <>2022-12-23 02:13:15 +0000
commitcbe70dd07d4650c041b37b035949887a36a7dd54 (patch)
treeefd5f0f35d3ee164f36c1353fb02450af11a28f2 /src
parent38545cc671f514b9eb4b8e34170cc14505fbadb9 (diff)
downloadopenbsd-cbe70dd07d4650c041b37b035949887a36a7dd54.tar.gz
openbsd-cbe70dd07d4650c041b37b035949887a36a7dd54.tar.bz2
openbsd-cbe70dd07d4650c041b37b035949887a36a7dd54.zip
Add regress coverage for shifts of zero bits.
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libcrypto/bn/bn_shift.c39
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: