mirror of
https://github.com/openssl/openssl.git
synced 2024-12-03 15:03:47 +08:00
test/bntest.c: add bn_sqrx8x_internal regression test.
Reviewed-by: Rich Salz <rsalz@openssl.org>
This commit is contained in:
parent
668a709a8d
commit
420b88cec8
@ -389,6 +389,54 @@ static int test_modexp_mont5(void)
|
||||
if (!TEST_BN_eq(c, d))
|
||||
goto err;
|
||||
|
||||
/* Regression test for carry bug in bn_sqrx8x_internal */
|
||||
{
|
||||
static const char *ahex[] = {
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8FFEADBCFC4DAE7FFF908E92820306B",
|
||||
"9544D954000000006C0000000000000000000000000000000000000000000000",
|
||||
"00000000000000000000FF030202FFFFF8FFEBDBCFC4DAE7FFF908E92820306B",
|
||||
"9544D954000000006C000000FF0302030000000000FFFFFFFFFFFFFFFFFFFFFF",
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF01FC00FF02FFFFFFFF",
|
||||
"00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FCFD",
|
||||
"FCFFFFFFFFFF000000000000000000FF0302030000000000FFFFFFFFFFFFFFFF",
|
||||
"FF00FCFDFDFF030202FF00000000FFFFFFFFFFFFFFFFFF00FCFDFCFFFFFFFFFF",
|
||||
NULL
|
||||
};
|
||||
static const char *nhex[] = {
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8F8F8F8000000",
|
||||
"00000010000000006C0000000000000000000000000000000000000000000000",
|
||||
"00000000000000000000000000000000000000FFFFFFFFFFFFF8F8F8F8000000",
|
||||
"00000010000000006C000000000000000000000000FFFFFFFFFFFFFFFFFFFFFF",
|
||||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
"00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
"FFFFFFFFFFFF000000000000000000000000000000000000FFFFFFFFFFFFFFFF",
|
||||
"FFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
NULL
|
||||
};
|
||||
|
||||
bigstring = glue(ahex);
|
||||
BN_hex2bn(&a, bigstring);
|
||||
OPENSSL_free(bigstring);
|
||||
bigstring = glue(nhex);
|
||||
BN_hex2bn(&n, bigstring);
|
||||
OPENSSL_free(bigstring);
|
||||
}
|
||||
BN_free(b);
|
||||
b = BN_dup(a);
|
||||
BN_MONT_CTX_set(mont, n, ctx);
|
||||
BN_mod_mul_montgomery(c, a, a, mont, ctx);
|
||||
BN_mod_mul_montgomery(d, a, b, mont, ctx);
|
||||
if (!TEST_BN_eq(c, d))
|
||||
goto err;
|
||||
|
||||
/* Zero input */
|
||||
BN_bntest_rand(p, 1024, 0, 0);
|
||||
BN_zero(a);
|
||||
|
Loading…
Reference in New Issue
Block a user