170 likes | 295 Views
Previous lecture. Practical things about the course. Example of cryptosystem — substitution cipher. Symmetric vs. asymmetric cryptography. RSA — keys, encryption, decryption. (Proof of correctness not part of course.). This lecture. Block ciphers Modes of operations First assignment
E N D
Previous lecture • Practical things about the course. • Example of cryptosystem — substitution cipher. • Symmetric vs. asymmetric cryptography. • RSA — keys, encryption, decryption. (Proof of correctness not part of course.) Mårten Trolin
This lecture • Block ciphers • Modes of operations • First assignment • Hash functions • Digital signatures Mårten Trolin
Block ciphers • A block cipher B is an encryption function Ekey:{0,1}k {0,1}l and a decryption function Dkey:{0,1}l {0,1}k such thatDkey(Ekey(m)) = m. • The value k is called block length. Usually k = l. • Commonly used block ciphers include DES, 3DES and IDEA. Clear (plain) text Cipher text Key Mårten Trolin
Chaining ciphers • What happens when the clear text is longer than the block length k? • Most simple solution — encrypt each block separately. • This mode is called ECB, Electronic Code Book Clear text Key Enc Enc Enc Enc Cipher text Mårten Trolin
Problems with ECB • The main problem with ECB is that an adversary can change order or remove blocks without detection. • The solution — link the encrypted blocks to each other. • Most common option — Cipher Block Chaining, CBC Mårten Trolin
Cipher Block Chaining • A feedback is introduced to link the blocks together Clear text IV Key Enc Enc Enc Enc Cipher text Mårten Trolin
Cipher Block Chaining, cont. • Let Ekey be the encryption function, Dkey be the decryption function, Pi block i of the clear text and Ci block i of the cipher text, i = 1, 2, 3... • Encryption of block i: Ci = Ekey(Pi Ci-1) where C0 = IV (initialization vector) • Decryption of block i: Pi =Ci-1 Dkey(Ci) • The Initialization Vector, IV = C0, must be known to both parties and can be sent in clear. Mårten Trolin
First assignment • Implement encryption and decryption using your favourite block cipher (DES, 3DES, IDEA etc) for two modes (e.g., ECB and CBC) with a usable (not necessarily user-friendly!) command-line interface. • Use an existing crypto library for the block cipher, but implement the chaining yourself! • Examples of possible crypto libraries to use: openssl (for C) or JSSE (for Java). • You can get a maximum of four points for the exam from this assignment. Mårten Trolin
Rules for the assignment • Choose your favourite language! • If you pick another language than C, C++, Pascal or Java, or another platform than UNIX/Linux or Windows/DOS, please contact me first! • Solve the assignment either individually or in pairs. • Hand in the solution no later than March 5th. You lose one point per day if you hand in late. You can hand in your solution • By email to marten@nada.kth.se. • On a diskette at the lecture • As a link to a site that I can reach Mårten Trolin
Rules for the assignment, cont. • Please include • source code • executable • a brief description of the interface (just enough so that I can run it) • contact information • the amount of time you spent on the assignment (not used for grading, just to tune the difficulty of the assignments) Mårten Trolin
Rules for the assignment, cont. • Co-operation between groups is allowed only on a conceptual level • Example of things you may discuss: Is it easier to solve the assignment in Java than C? What is a good format to provide the key? Is this input format reasonable? • Example of things you may not discuss: Please show me your code so I can copy part of it! • Please state the persons you have discussed the solution with. • You may be asked to explain your solution orally. Mårten Trolin
Hash functions • A hash function computes a fixed length value from a variable length source • Example: Check sums in communication protocols • Indices in databases • More convenient to handle a hash of a document instead of the document itself • We will consider cryptographically secure hash functions. Mårten Trolin
Hash functions, definition • A hash function is a function f:{0,1}* {0,1}n. • The size of the output, n, is a property of the function. Common values are 128, 160 and 256. • Commonly used hash functions are MD5, SHA and SHA-1 Mårten Trolin
Hash function — examples • f(m) = first 40 bits of m • f(m) = last 40 bits of m • f(m) = XOR of the bytes of m Mårten Trolin
Properties of good hash functions • Let H be a hash function • One-way • Given v, unfeasible to compute an x such that H(v) = x • Collision-free • Unfeasible to find x1 and x2 such that H(x1) = H(x2) Mårten Trolin
Digital signatures • Used to ensure authenticity. • A digital signatures binds a document to a person. • In a public key infrastructure (PKI), a person produces a digital signature using his private key • The signature can be verified using the public key. Mårten Trolin
How to sign a document d • Compute the hash of d, v = H(d). • Perform a private key operation on v. • The result is a digital signature. • What happens if the hash function is not one-way? Not collision free? Mårten Trolin