Lect 5
Lect 5
5 6
7 8
What Do Signatures Provide? Two Uses of Public Key Cryptography
Authentication
Same reason as before Sender Receiver
Confidentiality Encrypt using Decrypt using
Integrity receiver’s public key receiver’s private key
(no authentication)
Attacker cannot produce matching digest of tampered
message without correct encryption key Authentication Sign using sender’s Unsign using sender’s
(no confidentiality) private key public key
Confidentiality: No
Plaintext is sent
What if we want both confidentiality and
authentication?
Common signature algorithm: DSA
9 10
Step 3: Add data to the signature object Step 3: Add data to the signature object
final void update(byte[] input) ...
final void update(byte[] input) throws ...
Step 4: Check the signature against the signature to
Step 4: Calculate the signature be verified
final byte[] sign() throws ... final boolean verify(byte[] signature)...
11 12
Signature Based Login StrongClient.java
import Protection; // this class is from last lecture!
Recall we discussed a protected password login public class StrongClient {
system using message digest public void sendAuthentication(String user, PrivateKey key,
OutputStream outStream) throws IOException,
Still, there are problems NoSuchAlgorithmException, InvalidKeyException, SignatureException {
DataOutputStream out = new DataOutputStream(outStream);
People choose easy-to-guess passwords long t1 = (new Date()).getTime();
People write down their passwords double q1 = Math.random();
Signature sig = Signature.getInstance(“DSA”);
Here we consider a program which uses signatures sig.initSign(key);
(public/private key pairs) instead of passwords sig.update(Protection.makeBytes(t1,q1));
byte[] signature = sig.sign();
The client creates a signature of a timestamp and a random
number out.writeUTF(user);
out.writeLong(t1);
The server uses the client’s public key to verify the signature out.writeDouble(q1);
out.writeInt(signature.length);
out.write(signature);
out.flush();
}
13 14
15 16
StrongServer continued Signed Objects
private PublicKey getKey(String user) throws
FileNotFoundException, IOException, ClassNotFoundException {
How to sign an Java object (not just bytes?)
ObjectInputStream keyIn = new ObjectInputStream( Java provides a class
new FileInputStream(“PublicKey.ser”));
PublicKey publicKey = (PublicKey)keyIn.readObject();
java.security.SignedObject that encapsulates
keyIn.close(); (contains) and signs any serializable object
return publicKey;
} // assume hardcoded public key
Create a signed object:
SignedObject(Serializable object, PrivateKey
public static void main(String [] args) throws Exception { signingKey, Signature sigEngine) throws ...
int port = Integer.parseInt(args[1]);
ServerSocket s = new ServerSocket(port); Verify the signature in a signed object:
Socket client = s.accept(); final boolean verify(PublicKey verifyKey,
StrongServer server = new StrongServer(); Signature verifyEngine) throws ...
if (server.authenticate(client.getInputStream())
System.out.println(“Client logged in”); Retrieve the object:
else Object getObject() throws ...
System.out.println(“Client failed to log in”);
s.close();
}}
17 18
19 20
Message with Many Variations Summary
To support authentication and integrity:
MAC: digest + secret key cryptography
Digest computed from message and shared secret value
Signature: digest + public key cryptography
Digest en/decrypted using sender’s private/public keys
Birthday attack (on signatures)
Key idea: create multiple copies of “genuine” and “fraudulent”
documents
Conclusion: Reduce complexity from 2n to ~2n/2
digest need to
be long enough
21 22