X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=test%2Fbntest.c;h=9542800444579bfb15fd095059cfde8a37503623;hp=9caa2c904ba879e75ddae8642c97143adb248efd;hb=29851264f11ccc70c6c0140d7e3d8d93ef5c9b11;hpb=df2ee0e27d2db02660c1d15fe6a3e38be9df0a60 diff --git a/test/bntest.c b/test/bntest.c index 9caa2c904b..9542800444 100644 --- a/test/bntest.c +++ b/test/bntest.c @@ -1023,6 +1023,24 @@ int test_mod_exp(BIO *bp, BN_CTX *ctx) return 0; } } + + /* Regression test for carry propagation bug in sqr8x_reduction */ + BN_hex2bn(&a, "050505050505"); + BN_hex2bn(&b, "02"); + BN_hex2bn(&c, + "4141414141414141414141274141414141414141414141414141414141414141" + "4141414141414141414141414141414141414141414141414141414141414141" + "4141414141414141414141800000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000001"); + BN_mod_exp(d, a, b, c, ctx); + BN_mul(e, a, a, ctx); + if (BN_cmp(d, e)) { + fprintf(stderr, "BN_mod_exp and BN_mul produce different results!\n"); + return 0; + } + BN_free(a); BN_free(b); BN_free(c);