The goal with this tutorial is to achieve some familiarity with the
fundamental concepts behind the Java Cryptography Architecture and
provide hands on experience with the APIs and cryptographic primitives
supported in Java.
Laboratory Work
The laboratory work will take you through three classes of cryptographic
primitives: cryptographic hash functions, symmetric cryptography and
asymmetric cryptography (digital signatures.)
For the purpose of this exercise, you should download and use the
file AandB.txt, which is an extract from
"The Alice
and Bob After Dinner Speech" given at the Zurich Seminar,
April 1984, by John Gordon, by invitation of Professor James Massey.
Cryptographic Hash Functions
Write a simple program that calculates the cryptographic hash of the file
"AandB.txt". Try to use at least two different cryptographic
hash functions. A few cryptographic hash values for the files are listed
in the table below.
Write a simple program that generates a symmetric key and encrypts the
file "AandB.txt". Consider encrypting the file using different
modes. Having encrypted the file, you should decrypt it again using the
previously generated key and compare the decrypted file to the original file.
Asymmetric Cryptography
Generate an asymmetric key-pair and use the private key to sign
one of the files that you encrypted above. Then use the public-key to
verify the signature on the file.
You can find information about the
Java Cryptographic Architecture (JCA), which also contains a number of examples.