RSA Security 5.2.2 If status = secretSharecount == Nullptr != 0 break, Break If status != 0 break

Models: 5.2.2

1 376
Download 376 pages 13.91 Kb
Page 330
Image 330

Secret Sharing

for (count = 0; count < TOTAL_SHARES; ++count) { secretShare[count] = T_malloc (SECRET_SIZE + 1);

if ((status = (secretShare[count] == NULL_PTR)) != 0) break;

if ((status = B_EncryptUpdate (secretSplitter, secretShare[count], &(secretShareLen[count]), SECRET_SIZE + 1, secretKey, SECRET_SIZE, randomAlgorithm, (A_SURRENDER_CTX *)NULL_PTR)) != 0)

break;

}

if (status != 0) break;

Step 5: Final

Finalize the process with B_EncryptFinal. This function does not need a random algorithm, so pass a NULL_PTR. It is a quick call, so it is reasonable to pass a NULL_PTR for the surrender context:

unsigned int outputLenFinal;

if ((status = B_EncryptFinal

(secretSplitter, NULL_PTR, &outputLenFinal, 0, (B_ALGORITHM_OBJ)NULL_PTR, (A_SURRENDER_CTX *)NULL_PTR)) != 0)

Step 6: Destroy

Remember to destroy all objects and free up any allocated memory when you are done. Save the shares to files or disks before freeing the memory:

B_DestroyAlgorithmObject (&secretSplitter); B_DestroyAlgorithmObject (&randomAlgorithm); for (count = 0; count < TOTAL_SHARES; ++count)

T_free (secretShare[count]);

3 0 8

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 330
Image 330
RSA Security 5.2.2 If status = secretSharecount == Nullptr != 0 break, Break If status != 0 break, Tfree secretSharecount