SignatureMessageRecovery Sample
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 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:
-
The script sends the sample application a large message to sign.
-
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. -
The script then simulates the verification phase in which it sends the signature data to the sample application.
- The application recovers the partial message and returns back to the script.
- The script sends the remainder of the message to the application to verify the signature.
- The application verifies the signature against the entire message and returns success.
The second script 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 this script are:
-
The script sends the sample application a small message to be signed.
-
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. -
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.