RSA Security 5.2.2 Secret Sharing, Example in this section corresponds to the file scrtshar.c

Models: 5.2.2

1 376
Download 376 pages 13.91 Kb
Page 328
Image 328

Secret Sharing

The example in this section corresponds to the file scrtshar.c.

Step 1: Creating An Algorithm Object

Declare a variable to be B_ALGORITHM_OBJ. As defined in the function prototype in Chapter 4 of the Reference Manual, its address is the argument for B_CreateAlgorithmObject:

B_ALGORITHM_OBJ secretSplitter = (B_ALGORITHM_OBJ)NULL_PTR;

if ((status = B_CreateAlgorithmObject (&secretSplitter)) != 0) break;

Step 2: Setting The Algorithm Object

There is only one AI that implements the Bloom-Shamir secret sharing algorithm:

AI_BSSecretSharing. The Reference Manual Chapter 2 entry on this AI reports that the format of info supplied to B_SetAlgorithmInfo is the following struct:

typedef struct

{

 

unsigned int

threshold;

/* share threshold */

}B_SECRET_SHARING_PARAMS;

Because you want to set the threshold to two, set your algorithm object as follows:

B_SECRET_SHARING_PARAMS secretSharingParams; secretSharingParams.threshold = 2;

if ((status = B_SetAlgorithmInfo (secretSplitter, AI_BSSecretSharing, (POINTER)&secretSharingParams)) != 0)

break;

Step 3: Init

Initialize the algorithm with B_EncryptInit. No key is necessary, so pass a properly cast NULL_PTR for the key object. This algorithm object does not need an algorithm chooser, so pass a properly cast NULL_PTR for that argument as well. This function is very quick, so it is reasonable to pass a NULL_PTR for the surrender context:

3 0 6

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 328
Image 328
RSA Security 5.2.2 manual Secret Sharing, Example in this section corresponds to the file scrtshar.c