]>
git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/threadTest/cspRand.cpp
3 #include "testParams.h"
4 #include <utilLib/common.h>
7 #include <security_utilities/threading.h>
9 #define INNER_LOOPS 100
12 int cspRandInit(TestParams
*testParams
)
17 int cspRand(TestParams
*testParams
)
21 unsigned char randData
[MAX_SIZE
];
23 for(loopNum
=0; loopNum
<testParams
->numLoops
; loopNum
++) {
25 if(!testParams
->quiet
) {
26 printChar(testParams
->progressChar
);
29 /* pick a rand size for this outer loop using the global devRand */
30 unsigned char randSize
;
32 cdata
.Data
= &randSize
;
34 threadGetRandData(testParams
, &cdata
, 1);
38 for(iLoop
=0; iLoop
<INNER_LOOPS
; iLoop
++) {
39 CSSM_CC_HANDLE rngHand
;
42 crtn
= CSSM_CSP_CreateRandomGenContext(testParams
->cspHand
,
43 CSSM_ALGID_APPLE_YARROW
,
48 printError("CSSM_CSP_CreateRandomGenContext", crtn
);
51 cdata
.Data
= randData
;
52 cdata
.Length
= randSize
;
53 crtn
= CSSM_GenerateRandom(rngHand
, &cdata
);
55 printError("CSSM_GenerateRandom", crtn
);
58 CSSM_DeleteContext(rngHand
);