Add command line argument to enable key par generation test with an invalid public exponent.
Signed-off-by: Ramon de Carvalho Valle <[email protected]> --- testcases/rsa_keygen/rsa_keygen.c | 39 +++++++++++++++++++++--------------- 1 files changed, 23 insertions(+), 16 deletions(-) diff --git a/testcases/rsa_keygen/rsa_keygen.c b/testcases/rsa_keygen/rsa_keygen.c index 8f0465b..44c3aa7 100755 --- a/testcases/rsa_keygen/rsa_keygen.c +++ b/testcases/rsa_keygen/rsa_keygen.c @@ -16,6 +16,7 @@ #include "pkcs11types.h" #include "regress.h" +static int inv_pub_exp = 0; int do_GetFunctionList(void); @@ -102,24 +103,27 @@ do_GenerateRSAKeyPair(CK_ULONG bits) } + if (inv_pub_exp) { // Use an invalid pub exp - { - CK_BYTE pub_exp[] = { 0x1, 0x0, 0x2 }; - - CK_ATTRIBUTE pub_tmpl[] = { - {CKA_MODULUS_BITS, &bits, sizeof(bits) }, - {CKA_PUBLIC_EXPONENT, &pub_exp, sizeof(pub_exp) } - }; + CK_BYTE pub_exp[] = { 0x1, 0x0, 0x2 }; + + CK_ATTRIBUTE pub_tmpl[] = + { + {CKA_MODULUS_BITS, &bits, sizeof(bits) }, + {CKA_PUBLIC_EXPONENT, &pub_exp, sizeof(pub_exp) } + }; + + rc = funcs->C_GenerateKeyPair( session, &mech, + pub_tmpl, 2, + NULL, 0, + &publ_key, &priv_key ); + if (rc != CKR_FUNCTION_FAILED) { + show_error(" C_GenerateKeyPair #3", rc ); + return rc; + } - rc = funcs->C_GenerateKeyPair( session, &mech, - pub_tmpl, 2, - NULL, 0, - &publ_key, &priv_key ); - if (rc != CKR_FUNCTION_FAILED) { - show_error(" C_GenerateKeyPair #3", rc ); - return rc; - } + } } @@ -169,8 +173,11 @@ main( int argc, char **argv ) SLOT_ID = atoi(argv[i]); } + if (strcmp(argv[i], "-i") == 0) + inv_pub_exp = 1; + if (strcmp(argv[i], "-h") == 0) { - printf("usage: %s [-noskip] [-slot <num>] [-h]\n\n", argv[0] ); + printf("usage: %s [-i] [-noskip] [-slot <num>] [-h]\n\n", argv[0] ); printf("By default, Slot #1 is used\n\n"); printf("By default we skip anything that creates or modifies\n"); printf("token objects to preserve flash lifetime.\n"); -- 1.6.3.3 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Opencryptoki-tech mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opencryptoki-tech
