RSA Security 5.2.2 Projection Television User Manual


 
Secret Sharing
308 RSA BSAFE Crypto-C Developers Guide
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:
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:
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;
unsigned int outputLenFinal;
if ((status = B_EncryptFinal
(secretSplitter, NULL_PTR, &outputLenFinal, 0,
(B_ALGORITHM_OBJ)NULL_PTR,
(A_SURRENDER_CTX *)NULL_PTR)) != 0)
B_DestroyAlgorithmObject (&secretSplitter);
B_DestroyAlgorithmObject (&randomAlgorithm);
for (count = 0; count < TOTAL_SHARES; ++count)
T_free (secretShare[count]);