aboutsummaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJoachim StroĢˆmbergson <joachim@secworks.se>2015-06-03 09:56:54 +0200
committerJoachim StroĢˆmbergson <joachim@secworks.se>2015-06-03 09:56:54 +0200
commitecb1a3f810c718a35e871cdba58e76a4d4aacf5e (patch)
treef8c81ec9f0f4c674ad29c03cef1e95149fe3f3c7 /sw
parentda10db7e89b9266972a8954a5ac88fbd25978b7f (diff)
Adding the 1024 bit sign and verify test cases used in the C model and the testbench that are based on the real RSA key generated by Rob. Both tests works on the modexp in the Novena.
Diffstat (limited to 'sw')
-rw-r--r--sw/modexp_tester.c201
1 files changed, 110 insertions, 91 deletions
diff --git a/sw/modexp_tester.c b/sw/modexp_tester.c
index c9b9a80..2288ad5 100644
--- a/sw/modexp_tester.c
+++ b/sw/modexp_tester.c
@@ -514,7 +514,7 @@ static void tc7()
//------------------------------------------------------------------
// tc8()
//
-// Testcase with 2048 bit operands.
+// Testcase with 1024 bit operands.
//------------------------------------------------------------------
static void tc8()
{
@@ -591,7 +591,7 @@ static void tc8()
0xd5535329 };
uint8_t result;
- printf("Running TC8: 2048 bit operands.s\n");
+ printf("Running TC8: 1024 bit operands...\n");
result = testrunner(65, exponent, 65, modulus, message, expected);
@@ -602,94 +602,112 @@ static void tc8()
}
-//------------------------------------------------------------------
-// tc9()
-//
-// Testcase with 2048 bit operands.
-//------------------------------------------------------------------
-static void tc9()
+void rob_dec_1024(void)
+{
+ uint32_t exponent[] = {0x00000000, 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[] = {0x00000000, 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[] = {0x00000000, 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[] = {0x00000000, 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};
+
+ uint8_t result;
+
+ printf("=== Running 1024 bit decipher/sign test from Robs RSA code. ===\n");
+
+ result = testrunner(33, exponent, 33, modulus, message, expected);
+
+ if (result)
+ printf("Rob 1024 dec/sign test OK\n");
+ else
+ printf("Rob 1024 dec/sign test NOT OK\n");
+
+}
+
+
+void rob_enc_1024(void)
{
- uint32_t message[] = {0x21558179, 0x3e2914b1, 0xefe95957, 0x965fdead,
- 0xe766d8fc, 0x136eadf4, 0xa6106a2a, 0x88b2df7e,
- 0xe0b0eaae, 0x2c17946a, 0x6f5b5563, 0x228052ae,
- 0x7fc40d80, 0xf81354db, 0xfceecd1a, 0xa5e4c97d,
- 0x433ecfcd, 0xc20d1e4d, 0x2a748fe3, 0x1d9e63f0,
- 0xdc6c25d6, 0xdae5c8be, 0x1d8c5431, 0xb1d7d270,
- 0xed5b2566, 0x1463b0fd, 0xa9e26cf7, 0x3dd6fbd7,
- 0x1347c8f7, 0x76c2cc37, 0xf382b786, 0x1d5ac517,
- 0x26b96692, 0x2c1fe6f8, 0x5852dbf8, 0x4bcabda2,
- 0xbedb2f5f, 0xbfe58158, 0x8cd5d15f, 0xac7c7f4c,
- 0xf8ba47d2, 0x86c6571d, 0x06a4760b, 0xa6afa0e1,
- 0x7a819f62, 0x5cdbfe15, 0x9b2d10b5, 0xf508b1fd,
- 0xb3f0462a, 0x92f45a64, 0x69b6ec58, 0xbfad8fab,
- 0x6799260f, 0x27415db5, 0xf6ac7832, 0xe547826d,
- 0x6a9806a5, 0x36c62a88, 0x98bee14d, 0x9b8c2648,
- 0xabdbbd3d, 0xaf59eea1, 0x164eacb5, 0x3a18e427};
-
-
- uint32_t exponent[] = {0x2519837b, 0xe73a9031, 0xe241606d, 0x21e70fa2,
- 0x7881f254, 0x4e60831d, 0x266f408e, 0x4a83e6ed,
- 0xa7741995, 0x32b477ba, 0x91bdf5d0, 0x4acd7a06,
- 0x51e344b9, 0xdf376e4e, 0x8494e625, 0xa0cc9697,
- 0x817a0c93, 0x3b68cefb, 0x46de14c1, 0x52229965,
- 0x329645bd, 0xf4176adc, 0x29a8bc50, 0x44900fec,
- 0x1558d492, 0xf838a8e7, 0xea207abd, 0xcd21a28c,
- 0x91e6b02f, 0x2a490ea8, 0x5d99663b, 0x87c92fb6,
- 0x0a185325, 0x5256a7a3, 0x496b7288, 0x6688b6c8,
- 0x650e1776, 0x54cd429f, 0x90ea3b18, 0x0b72ae61,
- 0xcc8651b3, 0xa488742d, 0x93c401ef, 0x5a2220ff,
- 0xaee1f257, 0xf9d1e29a, 0xd47151fe, 0x4978342b,
- 0x0927048a, 0x404b0689, 0xdc9df8cc, 0xfba9845f,
- 0xeb8a39b0, 0xd3f24ae2, 0x5ea9ca0a, 0x0c064f94,
- 0x35368ae2, 0xeab6c035, 0x9baa39c6, 0x2ef6259d,
- 0xa2577555, 0x514c7d98, 0x0890d44f, 0xf416fbdd};
-
-
- uint32_t modulus[] = {0x2c5337a9, 0x3f2e1ca6, 0x91de65ea, 0xc3f9a3c2,
- 0xdc9099e0, 0x64ebe412, 0xf4583fae, 0x1fc8e8dd,
- 0x92dcbbfb, 0x9159239e, 0xdbbec456, 0x8735a660,
- 0x8248dbbc, 0x76f01415, 0x3cb8a897, 0x7cc09280,
- 0x6cc6db51, 0x9c2544da, 0x316564ce, 0x4b6d9b3b,
- 0x3e0e123f, 0x942a4a3c, 0x1f128873, 0x5ad14862,
- 0xdde8e6dd, 0x73da31fb, 0x1a8a2046, 0xc3ff18c6,
- 0x24e31d54, 0x7d8a1796, 0x88ab346c, 0x262bb321,
- 0x2cada5dc, 0x1fb2284c, 0x042375fd, 0xba10d309,
- 0xcda978ec, 0x229ee156, 0x8470728a, 0xa58017fd,
- 0x65727801, 0x1ea396a6, 0xbd9a4bc1, 0x8e97c08f,
- 0xd7529796, 0x2c8339e9, 0xc5340a83, 0x6f7d1f9c,
- 0xd6014fec, 0xdffa2265, 0xfa9906a9, 0xafbd424a,
- 0x631994ae, 0x73a9b3f1, 0x2284f999, 0x6f8c87f6,
- 0x93136a66, 0x47c81e45, 0xd35f0e41, 0x238d6960,
- 0x96cf337d, 0x8865e4cc, 0x15039c40, 0x65ee7211};
-
-
- uint32_t expected[] = {0x24665860, 0x4b150493, 0xc0834602, 0xc0b99ab5,
- 0xbe649545, 0xa7d8b1ca, 0x55c1b98a, 0x1dce374b,
- 0x65750415, 0x573dfed7, 0x95df9943, 0x58a4aea0,
- 0x5fb40a92, 0x1408d9c2, 0xb5e23fc9, 0x225eb60b,
- 0x41d33a41, 0xbf958f7f, 0x619f5ac1, 0x207647f3,
- 0x223e56f8, 0x26afd4ae, 0x6a297840, 0x830947db,
- 0xbc5af940, 0x4c97ebb1, 0xca38b220, 0x04c9a26d,
- 0x49a16b72, 0x0882c658, 0x2dbc50e0, 0x67e2d057,
- 0x4b8ef356, 0x4ba5eac3, 0x17237d9f, 0x27c111a8,
- 0xc1b1944e, 0xe91fd6b6, 0xa78d9747, 0x61e946d3,
- 0x0078fe23, 0x7770a088, 0x6d5762af, 0x435ac5f9,
- 0x36cde9d5, 0xc313804d, 0xa4623760, 0xb1c37572,
- 0x2b22486d, 0x8af131e3, 0x3e5fc3ea, 0x0d9c9ba0,
- 0x218bcc8f, 0x8bcdfea2, 0xcf55a599, 0x57b9fcbc,
- 0x5c087f62, 0xec130a15, 0x7e8bd1f5, 0x60eaaa51,
- 0x020dd89b, 0x890cc6ea, 0x042d0054, 0x74055863};
+ uint32_t exponent[] = {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00010001};
+
+
+ uint32_t modulus[] = {0x00000000, 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[] = {0x00000000, 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[] = {0x00000000, 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};
uint8_t result;
- printf("Running TC9: 2048 bit operands.s\n");
+ printf("=== Running 1024 bit enc/verify test from Robs RSA code. ===\n");
- result = testrunner(64, exponent, 64, modulus, message, expected);
+ result = testrunner(33, exponent, 33, modulus, expected, message);
if (result)
- printf("TC9: OK\n");
+ printf("Rob 1024 enc/verify test OK\n");
else
- printf("TC9: NOT OK\n");
+ printf("Rob 1024 enc/verify test NOT OK\n");
}
@@ -705,15 +723,16 @@ int main(void)
// check_exponent_mem();
// check_message_mem();
- tc1();
- tc2();
- tc3();
- tc4();
- tc5();
- tc6();
- tc7();
- tc8();
- tc9();
+// tc1();
+// tc2();
+// tc3();
+// tc4();
+// tc5();
+// tc6();
+// tc7();
+// tc8();
+ rob_dec_1024();
+ rob_enc_1024();
return 0;
}