2 * Simple sign/verify test
4 #include "testParams.h"
5 #include <Security/cssm.h>
9 #include <utilLib/common.h>
10 #include <utilLib/cspwrap.h>
13 /* for memory leak debug only, with only one thread running */
16 #define SIG_ALG CSSM_ALGID_SHA1WithRSA
17 #define KEY_GEN_ALG CSSM_ALGID_RSA
18 #define KEY_SIZE CSP_RSA_KEY_SIZE_DEFAULT
19 #define PTEXT_SIZE 1024
20 #define USAGE_DEF "noUsage"
29 int signVerifyInit(TestParams
*testParams
)
34 TT_SignVfyParams
*svParams
;
36 /* flip coin for ref/blob key forms */
37 if(testParams
->threadNum
& 1) {
39 privIsRef
= CSSM_FALSE
;
42 pubIsRef
= CSSM_FALSE
;
43 privIsRef
= CSSM_TRUE
;
45 svParams
= (TT_SignVfyParams
*)CSSM_MALLOC(sizeof(TT_SignVfyParams
));
46 crtn
= cspGenKeyPair(testParams
->cspHand
,
54 CSSM_KEYBLOB_RAW_FORMAT_NONE
,
58 CSSM_KEYBLOB_RAW_FORMAT_NONE
,
61 printf("***Error generating key pair; aborting\n");
64 svParams
->ptext
.Data
= (uint8
*)CSSM_MALLOC(PTEXT_SIZE
);
65 svParams
->ptext
.Length
= PTEXT_SIZE
;
67 testParams
->perThread
= svParams
;
71 int signVerify(TestParams
*testParams
)
73 TT_SignVfyParams
*svParams
= (TT_SignVfyParams
*)testParams
->perThread
;
78 for(loop
=0; loop
<testParams
->numLoops
; loop
++) {
79 if(testParams
->verbose
) {
80 printf("signVerify thread %d: loop %d\n",
81 testParams
->threadNum
, loop
);
83 else if(!testParams
->quiet
) {
84 printChar(testParams
->progressChar
);
86 crtn
= threadGetRandData(testParams
, &svParams
->ptext
, PTEXT_SIZE
);
92 crtn
= cspSign(testParams
->cspHand
,
100 crtn
= cspSigVerify(testParams
->cspHand
,
109 appFree(sig
.Data
, NULL
);
112 printf("Hit CR to proceed: ");