diff --git a/library/bignum.c b/library/bignum.c index 98bea731e..44b2c87c2 100644 --- a/library/bignum.c +++ b/library/bignum.c @@ -1553,30 +1553,10 @@ static void mpi_montg_init( mbedtls_mpi_uint *mm, const mbedtls_mpi *N ) *mm = mbedtls_mpi_montg_init( N->p[0] ); } -/** Montgomery multiplication: A = A * B * R^-1 mod N (HAC 14.36) - * - * \param[in,out] A One of the numbers to multiply. - * It must have at least as many limbs as N - * (A->n >= N->n), and any limbs beyond n are ignored. - * On successful completion, A contains the result of - * the multiplication A * B * R^-1 mod N where - * R = (2^ciL)^n. - * \param[in] B One of the numbers to multiply. - * It must be nonzero and must not have more limbs than N - * (B->n <= N->n). - * \param[in] N The modulo. N must be odd. - * \param mm The value calculated by `mpi_montg_init(&mm, N)`. - * This is -N^-1 mod 2^ciL. - * \param[in,out] T A bignum for temporary storage. - * It must be at least twice the limb size of N plus 1 - * (T->n >= 2 * N->n + 1). - * Its initial content is unused and - * its final content is indeterminate. - * Note that unlike the usual convention in the library - * for `const mbedtls_mpi*`, the content of T can change. - */ -static void mpi_montmul( mbedtls_mpi *A, const mbedtls_mpi *B, const mbedtls_mpi *N, mbedtls_mpi_uint mm, - const mbedtls_mpi *T ) +/* This would be static, but is tested */ +void mbedtls_mpi_montmul( mbedtls_mpi *A, const mbedtls_mpi *B, + const mbedtls_mpi *N, mbedtls_mpi_uint mm, + const mbedtls_mpi *T ) { size_t n, m; mbedtls_mpi_uint *d; @@ -1630,7 +1610,8 @@ static void mpi_montmul( mbedtls_mpi *A, const mbedtls_mpi *B, const mbedtls_mpi /* * Montgomery reduction: A = A * R^-1 mod N * - * See mpi_montmul() regarding constraints and guarantees on the parameters. + * See the doc for mbedtls_mpi_montmul() regarding constraints and guarantees on + * the parameters. */ static void mpi_montred( mbedtls_mpi *A, const mbedtls_mpi *N, mbedtls_mpi_uint mm, const mbedtls_mpi *T ) @@ -1641,7 +1622,7 @@ static void mpi_montred( mbedtls_mpi *A, const mbedtls_mpi *N, U.n = U.s = (int) z; U.p = &z; - mpi_montmul( A, &U, N, mm, T ); + mbedtls_mpi_montmul( A, &U, N, mm, T ); } /** @@ -1723,7 +1704,7 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, #endif j = N->n + 1; - /* All W[i] and X must have at least N->n limbs for the mpi_montmul() + /* All W[i] and X must have at least N->n limbs for the mbedtls_mpi_montmul() * and mpi_montred() calls later. Here we ensure that W[1] and X are * large enough, and later we'll grow other W[i] to the same length. * They must not be shrunk midway through this function! @@ -1766,7 +1747,7 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &W[1], A, N ) ); /* This should be a no-op because W[1] is already that large before * mbedtls_mpi_mod_mpi(), but it's necessary to avoid an overflow - * in mpi_montmul() below, so let's make sure. */ + * in mbedtls_mpi_montmul() below, so let's make sure. */ MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &W[1], N->n + 1 ) ); } else @@ -1774,7 +1755,7 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, /* Note that this is safe because W[1] always has at least N->n limbs * (it grew above and was preserved by mbedtls_mpi_copy()). */ - mpi_montmul( &W[1], &RR, N, mm, &T ); + mbedtls_mpi_montmul( &W[1], &RR, N, mm, &T ); /* * X = R^2 * R^-1 mod N = R mod N @@ -1793,7 +1774,7 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &W[j], &W[1] ) ); for( i = 0; i < wsize - 1; i++ ) - mpi_montmul( &W[j], &W[j], N, mm, &T ); + mbedtls_mpi_montmul( &W[j], &W[j], N, mm, &T ); /* * W[i] = W[i - 1] * W[1] @@ -1803,7 +1784,7 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &W[i], N->n + 1 ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &W[i], &W[i - 1] ) ); - mpi_montmul( &W[i], &W[1], N, mm, &T ); + mbedtls_mpi_montmul( &W[i], &W[1], N, mm, &T ); } } @@ -1840,7 +1821,7 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, /* * out of window, square X */ - mpi_montmul( X, X, N, mm, &T ); + mbedtls_mpi_montmul( X, X, N, mm, &T ); continue; } @@ -1858,13 +1839,13 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, * X = X^wsize R^-1 mod N */ for( i = 0; i < wsize; i++ ) - mpi_montmul( X, X, N, mm, &T ); + mbedtls_mpi_montmul( X, X, N, mm, &T ); /* * X = X * W[wbits] R^-1 mod N */ MBEDTLS_MPI_CHK( mpi_select( &WW, W, (size_t) 1 << wsize, wbits ) ); - mpi_montmul( X, &WW, N, mm, &T ); + mbedtls_mpi_montmul( X, &WW, N, mm, &T ); state--; nbits = 0; @@ -1877,12 +1858,12 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, */ for( i = 0; i < nbits; i++ ) { - mpi_montmul( X, X, N, mm, &T ); + mbedtls_mpi_montmul( X, X, N, mm, &T ); wbits <<= 1; if( ( wbits & ( one << wsize ) ) != 0 ) - mpi_montmul( X, &W[1], N, mm, &T ); + mbedtls_mpi_montmul( X, &W[1], N, mm, &T ); } /* diff --git a/library/bignum_core.h b/library/bignum_core.h index 02ac55d1b..ca45480b9 100644 --- a/library/bignum_core.h +++ b/library/bignum_core.h @@ -263,4 +263,32 @@ mbedtls_mpi_uint mbedtls_mpi_core_add_if( mbedtls_mpi_uint *d, size_t n, unsigned cond ); +/** Montgomery multiplication: A = A * B * R^-1 mod N (HAC 14.36) + * + * This would be static, but is tested. + * + * \param[in,out] A One of the numbers to multiply. + * It must have at least as many limbs as N + * (A->n >= N->n), and any limbs beyond n are ignored. + * On successful completion, A contains the result of + * the multiplication A * B * R^-1 mod N where + * R = (2^ciL)^n. + * \param[in] B One of the numbers to multiply. + * It must be nonzero and must not have more limbs than N + * (B->n <= N->n). + * \param[in] N The modulo. N must be odd. + * \param mm The value calculated by `mpi_montg_init(&mm, N)`. + * This is -N^-1 mod 2^ciL. + * \param[in,out] T A bignum for temporary storage. + * It must be at least twice the limb size of N plus 1 + * (T->n >= 2 * N->n + 1). + * Its initial content is unused and + * its final content is indeterminate. + * Note that unlike the usual convention in the library + * for `const mbedtls_mpi*`, the content of T can change. + */ +void mbedtls_mpi_montmul( mbedtls_mpi *A, const mbedtls_mpi *B, + const mbedtls_mpi *N, mbedtls_mpi_uint mm, + const mbedtls_mpi *T ); + #endif /* MBEDTLS_BIGNUM_CORE_H */ diff --git a/tests/suites/test_suite_mpi.data b/tests/suites/test_suite_mpi.data index a7a074f63..9ee37312e 100644 --- a/tests/suites/test_suite_mpi.data +++ b/tests/suites/test_suite_mpi.data @@ -15308,6 +15308,429 @@ mbedtls_mpi_montg_init:"baea2d65939296fc2536f18f2a4042a741f33088ecd5000e76c67a46 mbedtls_mpi_montg_init #15 mbedtls_mpi_montg_init:"bf741f75e28a44e271cf43e68dbadd23c72d2f2e1fc78a6d6aaaadf2ccbf26c9a232aff5b3f3f29323b114f3018144ed9438943e07820e222137d3bb229b61671e61f75f6021a26436df9e669929fa392df021f105d2fce0717468a522018721ccde541b9a7b558128419f457ef33a5753f00c20c2d709727eef6278c55b278b10abe1d13e538514128b5dcb7bfd015e0fdcb081555071813974135d5ab5000630a94f5b0f4021a504ab4f3df2403e6140b9939f8bbe714635f5cff10744be03":"aab901da57bba355" +mbedtls_mpi_core_montmul #1 (replay) +mbedtls_mpi_core_montmul:2:1:1:1:"19":"1":"1D":"18":"18" + +mbedtls_mpi_core_montmul #2 (replay) +mbedtls_mpi_core_montmul:2:1:1:1:"7":"1":"9":"1":"1" + +mbedtls_mpi_core_montmul #3 (replay) +mbedtls_mpi_core_montmul:2:1:1:1:"4":"1":"9":"7":"7" + +mbedtls_mpi_core_montmul #4 (replay) +mbedtls_mpi_core_montmul:12:1:6:1:"3C246D0E059A93A266288A7718419EC741661B474C58C032C5EDAF92709402B07CC8C7CE0B781C641A1EA8DB2F4343":"1":"66A198186C18C10B2F5ED9B522752A9830B69916E535C8F047518A889A43A594B6BED27A168D31D4A52F88925AA8F5":"36E139AEA55215609D2816998ED020BBBD96C37890F65171D948E9BC7CBAA4D9325D24D6A3C12710F10A09FA08AB87":"36E139AEA55215609D2816998ED020BBBD96C37890F65171D948E9BC7CBAA4D9325D24D6A3C12710F10A09FA08AB87" + +mbedtls_mpi_core_montmul #5 (replay) +mbedtls_mpi_core_montmul:8:1:4:1:"1E442976B0E63D64FCCE74B999E470CA9888165CB75BFA1F340E918CE03C6211":"1":"B3A119602EE213CDE28581ECD892E0F592A338655DCE4CA88054B3D124D0E561":"38EB7749F4A5DA80F23BC08FD0801C55B103B17A2EEF84E60E65383B59F8CA5B":"38EB7749F4A5DA80F23BC08FD0801C55B103B17A2EEF84E60E65383B59F8CA5B" + +mbedtls_mpi_core_montmul #6 (replay) +mbedtls_mpi_core_montmul:22:1:11:1:"7CF5AC97304E0B63C65413F57249F59994B0FED1D2A8D3D83ED5FA38560FFB82392870D6D08F87D711917FD7537E13B7E125BE407E74157776839B0AC9DB23CBDFC696104353E4D2780B2B4968F8D8542306BCA7A2366E":"1":"284139EA19C139EBE09A8111926AAA39A2C2BE12ED487A809D3CB5BC55854725B4CDCB5734C58F90B2F60D99CC1950CDBC8D651793E93C9C6F0EAD752500A32C56C62082912B66132B2A6AA42ADA923E1AD22CEB7BA0123":"1E4426A3D6C425F0630B14113BEAD742C92B02886267AB41F70C4CB2426AEE1FAACEC6982E0E5BE964ECA2527A031ED49C371DB2A4FB16482F3590C866BF9F81C3D52C7CB9E0BA6FF843ED3B17C44D7F6B14471839D8D31":"1E4426A3D6C425F0630B14113BEAD742C92B02886267AB41F70C4CB2426AEE1FAACEC6982E0E5BE964ECA2527A031ED49C371DB2A4FB16482F3590C866BF9F81C3D52C7CB9E0BA6FF843ED3B17C44D7F6B14471839D8D31" + +mbedtls_mpi_core_montmul #7 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"2":"2":"3":"1":"1" + +mbedtls_mpi_core_montmul #8 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"1":"2":"3":"2":"2" + +mbedtls_mpi_core_montmul #9 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"2":"1":"3":"2":"2" + +mbedtls_mpi_core_montmul #10 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"6":"5":"7":"4":"1" + +mbedtls_mpi_core_montmul #11 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"3":"4":"7":"3":"6" + +mbedtls_mpi_core_montmul #12 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"1":"6":"7":"5":"3" + +mbedtls_mpi_core_montmul #13 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"5":"6":"7":"4":"1" + +mbedtls_mpi_core_montmul #14 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"3":"4":"B":"3":"9" + +mbedtls_mpi_core_montmul #15 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"7":"4":"B":"7":"a" + +mbedtls_mpi_core_montmul #16 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"9":"7":"B":"2":"6" + +mbedtls_mpi_core_montmul #17 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"2":"a":"B":"5":"4" + +mbedtls_mpi_core_montmul #18 (gen) (0x29 is prime) +mbedtls_mpi_core_montmul:1:1:1:1:"25":"16":"29":"16":"f" + +mbedtls_mpi_core_montmul #19 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"8":"28":"29":"2":"14" + +mbedtls_mpi_core_montmul #20 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"18":"21":"29":"7":"1d" + +mbedtls_mpi_core_montmul #21 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"15":"f":"29":"22":"c" + +mbedtls_mpi_core_montmul #22 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"e2":"ea":"FF":"63":"63" + +mbedtls_mpi_core_montmul #23 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"43":"72":"FF":"f3":"f3" + +mbedtls_mpi_core_montmul #24 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"d8":"70":"FF":"de":"de" + +mbedtls_mpi_core_montmul #25 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"3c":"7c":"FF":"2d":"2d" + +mbedtls_mpi_core_montmul #26 (gen) (0x101 is prime) +mbedtls_mpi_core_montmul:1:1:1:1:"99":"b9":"101":"23":"23" + +mbedtls_mpi_core_montmul #27 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"65":"b2":"101":"f5":"f5" + +mbedtls_mpi_core_montmul #28 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"81":"32":"101":"19":"19" + +mbedtls_mpi_core_montmul #29 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"51":"dd":"101":"a8":"a8" + +mbedtls_mpi_core_montmul #30 (gen) (0x38B is prime) +mbedtls_mpi_core_montmul:1:1:1:1:"d5":"143":"38B":"313":"14f" + +mbedtls_mpi_core_montmul #31 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"3d":"387":"38B":"212":"19a" + +mbedtls_mpi_core_montmul #32 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"160":"2e5":"38B":"a5":"14d" + +mbedtls_mpi_core_montmul #33 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"10f":"137":"38B":"10f":"19f" + +mbedtls_mpi_core_montmul #34 (gen) (0x8003 is prime) +mbedtls_mpi_core_montmul:1:1:1:1:"7dac":"25a":"8003":"5fff":"29c8" + +mbedtls_mpi_core_montmul #35 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"6f1c":"3286":"8003":"245e":"79e9" + +mbedtls_mpi_core_montmul #36 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"59ed":"2f3f":"8003":"7008":"5874" + +mbedtls_mpi_core_montmul #37 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"6893":"736d":"8003":"3178":"f99" + +mbedtls_mpi_core_montmul #38 (gen) (0x10001 is prime) +mbedtls_mpi_core_montmul:1:1:1:1:"d199":"2832":"10001":"b6fa":"b6fa" + +mbedtls_mpi_core_montmul #39 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"c3b2":"3e5b":"10001":"7c9c":"7c9c" + +mbedtls_mpi_core_montmul #40 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"abe4":"214e":"10001":"ad1c":"ad1c" + +mbedtls_mpi_core_montmul #41 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"4360":"a05d":"10001":"4fac":"4fac" + +mbedtls_mpi_core_montmul #42 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"3f5a1":"165b2":"7F7F7":"63052":"71254" + +mbedtls_mpi_core_montmul #43 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"3bd29":"37863":"7F7F7":"34ff8":"40755" + +mbedtls_mpi_core_montmul #44 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"60c47":"64819":"7F7F7":"34967":"3a83e" + +mbedtls_mpi_core_montmul #45 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"16584":"12c49":"7F7F7":"283b9":"14991" + +mbedtls_mpi_core_montmul #46 (gen) (0x800009 is prime) +mbedtls_mpi_core_montmul:1:1:1:1:"1ff03f":"610347":"800009":"1cef09":"4e3e6a" + +mbedtls_mpi_core_montmul #47 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"340fd5":"19812e":"800009":"5c1fc2":"64ecb0" + +mbedtls_mpi_core_montmul #48 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"3fe2e8":"4d0dc7":"800009":"2c4c9f":"5112e5" + +mbedtls_mpi_core_montmul #49 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"40356":"e6392":"800009":"1dc356":"5661ed" + +mbedtls_mpi_core_montmul #50 (gen) (0x100002B is prime) +mbedtls_mpi_core_montmul:1:1:1:1:"dd8a1d":"266c0e":"100002B":"e6cfeb":"66b342" + +mbedtls_mpi_core_montmul #51 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"3fa1cb":"847fd6":"100002B":"5679d":"ea359c" + +mbedtls_mpi_core_montmul #52 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"5f439d":"5c3196":"100002B":"72985e":"89865b" + +mbedtls_mpi_core_montmul #53 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"18d645":"f72dc6":"100002B":"11807c":"442f44" + +mbedtls_mpi_core_montmul #54 (gen) (0x37EEE9D is prime) +mbedtls_mpi_core_montmul:1:1:1:1:"20051ad":"37def6e":"37EEE9D":"126b1f8":"639bef" + +mbedtls_mpi_core_montmul #55 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"2ec140b":"3580dbf":"37EEE9D":"182364a":"265b419" + +mbedtls_mpi_core_montmul #56 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"1d91b46":"190d4fc":"37EEE9D":"f501a4":"2c06311" + +mbedtls_mpi_core_montmul #57 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"34e488d":"1224d24":"37EEE9D":"3097def":"1c134c4" + +mbedtls_mpi_core_montmul #58 (gen) (0x8000000B is prime) +mbedtls_mpi_core_montmul:1:1:1:1:"2a4fe2cb":"263466a9":"8000000B":"2f7b2c6b":"551d4f77" + +mbedtls_mpi_core_montmul #59 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"5643fe94":"29a1aefa":"8000000B":"7f473a3d":"86615" + +mbedtls_mpi_core_montmul #60 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"29633513":"7b007ac4":"8000000B":"589a07cd":"d6d5cbe" + +mbedtls_mpi_core_montmul #61 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"2439cef5":"5c9d5a47":"8000000B":"77b1ca47":"691ad3ef" + +mbedtls_mpi_core_montmul #62 (gen) (0x8CD626B9 is prime) +mbedtls_mpi_core_montmul:1:1:1:1:"4de3cfaa":"50dea178":"8CD626B9":"5d6c70fe":"1017c1af" + +mbedtls_mpi_core_montmul #63 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"b8b8563":"10dbbbac":"8CD626B9":"1ebb1ae4":"3abf8696" + +mbedtls_mpi_core_montmul #64 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"4e8a6151":"5574ec19":"8CD626B9":"88c056da":"5ff76076" + +mbedtls_mpi_core_montmul #65 (gen) +mbedtls_mpi_core_montmul:1:1:1:1:"69224878":"309cfc23":"8CD626B9":"14f5037d":"2ab92db7" + +mbedtls_mpi_core_montmul #66 (gen) (start of 2-MPI 4-byte bignums) (0x10000000F is prime) +mbedtls_mpi_core_montmul:2:1:1:1:"fb6f7fb6":"afb05423":"10000000F":"1b61c4f8":"1b61c4f8" + +mbedtls_mpi_core_montmul #67 (gen) +mbedtls_mpi_core_montmul:2:1:1:1:"8391a243":"26034dcd":"10000000F":"c5d18a1f":"c5d18a1f" + +mbedtls_mpi_core_montmul #68 (gen) +mbedtls_mpi_core_montmul:2:1:1:1:"d26b98c":"14b2d6aa":"10000000F":"4e7fad06":"4e7fad06" + +mbedtls_mpi_core_montmul #69 (gen) +mbedtls_mpi_core_montmul:2:1:1:1:"6b9f1371":"a21daf1d":"10000000F":"c6b6f98b":"c6b6f98b" + +mbedtls_mpi_core_montmul #70 (gen) 0x174876E7E9 is prime (dec) 99999999977 +mbedtls_mpi_core_montmul:2:2:1:1:"9f49435ad":"c8264ade8":"174876E7E9":"6f386b4ce":"6f386b4ce" + +mbedtls_mpi_core_montmul #71 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"c402da434":"1fb427acf":"174876E7E9":"271c9b457":"271c9b457" + +mbedtls_mpi_core_montmul #72 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"f6ebc2bb1":"1096d39f2a":"174876E7E9":"78a3ebdad":"78a3ebdad" + +mbedtls_mpi_core_montmul #73 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"153b7f7b6b":"878fda8ff":"174876E7E9":"81843925c":"81843925c" + +mbedtls_mpi_core_montmul #74 (gen) (0x8000000017 is prime) +mbedtls_mpi_core_montmul:2:2:1:1:"2c1adbb8d6":"4384d2d3c6":"8000000017":"7ee47165db":"7ee47165db" + +mbedtls_mpi_core_montmul #75 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"2e4f9cf5fb":"794f3443d9":"8000000017":"79446995ec":"79446995ec" + +mbedtls_mpi_core_montmul #76 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"149e495582":"3802b8f7b7":"8000000017":"1e4ef00e22":"1e4ef00e22" + +mbedtls_mpi_core_montmul #77 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"7b9d49df82":"69c68a442a":"8000000017":"74dee0f58a":"74dee0f58a" + +mbedtls_mpi_core_montmul #78 (gen) (0x864CB9076D is prime) +mbedtls_mpi_core_montmul:2:2:1:1:"683a134600":"6dd80ea9f6":"864CB9076D":"5c3f421e55":"5c3f421e55" + +mbedtls_mpi_core_montmul #79 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"13a870ff0d":"59b099694a":"864CB9076D":"615b45edcf":"615b45edcf" + +mbedtls_mpi_core_montmul #80 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"37d06b0e63":"4d2147e46f":"864CB9076D":"6e47e78c45":"6e47e78c45" + +mbedtls_mpi_core_montmul #81 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"661714f8f4":"22e55df507":"864CB9076D":"63f7b7766d":"63f7b7766d" + +mbedtls_mpi_core_montmul #82 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"2f0a96363":"52693307b4":"F7F7F7F7F7":"99e7b7a2f6":"99e7b7a2f6" + +mbedtls_mpi_core_montmul #83 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"3c85078e64":"f2275ecb6d":"F7F7F7F7F7":"5b30b7ecd8":"5b30b7ecd8" + +mbedtls_mpi_core_montmul #84 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"352dae68d1":"707775b4c6":"F7F7F7F7F7":"922215581":"922215581" + +mbedtls_mpi_core_montmul #85 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"37ae0f3e0b":"912113040f":"F7F7F7F7F7":"9724ae9827":"9724ae9827" + +mbedtls_mpi_core_montmul #86 (gen) (0x1000000000F is prime) +mbedtls_mpi_core_montmul:2:2:1:1:"6dada15e31":"f58ed9eff7":"1000000000F":"a11a0b6bd4":"a11a0b6bd4" + +mbedtls_mpi_core_montmul #87 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"69627a7c89":"cfb5ebd13d":"1000000000F":"bdd403e1e8":"bdd403e1e8" + +mbedtls_mpi_core_montmul #88 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"a5e1ad239b":"afc030c731":"1000000000F":"d9159b287c":"d9159b287c" + +mbedtls_mpi_core_montmul #89 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"f1cc45f4c5":"c64ad607c8":"1000000000F":"fdaa868e":"fdaa868e" + +mbedtls_mpi_core_montmul #90 (gen) (0x800000000005 is prime) +mbedtls_mpi_core_montmul:2:2:1:1:"2ebad87d2e31":"4c72d90bca78":"800000000005":"102277c75b46":"102277c75b46" + +mbedtls_mpi_core_montmul #91 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"a30b3cc50d":"29ac4fe59490":"800000000005":"7a0bb5e477ca":"7a0bb5e477ca" + +mbedtls_mpi_core_montmul #92 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"33674e9647b4":"5ec7ee7e72d3":"800000000005":"431f6a298b9f":"431f6a298b9f" + +mbedtls_mpi_core_montmul #93 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"3d956f474f61":"74070040257d":"800000000005":"1bf1cc423f85":"1bf1cc423f85" + +mbedtls_mpi_core_montmul #94 (gen) (0x800795D9BA47 is prime) +mbedtls_mpi_core_montmul:2:2:1:1:"48348e3717d6":"43fcb4399571":"800795D9BA47":"be7aa205fdd":"be7aa205fdd" + +mbedtls_mpi_core_montmul #95 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"5234c03cc99b":"2f3cccb87803":"800795D9BA47":"38c915c43e15":"38c915c43e15" + +mbedtls_mpi_core_montmul #96 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"3ed13db194ab":"44b8f4ba7030":"800795D9BA47":"37052e8c2720":"37052e8c2720" + +mbedtls_mpi_core_montmul #97 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"1c11e843bfdb":"95bd1b47b08":"800795D9BA47":"57783cead5bc":"57783cead5bc" + +mbedtls_mpi_core_montmul #98 (gen) (0x1000000000015 is prime) +mbedtls_mpi_core_montmul:2:2:1:1:"a81d11cb81fd":"1e5753a3f33d":"1000000000015":"1524843bbe60":"1524843bbe60" + +mbedtls_mpi_core_montmul #99 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"688c4db99232":"36fc0cf7ed":"1000000000015":"d987f015f9c8":"d987f015f9c8" + +mbedtls_mpi_core_montmul #100 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"f0720cc07e07":"fc76140ed903":"1000000000015":"c0a15846d9ab":"c0a15846d9ab" + +mbedtls_mpi_core_montmul #101 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"2ec61f8d17d1":"d270c85e36d2":"1000000000015":"b25b655a6234":"b25b655a6234" + +mbedtls_mpi_core_montmul #102 (gen) (0x100000000000051 is prime) +mbedtls_mpi_core_montmul:2:2:1:1:"6a24cd3ab63820":"ed4aad55e5e348":"100000000000051":"f4fb80f56821d9":"f4fb80f56821d9" + +mbedtls_mpi_core_montmul #103 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"e680c160d3b248":"31e0d8840ed510":"100000000000051":"aa5e1c3bb30ab8":"aa5e1c3bb30ab8" + +mbedtls_mpi_core_montmul #104 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"a80637e9aebc38":"bb81decc4e1738":"100000000000051":"14a17c662fb3fd":"14a17c662fb3fd" + +mbedtls_mpi_core_montmul #105 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"9afa5a59e9d630":"be9e65a6d42938":"100000000000051":"1fa880b76c7bbf":"1fa880b76c7bbf" + +mbedtls_mpi_core_montmul #106 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"ab5e104eeb71c000":"2cffbd639e9fea00":"ABCDEF0123456789":"a7bd05d2ad72bbac":"a7bd05d2ad72bbac" + +mbedtls_mpi_core_montmul #107 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"197b867547f68a00":"44b796cf94654800":"ABCDEF0123456789":"94683e1ac1068cfc":"94683e1ac1068cfc" + +mbedtls_mpi_core_montmul #108 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"329f9483a04f2c00":"9892f76961d0f000":"ABCDEF0123456789":"12ca7ba6189f5080":"12ca7ba6189f5080" + +mbedtls_mpi_core_montmul #109 (gen) +mbedtls_mpi_core_montmul:2:2:1:1:"4a2e12dfb4545000":"1aa3e89a69794500":"ABCDEF0123456789":"591fced0c97f7916":"591fced0c97f7916" + +mbedtls_mpi_core_montmul #110 (gen) (start of 2-MPI 8-byte bignums) 0x25A55A46E5DA99C71C7 is the 3rd repunit prime (dec) 11111111111111111111111 +mbedtls_mpi_core_montmul:3:3:2:2:"8b9acdf013d140f000":"12e4ceaefabdf2b2f00":"25A55A46E5DA99C71C7":"145e13d825f558e1528":"5965c1bea1c065c1f9" + +mbedtls_mpi_core_montmul #111 (gen) +mbedtls_mpi_core_montmul:3:3:2:2:"1b8d960ea277e3f5500":"14418aa980e37dd000":"25A55A46E5DA99C71C7":"3296eca7d29742119d":"e62a0288b09791369c" + +mbedtls_mpi_core_montmul #112 (gen) +mbedtls_mpi_core_montmul:3:3:2:2:"7314524977e8075980":"8172fa45618ccd0d80":"25A55A46E5DA99C71C7":"16ce65e208c75d6959b":"20f256de8b8761f07a1" + +mbedtls_mpi_core_montmul #113 (gen) +mbedtls_mpi_core_montmul:3:3:2:2:"ca14f031769be63580":"147a2f3cf2964ca9400":"25A55A46E5DA99C71C7":"1b33a89ac4a750a245d":"209a484f1216347030" + +mbedtls_mpi_core_montmul #114 (gen) 0x314DC643FB763F2B8C0E2DE00879 is (dec)99999999977^3 +mbedtls_mpi_core_montmul:4:4:2:2:"18532ba119d5cd0cf39735c0000":"25f9838e31634844924733000000":"314DC643FB763F2B8C0E2DE00879":"e7b248b17e952a3b5bf96467c9e":"e7b248b17e952a3b5bf96467c9e" + +mbedtls_mpi_core_montmul #115 (gen) +mbedtls_mpi_core_montmul:4:4:2:2:"a56e2d2517519e3970e70c40000":"ec27428d4bb380458588fa80000":"314DC643FB763F2B8C0E2DE00879":"26c158897a56747970ce53723ab0":"26c158897a56747970ce53723ab0" + +mbedtls_mpi_core_montmul #116 (gen) +mbedtls_mpi_core_montmul:4:4:2:2:"1cb5e8257710e8653fff33a00000":"15fdd42fe440fd3a1d121380000":"314DC643FB763F2B8C0E2DE00879":"2bbf68c08200acd799df33fb6cf3":"2bbf68c08200acd799df33fb6cf3" + +mbedtls_mpi_core_montmul #117 (gen) +mbedtls_mpi_core_montmul:4:4:2:2:"e50d07a65fc6f93e538ce040000":"1f4b059ca609f3ce597f61240000":"314DC643FB763F2B8C0E2DE00879":"27ce5f2c1819fe02f4335558de21":"27ce5f2c1819fe02f4335558de21" + +mbedtls_mpi_core_montmul #118 (gen) 0x47BF19662275FA2F6845C74942ED1D852E521 is (dec) 99999999977^4 +mbedtls_mpi_core_montmul:5:5:3:3:"1ea3ade786a095d978d387f30df9f20000000":"127c448575f04af5a367a7be06c7da0000000":"47BF19662275FA2F6845C74942ED1D852E521":"42c40f627a678ddf5ba6f27baedae85022b83":"24ee52f9383c9213f6641ca1a1293f6c90c28" + +mbedtls_mpi_core_montmul #119 (gen) +mbedtls_mpi_core_montmul:5:5:3:3:"16e15b0ca82764e72e38357b1f10a20000000":"43e2355d8514bbe22b0838fdc3983a0000000":"47BF19662275FA2F6845C74942ED1D852E521":"2cfd2125bb4d48f9d38a1d1dc9e546463eb62":"c96be8fa4c2a1981847403e0c45da464ea83" + +mbedtls_mpi_core_montmul #120 (gen) +mbedtls_mpi_core_montmul:5:5:3:3:"be39332529d93f25c3d116c004c620000000":"5cccec42370a0a2c89c6772da801a0000000":"47BF19662275FA2F6845C74942ED1D852E521":"29081a3513837bdb55dfdab9de4d31dfe4bc4":"1b543f0226cdc674fc60c0822d275954530cf" + +mbedtls_mpi_core_montmul #121 (gen) +mbedtls_mpi_core_montmul:5:5:3:3:"ecaa468d90de0eeda474d39b3e1fc0000000":"1e714554018de6dc0fe576bfd3b5660000000":"47BF19662275FA2F6845C74942ED1D852E521":"18eb78f9fe89aaf4f32968af4d64627be81fe":"439b0325171f87ba20ddf220d61bc0f1e5865" + +mbedtls_mpi_core_montmul #122 (gen) 0x97EDD86E4B5C4592C6D32064AC55C888A7245F07CA3CC455E07C931 is (dec) 99999999977^6 +mbedtls_mpi_core_montmul:7:7:4:4:"32298816711c5dce46f9ba06e775c4bedfc770e6700000000000000":"8ee751fd5fb24f0b4a653cb3a0c8b7d9e724574d168000000000000":"97EDD86E4B5C4592C6D32064AC55C888A7245F07CA3CC455E07C931":"d20edd4f6c266489796ac74b96dde9bdffcb5131de686f9cac736c":"496a11382c5396c40b8e146b31fd98b8bc53648f93d04ff21b31725" + +mbedtls_mpi_core_montmul #123 (gen) +mbedtls_mpi_core_montmul:7:7:4:4:"29213b9df3cfd15f4b428645b67b677c29d1378d810000000000000":"6cbb732c65e10a28872394dfdd1936d5171c3c3aac0000000000000":"97EDD86E4B5C4592C6D32064AC55C888A7245F07CA3CC455E07C931":"29b3e797ff5104e01323f855aaccdbe9740facd77c04abda1c52bd5":"602b40d7c1feff4cfa2d4061046e4178c38e51172a5ca4326ebbb80" + +mbedtls_mpi_core_montmul #124 (gen) +mbedtls_mpi_core_montmul:7:7:4:4:"6f18db06ad4abc52c0c50643dd13098abccd4a232f0000000000000":"7e6bf41f2a86098ad51f98dfc10490ba3e8081bc830000000000000":"97EDD86E4B5C4592C6D32064AC55C888A7245F07CA3CC455E07C931":"74c0a781f976ae0781fa4c408f3aca6290ed7c926ea4972d8cbd00e":"1134ccaea14ab4de865b0abce56638d4ca1e948d963389003cdcf5a" + +mbedtls_mpi_core_montmul #125 (gen) +mbedtls_mpi_core_montmul:7:7:4:4:"62d3286cd706ad9d73caff63f1722775d7e8c731208000000000000":"530f7ba02ae2b04c2fe3e3d27ec095925631a6c2528000000000000":"97EDD86E4B5C4592C6D32064AC55C888A7245F07CA3CC455E07C931":"40e7f208928702cdfd45a1e085668af52f634d7ca0db34dfb161fc5":"8510d78927c62b26f1965ce5f2d6b5978566b608bfdd02dfb450d43" + +mbedtls_mpi_core_montmul #126 (gen) 0xDD15FE80B731872AC104DB37832F7E75A244AA2631BC87885B861E8F20375499 is (dec) 99999999977^7 +mbedtls_mpi_core_montmul:8:8:4:4:"a6c6503e3c031fdbf6009a89ed60582b7233c5a85de28b16000000000000000":"75c8ed18270b583f16d442a467d32bf95c5e491e9b8523798000000000000000":"DD15FE80B731872AC104DB37832F7E75A244AA2631BC87885B861E8F20375499":"73cdf58f541b4a4b200d163b82d60488207147401ce5e9e87e4c8743734fc115":"73cdf58f541b4a4b200d163b82d60488207147401ce5e9e87e4c8743734fc115" + +mbedtls_mpi_core_montmul #127 (gen) +mbedtls_mpi_core_montmul:8:8:4:4:"bf84d1f85cf6b51e04d2c8f4ffd03532d852053cf99b387d4000000000000000":"397ba5a743c349f4f28bc583ecd5f06e0a25f9c6d98f09134000000000000000":"DD15FE80B731872AC104DB37832F7E75A244AA2631BC87885B861E8F20375499":"7aee85838cad05594c16c0f8dc37dcedbfc5cabd535243d1f6e9a72597421b16":"7aee85838cad05594c16c0f8dc37dcedbfc5cabd535243d1f6e9a72597421b16" + +mbedtls_mpi_core_montmul #128 (gen) +mbedtls_mpi_core_montmul:8:8:4:4:"6db11c3a4152ed1a2aa6fa34b0903ec82ea1b88908dcb482000000000000000":"ac8ac576a74ad6ca48f201bf89f77350ce86e821358d85920000000000000000":"DD15FE80B731872AC104DB37832F7E75A244AA2631BC87885B861E8F20375499":"543bb63086c17abcfb027fac0e173b0661225ce534fc035f4c571168704f3562":"543bb63086c17abcfb027fac0e173b0661225ce534fc035f4c571168704f3562" + +mbedtls_mpi_core_montmul #129 (gen) +mbedtls_mpi_core_montmul:8:8:4:4:"3001d96d7fe8b733f33687646fc3017e3ac417eb32e0ec708000000000000000":"925ddbdac4174e8321a48a32f79640e8cf7ec6f46ea235a80000000000000000":"DD15FE80B731872AC104DB37832F7E75A244AA2631BC87885B861E8F20375499":"9af46358ac6898dd3a4668f58748be748a93c45dae8309756a85c25f3370ea1e":"9af46358ac6898dd3a4668f58748be748a93c45dae8309756a85c25f3370ea1e" + +mbedtls_mpi_core_montmul #130 (gen) 0x141B8EBD9009F84C241879A1F680FACCED355DA36C498F73E96E880CF78EA5F96146380E41 is 99999999977^8 +mbedtls_mpi_core_montmul:10:10:5:5:"1029048755f2e60dd98c8de6d9989226b6bb4f0db8e46bd1939de560000000000000000000":"51bb7270b2e25cec0301a03e8275213bb6c2f6e6ec93d4d46d36ca0000000000000000000":"141B8EBD9009F84C241879A1F680FACCED355DA36C498F73E96E880CF78EA5F96146380E41":"bc135600e66e2f35482f257a39153e5a2313bb34fdf678a7768ef68baf4eb4af7950db678":"bc135600e66e2f35482f257a39153e5a2313bb34fdf678a7768ef68baf4eb4af7950db678" + +mbedtls_mpi_core_montmul #131 (gen) +mbedtls_mpi_core_montmul:10:10:5:5:"1c5337ff982b3ad6611257dbff5bbd7a9920ba2d4f5838a0cc681ce000000000000000000":"520c5d049ca4702031ba728591b665c4d4ccd3b2b86864d4c160fd2000000000000000000":"141B8EBD9009F84C241879A1F680FACCED355DA36C498F73E96E880CF78EA5F96146380E41":"a4041530bd752163a32ad6e21605d43621783491c739cc5b8426ed5c013c8f1874f4c33cf":"a4041530bd752163a32ad6e21605d43621783491c739cc5b8426ed5c013c8f1874f4c33cf" + +mbedtls_mpi_core_montmul #132 (gen) +mbedtls_mpi_core_montmul:10:9:5:5:"57074dfa00e42f6555bae624b7f0209f218adf57f73ed34ab0ff90c000000000000000000":"41eb14b6c07bfd3d1fe4f4a610c17cc44fcfcda695db040e011065000000000000000000":"141B8EBD9009F84C241879A1F680FACCED355DA36C498F73E96E880CF78EA5F96146380E41":"50035f4ad135181424da54e119e7b6c2d8563e4237d5c636457489fdcad2c98974f4d6986":"50035f4ad135181424da54e119e7b6c2d8563e4237d5c636457489fdcad2c98974f4d6986" + +mbedtls_mpi_core_montmul #133 (gen) +mbedtls_mpi_core_montmul:10:10:5:5:"d8ed7feed2fe855e6997ad6397f776158573d425031bf085a615784000000000000000000":"6f121dcd18c578ab5e229881006007bb6d319b179f11015fe958b9c000000000000000000":"141B8EBD9009F84C241879A1F680FACCED355DA36C498F73E96E880CF78EA5F96146380E41":"ec6c4ef84cdba8b8fb0e23834f954b74f695da3a7036afd2b8bda4cf1969a22a2703f4810":"ec6c4ef84cdba8b8fb0e23834f954b74f695da3a7036afd2b8bda4cf1969a22a2703f4810" + +mbedtls_mpi_core_montmul #134 (gen) 0x2A94608DE88B6D5E9F8920F5ABB06B24CC35AE1FBACC87D075C621C3E2833EC902713E40F51E3B3C214EDFABC451 is (dec) 99999999977^10 +mbedtls_mpi_core_montmul:12:12:6:6:"2a462b156180ea5fe550d3758c764e06fae54e626b5f503265a09df76edbdfbfa1e6000000000000000000000000":"1136f41d1879fd4fb9e49e0943a46b6704d77c068ee237c3121f9071cfd3e6a00315800000000000000000000000":"2A94608DE88B6D5E9F8920F5ABB06B24CC35AE1FBACC87D075C621C3E2833EC902713E40F51E3B3C214EDFABC451":"204e2ee5416bf5cdc9d983d92ec60d5df79e331272efa041f3cdb2a172361806ba048bd578108d717dd29c38dc1e":"204e2ee5416bf5cdc9d983d92ec60d5df79e331272efa041f3cdb2a172361806ba048bd578108d717dd29c38dc1e" + +mbedtls_mpi_core_montmul #135 (gen) +mbedtls_mpi_core_montmul:12:12:6:6:"c1ac3800dfb3c6954dea391d206200cf3c47f795bf4a5603b4cb88ae7e574de4740800000000000000000000000":"c0d16eda0549ede42fa0deb4635f7b7ce061fadea02ee4d85cba4c4f7096034193c800000000000000000000000":"2A94608DE88B6D5E9F8920F5ABB06B24CC35AE1FBACC87D075C621C3E2833EC902713E40F51E3B3C214EDFABC451":"e61059c9d6aff1b0c8d1fae7c880b9491a7e8e7715283f9d27b17423c282ada6016362d610f7a2509c859b4e2c3":"e61059c9d6aff1b0c8d1fae7c880b9491a7e8e7715283f9d27b17423c282ada6016362d610f7a2509c859b4e2c3" + +mbedtls_mpi_core_montmul #136 (gen) +mbedtls_mpi_core_montmul:12:12:6:6:"19e45bb7633094d272588ad2e43bcb3ee341991c6731b6fa9d47c4018d7ce7bba5ee800000000000000000000000":"1e4f83166ae59f6b9cc8fd3e7677ed8bfc01bb99c98bd3eb084246b64c1e18c3365b800000000000000000000000":"2A94608DE88B6D5E9F8920F5ABB06B24CC35AE1FBACC87D075C621C3E2833EC902713E40F51E3B3C214EDFABC451":"14dfcf79e82a33b504f887088c66d85abb43e4eb93ae643e6413a655c48fa6643fc9032c5e7dbfbb6291d707abc8":"14dfcf79e82a33b504f887088c66d85abb43e4eb93ae643e6413a655c48fa6643fc9032c5e7dbfbb6291d707abc8" + +mbedtls_mpi_core_montmul #137 (gen) +mbedtls_mpi_core_montmul:12:12:6:6:"1aa93395fad5f9b7f20b8f9028a054c0bb7c11bb8520e6a95e5a34f06cb70bcdd01a800000000000000000000000":"54b45afa5d4310192f8d224634242dd7dcfb342318df3d9bd37b4c614788ba13b8b000000000000000000000000":"2A94608DE88B6D5E9F8920F5ABB06B24CC35AE1FBACC87D075C621C3E2833EC902713E40F51E3B3C214EDFABC451":"1c56a73d8698564b51a42613a20c07f7fda723cbada776bebdb075b349a19b588345e9930dcf12178400d7fb32e6":"1c56a73d8698564b51a42613a20c07f7fda723cbada776bebdb075b349a19b588345e9930dcf12178400d7fb32e6" + +mbedtls_mpi_core_montmul #138 (gen) 0x8335616AED761F1F7F44E6BD49E807B82E3BF2BF11BFA6AF813C808DBF33DBFA11DABD6E6144BEF37C6800000000000000000000000000000000051 is prime, (dec) 10^143 + 3^4 +mbedtls_mpi_core_montmul:15:15:8:8:"544f2628a28cfb5ce0a1b7180ee66b49716f1d9476c466c57f0c4b2308991784306d48f78686115ee19e25400000000000000000000000000000000":"677eb31ef8d66c120fa872a60cd47f6e10cbfdf94f90501bd7883cba03d185be0a0148d1625745e9c4c827300000000000000000000000000000000":"8335616AED761F1F7F44E6BD49E807B82E3BF2BF11BFA6AF813C808DBF33DBFA11DABD6E6144BEF37C6800000000000000000000000000000000051":"1c17879ba8ffaf6e01f145b954e6f2d1da9b5e91b0cd41324228e0da4e2d8c8b7de9be8533452f0420d1c21e2b91ce6a47be8a154b70ab8e3afa0e2":"45d5439e49004056f25a7af76fa1fa0b2f41c6ac4da7d960f3c8619eabafe0f9637e4d0551442a732d4bc3832e01c21e2b91ce6a47be8a154b70ae4" + +mbedtls_mpi_core_montmul #139 (gen) +mbedtls_mpi_core_montmul:15:15:8:8:"76bb3470985174915e9993522aec989666908f9e8cf5cb9f037bf4aee33d8865cb6464174795d07e30015b80000000000000000000000000000000":"6aaaf60d5784dcef612d133613b179a317532ecca0eed40b8ad0c01e6d4a6d8c79a52af190abd51739009a900000000000000000000000000000000":"8335616AED761F1F7F44E6BD49E807B82E3BF2BF11BFA6AF813C808DBF33DBFA11DABD6E6144BEF37C6800000000000000000000000000000000051":"10676de6ef5976bb3d0e91e01ad3de619c1c4d60644c38d061da315f0d11f81a961a8fe63625bb4ccd9f963765a89f46e88c73fc02d8f16af74bef5":"2f7c4c22707c864397f9905b3f7f6a558cd793e56bda9a594600a895b62581d391c9f98b91e9ef02b94c9befa097963765a89f46e88c73fc02d8f34" + +mbedtls_mpi_core_montmul #140 (gen) +mbedtls_mpi_core_montmul:15:15:8:8:"6cfdd6e60912e441d2d1fc88f421b533f0103a5322ccd3f4db84861643ad63fd63d1d8cfbc1d498162786ba00000000000000000000000000000000":"1177246ec5e93814816465e7f8f248b350d954439d35b2b5d75d917218e7fd5fb4c2f6d0667f9467fdcf33400000000000000000000000000000000":"8335616AED761F1F7F44E6BD49E807B82E3BF2BF11BFA6AF813C808DBF33DBFA11DABD6E6144BEF37C6800000000000000000000000000000000051":"485cca6586b0540eceb3ef8644bd400f3c32a9e38dfe4f4513945895808d648cfa45a3a2e9691b6111ddef29103fa8981dd8a3bbc52c9b768034ac5":"43603ad0efccbc0db5981c2cc75573d32dc0c0d94a8a2f6a67bb003e769f421626e68bdf1ff7d809a8b9ebddc055ef29103fa8981dd8a3bbc52c9e1" + +mbedtls_mpi_core_montmul #141 (gen) +mbedtls_mpi_core_montmul:15:15:8:8:"7a09a0b0f8bbf8057116fb0277a9bdf3a91b5eaa8830d448081510d8973888be5a9f0ad04facb69aa3715f00000000000000000000000000000000":"764dec6c05a1c0d87b649efa5fd94c91ea28bffb4725d4ab4b33f1a3e8e3b314d799020e244a835a145ec9800000000000000000000000000000000":"8335616AED761F1F7F44E6BD49E807B82E3BF2BF11BFA6AF813C808DBF33DBFA11DABD6E6144BEF37C6800000000000000000000000000000000051":"36a534b574adac80dfea3dabdf0a8c95f47511ff202eab325e5a6edfb7e3ab28ddc15b2f6023240939ba5b7339f7ada7225376a817263464cfba89d":"7a9f42a7ed20ab041b748b5594d63e5aa5c890cd88826a4120bec4c43a90bfb8c7f78ad9cd91756a5f0f5a9154725b7339f7ada7225376a81726392" + MPI Selftest depends_on:MBEDTLS_SELF_TEST mpi_selftest: diff --git a/tests/suites/test_suite_mpi.function b/tests/suites/test_suite_mpi.function index 26d1553ba..d9109eced 100644 --- a/tests/suites/test_suite_mpi.function +++ b/tests/suites/test_suite_mpi.function @@ -2026,6 +2026,86 @@ exit: } /* END_CASE */ +/* BEGIN_CASE */ +void mbedtls_mpi_core_montmul( int limbs_AN4, int limbs_B4, + int limbs_AN8, int limbs_B8, + char * input_A, + char * input_B, + char * input_N, + char * input_X4, + char * input_X8 ) +{ + mbedtls_mpi A, B, N, X4, X8, T, CA; + + mbedtls_mpi_init( &A ); + mbedtls_mpi_init( &B ); + mbedtls_mpi_init( &N ); + mbedtls_mpi_init( &X4 ); /* expected result, sizeof(mbedtls_mpi_uint) == 4 */ + mbedtls_mpi_init( &X8 ); /* expected result, sizeof(mbedtls_mpi_uint) == 8 */ + mbedtls_mpi_init( &T ); + mbedtls_mpi_init( &CA ); /* copy of A */ + + TEST_EQUAL( mbedtls_test_read_mpi( &A, input_A ), 0 ); + TEST_EQUAL( mbedtls_test_read_mpi( &B, input_B ), 0 ); + TEST_EQUAL( mbedtls_test_read_mpi( &N, input_N ), 0 ); + TEST_EQUAL( mbedtls_test_read_mpi( &X4, input_X4 ), 0 ); + TEST_EQUAL( mbedtls_test_read_mpi( &X8, input_X8 ), 0 ); + + mbedtls_mpi *X = ( sizeof(mbedtls_mpi_uint) == 4 ) ? &X4 : &X8; + + int limbs_AN = ( sizeof(mbedtls_mpi_uint) == 4 ) ? limbs_AN4 : limbs_AN8; + int limbs_B = ( sizeof(mbedtls_mpi_uint) == 4 ) ? limbs_B4 : limbs_B8; + + TEST_ASSERT( (size_t)limbs_AN >= A.n && (size_t)limbs_AN >= X->n ); + TEST_ASSERT( (size_t)limbs_B >= B.n ); + TEST_ASSERT( limbs_B <= limbs_AN ); + + /* All of the inputs are +ve (or zero) */ + TEST_EQUAL( A.s, 1 ); + TEST_EQUAL( B.s, 1 ); + TEST_EQUAL( N.s, 1 ); + TEST_EQUAL( X->s, 1 ); + + TEST_EQUAL( mbedtls_mpi_grow( &A, limbs_AN ), 0 ); + TEST_EQUAL( mbedtls_mpi_grow( &N, limbs_AN ), 0 ); + TEST_EQUAL( mbedtls_mpi_grow( X, limbs_AN ), 0 ); + TEST_EQUAL( mbedtls_mpi_grow( &B, limbs_B ), 0 ); + + TEST_EQUAL( mbedtls_mpi_grow( &T, limbs_AN * 2 + 1 ), 0 ); + + /* Calculate the Montgomery constant (this is unit tested separately) */ + mbedtls_mpi_uint mm = mbedtls_mpi_montg_init( N.p[0] ); + + TEST_EQUAL( mbedtls_mpi_copy( &CA, &A ), 0 ); /* take a copy */ + TEST_EQUAL( mbedtls_mpi_grow( &CA, limbs_AN ), 0 ); /* ensure it's got the right number of limbs */ + + mbedtls_mpi_montmul( &A, &B, &N, mm, &T ); + TEST_EQUAL( A.s, 1 ); /* ensure still positive */ + + /* Could use mbedtls_mpi_cmp_mpi(), but this gives finer detail if not the same */ + TEST_EQUAL( A.n, X->n ); + TEST_EQUAL( memcmp( A.p, X->p, A.n * sizeof(mbedtls_mpi_uint) ), 0 ); + + /* First overwrite A so we ensure mbedtls_mpi_core_montmul() does something */ + memset( A.p, 0xAA, A.n * sizeof(mbedtls_mpi_uint) ); + + /* Now test the new function: use the copy CA we took earlier of A as the + * LHS, and use A as the destination + */ + mbedtls_mpi_core_montmul( A.p, CA.p, B.p, B.n, N.p, N.n, mm, T.p ); + TEST_EQUAL( memcmp( A.p, X->p, A.n * sizeof(mbedtls_mpi_uint) ), 0 ); + +exit: + mbedtls_mpi_free( &A ); + mbedtls_mpi_free( &B ); + mbedtls_mpi_free( &N ); + mbedtls_mpi_free( &X4 ); + mbedtls_mpi_free( &X8 ); + mbedtls_mpi_free( &T ); + mbedtls_mpi_free( &CA ); +} +/* END_CASE */ + /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ void mpi_selftest( ) {