Skip to content

Commit 3e74f84

Browse files
committed
Add tests for BN_bn2binpad with zero output length
1 parent a4632ea commit 3e74f84

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

tests/api/test_ossl_bn.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,11 @@ int test_wolfSSL_BN_enc_dec(void)
352352
ExpectIntEQ(padOut[0], 0x00);
353353
ExpectIntEQ(padOut[1], 0x00);
354354
ExpectIntEQ(padOut[2], 0x00);
355-
/* Restore a = 2 for subsequent tests */
355+
/* toLen == 0 with zero-valued BN is valid */
356+
ExpectIntEQ(BN_bn2binpad(a, padOut, 0), 0);
357+
/* toLen == 0 with non-zero BN is an error */
356358
ExpectIntEQ(BN_set_word(a, 2), 1);
359+
ExpectIntEQ(BN_bn2binpad(a, padOut, 0), -1);
357360
}
358361

359362
ExpectNotNull(str = BN_bn2hex(a));

0 commit comments

Comments
 (0)