RSA Security 5.2.2 manual Break, If status = BDigestInit

Models: 5.2.2

1 376
Download 376 pages 13.91 Kb
Page 175
Image 175
1 5 3
NULL_PTR

Message Digests

if ((status = B_SetAlgorithmInfo (digester, AI_SHA1, NULL_PTR)) != 0)

break;

Step 3: Init

To initialize a message digest, call B_DigestInit. The Reference Manual Chapter 4 entry on B_DigestInit shows that it requires four arguments. The first argument is the algorithm object. The second is a key object. All Crypto-C message digest AIs call for a properly cast NULL_PTR as the key object; Crypto-C provides this argument for algorithms, like HMAC, that require keys. The third argument is an algorithm chooser. The fourth is a surrender context; this is a fast function, so it is reasonable to pass a properly cast NULL_PTR:

B_ALGORITHM_METHOD *DIGEST_CHOOSER[] = { &AM_SHA,

(B_ALGORITHM_METHOD *)NULL_PTR

};

if ((status = B_DigestInit

(digester, (B_KEY_OBJ)NULL_PTR, DIGEST_CHOOSER, (A_SURRENDER_CTX *)NULL_PTR)) != 0)

break;

Refer to “Saving State” on page 120 for a discussion of how to save the state of the algorithm object for future use.

Step 4: Update

Use B_DigestUpdate to enter the data to digest. If you have separate units of data (for example, two or more files or several strings), make a call to B_DigestUpdate for each unit. Message digesting is quick, so unless you are digesting an extremely large amount of data (a megabyte or more), it is reasonable to pass a properly cast

for the surrender context.

C h a p t e r 5 N o n - C r y p t o g r a p h i c O p e r a t i o n s

Page 175
Image 175
RSA Security 5.2.2 manual Break, If status = BDigestInit