System Considerations In Crypto-C

if ((int)*handle == 0) {

printf (“\nSurrender function ...\n”); *handle = 1;

time (¤tTime);

}

else {

time (&getTime);

if (currentTime != getTime) { printf “ ."); currentTime = getTime;

}

}

return (0);

}

A routine that calls Crypto-C functions would use the above surrender function as follows:

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;

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 properly 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

1 2 0

R S A B S A F E C r y p t o - C D e v e l o p e r ’s G u i d e

Page 142
Image 142
RSA Security 5.2.2 manual Saving State