Tutorial 2 - Applied Cryptography

The purpose of this tutorial is to introduce students to practical use of symmetric and asymmetric cryptography techniques. Note: You SHOULD NOT implement cryptography algorithms yourself. Instead, use existing libraries, e.g. java.security and javax.crypto. During the tutorial, a teacher will be present to help with any practical issues that may arise. If you finish the tutorial ahead of time, you are recommended to get started on assignment 2. This tutorial is volountary and your work will not be graded.
    First work individually:
  1. Create a program that can encrypt and decrypt text using symmetric cryptography (AES).
  2. Test your program by encoding and decoding a message.
  3. Create a second program that can:
    • generate key pairs using asymmetric cryptography (RSA),
    • encrypt and decrypt text using asymmetric cryptography (RSA).
  4. Test your program by:
    • generating a key pair,
    • use all four possible combinations of keys (Priv - Pub, Pub - Priv, Pub - Pub, Priv - Priv) for encryption and decryption.
    Questions: which of them work/make sense? What properties so each of them have?

    Next, work in groups of (up to) three people:
  5. Upgrade your second program with the following functions:
    • exporting (your) public key to a file,
    • loading (somebody else’s) public key from a file,
    • exporting (your) encoded message to a file,
    • loading (somebody else’s) encoded message from a file.
  6. Test upgraded version of your second program:
    • first person (P1) generates a key pair using asymmetric cryptography (RSA),
    • P1 exports his/her public key,
    • other persons (P2 and P3) load P1’s public key,
    • each person creates and encodes message (P1 using his/her own private key, P2 and P3 using P1’s public key),
    • each person sends encoded message to another,
    • each person tries to decode each message.
    Question: Who can read what messages?