SignatureMessageRecovery Sample

Note:

This sample is available only in bundles intended solely for distribution inside the U.S.

Message recovery refers to the mechanism whereby part of the message used to create the message digest is also included as padding in the signature block. During signature verification, the message data padding does not need to be explicitly sent to the verifying entity, it can automatically be extracted from the signature block.

This sample consists of two scripts representing two scenarios for Signature with Message Recovery. The first script, sigMsgFullRec.scr, shows the scenario in which the message to sign is small enough that the entire message itself becomes part of the signature padding (hence the name "Full Recovery" since you can recover the full message from the signature itself).

The sequence of events resulting from running the first script, sigMsgFullRec.scr, are:

  1. The script sends to the sample application a small message to sign.

  2. The application initializes the signature object with the algorithm Signature.ALG_RSA_SHA_ISO9796_MR and signs the message. Because the message is small enough, the application returns the signature data to the script.

  3. The script then simulates the verification phase in which it sends the signature data to the sample application asking it to verify the message.

    The application recovers the original message from the signature data and also verifies the signature, then returns the original data back to the script. If the signature verification fails, it returns an error code.

The second script, sigMsgPartRec.scr, demonstrates a scenario in which the message to sign is large enough that only some part of it is included in the signature padding (hence the name "Partial Recovery"). The sequence of events resulting from running this script are:

  1. The script sends to the sample application a large message to be signed.

  2. The application initializes the signature object with algorithm Signature.ALG_RSA_SHA_ISO9796_MR and signs the message. Because the message is too large to fit in the signature, the application returns back to the script the number of bytes of original message that is embedded in the signature data. The application also returns back to the script the signature data.

  3. The script then simulates the verification phase in which it sends the signature data to the sample application.

  4. The application recovers the partial message and returns back to the script.

  5. The script sends the remainder of the message to the application to verify the signature.

  6. The application verifies the signature against the entire message and returns success.