Cryptography (One Day Cryptography Tuto T rial) By Dr. r Mohsen M. Ta T ntawy
Definitions Plaintext: easy to understand form (original message) Ciphertext: difficult to understand form Encryption: encoding (plaintext -> ciphertext) Decryption: decoding (ciphertext -> plaintext) Cryptology: study of encryption Cryptography: use of encryption Cryptanalysis: breaking encryption
Gr Def ou in p of ii p of i t ni n o dins dividuals Alice—She is an end user/computer without malicious intentions, one of the main users of cryptography. y Bob—He is A lice’s friend and is also a main user of cryptography, y without malicious intentions. Cathy—Another user of cryptography; she does not usual y have a large roll nor malicious intentions. Eve—A A malicious user that does not interfere with communications. She simply wants to eavesdrop on the conversation between two other characters, typically A lice and Bob, but does not actively try to attack the communication. Mallory—The malicious user. r Al ways trying to thwart attempts by other characters to communicate securely. y Tr T ent—He is a trusted third party. y He only communicates with A lice, Bob, or Cathy when they ask for his help. He can always be trusted to do what he says he wil do.
Group of individuals Hacker – is a general term that has historically been used to describe a computer programming expert. More recently, y this term is commonly used in a negative way to describe an individual that attempts to gain unauthorized access to network resources with malicious intent.
Cracker – is the term that is generally regarded as the more accurate word that is used to describe an individual that attempts to gain unauthorized access to network resources with malicious intent.
Group of individuals Phreaker – is an individual that manipulates the phone network in order to cause it to perform a function that is normal y not al owed. A A common goal of phreaking is breaking into the phone network, usual y through a payphone, to make free long distance cal s. Spammer – is an individual that sends large quantities of unsolicited email messages. Spammers often use viruses to take control of home computers in order to use these computers to send out their bulk messages. Fisher – uses email or other means in an attempt to trick others into providing sensitive information, such as credit card numbers or passwords. The Phisher wil masquerade as a trusted party that would have a legitimate need for the sensitive information.
Group of individuals White hat – is a term used to describe individuals that use their abilities to find vulnerabilities in systems or networks, and then report these vulnerabilities to the owners of the system so that they can be fixed.
Black hat – is another term for individuals that use their knowledge of computer systems to break into systems or networks that they are not authorized to use.
Definitions Key—A ran —A dom piece of data used with encryption and decryption. Encryption and decryption algorithms require a key and plain text or cipher text to produce cipher text or plain text, respectively. y Security Association— A — set of information that describes how the communicating entities will utilize security. y
Ty T pes of Cryptographic Systems Symmetric-key cryptosystems Asymmetric-key or Public-key cryptosystems Hybrid (Symmetric-key and Asymmetric-key) cryptosystems
Symmetric Encryption Uses conventional / secret-key / single-key Sender and recipient share a common key All classical encryption algorithms are private- key The only type prior to invention of public-key in 1970’s
Symmetric Cipher Model
Requirements Tw T o requirements for secure use of symmetric encryption: Strong encryption algorithm Secret key known only to sender / receiver Y = EK(X) X = DK(Y) Assume encryption algorithm is known Implies a secure channel to distribute key
Block ciphers and Stream ciphers Each secret-key cryptography algorithm or cipher typically works in two phases: key set-up phase ciphering or encrypt and decrypt phase. There are two major classes of these algorithms: block ciphers and stream ciphers. Block ciphers encrypt plaintext in units of blocks and likewise decrypt cipher text in units of blocks. Stream ciphers encrypt plaintext in one stream and decrypt cipher text likewise.
Block cipher operation
Stream cipher operation
Mode of Operation There are three important block cipher modes: Electronic Code Book (ECB) Cipher Block Chaining (CBC) Cipher Feedback Mode (CFB)
Initial Permutation IP first step of the data computation IP reorders the input data bits even bits to LH half, odd bits to RH half quite regular in structure (easy in h/w)
DES Round Structure uses two 32-bit L & R halves as for any Feistel cipher can describe as: Li = Ri–1 Ri = Li–1 xor F(Ri–1, Ki) takes 32-bit R half and 48-bit subkey and: expands R to 48-bits using perm E adds to subkey passes through 8 S-boxes to get 32-bit result final y permutes this using 32-bit perm P
DES Round Structure
Substitution Boxes S have eight S-boxes which map 6 to 4 bits each S-box is actually 4 little 4 bit boxes outer bits 1 & 6 (row bits) select one rows inner bits 2-5 (col bits) are substituted result is 8 lots of 4 bits, or 32 bits row selection depends on both data & key feature known as autokeying
Tri T ple DES clear a replacement for DES was needed theoretical attacks that can break it demonstrated exhaustive key search attacks AES is a new cipher alternative prior to this alternative was to use multiple encryption with DES implementations Triple-DES is the chosen form
Tr T iple-DES with Two- T Keys hence must use 3 encryptions would seem to need 3 distinct keys but can use 2 keys with E-D-E sequence C = EK1[DK2[EK1[P]]] if K1=K2 then can work with single DES standardized in ANSI X9.17 & ISO8732 no current known practical attacks
Tr T iple-DES with Three-Keys although are no practical attacks on two- key Triple-DES have some indications can use Triple-DES with Three-Keys to avoid even these C = EK3[DK2[EK1[P]]] has been adopted by some Internet applications, eg PGP, S/MI GP ME
Tr T iple DES (3DES) The technique used by 3DES is known as EDE (Encrypt-Decrypt-Encrypt).
The plaintext message is encrypted using the first 8 bytes of the 3DES.
Then the message is decrypted using the middle 8 bytes of the key. y
Finally, y the message is encrypted using the last 8 bytes of the key to produce an 8-byte block.
AES Requirements private key symmetric block cipher 128-bit data, 128/192/256-bit keys stronger & faster than Triple-DES active life of 20-30 years (+ archival use) provide full specification & design details both C & Java implementations
Rijndael data block of 4 columns of 4 bytes is state key is expanded to array of words has 9/11 1 /13 rounds in which state undergoes: byte substitution (1 S-box used on every byte) shift rows (permute bytes between groups/columns) mix columns (subs using matrix multipy of groups) add round key (XOR state with key material) view as alternating XOR key & scramble data bytes initial XOR key material & incomplete last round with fast XOR & table lookup implementation
Add Round Key
Asymmetric-key or Public Key Encryption Based on mathematical algorithms Asymmetric Use two separate keys Public Key issues Plain text Encryption algorithm Public and private key Cipher text Decryption algorithm
Public Key Encryption – Encryption
Public Key Encryption – Authentication
Public Key Encryption - Operation One key made public Used for encryption Other kept private Used for decryption Infeasible to determine decryption key given encryption key and algorithm Either key can be used for encryption, the other for decryption
Steps User generates pair of keys User places one key in public domain To T send a message to this user, en r crypt using public key User decrypts using private key
Digital Signature Sender encrypts message with their private key Receiver can decrypt using senders public key This authenticates sender, er who is only person who has the matching key Does not give privacy of data Decrypt key is public
Asymmetric-key or Public-key Cryptosystems There are many examples of commonly used public-key systems including: Diffie-Hellman Rivest, Shamir, Adleman (RSA) Digital Signature Algorithm (DSA) / Al Gamal Elliptic Curve Cryptosystem (ECC)
Diffie-Hellman Key Exchange first public-key type scheme proposed by Diffie & Hellman in 1976 along with the exposition of public key concepts note: now know that James El is (UK CESG) secretly proposed the concept in 1970 is a practical method for public exchange of a secret key
Diffie-Hellman Key Exchange
RSA Algorithm We’re using Big Integers here:
Choose large secret prime numbers p and p=7, q=11 q N=77
Calculate N = p * q 37
Choose exponent e such that gcd (37,(7-1)(11-1)) = 1
gcd(e, (p-1)(q-1)) = 1
Normally choose 3, 17 or 65537
Public key is pair N and e 77, 37 13
Choose d so that
e * d = 1 (mod (p-1)(q-1)) 37*13=481=1(mod 60)
Private key is d (for efficiency d, p, q) 13
Encryption: c = me (mod N) 237 mod 77 = 51
Decryption: m = cd (mod N) 5113 mod 77 = 2
Public Key Certificate Use
Digital certificates Digital certificates include: A public key An individual or organisation’s details A digital signature from a certifying authority (CA) • This states that the CA has seen proof of identity Common certifying authorities: VeriSign, Thawte, Equifax Secure, British Telecom CAs are themselves certified by other CAs A few “root” CAs are usually trusted
Message Authentication Code Generate authentication code based on shared key and message Common key shared between A
A and B If only sender and receiver know key and code matches: Receiver assured message has not altered Receiver assured message is from al eged sender If message has sequence number, r receiver assured of proper sequence
Hash Functions vs. MAC
Hash Functions Message M Hash Function Generate a fixed length “Fingerprint” for an arbitrary length message No Key involved Must be at least One-way to be useful Constructions H Iterated hash functions (MD4-family hash functions): MD5, SHA1, … Hash functions based on block ciphers: MDC(Manipulation Detection Code) Message Digest D D = H(M)
Message Authentication Codes (MACs) MAC Shared Generate a fixed length MAC for an Secret Key arbitrary length message A keyed hash function Message origin authentication Message integrity MAC Entity authentication Transaction authentication MAC S E N D MAC
Comparison of Hash Function & MAC Arbitrary length Arbitrary length message message Hash MAC function function Secret key Hash MAC fixed length fixed length Easy to compute Compression: arbitrary length input to fixed length output Unkeyed function vs. Keyed function
Symmetric Authentication (MAC) Alice Bob Message MAC Message transmit MAC Secret key K Secret key K AB algorithm AB algorithm Shared Shared Secret key Secret key between between Alice and Bob Alice and Bob MAC yes no
Digital Signature Alice Bob Message Signature transmit Message Signature Hash Hash function function Hash value Hash value 1 Alice’s Public key yes no Public key algorithm Hash value 2 Alice’s Public key Private key algorithm
Hashing A A hashing algorithm refers to a mathematical function that takes a variable- size string as input and transforms (hashes) it into a fixed-size string, which is cal ed the hash value. One of the most common uses of hashing in network security is to produce condensed representations of messages or “fingerprints,” often known as “message digests,” by applying a hashing algorithm to an arbitrary amount of data — the message. The two most commonly used hashing algorithms are MD5 and SHA 1 (part of the secure hash standard [SHS]).
Using One Way Hash
Secure Hash Functions Hash function must have following properties: Can be applied to any size data block Produce fixed length output Easy to compute Not feasible to reverse Not feasible to find two message that give the same hash
SHA-1 Secure Hash Algorithm 1 Input message less than 264 bits Processed in 512 bit blocks Output 160 bit digest
Message Digest Generation Using SHA-1
ISAKMP The Internet Security A y ssociation and Key Manage m e ent Protocol (ISAKMP) is defined primarily as a very comprehensive framework for key management offering maximum flexibility OAKLEY is defined based on the Diffie–Hellman key-exchange algorithm. IKE, on the other hand, is defined primarily to be the key management for the IPSec A ec rchitecture and makes use of parts of the ISAKMP and OAKLEY definitions.
ISAKMP ISAKMP defines procedures and packet formats to establish, negotiate, modify, y and delete SAs. ISAKMP only describes the procedures, i.e., how something is done. ISAKMP is independent of the security protocols, cryptographic algorithms, and key-generation and key-exchange techniques that are actually used.
ISAKMP phases ISAKMP offers two phases of negotiation. In the first phase, the two entities agree on how to protect further negotiation traffic between themselves, establishing an ISAKMP SA. The second phase of negotiation is used to establish security associations for other security protocols. The security associations established by ISAKMP during this phase can be used by a security protocol to protect many message or data exchanges.
ISAKMP and TCP/IP
OAKLEY The OAKLEY protocol allows two authenticated entities to exchange and establish secret keying material. It is designed to be a compatible component of ISAKMP. P The two communicating entities negotiate methods for encryption, key derivation, and authentication. The basic mechanism of OAKLEY is the Diffie– Hellman key-exchange algorithm, which estab lishes a shared key without transmitting this key. ey
OAKLEY Key Exchange An OAKLEY key exchange is made up of a sequence of message exchanges. The goal of key-exchange processing is the secure establishment of a common keying information state in the two communicating entities. This state information consists of a key name, secret keying material, the identities of the two parties, and three algorithms for use during authentication: encryption hashing, and authentication
IKE IKE is the protocol that performs mutual authentication and establishes SAs between two parties for IPSec. IKE uses parts of ISAKMP, OA KMP KLEY, Y and SKEME to provide management of keys and security associations.
Key ISAKMP, P OAKLEY, Y AND SKEME concept in IKE
Digital Certificates Digital Signatures: (Data Origin Authentication, Data Integrity, y and Non- repudiation) Digital Signature
Digital Signature with Hash Function
Pretty good privacy (PGP) PGP Encryption (Pretty Good Privacy) is a computer program that provides cryptographic privacy and authentication. Public key cryptography, also known as asymmetric cryptography, is a form of cryptography in which a user has a pair of cryptographic keys - a public key and a private key It was original y created by Philip Zimmermann in 1991.
Pretty Good Privacy PGP encryption
Pretty Good Privacy PGP decryption
Applications of Cryptosystems Automatic Te T ller Machines Phone Cards Cellular Phone Networks Remote System Access Credit Cards Electronic Cash Medical Records