Chapter 1 Introduction to Cryptography
Total Page:16
File Type:pdf, Size:1020Kb
introduction to cryptography chapter 1 introduction to cryptography 1.1 basic terminology Cryptography is the art of making and keeping messages secret. In practical terms, this involves the conversion of a plaintext message into a cryptic one, called cyphertext. The process of conversion, or encoding of the clear text is called encryption. The process of converting the cyphertext to the original content of the message, the plaintext, is called decryption. Both processes make use (in one way or another) of an encryption procedure, called encryption (decryption) algorithm. While most of these algorithms are public, the secrecy is guaranteed by the usage of an encryption (decryption) key, which is, in most cases, known only by the legitimate entities at the both ends of the communication channel. Cryptology is a branch of mathematics and describes the mathematical foundation of cryptographic methods, while cryptanalysis is the art of breaking ciphers. 1.2 cryptography Cryptography provides the following services: • authentication • integrity • non-repudiation • secrecy Let’s have a more detailed look at these services. Authentication allows the recipient of the message to validate the identity of the sender. It prevents an unauthorized entity to masquerade itself as a legitimate sender of the message. Integrity guarantees that the message sent has not been modified or altered along the communication channel. This is usually accomplished by attaching to the message itself a digest (compressed version) of fixed length of the message, digest which allows verify if the original message was (intentionally or not) altered. Non-repudiation with proof of origin assures the receiver of the identity of the sender, while non- repudiation with proof of delivery ensures the sender that the message was delivered. Secrecy prevents unauthorized entities from accessing the real content of a message. 1.3 cryptographic algorithms classification There are two types of key-based encryption algorithms: • secret – key, or symmetric key algorithms • public – key, or asymmetric key algorithms Symmetric key algorithms rely on the secrecy of the encoding (decoding) key. This key is only known by 1 chapter 1 the sender and the receiver of the message. These algorithms can be classified further into stream ciphers and block ciphers. The former ones act on characters as encoding unit while thy later one act upon a block of characters, which is treated as an encoding unit. The execution of symmetric algorithms is much faster than the execution of asymmetric ones. On the other side, the key exchange implied by the utilization of symmetric algorithms raises new security issues. In practice, it is customary to use an asymmetric encryption for key generation and exchange and the generated key to be used for symmetric encryption of the actual message. 1.4 symmetric key algorithms Symmetric key encryption algorithms use a single (secret) key to perform both encryption and decryption of the message. Therefore, preserving the secrecy of this common key is crucial in preserving the security of the communication. • DES – Data Encryption Standard – developed in the mid 70’s. It is a standard of NIST (US National Institute of Standards and Technology). DES is a block cipher which uses 64-bit blocks and a 56-bit key. The short length of the key makes it susceptible to exhaustion attacks. Specified initially in FIPS 46. The latest variant of DES is called Triple-DES and is based on using DES 3 times, with 3 different, unrelated keys. It is much stronger than DES, but slow compared to the newest algorithms. 3DES is the object of FIPS 46-3 (October 1999) • AES – Advanced Encryption Standard – object of FIPS 197 (nov. 2001). AES is a block cipher which uses 128-bit blocks and a key of size 128 bits. Variations using 192 and 256-bit keys are also specified. What is specific for this algorithm is that it processes data at byte level, as opposed to bit level processing which was used previously. The algorithm is efficient and considered safe. 1.5 secret key distribution As mentioned before, symmetric key encryption requires a system for secret key exchange between all parties involved in the communication process. Of course, the key itself, being secret, must be encrypted before being sent electronically, or it may be distributed by other means, which make the event of intercepting the key by an unauthorized party unlikely. There are 2 main standards for automated secret key distribution. The first standard, called X9.17 is defined by the American National standards Institute (ANSI) and the second one is the Diffie-Hellman protocol. 1.6 asymmetric key algorithms Asymmetric key algorithms rely on two distinct keys for the implementation of the encryption/decryption phases: • a public key, which may be distributed or made public upon request • a private (secret) key which corresponds to a particular public key, and which is known only by the authorized entities. 2 introduction to cryptography Each of these two keys defines a transformation function. The 2 transformation functions defined by a pair of public/private keys are inverse to each other, and can be used the encryption/decryption of the message. It is irrelevant which of those 2 functions is used for a particular task. Although asymmetric key algorithms are slower in execution but have the advantage of eliminating the need for key exchange. Main public algorithms : • RSA – (Rivest-Shamir-Aldeman) is the most used asymmetric (public) key algorithm. Used mainly for private key exchange and digital signatures. All computation are made modulo some big integer n = p*q, where n is public, but p and q are secret prime numbers. The message m is used to create a cyphertext c = m^e (mod n). The recipient uses the multiplicative inverse d = e^(-1) (mod (p-1)*(q-1)). Then c^d = m^(e*d) = m (mod n). The private key is (n, p, q, e, d) (or just p, q, d) while the public key is (n, e). The size of n should be greater than 1024 bits (about 10^300). • Rabin – This cryptosystem is proven to be equivalent to factoring. Although is not the subject of a federal standard (as RSA is), it is explained well in several books. Keys of size greater than 1024 bits are deemed safe. 1.7 hash functions Hash functions take a message of arbitrary length as input and generate a fixed length digest (checksum). The length of the digest depends on the function used, but in general is between 128 and 512 bits. The hash functions are used in 3 main areas: • assure the integrity of a message (or of a downloaded file) by attaching the generated digest to the message itself. The receiver recomputes the digest using the received message and compares it against the digest generated by the sender. • are part of the creation of the digital signature • password storage – password are (almost) never stored in their original form. What is stored, in general, is a hash of the password. When a user introduces a password, its hash is computed and is compared with the stored hash. The most used hash functions are those in the MD and the SHA families – namely MD5 and SHA-1 and the newest ones SHA-2 and SHA-3. Another hash function of interest is RipeMD-160. The MD functions generate a 128 bit digest and were designed by the company RSA Security. While MD5 is still widespread, MD4 has been broken and is deemed insecure. SHA-1 and RipeMD-160 are considered safe for now. While SHA-2 is an extension of SHA-1, SHA_3 features a brand new algorithm for computing the hash. Starting with the newest function, here is a list of hash functions of practical interest. • SHA-3 uses the Keccak algorithm, a sponge construction in which message blocks are XORed into a subset of the state, which is then transformed as a whole. In the version used in SHA-3, the state consists of a 5×5 array of 64-bit words, 1600 bits total. The standardization process is not finished yet as of April 2015. • SHA-2 includes significant changes from its predecessor, SHA-1. The SHA-2 family consists of six hash functions with digests (hash values) that are 224, 256, 384 or 512 bits: SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, SHA-512/256. • SHA-1 – Secure Hash Algorithm. Published by the US Government. Its specification is the object of FIPS 180-1 (April 1995). FIPS stands for Federal Information Processing Standards. Produces a 160 bit digest (5 32-bit words). • RipeMD-160 – designed as a replacement for the MD series. It produces a digest of 160 bits (or 20 bytes, if you want). • MD5 – Message Digest Algorithm 5. Developed by RSA Labs. Produces a 128 bit digest. Still in use, 3 chapter 1 especially for message (download) integrity check. • MD2, MD4 – Older hash algorithms from RSA Data Security. Since they have known flaws, they are only of historic interest. 1.8 digital signature Some public-key algorithms can be used to generate digital signatures. A digital signature is a small amount of data that was created using some private key, and there is a public key that can be used to verify that the signature was really generated using the corresponding private key. The algorithm used to generate the signature must be such that without knowing the private key it is not possible to create a signature that would verify as valid. Digital signatures are used to verify that a message really comes from the claimed sender (assuming only the sender knows the private key corresponding to the public key). This is called (data origin) authentication.