The X9.31 Sample Program
322 RSA BSAFE Crypto-C Developers Guide
signVerifyParams.encryptionMethodName = (unsigned char *)"rsaSignX931";
signVerifyParams.encryptionParams = NULL_PTR;
signVerifyParams.digestMethodName = (unsigned char *)"sha1";
signVerifyParams.digestParams = NULL_PTR;
signVerifyParams.formatMethodName = (unsigned char *)"formatX931";
signVerifyParams.formatParams = (POINTER)&x931params;
if ((status = B_SetAlgorithmInfo (digitalSigner, AI_SignVerify,
(POINTER)&signVerifyParams)) != 0)
break;
/* Step 3: Init */
/* You must include the appropriate algorithm methods as
specified by the Reference Manual in the
chooser. See the RM entry for AI_SignVerify for that
list. */
if ((status = B_SignInit
(digitalSigner, privateKey, X931_SAMPLE_CHOOSER,
(A_SURRENDER_CTX *)NULL_PTR)) != 0)
break;
/* Step 4: Update -- digest the data to sign */
printf (".......Digesting the input data\n");
if ((status = B_SignUpdate
(digitalSigner, (unsigned char *)inputData, inputDataLen,
(A_SURRENDER_CTX *)NULL_PTR)) != 0)
break;
/* Step 5: Final -- Encrypt the digest and output the result to a
signature buffer */
printf (".......Encrypting the digest (digital signature)\n");
if ((status = B_SignFinal
(digitalSigner, signature, &signatureLen, 64,
(B_ALGORITHM_OBJ)NULL_PTR,
(A_SURRENDER_CTX *)NULL_PTR)) != 0)
break;
printf ("\nThe digital signature (%u bytes): \n", signatureLen);
PrintBuf (signature, signatureLen);