System Considerations In Crypto-C
120 RSA BSAFE Crypto-C Developers Guide
A routine that calls Crypto-C functions would use the above surrender function as
follows:
For this surrender function, the
handle
contains a flag passed from the user. If
handle
is 0, this is the first time the surrender function has been called by the particular
Crypto-C routine currently executing. Then the surrender function will reset the flag
and the next time it is called, it will skip the if clause and execute the else clause.
The coding examples in this manual use the example in this section as their surrender
context. The examples also note when a routine is lengthy enough to warrant use of a
surrender context. When a surrender context is not necessary, you can pass a p roperly
cast NULL_PTR.
Saving State
Crypto-C v5.1 offers two new functions: B_GetAlgorithmState and
B_SetAlgorithmState. Use these functions to serialize (create and use) an algorithm
if ((int)*handle == 0) {
printf (\nSurrender function ...\n);
*handle = 1;
time (&currentTime);
}
else {
time (&getTime);
if (currentTime != getTime) {
printf .");
currentTime = getTime;
}
}
return (0);
}
A_SURRENDER_CTX generalSurrenderContext;
int generalFlag;
generalSurrenderContext.Surrender = GeneralSurrenderFunction;
generalSurrenderContext.handle = (POINTER)&generalFlag;
generalSurrenderContext.reserved = NULL_PTR;
generalFlag = 0;
if ((status = B_<function>
(<other arguments>, &generalSurrenderContext)) != 0)
break;