aboutsummaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorJoachim StroĢˆmbergson <joachim@secworks.se>2015-06-02 09:41:56 +0200
committerJoachim StroĢˆmbergson <joachim@secworks.se>2015-06-02 09:41:56 +0200
commit16723b974c57ae3def8b070ee81b4df27279fc0c (patch)
treee74a8adeeb9546dc1680f5c085e526a1fd313c1c /src/model
parentfdc354a34d715d8087ad68e25e182bbff513074b (diff)
Fixd nits in test case. Added simple line break to clean up.
Diffstat (limited to 'src/model')
-rw-r--r--src/model/c/src/bignum_uint32_t.c1
-rw-r--r--src/model/c/src/simple_tests.c82
2 files changed, 43 insertions, 40 deletions
diff --git a/src/model/c/src/bignum_uint32_t.c b/src/model/c/src/bignum_uint32_t.c
index 8dcadd7..956e755 100644
--- a/src/model/c/src/bignum_uint32_t.c
+++ b/src/model/c/src/bignum_uint32_t.c
@@ -11,6 +11,7 @@ void assertArrayEquals(uint32_t length, uint32_t *expected, uint32_t *actual) {
printf("%s expected: [", equals ? "PASS" : "FAIL");
for (uint32_t i = 0; i < length - 1; i++)
printf("%8x, ", expected[i]);
+ printf("\n");
printf("%8x] actual: [ ", expected[length - 1]);
for (uint32_t i = 0; i < length - 1; i++)
printf("%8x, ", actual[i]);
diff --git a/src/model/c/src/simple_tests.c b/src/model/c/src/simple_tests.c
index 1b2b258..68dcb2a 100644
--- a/src/model/c/src/simple_tests.c
+++ b/src/model/c/src/simple_tests.c
@@ -116,44 +116,44 @@ void small_e_256_mod(void) {
void rob_1024(void)
{
- uint32_t exponent = {0x3ff26c9e, 0x32685b93, 0x66570228, 0xf0603c4e,
- 0x04a717c1, 0x8038b116, 0xeb48325e, 0xcada992a,
- 0x920bb241, 0x5aee4afe, 0xe2a37e87, 0xb35b9519,
- 0xb335775d, 0x989553e9, 0x1326f46e, 0x2cdf6b7b,
- 0x84aabfa9, 0xef24c600, 0xb56872ad, 0x5edb9041,
- 0xe8ecd7f8, 0x535133fb, 0xdefc92c7, 0x42384226,
- 0x7d40e5f5, 0xc91bd745, 0x9578e460, 0xfc858374,
- 0x3172bed3, 0x73b6957c, 0xc0d6a68e, 0x33156a61};
-
-
- uint32_t modulus = {0xd075ec0a, 0x95048ef8, 0xcaa69073, 0x8d9d58e9,
- 0x1764b437, 0x50b58cad, 0x8a6e3199, 0x135f80ee,
- 0x84eb2bde, 0x58d38ee3, 0x5825e91e, 0xafdeb1ba,
- 0xa15a160b, 0x0057c47c, 0xc7765e31, 0x868a3e15,
- 0x5ee57cef, 0xb008c4dd, 0x6a0a89ee, 0x98a4ee9c,
- 0x971a07de, 0x61e5b0d3, 0xcf70e1cd, 0xc6a0de5b,
- 0x451f2fb9, 0xdb995196, 0x9f2f884b, 0x4b09749a,
- 0xe6c4ddbe, 0x7ee61f79, 0x265c6adf, 0xb16b3015};
-
-
- uint32_t message = {0x0001ffff, 0xffffffff, 0xffffffff, 0xffffffff,
- 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
- 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
- 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
- 0xffffffff, 0xffffffff, 0xffffffff, 0x00303130,
- 0x0d060960, 0x86480165, 0x03040201, 0x05000420,
- 0x8e36fc9a, 0xa31724c3, 0x2416263c, 0x0366a175,
- 0xfabbb92b, 0x741ca649, 0x6107074d, 0x0343b597};
-
-
- uint32_t expected = {0x06339a64, 0x367db02a, 0xf41158cc, 0x95e76049,
- 0x4519c165, 0x111184be, 0xe41d8ee2, 0x2ae5f5d1,
- 0x1da7f962, 0xac93ac88, 0x915eee13, 0xa3350c22,
- 0xf0dfa62e, 0xfdfc2b62, 0x29f26e27, 0xbebdc84e,
- 0x4746df79, 0x7b387ad2, 0x13423c9f, 0x98e8a146,
- 0xff486b6c, 0x1a85414e, 0x73117121, 0xb700e547,
- 0xab4e07b2, 0x21b988b8, 0x24dd77c2, 0x046b0a20,
- 0xcddb986a, 0xac75c2f2, 0xb044ed59, 0xea565879};
+ uint32_t exponent[] = {0x3ff26c9e, 0x32685b93, 0x66570228, 0xf0603c4e,
+ 0x04a717c1, 0x8038b116, 0xeb48325e, 0xcada992a,
+ 0x920bb241, 0x5aee4afe, 0xe2a37e87, 0xb35b9519,
+ 0xb335775d, 0x989553e9, 0x1326f46e, 0x2cdf6b7b,
+ 0x84aabfa9, 0xef24c600, 0xb56872ad, 0x5edb9041,
+ 0xe8ecd7f8, 0x535133fb, 0xdefc92c7, 0x42384226,
+ 0x7d40e5f5, 0xc91bd745, 0x9578e460, 0xfc858374,
+ 0x3172bed3, 0x73b6957c, 0xc0d6a68e, 0x33156a61};
+
+
+ uint32_t modulus[] = {0xd075ec0a, 0x95048ef8, 0xcaa69073, 0x8d9d58e9,
+ 0x1764b437, 0x50b58cad, 0x8a6e3199, 0x135f80ee,
+ 0x84eb2bde, 0x58d38ee3, 0x5825e91e, 0xafdeb1ba,
+ 0xa15a160b, 0x0057c47c, 0xc7765e31, 0x868a3e15,
+ 0x5ee57cef, 0xb008c4dd, 0x6a0a89ee, 0x98a4ee9c,
+ 0x971a07de, 0x61e5b0d3, 0xcf70e1cd, 0xc6a0de5b,
+ 0x451f2fb9, 0xdb995196, 0x9f2f884b, 0x4b09749a,
+ 0xe6c4ddbe, 0x7ee61f79, 0x265c6adf, 0xb16b3015};
+
+
+ uint32_t message[] = {0x0001ffff, 0xffffffff, 0xffffffff, 0xffffffff,
+ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+ 0xffffffff, 0xffffffff, 0xffffffff, 0x00303130,
+ 0x0d060960, 0x86480165, 0x03040201, 0x05000420,
+ 0x8e36fc9a, 0xa31724c3, 0x2416263c, 0x0366a175,
+ 0xfabbb92b, 0x741ca649, 0x6107074d, 0x0343b597};
+
+
+ uint32_t expected[] = {0x06339a64, 0x367db02a, 0xf41158cc, 0x95e76049,
+ 0x4519c165, 0x111184be, 0xe41d8ee2, 0x2ae5f5d1,
+ 0x1da7f962, 0xac93ac88, 0x915eee13, 0xa3350c22,
+ 0xf0dfa62e, 0xfdfc2b62, 0x29f26e27, 0xbebdc84e,
+ 0x4746df79, 0x7b387ad2, 0x13423c9f, 0x98e8a146,
+ 0xff486b6c, 0x1a85414e, 0x73117121, 0xb700e547,
+ 0xab4e07b2, 0x21b988b8, 0x24dd77c2, 0x046b0a20,
+ 0xcddb986a, 0xac75c2f2, 0xb044ed59, 0xea565879};
uint32_t target[] = {0x00000000, 0x00000000, 0x00000000, 0x00000000,
@@ -165,8 +165,10 @@ void rob_1024(void)
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000};
- mod_exp_array(128, message, exponent, modulus, target);
- assertArrayEquals(128, expected, target);
+ printf("=== 1024 bit test from Robs RSA code. ===\n");
+
+ mod_exp_array(32, message, exponent, modulus, target);
+ assertArrayEquals(32, expected, target);
}