summaryrefslogtreecommitdiff
path: root/nss/cmd/rsaperf
diff options
context:
space:
mode:
Diffstat (limited to 'nss/cmd/rsaperf')
-rw-r--r--nss/cmd/rsaperf/defkey.c322
-rw-r--r--nss/cmd/rsaperf/rsaperf.c538
-rw-r--r--nss/cmd/rsaperf/rsaperf.gyp36
3 files changed, 476 insertions, 420 deletions
diff --git a/nss/cmd/rsaperf/defkey.c b/nss/cmd/rsaperf/defkey.c
index eedd9f7..3ca366f 100644
--- a/nss/cmd/rsaperf/defkey.c
+++ b/nss/cmd/rsaperf/defkey.c
@@ -13,234 +13,234 @@
#define CONST
static CONST unsigned char default_n1024[128] = {
-0xc2,0xae,0x96,0x89,0xaf,0xce,0xd0,0x7b,0x3b,0x35,0xfd,0x0f,0xb1,0xf4,0x7a,0xd1,
-0x3c,0x7d,0xb5,0x86,0xf2,0x68,0x36,0xc9,0x97,0xe6,0x82,0x94,0x86,0xaa,0x05,0x39,
-0xec,0x11,0x51,0xcc,0x5c,0xa1,0x59,0xba,0x29,0x18,0xf3,0x28,0xf1,0x9d,0xe3,0xae,
-0x96,0x5d,0x6d,0x87,0x73,0xf6,0xf6,0x1f,0xd0,0x2d,0xfb,0x2f,0x7a,0x13,0x7f,0xc8,
-0x0c,0x7a,0xe9,0x85,0xfb,0xce,0x74,0x86,0xf8,0xef,0x2f,0x85,0x37,0x73,0x0f,0x62,
-0x4e,0x93,0x17,0xb7,0x7e,0x84,0x9a,0x94,0x11,0x05,0xca,0x0d,0x31,0x4b,0x2a,0xc8,
-0xdf,0xfe,0xe9,0x0c,0x13,0xc7,0xf2,0xad,0x19,0x64,0x28,0x3c,0xb5,0x6a,0xc8,0x4b,
-0x79,0xea,0x7c,0xce,0x75,0x92,0x45,0x3e,0xa3,0x9d,0x64,0x6f,0x04,0x69,0x19,0x17
+ 0xc2, 0xae, 0x96, 0x89, 0xaf, 0xce, 0xd0, 0x7b, 0x3b, 0x35, 0xfd, 0x0f, 0xb1, 0xf4, 0x7a, 0xd1,
+ 0x3c, 0x7d, 0xb5, 0x86, 0xf2, 0x68, 0x36, 0xc9, 0x97, 0xe6, 0x82, 0x94, 0x86, 0xaa, 0x05, 0x39,
+ 0xec, 0x11, 0x51, 0xcc, 0x5c, 0xa1, 0x59, 0xba, 0x29, 0x18, 0xf3, 0x28, 0xf1, 0x9d, 0xe3, 0xae,
+ 0x96, 0x5d, 0x6d, 0x87, 0x73, 0xf6, 0xf6, 0x1f, 0xd0, 0x2d, 0xfb, 0x2f, 0x7a, 0x13, 0x7f, 0xc8,
+ 0x0c, 0x7a, 0xe9, 0x85, 0xfb, 0xce, 0x74, 0x86, 0xf8, 0xef, 0x2f, 0x85, 0x37, 0x73, 0x0f, 0x62,
+ 0x4e, 0x93, 0x17, 0xb7, 0x7e, 0x84, 0x9a, 0x94, 0x11, 0x05, 0xca, 0x0d, 0x31, 0x4b, 0x2a, 0xc8,
+ 0xdf, 0xfe, 0xe9, 0x0c, 0x13, 0xc7, 0xf2, 0xad, 0x19, 0x64, 0x28, 0x3c, 0xb5, 0x6a, 0xc8, 0x4b,
+ 0x79, 0xea, 0x7c, 0xce, 0x75, 0x92, 0x45, 0x3e, 0xa3, 0x9d, 0x64, 0x6f, 0x04, 0x69, 0x19, 0x17
};
-static CONST unsigned char default_e1024[3] = { 0x01,0x00,0x01 };
+static CONST unsigned char default_e1024[3] = { 0x01, 0x00, 0x01 };
static CONST unsigned char default_d1024[128] = {
-0x13,0xcb,0xbc,0xf2,0xf3,0x35,0x8c,0x6d,0x7b,0x6f,0xd9,0xf3,0xa6,0x9c,0xbd,0x80,
-0x59,0x2e,0x4f,0x2f,0x11,0xa7,0x17,0x2b,0x18,0x8f,0x0f,0xe8,0x1a,0x69,0x5f,0x6e,
-0xac,0x5a,0x76,0x7e,0xd9,0x4c,0x6e,0xdb,0x47,0x22,0x8a,0x57,0x37,0x7a,0x5e,0x94,
-0x7a,0x25,0xb5,0xe5,0x78,0x1d,0x3c,0x99,0xaf,0x89,0x7d,0x69,0x2e,0x78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x63, 0x40, 0xb5, 0x8a, 0xc3, 0x01
};
static CONST unsigned char default_p1024[64] = {
-0xf6,0x3c,0x3f,0x56,0x58,0x4f,0xb3,0x82,0x0c,0xf0,0x5b,0x42,0x36,0x1c,0x93,0xde,
-0x9b,0x32,0x01,0xb1,0x48,0xf8,0x00,0x57,0x9b,0xc1,0xbe,0x66,0xc2,0xbb,0xea,0x7c,
-0x75,0x29,0x2c,0x22,0xaa,0x7c,0xaf,0xbd,0x0d,0x3f,0xb0,0x64,0x97,0xf0,0x88,0x25,
-0xcb,0x8d,0xc7,0x19,0x0a,0x75,0x44,0xa4,0x5a,0xc3,0xb5,0xb9,0x85,0xea,0x27,0xa7
+ 0xf6, 0x3c, 0x3f, 0x56, 0x58, 0x4f, 0xb3, 0x82, 0x0c, 0xf0, 0x5b, 0x42, 0x36, 0x1c, 0x93, 0xde,
+ 0x9b, 0x32, 0x01, 0xb1, 0x48, 0xf8, 0x00, 0x57, 0x9b, 0xc1, 0xbe, 0x66, 0xc2, 0xbb, 0xea, 0x7c,
+ 0x75, 0x29, 0x2c, 0x22, 0xaa, 0x7c, 0xaf, 0xbd, 0x0d, 0x3f, 0xb0, 0x64, 0x97, 0xf0, 0x88, 0x25,
+ 0xcb, 0x8d, 0xc7, 0x19, 0x0a, 0x75, 0x44, 0xa4, 0x5a, 0xc3, 0xb5, 0xb9, 0x85, 0xea, 0x27, 0xa7
};
static CONST unsigned char default_q1024[64] = {
-0xca,0x66,0xfa,0x18,0x6a,0x46,0x36,0x1c,0x46,0xfe,0x47,0xe9,0x7e,0x52,0x83,0x8a,
-0xbb,0x72,0x13,0xcc,0x83,0x56,0x3d,0x64,0x22,0xdd,0xfa,0x7c,0x61,0x99,0xea,0xa4,
-0xb3,0x0e,0x8f,0x79,0x10,0xab,0xba,0x4a,0x73,0xd1,0x48,0x40,0x34,0x34,0xd3,0xd2,
-0x54,0x92,0xbe,0xf5,0xc8,0xc4,0x60,0x5f,0xd3,0xf7,0xce,0xbe,0x60,0x3e,0xb1,0x11
+ 0xca, 0x66, 0xfa, 0x18, 0x6a, 0x46, 0x36, 0x1c, 0x46, 0xfe, 0x47, 0xe9, 0x7e, 0x52, 0x83, 0x8a,
+ 0xbb, 0x72, 0x13, 0xcc, 0x83, 0x56, 0x3d, 0x64, 0x22, 0xdd, 0xfa, 0x7c, 0x61, 0x99, 0xea, 0xa4,
+ 0xb3, 0x0e, 0x8f, 0x79, 0x10, 0xab, 0xba, 0x4a, 0x73, 0xd1, 0x48, 0x40, 0x34, 0x34, 0xd3, 0xd2,
+ 0x54, 0x92, 0xbe, 0xf5, 0xc8, 0xc4, 0x60, 0x5f, 0xd3, 0xf7, 0xce, 0xbe, 0x60, 0x3e, 0xb1, 0x11
};
static CONST unsigned char default_dModP1024[64] = {
-0x8e,0x80,0xbf,0x87,0x11,0x04,0xcf,0x36,0x6c,0x96,0x8d,0xb9,0xfb,0xe6,0xfe,0x0c,
-0xce,0x74,0x5a,0x56,0x67,0x8c,0x5f,0x66,0x54,0x56,0x04,0x03,0x24,0x9f,0xec,0x4c,
-0xaa,0xe1,0x71,0x11,0x7e,0xe9,0x3a,0x2b,0x87,0x07,0x5c,0xe6,0x5a,0xa8,0x71,0xa2,
-0xad,0xf3,0x17,0x4e,0x7e,0xa6,0xef,0x5a,0xce,0xcc,0x84,0xd7,0x21,0x91,0x29,0xf1
+ 0x8e, 0x80, 0xbf, 0x87, 0x11, 0x04, 0xcf, 0x36, 0x6c, 0x96, 0x8d, 0xb9, 0xfb, 0xe6, 0xfe, 0x0c,
+ 0xce, 0x74, 0x5a, 0x56, 0x67, 0x8c, 0x5f, 0x66, 0x54, 0x56, 0x04, 0x03, 0x24, 0x9f, 0xec, 0x4c,
+ 0xaa, 0xe1, 0x71, 0x11, 0x7e, 0xe9, 0x3a, 0x2b, 0x87, 0x07, 0x5c, 0xe6, 0x5a, 0xa8, 0x71, 0xa2,
+ 0xad, 0xf3, 0x17, 0x4e, 0x7e, 0xa6, 0xef, 0x5a, 0xce, 0xcc, 0x84, 0xd7, 0x21, 0x91, 0x29, 0xf1
};
static CONST unsigned char default_dModQ1024[64] = {
-0x87,0x60,0x1d,0x02,0xdb,0x82,0x1e,0x8b,0x07,0x48,0xe8,0x5c,0x59,0xeb,0x62,0xa4,
-0x15,0xff,0x95,0x12,0x82,0xfd,0xd9,0x8d,0xf2,0x6c,0x3a,0x2f,0x9b,0x30,0x51,0x6a,
-0xdb,0x80,0x6f,0xa1,0xef,0xee,0x8c,0x69,0x63,0xd1,0xa4,0xdb,0x9c,0x8f,0x80,0xe5,
-0xfb,0x3f,0x33,0x8e,0x3d,0x3c,0x6b,0xa1,0x6c,0xab,0x20,0x92,0xe0,0xd8,0xcd,0xa1
+ 0x87, 0x60, 0x1d, 0x02, 0xdb, 0x82, 0x1e, 0x8b, 0x07, 0x48, 0xe8, 0x5c, 0x59, 0xeb, 0x62, 0xa4,
+ 0x15, 0xff, 0x95, 0x12, 0x82, 0xfd, 0xd9, 0x8d, 0xf2, 0x6c, 0x3a, 0x2f, 0x9b, 0x30, 0x51, 0x6a,
+ 0xdb, 0x80, 0x6f, 0xa1, 0xef, 0xee, 0x8c, 0x69, 0x63, 0xd1, 0xa4, 0xdb, 0x9c, 0x8f, 0x80, 0xe5,
+ 0xfb, 0x3f, 0x33, 0x8e, 0x3d, 0x3c, 0x6b, 0xa1, 0x6c, 0xab, 0x20, 0x92, 0xe0, 0xd8, 0xcd, 0xa1
};
static CONST unsigned char default_qInvModP1024[64] = {
-0xce,0xcf,0x5a,0xad,0xc4,0x8c,0x44,0x91,0x3a,0xbc,0x7b,0xf8,0x80,0xf8,0x53,0xf5,
-0x12,0x84,0x8c,0x9c,0x6b,0x33,0x93,0x0d,0xa1,0x11,0xea,0xfa,0x4a,0xc1,0xeb,0x48,
-0xdc,0x44,0x86,0x93,0x1b,0x98,0xc7,0x82,0x22,0x68,0x30,0x44,0xd7,0x62,0x1b,0x90,
-0x54,0x07,0x4b,0x66,0xa7,0xc5,0x75,0x5a,0x72,0x77,0x92,0xdd,0x6c,0xf3,0x37,0xab
+ 0xce, 0xcf, 0x5a, 0xad, 0xc4, 0x8c, 0x44, 0x91, 0x3a, 0xbc, 0x7b, 0xf8, 0x80, 0xf8, 0x53, 0xf5,
+ 0x12, 0x84, 0x8c, 0x9c, 0x6b, 0x33, 0x93, 0x0d, 0xa1, 0x11, 0xea, 0xfa, 0x4a, 0xc1, 0xeb, 0x48,
+ 0xdc, 0x44, 0x86, 0x93, 0x1b, 0x98, 0xc7, 0x82, 0x22, 0x68, 0x30, 0x44, 0xd7, 0x62, 0x1b, 0x90,
+ 0x54, 0x07, 0x4b, 0x66, 0xa7, 0xc5, 0x75, 0x5a, 0x72, 0x77, 0x92, 0xdd, 0x6c, 0xf3, 0x37, 0xab
};
static CONST unsigned char default_n2048[256] = {
-0xb3,0x9b,0x57,0x2c,0x15,0xdf,0x6c,0x6b,0xfc,0x04,0x83,0x02,0xf5,0xb3,0x2c,0x87,
-0x1b,0x9c,0xbf,0x6c,0x46,0x1d,0xdd,0xe2,0xc0,0x6d,0xfe,0xf9,0x00,0xd1,0x85,0x91,
-0x17,0x0d,0x43,0x67,0xa1,0x1f,0x8b,0xcd,0x22,0x8a,0x93,0xdc,0x9f,0xf0,0x45,0x9e,
-0x58,0x0f,0x99,0x87,0xe6,0x60,0xdf,0x8c,0x1a,0xa3,0x8f,0xc3,0x6c,0xa0,0x49,0x3a,
-0xdb,0x7f,0xd0,0xda,0x48,0x47,0xe3,0xd6,0x1f,0x29,0xcb,0xf2,0x1d,0xf3,0x81,0xd0,
-0x4d,0xf1,0x64,0xcf,0x42,0x8e,0x0f,0xe0,0x10,0x18,0x4c,0x75,0xce,0x96,0x09,0x2e,
-0x52,0xa6,0x96,0xa9,0xe1,0xab,0x3e,0x6f,0xa5,0xd3,0xee,0xd8,0xb2,0x4f,0x17,0x08,
-0x6d,0x43,0xd4,0xb3,0x1c,0x8a,0x4a,0x43,0x06,0xb5,0xab,0xfb,0xf4,0x34,0x2f,0x2f,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0xde, 0x2f, 0x1b, 0xbb, 0x44, 0xa7, 0x12, 0x2c, 0x9d
};
-static CONST unsigned char default_e2048[3] = { 0x01,0x00,0x01 };
+static CONST unsigned char default_e2048[3] = { 0x01, 0x00, 0x01 };
static CONST unsigned char default_d2048[256] = {
-0x0f,0x03,0x3f,0x08,0x1a,0x53,0xf0,0x96,0x1e,0x1c,0xaa,0x6e,0xc6,0xe6,0xd1,0x24,
-0x01,0xf4,0xda,0x33,0x4c,0xb1,0x16,0x68,0xeb,0xb8,0xc6,0x05,0x3e,0x42,0x45,0x2d,
-0xd9,0x85,0x6c,0x4a,0xef,0x36,0xd9,0xd2,0xad,0xbe,0x73,0x99,0x8f,0x6c,0xe0,0x04,
-0xda,0x4b,0x83,0x83,0xce,0x87,0xee,0x67,0xa1,0x9a,0x66,0x5b,0xe9,0x6a,0x84,0x74,
-0x7d,0x00,0x74,0x0e,0xaa,0xd8,0x07,0x7d,0x50,0x61,0x88,0x00,0x96,0xec,0x51,0xbf,
-0x7d,0xa4,0x5d,0xce,0xcd,0x3b,0x5e,0xac,0x55,0xec,0x12,0x08,0x0e,0xda,0x8f,0xad,
-0xe5,0x8e,0xb3,0x2d,0x44,0x05,0xb2,0x54,0x56,0xc2,0x1e,0x46,0xd2,0xb0,0xb5,0xb6,
-0x28,0x9b,0xf0,0xdd,0x7f,0xd7,0x37,0x59,0xde,0xe7,0xb4,0x96,0x7c,0xd5,0x17,0xd4,
-0x7e,0xe0,0xcb,0xb3,0x3c,0x5f,0x72,0x30,0xbe,0x3c,0x81,0x82,0x8e,0xb9,0xc6,0xa7,
-0x23,0x71,0xf5,0x6f,0xd7,0x56,0xe4,0xee,0x3b,0x2d,0x8f,0x3e,0x43,0x98,0xc8,0xe8,
-0x95,0xfd,0xc3,0x73,0xd3,0x8e,0x38,0x01,0xa5,0xc6,0xbe,0x0c,0x6b,0x6b,0x4f,0x13,
-0x2f,0x66,0x8b,0x85,0xe3,0x9e,0x12,0xc0,0x52,0x60,0xec,0x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xd4, 0x70, 0xf8, 0x4b, 0x09, 0x71, 0xa8, 0xbe, 0xca, 0x0d, 0x68, 0x16, 0x5f
};
static CONST unsigned char default_q2048[128] = {
-0xd5,0x32,0x38,0x82,0x14,0xed,0xd1,0x90,0x51,0xef,0x17,0xa2,0x9b,0xc3,0xb0,0x45,
-0x86,0x64,0xbe,0xce,0x8f,0x85,0x78,0x18,0x7a,0xf8,0x3a,0xb7,0x17,0x7b,0x5d,0xf3,
-0xe9,0xd7,0x9d,0xb3,0x2f,0x96,0x35,0x96,0x60,0x38,0xe7,0x96,0xc3,0x08,0xe6,0xf1,
-0xb8,0x16,0xc0,0x1d,0xc9,0x6f,0xd3,0x99,0x14,0x8e,0xd3,0x6a,0x2b,0x6c,0x4d,0xd1,
-0x71,0x1c,0x4c,0x38,0x72,0x18,0x23,0xf9,0xd1,0x6c,0xa2,0x87,0xfe,0x33,0xc2,0x9d,
-0x6e,0xd0,0x80,0x62,0x44,0x7b,0x3a,0x4d,0x2f,0xff,0x5f,0x73,0xe5,0x53,0x32,0x18,
-0x14,0xb2,0xdb,0x6b,0x25,0x7b,0xac,0xb4,0x3b,0x1e,0x5e,0xcd,0xec,0x01,0x99,0xdb,
-0x0c,0x1f,0xc2,0xa6,0x50,0x1d,0x6d,0x7b,0x58,0x75,0x04,0x89,0x5d,0x87,0x86,0x83
+ 0xd5, 0x32, 0x38, 0x82, 0x14, 0xed, 0xd1, 0x90, 0x51, 0xef, 0x17, 0xa2, 0x9b, 0xc3, 0xb0, 0x45,
+ 0x86, 0x64, 0xbe, 0xce, 0x8f, 0x85, 0x78, 0x18, 0x7a, 0xf8, 0x3a, 0xb7, 0x17, 0x7b, 0x5d, 0xf3,
+ 0xe9, 0xd7, 0x9d, 0xb3, 0x2f, 0x96, 0x35, 0x96, 0x60, 0x38, 0xe7, 0x96, 0xc3, 0x08, 0xe6, 0xf1,
+ 0xb8, 0x16, 0xc0, 0x1d, 0xc9, 0x6f, 0xd3, 0x99, 0x14, 0x8e, 0xd3, 0x6a, 0x2b, 0x6c, 0x4d, 0xd1,
+ 0x71, 0x1c, 0x4c, 0x38, 0x72, 0x18, 0x23, 0xf9, 0xd1, 0x6c, 0xa2, 0x87, 0xfe, 0x33, 0xc2, 0x9d,
+ 0x6e, 0xd0, 0x80, 0x62, 0x44, 0x7b, 0x3a, 0x4d, 0x2f, 0xff, 0x5f, 0x73, 0xe5, 0x53, 0x32, 0x18,
+ 0x14, 0xb2, 0xdb, 0x6b, 0x25, 0x7b, 0xac, 0xb4, 0x3b, 0x1e, 0x5e, 0xcd, 0xec, 0x01, 0x99, 0xdb,
+ 0x0c, 0x1f, 0xc2, 0xa6, 0x50, 0x1d, 0x6d, 0x7b, 0x58, 0x75, 0x04, 0x89, 0x5d, 0x87, 0x86, 0x83
};
static CONST unsigned char default_dModP2048[128] = {
-0xc0,0xba,0x16,0x1b,0xc1,0x3e,0xc8,0x51,0xb3,0x22,0x21,0xf7,0x54,0x66,0x14,0xa7,
-0x17,0xdc,0x15,0xb4,0x31,0x16,0x0e,0x39,0xa4,0x6a,0x96,0x88,0x11,0x98,0xf7,0xe4,
-0xc2,0x87,0xa2,0x57,0x83,0xfe,0x67,0x41,0x83,0xae,0x3e,0x73,0x7d,0xaf,0xe5,0x33,
-0x4d,0x00,0x70,0xaa,0xda,0x3f,0xc8,0xd6,0xd6,0xd7,0x0b,0x4a,0xff,0x63,0x09,0x01,
-0x22,0xca,0x71,0x86,0xd0,0xad,0x96,0xf1,0xb9,0x66,0x43,0x71,0x88,0xba,0x53,0x14,
-0xfb,0xd3,0xe4,0x5c,0x3f,0xfd,0xf6,0x22,0x6f,0x01,0x1c,0x2c,0xb9,0x76,0xad,0xf9,
-0x09,0x96,0x3e,0x9c,0x0e,0x70,0xec,0x06,0xba,0x36,0x69,0xbb,0x00,0x93,0x53,0xd5,
-0xc0,0x08,0x18,0xa5,0xcc,0x46,0xb6,0x97,0xbb,0xf0,0x76,0x7f,0x0d,0xb8,0x04,0xb5
+ 0xc0, 0xba, 0x16, 0x1b, 0xc1, 0x3e, 0xc8, 0x51, 0xb3, 0x22, 0x21, 0xf7, 0x54, 0x66, 0x14, 0xa7,
+ 0x17, 0xdc, 0x15, 0xb4, 0x31, 0x16, 0x0e, 0x39, 0xa4, 0x6a, 0x96, 0x88, 0x11, 0x98, 0xf7, 0xe4,
+ 0xc2, 0x87, 0xa2, 0x57, 0x83, 0xfe, 0x67, 0x41, 0x83, 0xae, 0x3e, 0x73, 0x7d, 0xaf, 0xe5, 0x33,
+ 0x4d, 0x00, 0x70, 0xaa, 0xda, 0x3f, 0xc8, 0xd6, 0xd6, 0xd7, 0x0b, 0x4a, 0xff, 0x63, 0x09, 0x01,
+ 0x22, 0xca, 0x71, 0x86, 0xd0, 0xad, 0x96, 0xf1, 0xb9, 0x66, 0x43, 0x71, 0x88, 0xba, 0x53, 0x14,
+ 0xfb, 0xd3, 0xe4, 0x5c, 0x3f, 0xfd, 0xf6, 0x22, 0x6f, 0x01, 0x1c, 0x2c, 0xb9, 0x76, 0xad, 0xf9,
+ 0x09, 0x96, 0x3e, 0x9c, 0x0e, 0x70, 0xec, 0x06, 0xba, 0x36, 0x69, 0xbb, 0x00, 0x93, 0x53, 0xd5,
+ 0xc0, 0x08, 0x18, 0xa5, 0xcc, 0x46, 0xb6, 0x97, 0xbb, 0xf0, 0x76, 0x7f, 0x0d, 0xb8, 0x04, 0xb5
};
static CONST unsigned char default_dModQ2048[128] = {
-0xa9,0x18,0xfd,0x43,0x07,0xf0,0x9d,0x50,0x77,0xfc,0x48,0xe5,0xdb,0xe0,0x39,0xd6,
-0xdb,0x42,0xdb,0x28,0xa1,0x23,0x7e,0xdf,0x03,0xe2,0x11,0x48,0x19,0xa2,0xeb,0x21,
-0x44,0xaf,0x95,0x50,0x83,0x85,0x03,0x99,0xf3,0x56,0x0f,0x32,0x40,0x1d,0xb6,0x77,
-0xb0,0xc8,0xb2,0xb6,0xad,0x88,0x39,0xef,0xe8,0x23,0x64,0xc2,0x88,0x10,0x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ef, 0xea, 0x9b
};
static CONST unsigned char default_qInvModP2048[128] = {
-0x77,0xd9,0x45,0xd4,0xd2,0xd1,0x46,0xa8,0xaf,0x57,0x8f,0x5e,0x4f,0x6b,0x24,0x0f,
-0xb4,0xaa,0xff,0x92,0x86,0x78,0xa8,0xc1,0x69,0x9c,0x54,0xe9,0x81,0xa1,0x9c,0x26,
-0x11,0x5d,0xfa,0xff,0x70,0x9e,0xa3,0xf3,0xe3,0x78,0x41,0x2b,0x31,0x35,0x09,0xa2,
-0x5c,0x5f,0x6e,0x4d,0xad,0xeb,0x4a,0xe0,0xb1,0xce,0x2c,0x22,0x59,0x72,0x4c,0x17,
-0xad,0x71,0x5c,0x25,0xca,0x4f,0x00,0xc6,0xee,0x63,0x10,0x8e,0xf7,0xbe,0xa4,0x55,
-0x22,0x0d,0x2c,0xb9,0xe5,0xa9,0x72,0x07,0xa2,0xb1,0x29,0xf2,0x4a,0x9f,0xde,0x70,
-0x0c,0x28,0xb7,0x60,0x12,0x9d,0x4b,0x04,0xd7,0xe3,0xd7,0xc5,0x71,0xdf,0x5c,0xc0,
-0x65,0x75,0x6e,0xfb,0xc6,0x3e,0x61,0x4c,0xc2,0xdf,0xb3,0xd3,0xba,0x17,0x36,0x24
+ 0x77, 0xd9, 0x45, 0xd4, 0xd2, 0xd1, 0x46, 0xa8, 0xaf, 0x57, 0x8f, 0x5e, 0x4f, 0x6b, 0x24, 0x0f,
+ 0xb4, 0xaa, 0xff, 0x92, 0x86, 0x78, 0xa8, 0xc1, 0x69, 0x9c, 0x54, 0xe9, 0x81, 0xa1, 0x9c, 0x26,
+ 0x11, 0x5d, 0xfa, 0xff, 0x70, 0x9e, 0xa3, 0xf3, 0xe3, 0x78, 0x41, 0x2b, 0x31, 0x35, 0x09, 0xa2,
+ 0x5c, 0x5f, 0x6e, 0x4d, 0xad, 0xeb, 0x4a, 0xe0, 0xb1, 0xce, 0x2c, 0x22, 0x59, 0x72, 0x4c, 0x17,
+ 0xad, 0x71, 0x5c, 0x25, 0xca, 0x4f, 0x00, 0xc6, 0xee, 0x63, 0x10, 0x8e, 0xf7, 0xbe, 0xa4, 0x55,
+ 0x22, 0x0d, 0x2c, 0xb9, 0xe5, 0xa9, 0x72, 0x07, 0xa2, 0xb1, 0x29, 0xf2, 0x4a, 0x9f, 0xde, 0x70,
+ 0x0c, 0x28, 0xb7, 0x60, 0x12, 0x9d, 0x4b, 0x04, 0xd7, 0xe3, 0xd7, 0xc5, 0x71, 0xdf, 0x5c, 0xc0,
+ 0x65, 0x75, 0x6e, 0xfb, 0xc6, 0x3e, 0x61, 0x4c, 0xc2, 0xdf, 0xb3, 0xd3, 0xba, 0x17, 0x36, 0x24
};
static struct NSSLOWKEYPrivateKeyStr rsaPriv;
-NSSLOWKEYPrivateKey *
+NSSLOWKEYPrivateKey*
getDefaultRSAPrivateKey(int keysize)
{
if (rsaPriv.keyType != NSSLOWKEYRSAKey) {
- /* leaving arena uninitialized. It isn't used in this test. */
+ /* leaving arena uninitialized. It isn't used in this test. */
- rsaPriv.keyType = NSSLOWKEYRSAKey;
+ rsaPriv.keyType = NSSLOWKEYRSAKey;
- /* leaving arena uninitialized. It isn't used. */
- /* leaving version uninitialized. It isn't used. */
+ /* leaving arena uninitialized. It isn't used. */
+ /* leaving version uninitialized. It isn't used. */
if (keysize == 2048) {
- rsaPriv.u.rsa.modulus.data = default_n2048;
- rsaPriv.u.rsa.modulus.len = sizeof default_n2048;
- rsaPriv.u.rsa.publicExponent.data = default_e2048;
- rsaPriv.u.rsa.publicExponent.len = sizeof default_e2048;
- rsaPriv.u.rsa.privateExponent.data = default_d2048;
- rsaPriv.u.rsa.privateExponent.len = sizeof default_d2048;
- rsaPriv.u.rsa.prime1.data = default_p2048;
- rsaPriv.u.rsa.prime1.len = sizeof default_p2048;
- rsaPriv.u.rsa.prime2.data = default_q2048;
- rsaPriv.u.rsa.prime2.len = sizeof default_q2048;
- rsaPriv.u.rsa.exponent1.data = default_dModP2048;
- rsaPriv.u.rsa.exponent1.len = sizeof default_dModP2048;
- rsaPriv.u.rsa.exponent2.data = default_dModQ2048;
- rsaPriv.u.rsa.exponent2.len = sizeof default_dModQ2048;
- rsaPriv.u.rsa.coefficient.data = default_qInvModP2048;
- rsaPriv.u.rsa.coefficient.len = sizeof default_qInvModP2048;
- } else {
- rsaPriv.u.rsa.modulus.data = default_n1024;
- rsaPriv.u.rsa.modulus.len = sizeof default_n1024;
- rsaPriv.u.rsa.publicExponent.data = default_e1024;
- rsaPriv.u.rsa.publicExponent.len = sizeof default_e1024;
- rsaPriv.u.rsa.privateExponent.data = default_d1024;
- rsaPriv.u.rsa.privateExponent.len = sizeof default_d1024;
- rsaPriv.u.rsa.prime1.data = default_p1024;
- rsaPriv.u.rsa.prime1.len = sizeof default_p1024;
- rsaPriv.u.rsa.prime2.data = default_q1024;
- rsaPriv.u.rsa.prime2.len = sizeof default_q1024;
- rsaPriv.u.rsa.exponent1.data = default_dModP1024;
- rsaPriv.u.rsa.exponent1.len = sizeof default_dModP1024;
- rsaPriv.u.rsa.exponent2.data = default_dModQ1024;
- rsaPriv.u.rsa.exponent2.len = sizeof default_dModQ1024;
- rsaPriv.u.rsa.coefficient.data = default_qInvModP1024;
- rsaPriv.u.rsa.coefficient.len = sizeof default_qInvModP1024;
- }
+ rsaPriv.u.rsa.modulus.data = default_n2048;
+ rsaPriv.u.rsa.modulus.len = sizeof default_n2048;
+ rsaPriv.u.rsa.publicExponent.data = default_e2048;
+ rsaPriv.u.rsa.publicExponent.len = sizeof default_e2048;
+ rsaPriv.u.rsa.privateExponent.data = default_d2048;
+ rsaPriv.u.rsa.privateExponent.len = sizeof default_d2048;
+ rsaPriv.u.rsa.prime1.data = default_p2048;
+ rsaPriv.u.rsa.prime1.len = sizeof default_p2048;
+ rsaPriv.u.rsa.prime2.data = default_q2048;
+ rsaPriv.u.rsa.prime2.len = sizeof default_q2048;
+ rsaPriv.u.rsa.exponent1.data = default_dModP2048;
+ rsaPriv.u.rsa.exponent1.len = sizeof default_dModP2048;
+ rsaPriv.u.rsa.exponent2.data = default_dModQ2048;
+ rsaPriv.u.rsa.exponent2.len = sizeof default_dModQ2048;
+ rsaPriv.u.rsa.coefficient.data = default_qInvModP2048;
+ rsaPriv.u.rsa.coefficient.len = sizeof default_qInvModP2048;
+ } else {
+ rsaPriv.u.rsa.modulus.data = default_n1024;
+ rsaPriv.u.rsa.modulus.len = sizeof default_n1024;
+ rsaPriv.u.rsa.publicExponent.data = default_e1024;
+ rsaPriv.u.rsa.publicExponent.len = sizeof default_e1024;
+ rsaPriv.u.rsa.privateExponent.data = default_d1024;
+ rsaPriv.u.rsa.privateExponent.len = sizeof default_d1024;
+ rsaPriv.u.rsa.prime1.data = default_p1024;
+ rsaPriv.u.rsa.prime1.len = sizeof default_p1024;
+ rsaPriv.u.rsa.prime2.data = default_q1024;
+ rsaPriv.u.rsa.prime2.len = sizeof default_q1024;
+ rsaPriv.u.rsa.exponent1.data = default_dModP1024;
+ rsaPriv.u.rsa.exponent1.len = sizeof default_dModP1024;
+ rsaPriv.u.rsa.exponent2.data = default_dModQ1024;
+ rsaPriv.u.rsa.exponent2.len = sizeof default_dModQ1024;
+ rsaPriv.u.rsa.coefficient.data = default_qInvModP1024;
+ rsaPriv.u.rsa.coefficient.len = sizeof default_qInvModP1024;
+ }
}
return &rsaPriv;
}
static struct NSSLOWKEYPublicKeyStr rsaPub;
-NSSLOWKEYPublicKey *
+NSSLOWKEYPublicKey*
getDefaultRSAPublicKey(int keysize)
{
if (rsaPub.keyType != NSSLOWKEYRSAKey) {
- rsaPub.keyType = NSSLOWKEYRSAKey;
+ rsaPub.keyType = NSSLOWKEYRSAKey;
if (keysize == 2048) {
- rsaPub.u.rsa.modulus.data = default_n2048;
- rsaPub.u.rsa.modulus.len = sizeof default_n2048;
+ rsaPub.u.rsa.modulus.data = default_n2048;
+ rsaPub.u.rsa.modulus.len = sizeof default_n2048;
- rsaPub.u.rsa.publicExponent.data = default_e2048;
- rsaPub.u.rsa.publicExponent.len = sizeof default_e2048;
- } else {
- rsaPub.u.rsa.modulus.data = default_n1024;
- rsaPub.u.rsa.modulus.len = sizeof default_n1024;
+ rsaPub.u.rsa.publicExponent.data = default_e2048;
+ rsaPub.u.rsa.publicExponent.len = sizeof default_e2048;
+ } else {
+ rsaPub.u.rsa.modulus.data = default_n1024;
+ rsaPub.u.rsa.modulus.len = sizeof default_n1024;
- rsaPub.u.rsa.publicExponent.data = default_e1024;
- rsaPub.u.rsa.publicExponent.len = sizeof default_e1024;
- }
+ rsaPub.u.rsa.publicExponent.data = default_e1024;
+ rsaPub.u.rsa.publicExponent.len = sizeof default_e1024;
+ }
}
return &rsaPub;
}
diff --git a/nss/cmd/rsaperf/rsaperf.c b/nss/cmd/rsaperf/rsaperf.c
index 5550376..556030f 100644
--- a/nss/cmd/rsaperf/rsaperf.c
+++ b/nss/cmd/rsaperf/rsaperf.c
@@ -12,18 +12,17 @@
#include "lowkeyi.h"
#include "pk11pub.h"
-
-#define DEFAULT_ITERS 10
-#define DEFAULT_DURATION 10
-#define DEFAULT_KEY_BITS 1024
-#define MIN_KEY_BITS 512
-#define MAX_KEY_BITS 65536
-#define BUFFER_BYTES MAX_KEY_BITS / 8
-#define DEFAULT_THREADS 1
-#define DEFAULT_EXPONENT 0x10001
-
-extern NSSLOWKEYPrivateKey * getDefaultRSAPrivateKey(void);
-extern NSSLOWKEYPublicKey * getDefaultRSAPublicKey(void);
+#define DEFAULT_ITERS 10
+#define DEFAULT_DURATION 10
+#define DEFAULT_KEY_BITS 1024
+#define MIN_KEY_BITS 512
+#define MAX_KEY_BITS 65536
+#define BUFFER_BYTES MAX_KEY_BITS / 8
+#define DEFAULT_THREADS 1
+#define DEFAULT_EXPONENT 0x10001
+
+extern NSSLOWKEYPrivateKey *getDefaultRSAPrivateKey(void);
+extern NSSLOWKEYPublicKey *getDefaultRSAPublicKey(void);
secuPWData pwData = { PW_NONE, NULL };
@@ -34,32 +33,40 @@ struct TimingContextStr {
PRTime end;
PRTime interval;
- long days;
- int hours;
- int minutes;
- int seconds;
- int millisecs;
+ long days;
+ int hours;
+ int minutes;
+ int seconds;
+ int millisecs;
};
-TimingContext *CreateTimingContext(void) {
+TimingContext *
+CreateTimingContext(void)
+{
return PORT_Alloc(sizeof(TimingContext));
}
-void DestroyTimingContext(TimingContext *ctx) {
+void
+DestroyTimingContext(TimingContext *ctx)
+{
PORT_Free(ctx);
}
-void TimingBegin(TimingContext *ctx, PRTime begin) {
+void
+TimingBegin(TimingContext *ctx, PRTime begin)
+{
ctx->start = begin;
}
-static void timingUpdate(TimingContext *ctx) {
+static void
+timingUpdate(TimingContext *ctx)
+{
PRInt64 tmp, remaining;
- PRInt64 L1000,L60,L24;
+ PRInt64 L1000, L60, L24;
- LL_I2L(L1000,1000);
- LL_I2L(L60,60);
- LL_I2L(L24,24);
+ LL_I2L(L1000, 1000);
+ LL_I2L(L60, 60);
+ LL_I2L(L24, 24);
LL_DIV(remaining, ctx->interval, L1000);
LL_MOD(tmp, remaining, L1000);
@@ -77,14 +84,18 @@ static void timingUpdate(TimingContext *ctx) {
LL_L2I(ctx->days, remaining);
}
-void TimingEnd(TimingContext *ctx, PRTime end) {
+void
+TimingEnd(TimingContext *ctx, PRTime end)
+{
ctx->end = end;
LL_SUB(ctx->interval, ctx->end, ctx->start);
PORT_Assert(LL_GE_ZERO(ctx->interval));
timingUpdate(ctx);
}
-void TimingDivide(TimingContext *ctx, int divisor) {
+void
+TimingDivide(TimingContext *ctx, int divisor)
+{
PRInt64 tmp;
LL_I2L(tmp, divisor);
@@ -93,33 +104,38 @@ void TimingDivide(TimingContext *ctx, int divisor) {
timingUpdate(ctx);
}
-char *TimingGenerateString(TimingContext *ctx) {
+char *
+TimingGenerateString(TimingContext *ctx)
+{
char *buf = NULL;
if (ctx->days != 0) {
- buf = PR_sprintf_append(buf, "%d days", ctx->days);
+ buf = PR_sprintf_append(buf, "%d days", ctx->days);
}
if (ctx->hours != 0) {
- if (buf != NULL) buf = PR_sprintf_append(buf, ", ");
- buf = PR_sprintf_append(buf, "%d hours", ctx->hours);
+ if (buf != NULL)
+ buf = PR_sprintf_append(buf, ", ");
+ buf = PR_sprintf_append(buf, "%d hours", ctx->hours);
}
if (ctx->minutes != 0) {
- if (buf != NULL) buf = PR_sprintf_append(buf, ", ");
- buf = PR_sprintf_append(buf, "%d minutes", ctx->minutes);
+ if (buf != NULL)
+ buf = PR_sprintf_append(buf, ", ");
+ buf = PR_sprintf_append(buf, "%d minutes", ctx->minutes);
}
- if (buf != NULL) buf = PR_sprintf_append(buf, ", and ");
+ if (buf != NULL)
+ buf = PR_sprintf_append(buf, ", and ");
if (!buf && ctx->seconds == 0) {
- int interval;
- LL_L2I(interval, ctx->interval);
- if (ctx->millisecs < 100)
- buf = PR_sprintf_append(buf, "%d microseconds", interval);
- else
- buf = PR_sprintf_append(buf, "%d milliseconds", ctx->millisecs);
+ int interval;
+ LL_L2I(interval, ctx->interval);
+ if (ctx->millisecs < 100)
+ buf = PR_sprintf_append(buf, "%d microseconds", interval);
+ else
+ buf = PR_sprintf_append(buf, "%d milliseconds", ctx->millisecs);
} else if (ctx->millisecs == 0) {
- buf = PR_sprintf_append(buf, "%d seconds", ctx->seconds);
+ buf = PR_sprintf_append(buf, "%d seconds", ctx->seconds);
} else {
- buf = PR_sprintf_append(buf, "%d.%03d seconds",
- ctx->seconds, ctx->millisecs);
+ buf = PR_sprintf_append(buf, "%d.%03d seconds",
+ ctx->seconds, ctx->millisecs);
}
return buf;
}
@@ -128,19 +144,20 @@ void
Usage(char *progName)
{
fprintf(stderr, "Usage: %s [-s | -e] [-i iterations | -p period] "
- "[-t threads]\n[-n none [-k keylength] [ [-g] -x exponent] |\n"
- " -n token:nickname [-d certdir] [-w password] |\n"
- " -h token [-d certdir] [-w password] [-g] [-k keylength] "
- "[-x exponent] [-f pwfile]\n",
- progName);
+ "[-t threads]\n[-n none [-k keylength] [ [-g] -x exponent] |\n"
+ " -n token:nickname [-d certdir] [-w password] |\n"
+ " -h token [-d certdir] [-w password] [-g] [-k keylength] "
+ "[-x exponent] [-f pwfile]\n",
+ progName);
fprintf(stderr, "%-20s Cert database directory (default is ~/.netscape)\n",
- "-d certdir");
+ "-d certdir");
fprintf(stderr, "%-20s How many operations to perform\n", "-i iterations");
fprintf(stderr, "%-20s How many seconds to run\n", "-p period");
fprintf(stderr, "%-20s Perform signing (private key) operations\n", "-s");
- fprintf(stderr, "%-20s Perform encryption (public key) operations\n","-e");
+ fprintf(stderr, "%-20s Perform encryption (public key) operations\n", "-e");
fprintf(stderr, "%-20s Nickname of certificate or key, prefixed "
- "by optional token name\n", "-n nickname");
+ "by optional token name\n",
+ "-n nickname");
fprintf(stderr, "%-20s PKCS#11 token to perform operation with.\n",
"-h token");
fprintf(stderr, "%-20s key size in bits, from %d to %d\n", "-k keylength",
@@ -155,7 +172,7 @@ Usage(char *progName)
}
static void
-dumpBytes( unsigned char * b, int l)
+dumpBytes(unsigned char *b, int l)
{
int i;
if (l <= 0)
@@ -172,54 +189,55 @@ dumpBytes( unsigned char * b, int l)
}
static void
-dumpItem( SECItem * item, const char * description)
+dumpItem(SECItem *item, const char *description)
{
if (item->len & 1 && item->data[0] == 0) {
- printf("%s: (%d bytes)\n", description, item->len - 1);
- dumpBytes(item->data + 1, item->len - 1);
+ printf("%s: (%d bytes)\n", description, item->len - 1);
+ dumpBytes(item->data + 1, item->len - 1);
} else {
- printf("%s: (%d bytes)\n", description, item->len);
- dumpBytes(item->data, item->len);
+ printf("%s: (%d bytes)\n", description, item->len);
+ dumpBytes(item->data, item->len);
}
}
void
-printPrivKey(NSSLOWKEYPrivateKey * privKey)
+printPrivKey(NSSLOWKEYPrivateKey *privKey)
{
RSAPrivateKey *rsa = &privKey->u.rsa;
- dumpItem( &rsa->modulus, "n");
- dumpItem( &rsa->publicExponent, "e");
- dumpItem( &rsa->privateExponent, "d");
- dumpItem( &rsa->prime1, "P");
- dumpItem( &rsa->prime2, "Q");
- dumpItem( &rsa->exponent1, "d % (P-1)");
- dumpItem( &rsa->exponent2, "d % (Q-1)");
- dumpItem( &rsa->coefficient, "(Q ** -1) % P");
+ dumpItem(&rsa->modulus, "n");
+ dumpItem(&rsa->publicExponent, "e");
+ dumpItem(&rsa->privateExponent, "d");
+ dumpItem(&rsa->prime1, "P");
+ dumpItem(&rsa->prime2, "Q");
+ dumpItem(&rsa->exponent1, "d % (P-1)");
+ dumpItem(&rsa->exponent2, "d % (Q-1)");
+ dumpItem(&rsa->coefficient, "(Q ** -1) % P");
puts("");
}
-typedef SECStatus (* RSAOp)(void * key,
- unsigned char * output,
- unsigned char * input);
+typedef SECStatus (*RSAOp)(void *key,
+ unsigned char *output,
+ unsigned char *input);
typedef struct {
- SECKEYPublicKey* pubKey;
- SECKEYPrivateKey* privKey;
+ SECKEYPublicKey *pubKey;
+ SECKEYPrivateKey *privKey;
} PK11Keys;
-
-SECStatus PK11_PublicKeyOp (SECKEYPublicKey* key,
- unsigned char * output,
- unsigned char * input)
+SECStatus
+PK11_PublicKeyOp(SECKEYPublicKey *key,
+ unsigned char *output,
+ unsigned char *input)
{
return PK11_PubEncryptRaw(key, output, input, key->u.rsa.modulus.len,
NULL);
}
-SECStatus PK11_PrivateKeyOp (PK11Keys* keys,
- unsigned char * output,
- unsigned char * input)
+SECStatus
+PK11_PrivateKeyOp(PK11Keys *keys,
+ unsigned char *output,
+ unsigned char *input)
{
unsigned outLen = 0;
return PK11_PrivDecryptRaw(keys->privKey,
@@ -230,21 +248,21 @@ SECStatus PK11_PrivateKeyOp (PK11Keys* keys,
typedef struct ThreadRunDataStr ThreadRunData;
struct ThreadRunDataStr {
- const PRBool *doIters;
- const void *rsaKey;
+ const PRBool *doIters;
+ const void *rsaKey;
const unsigned char *buf;
- RSAOp fn;
- int seconds;
- long iters;
- long iterRes;
- PRErrorCode errNum;
- SECStatus status;
+ RSAOp fn;
+ int seconds;
+ long iters;
+ long iterRes;
+ PRErrorCode errNum;
+ SECStatus status;
};
-
-void ThreadExecFunction(void *data)
+void
+ThreadExecFunction(void *data)
{
- ThreadRunData *tdata = (ThreadRunData*)data;
+ ThreadRunData *tdata = (ThreadRunData *)data;
unsigned char buf2[BUFFER_BYTES];
tdata->status = SECSuccess;
@@ -252,8 +270,8 @@ void ThreadExecFunction(void *data)
long i = tdata->iters;
tdata->iterRes = 0;
while (i--) {
- SECStatus rv = tdata->fn((void*)tdata->rsaKey, buf2,
- (unsigned char*)tdata->buf);
+ SECStatus rv = tdata->fn((void *)tdata->rsaKey, buf2,
+ (unsigned char *)tdata->buf);
if (rv != SECSuccess) {
tdata->errNum = PORT_GetError();
tdata->status = rv;
@@ -266,8 +284,8 @@ void ThreadExecFunction(void *data)
PRIntervalTime start = PR_IntervalNow();
tdata->iterRes = 0;
while (PR_IntervalNow() - start < total) {
- SECStatus rv = tdata->fn((void*)tdata->rsaKey, buf2,
- (unsigned char*)tdata->buf);
+ SECStatus rv = tdata->fn((void *)tdata->rsaKey, buf2,
+ (unsigned char *)tdata->buf);
if (rv != SECSuccess) {
tdata->errNum = PORT_GetError();
tdata->status = rv;
@@ -278,152 +296,154 @@ void ThreadExecFunction(void *data)
}
}
-#define INT_ARG(arg,def) atol(arg)>0?atol(arg):def
+#define INT_ARG(arg, def) atol(arg) > 0 ? atol(arg) : def
int
main(int argc, char **argv)
{
- TimingContext * timeCtx = NULL;
- SECKEYPublicKey * pubHighKey = NULL;
- SECKEYPrivateKey * privHighKey = NULL;
- NSSLOWKEYPrivateKey * privKey = NULL;
- NSSLOWKEYPublicKey * pubKey = NULL;
- CERTCertificate * cert = NULL;
- char * progName = NULL;
- char * secDir = NULL;
- char * nickname = NULL;
- char * slotname = NULL;
- long keybits = 0;
- RSAOp fn;
- void * rsaKey = NULL;
- PLOptState * optstate;
- PLOptStatus optstatus;
- long iters = DEFAULT_ITERS;
- int i;
- PRBool doPriv = PR_FALSE;
- PRBool doPub = PR_FALSE;
- int rv;
- unsigned char buf[BUFFER_BYTES];
- unsigned char buf2[BUFFER_BYTES];
- int seconds = DEFAULT_DURATION;
- PRBool doIters = PR_FALSE;
- PRBool doTime = PR_FALSE;
- PRBool useTokenKey = PR_FALSE; /* use PKCS#11 token
+ TimingContext *timeCtx = NULL;
+ SECKEYPublicKey *pubHighKey = NULL;
+ SECKEYPrivateKey *privHighKey = NULL;
+ NSSLOWKEYPrivateKey *privKey = NULL;
+ NSSLOWKEYPublicKey *pubKey = NULL;
+ CERTCertificate *cert = NULL;
+ char *progName = NULL;
+ char *secDir = NULL;
+ char *nickname = NULL;
+ char *slotname = NULL;
+ long keybits = 0;
+ RSAOp fn;
+ void *rsaKey = NULL;
+ PLOptState *optstate;
+ PLOptStatus optstatus;
+ long iters = DEFAULT_ITERS;
+ int i;
+ PRBool doPriv = PR_FALSE;
+ PRBool doPub = PR_FALSE;
+ int rv;
+ unsigned char buf[BUFFER_BYTES];
+ unsigned char buf2[BUFFER_BYTES];
+ int seconds = DEFAULT_DURATION;
+ PRBool doIters = PR_FALSE;
+ PRBool doTime = PR_FALSE;
+ PRBool useTokenKey = PR_FALSE; /* use PKCS#11 token
object key */
- PRBool useSessionKey = PR_FALSE; /* use PKCS#11 session
+ PRBool useSessionKey = PR_FALSE; /* use PKCS#11 session
object key */
- PRBool useBLKey = PR_FALSE; /* use freebl */
- PK11SlotInfo* slot = NULL; /* slot for session
+ PRBool useBLKey = PR_FALSE; /* use freebl */
+ PK11SlotInfo *slot = NULL; /* slot for session
object key operations */
- PRBool doKeyGen = PR_FALSE;
- int publicExponent = DEFAULT_EXPONENT;
+ PRBool doKeyGen = PR_FALSE;
+ int publicExponent = DEFAULT_EXPONENT;
PK11Keys keys;
int peCount = 0;
CK_BYTE pubEx[4];
SECItem pe;
- RSAPublicKey pubKeyStr;
- int threadNum = DEFAULT_THREADS;
- ThreadRunData ** runDataArr = NULL;
- PRThread ** threadsArr = NULL;
- int calcThreads = 0;
+ RSAPublicKey pubKeyStr;
+ int threadNum = DEFAULT_THREADS;
+ ThreadRunData **runDataArr = NULL;
+ PRThread **threadsArr = NULL;
+ int calcThreads = 0;
progName = strrchr(argv[0], '/');
if (!progName)
- progName = strrchr(argv[0], '\\');
- progName = progName ? progName+1 : argv[0];
+ progName = strrchr(argv[0], '\\');
+ progName = progName ? progName + 1 : argv[0];
optstate = PL_CreateOptState(argc, argv, "d:ef:gh:i:k:n:p:st:w:x:");
while ((optstatus = PL_GetNextOpt(optstate)) == PL_OPT_OK) {
- switch (optstate->option) {
- case '?':
- Usage(progName);
- break;
- case 'd':
- secDir = PORT_Strdup(optstate->value);
- break;
- case 'i':
- iters = INT_ARG(optstate->value, DEFAULT_ITERS);
- doIters = PR_TRUE;
- break;
- case 's':
- doPriv = PR_TRUE;
- break;
- case 'e':
- doPub = PR_TRUE;
- break;
- case 'g':
- doKeyGen = PR_TRUE;
- break;
- case 'n':
- nickname = PORT_Strdup(optstate->value);
- /* for compatibility, nickname of "none" means go to freebl */
- if (nickname && strcmp(nickname, "none")) {
- useTokenKey = PR_TRUE;
- } else {
- useBLKey = PR_TRUE;
- }
- break;
- case 'p':
- seconds = INT_ARG(optstate->value, DEFAULT_DURATION);
- doTime = PR_TRUE;
- break;
- case 'h':
- slotname = PORT_Strdup(optstate->value);
- useSessionKey = PR_TRUE;
- break;
- case 'k':
- keybits = INT_ARG(optstate->value, DEFAULT_KEY_BITS);
- break;
- case 'w':
- pwData.data = PORT_Strdup(optstate->value);;
- pwData.source = PW_PLAINTEXT;
- break;
- case 'f':
- pwData.data = PORT_Strdup(optstate->value);
- pwData.source = PW_FROMFILE;
- break;
- case 'x':
- /* -x public exponent (for RSA keygen) */
- publicExponent = INT_ARG(optstate->value, DEFAULT_EXPONENT);
- break;
- case 't':
- threadNum = INT_ARG(optstate->value, DEFAULT_THREADS);
- break;
- }
+ switch (optstate->option) {
+ case '?':
+ Usage(progName);
+ break;
+ case 'd':
+ secDir = PORT_Strdup(optstate->value);
+ break;
+ case 'i':
+ iters = INT_ARG(optstate->value, DEFAULT_ITERS);
+ doIters = PR_TRUE;
+ break;
+ case 's':
+ doPriv = PR_TRUE;
+ break;
+ case 'e':
+ doPub = PR_TRUE;
+ break;
+ case 'g':
+ doKeyGen = PR_TRUE;
+ break;
+ case 'n':
+ nickname = PORT_Strdup(optstate->value);
+ /* for compatibility, nickname of "none" means go to freebl */
+ if (nickname && strcmp(nickname, "none")) {
+ useTokenKey = PR_TRUE;
+ } else {
+ useBLKey = PR_TRUE;
+ }
+ break;
+ case 'p':
+ seconds = INT_ARG(optstate->value, DEFAULT_DURATION);
+ doTime = PR_TRUE;
+ break;
+ case 'h':
+ slotname = PORT_Strdup(optstate->value);
+ useSessionKey = PR_TRUE;
+ break;
+ case 'k':
+ keybits = INT_ARG(optstate->value, DEFAULT_KEY_BITS);
+ break;
+ case 'w':
+ pwData.data = PORT_Strdup(optstate->value);
+ ;
+ pwData.source = PW_PLAINTEXT;
+ break;
+ case 'f':
+ pwData.data = PORT_Strdup(optstate->value);
+ pwData.source = PW_FROMFILE;
+ break;
+ case 'x':
+ /* -x public exponent (for RSA keygen) */
+ publicExponent = INT_ARG(optstate->value, DEFAULT_EXPONENT);
+ break;
+ case 't':
+ threadNum = INT_ARG(optstate->value, DEFAULT_THREADS);
+ break;
+ }
}
if (optstatus == PL_OPT_BAD)
- Usage(progName);
+ Usage(progName);
if ((doPriv && doPub) || (doIters && doTime) ||
((useTokenKey + useSessionKey + useBLKey) != PR_TRUE) ||
(useTokenKey && keybits) || (useTokenKey && doKeyGen) ||
- (keybits && (keybits<MIN_KEY_BITS || keybits>MAX_KEY_BITS))) {
+ (keybits && (keybits < MIN_KEY_BITS || keybits > MAX_KEY_BITS))) {
Usage(progName);
}
- if (doIters && doTime) Usage(progName);
+ if (doIters && doTime)
+ Usage(progName);
if (!doTime) {
doIters = PR_TRUE;
}
- PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1);
+ PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1);
PK11_SetPasswordFunc(SECU_GetModulePassword);
secDir = SECU_ConfigDirectory(secDir);
if (useTokenKey || useSessionKey) {
- rv = NSS_Init(secDir);
- if (rv != SECSuccess) {
- fprintf(stderr, "NSS_Init failed.\n");
- exit(1);
- }
+ rv = NSS_Init(secDir);
+ if (rv != SECSuccess) {
+ fprintf(stderr, "NSS_Init failed.\n");
+ exit(1);
+ }
} else {
- rv = NSS_NoDB_Init(NULL);
- if (rv != SECSuccess) {
- fprintf(stderr, "NSS_NoDB_Init failed.\n");
- exit(1);
- }
+ rv = NSS_NoDB_Init(NULL);
+ if (rv != SECSuccess) {
+ fprintf(stderr, "NSS_NoDB_Init failed.\n");
+ exit(1);
+ }
}
if (useTokenKey) {
@@ -444,8 +464,8 @@ main(int argc, char **argv)
if (doPub) {
/* do public key ops */
fn = (RSAOp)PK11_PublicKeyOp;
- rsaKey = (void *) pubHighKey;
-
+ rsaKey = (void *)pubHighKey;
+
kh = PK11_ImportPublicKey(cert->slot, pubHighKey, PR_FALSE);
if (CK_INVALID_HANDLE == kh) {
fprintf(stderr,
@@ -464,21 +484,21 @@ main(int argc, char **argv)
"Can't find private key by name \"%s\"\n", nickname);
exit(1);
}
-
+
SECKEY_CacheStaticFlags(privHighKey);
fn = (RSAOp)PK11_PrivateKeyOp;
keys.privKey = privHighKey;
keys.pubKey = pubHighKey;
- rsaKey = (void *) &keys;
+ rsaKey = (void *)&keys;
printf("Using PKCS#11 for RSA decryption with token %s.\n",
PK11_GetTokenName(privHighKey->pkcs11Slot));
- }
+ }
} else
- if (useSessionKey) {
+ if (useSessionKey) {
/* use PKCS#11 session key objects */
- PK11RSAGenParams rsaparams;
- void * params;
+ PK11RSAGenParams rsaparams;
+ void *params;
slot = PK11_FindSlotByName(slotname); /* locate target slot */
if (!slot) {
@@ -498,11 +518,11 @@ main(int argc, char **argv)
rsaparams.pe = publicExponent;
params = &rsaparams;
- fprintf(stderr,"\nGenerating RSA key. This may take a few moments.\n");
+ fprintf(stderr, "\nGenerating RSA key. This may take a few moments.\n");
privHighKey = PK11_GenerateKeyPair(slot, CKM_RSA_PKCS_KEY_PAIR_GEN,
params, &pubHighKey, PR_FALSE,
- PR_FALSE, (void*)&pwData);
+ PR_FALSE, (void *)&pwData);
if (!privHighKey) {
fprintf(stderr,
"Key generation failed in token \"%s\"\n",
@@ -511,22 +531,22 @@ main(int argc, char **argv)
}
SECKEY_CacheStaticFlags(privHighKey);
-
- fprintf(stderr,"Keygen completed.\n");
+
+ fprintf(stderr, "Keygen completed.\n");
if (doPub) {
/* do public key operations */
fn = (RSAOp)PK11_PublicKeyOp;
- rsaKey = (void *) pubHighKey;
+ rsaKey = (void *)pubHighKey;
} else {
/* do private key operations */
fn = (RSAOp)PK11_PrivateKeyOp;
keys.privKey = privHighKey;
keys.pubKey = pubHighKey;
- rsaKey = (void *) &keys;
- }
+ rsaKey = (void *)&keys;
+ }
} else
-
+
{
/* use freebl directly */
if (!keybits) {
@@ -539,13 +559,14 @@ main(int argc, char **argv)
}
printf("Using freebl with %ld bits key.\n", keybits);
if (doKeyGen) {
- fprintf(stderr,"\nGenerating RSA key. "
- "This may take a few moments.\n");
- for (i=0; i < 4; i++) {
+ fprintf(stderr, "\nGenerating RSA key. "
+ "This may take a few moments.\n");
+ for (i = 0; i < 4; i++) {
if (peCount || (publicExponent & ((unsigned long)0xff000000L >>
- (i*8)))) {
- pubEx[peCount] = (CK_BYTE)((publicExponent >>
- (3-i)*8) & 0xff);
+ (i * 8)))) {
+ pubEx[peCount] = (CK_BYTE)((publicExponent >>
+ (3 - i) * 8) &
+ 0xff);
peCount++;
}
}
@@ -554,7 +575,7 @@ main(int argc, char **argv)
pe.type = siBuffer;
rsaKey = RSA_NewKey(keybits, &pe);
- fprintf(stderr,"Keygen completed.\n");
+ fprintf(stderr, "Keygen completed.\n");
} else {
/* use a hardcoded key */
printf("Using hardcoded %ld bits key.\n", keybits);
@@ -571,9 +592,9 @@ main(int argc, char **argv)
if (rsaKey) {
/* convert the RSAPrivateKey to RSAPublicKey */
pubKeyStr.arena = NULL;
- pubKeyStr.modulus = ((RSAPrivateKey*)rsaKey)->modulus;
+ pubKeyStr.modulus = ((RSAPrivateKey *)rsaKey)->modulus;
pubKeyStr.publicExponent =
- ((RSAPrivateKey*)rsaKey)->publicExponent;
+ ((RSAPrivateKey *)rsaKey)->publicExponent;
rsaKey = &pubKeyStr;
} else {
/* convert NSSLOWKeyPublicKey to RSAPublicKey */
@@ -594,65 +615,64 @@ main(int argc, char **argv)
memset(buf, 1, sizeof buf);
rv = fn(rsaKey, buf2, buf);
if (rv != SECSuccess) {
- PRErrorCode errNum;
- const char * errStr = NULL;
-
- errNum = PORT_GetError();
- if (errNum)
- errStr = SECU_Strerror(errNum);
- else
- errNum = rv;
- if (!errStr)
- errStr = "(null)";
- fprintf(stderr, "Error in RSA operation: %d : %s\n", errNum, errStr);
- exit(1);
+ PRErrorCode errNum;
+ const char *errStr = NULL;
+
+ errNum = PORT_GetError();
+ if (errNum)
+ errStr = SECU_Strerror(errNum);
+ else
+ errNum = rv;
+ if (!errStr)
+ errStr = "(null)";
+ fprintf(stderr, "Error in RSA operation: %d : %s\n", errNum, errStr);
+ exit(1);
}
- threadsArr = (PRThread**)PORT_Alloc(threadNum*sizeof(PRThread*));
- runDataArr = (ThreadRunData**)PORT_Alloc(threadNum*sizeof(ThreadRunData*));
+ threadsArr = (PRThread **)PORT_Alloc(threadNum * sizeof(PRThread *));
+ runDataArr = (ThreadRunData **)PORT_Alloc(threadNum * sizeof(ThreadRunData *));
timeCtx = CreateTimingContext();
TimingBegin(timeCtx, PR_Now());
- for (i = 0;i < threadNum;i++) {
- runDataArr[i] = (ThreadRunData*)PORT_Alloc(sizeof(ThreadRunData));
+ for (i = 0; i < threadNum; i++) {
+ runDataArr[i] = (ThreadRunData *)PORT_Alloc(sizeof(ThreadRunData));
runDataArr[i]->fn = fn;
runDataArr[i]->buf = buf;
runDataArr[i]->doIters = &doIters;
runDataArr[i]->rsaKey = rsaKey;
runDataArr[i]->seconds = seconds;
runDataArr[i]->iters = iters;
- threadsArr[i] =
+ threadsArr[i] =
PR_CreateThread(PR_USER_THREAD,
- ThreadExecFunction,
- (void*) runDataArr[i],
- PR_PRIORITY_NORMAL,
- PR_GLOBAL_THREAD,
- PR_JOINABLE_THREAD,
- 0);
+ ThreadExecFunction,
+ (void *)runDataArr[i],
+ PR_PRIORITY_NORMAL,
+ PR_GLOBAL_THREAD,
+ PR_JOINABLE_THREAD,
+ 0);
}
iters = 0;
calcThreads = 0;
- for (i = 0;i < threadNum;i++, calcThreads++)
- {
+ for (i = 0; i < threadNum; i++, calcThreads++) {
PR_JoinThread(threadsArr[i]);
if (runDataArr[i]->status != SECSuccess) {
- const char * errStr = SECU_Strerror(runDataArr[i]->errNum);
+ const char *errStr = SECU_Strerror(runDataArr[i]->errNum);
fprintf(stderr, "Thread %d: Error in RSA operation: %d : %s\n",
i, runDataArr[i]->errNum, errStr);
calcThreads -= 1;
} else {
iters += runDataArr[i]->iterRes;
}
- PORT_Free((void*)runDataArr[i]);
+ PORT_Free((void *)runDataArr[i]);
}
PORT_Free(runDataArr);
PORT_Free(threadsArr);
TimingEnd(timeCtx, PR_Now());
-
+
printf("%ld iterations in %s\n",
- iters, TimingGenerateString(timeCtx));
- printf("%.2f operations/s .\n", ((double)(iters)*(double)1000000.0) /
- (double)timeCtx->interval );
+ iters, TimingGenerateString(timeCtx));
+ printf("%.2f operations/s .\n", ((double)(iters) * (double)1000000.0) /
+ (double)timeCtx->interval);
TimingDivide(timeCtx, iters);
printf("one operation every %s\n", TimingGenerateString(timeCtx));
@@ -661,7 +681,7 @@ main(int argc, char **argv)
}
if (privHighKey) {
- SECKEY_DestroyPrivateKey(privHighKey);
+ SECKEY_DestroyPrivateKey(privHighKey);
}
if (cert) {
diff --git a/nss/cmd/rsaperf/rsaperf.gyp b/nss/cmd/rsaperf/rsaperf.gyp
new file mode 100644
index 0000000..8ca4b4c
--- /dev/null
+++ b/nss/cmd/rsaperf/rsaperf.gyp
@@ -0,0 +1,36 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+{
+ 'includes': [
+ '../../coreconf/config.gypi',
+ '../../cmd/platlibs.gypi'
+ ],
+ 'targets': [
+ {
+ 'target_name': 'rsaperf',
+ 'type': 'executable',
+ 'sources': [
+ 'defkey.c',
+ 'rsaperf.c'
+ ],
+ 'dependencies': [
+ '<(DEPTH)/exports.gyp:dbm_exports',
+ '<(DEPTH)/exports.gyp:nss_exports',
+ '<(DEPTH)/lib/sqlite/sqlite.gyp:sqlite3'
+ ]
+ }
+ ],
+ 'target_defaults': {
+ 'include_dirs': [
+ '../../nss/lib/softoken'
+ ],
+ 'defines': [
+ 'NSS_USE_STATIC_LIBS'
+ ]
+ },
+ 'variables': {
+ 'module': 'nss',
+ 'use_static_libs': 1
+ }
+} \ No newline at end of file