Message Digests

Besides support for encryption and decryption, SATSA-CRYPTO contains facilities to create digests that can be used to verify the integrity of encrypted messages. A digest of a message will be unique with a high probability for a given message. Therefore, any modification to the integrity of the message will be detected by verifying the digest of the message.

SATSA-CRYPTO supports multiple digest algorithms using the javax.security.MessageDigest class. Analogous to the Cipher class, MessageDigest cannot be instantiated but instead the getInstance method will return an instance based on the digest algorithm's name. For algorithms supported in your SDK, see the implementation notes for SATSA API.

To calculate a digest, a byte array containing the message is passed to the update method that may be called multiple times if the message is very long. The digest method will finally calculate the digest. For example, to calculate a digest using the SHA-1 algorithm we may do as follows:

MessageDigest digest = MessageDigest.getInstance("SHA-1"); 
digest.update(plaintext, 0, plaintext.length);
byte[] output = new byte[20];
digest.digest(output, 0, output.length)