Docsity

Understanding Modern Cryptography: Symmetric vs. Asymmetric Encryption, Lecture notes of Computer Science

Toggle sidebar
bg1
COMPILED BY: SAMUEL G
1
Introduction to Computer Security
CHAPTER TWO
CRYPTOGRAPHY
2.1 Introduction
Cryptography is a branch of mathematics based on the transformation of data. It
provides an important tool for protecting information and is used in many aspects of
computer security. For example, cryptography can help provide data confidentiality,
integrity, electronic signatures, and advanced user authentication. Although modern
cryptography relies upon advanced mathematics, users can reap its benefits without
understanding its mathematical underpinnings.
Cryptography is traditionally associated only with keeping data secret. However,
modern cryptography can be used to provide many security services, such as
electronic signatures and ensuring that data has not been modified.
Cryptography relies upon two basic components: an algorithm (or cryptographic
methodology) and a key. In modern cryptographic systems, algorithms are complex
mathematical formulae and keys are strings of bits. For two parties to communicate,
they must use the same algorithm (or algorithms that are designed to work together).
In some cases, they must also use the same key. Many cryptographic keys must be
kept secret; sometimes algorithms are also kept secret. There are two basic types of
cryptography: secret key systems (also called symmetric systems) and public key
systems (also called asymmetric systems).
Symmetric encryption, also referred to as conventional encryption or single-key
encryption, was the only type of encryption in use prior to the development of public
key encryption in the 1970s. It remains by far the most widely used of the two types
of encryption. In this chapter, we begin with a look at a general model for the
symmetric encryption process; this will enable us to understand the context within
which the algorithms are used.
Before beginning, we define some terms. An original message is known as the
plaintext, while the coded message is called the cipher text. The process of
converting from plaintext to cipher text is known as enciphering or encryption;
restoring the plaintext from the cipher text is deciphering or decryption. The many
schemes used for encryption constitute the area of study known as cryptography.
Such a scheme is known as a cryptographic system or a cipher. Techniques used for
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20

Partial preview of the text

Download Understanding Modern Cryptography: Symmetric vs. Asymmetric Encryption and more Lecture notes Computer Science in PDF only on Docsity!

CHAPTER TWO

CRYPTOGRAPHY

2.1 Introduction

Cryptography is a branch of mathematics based on the transformation of data. It provides an important tool for protecting information and is used in many aspects of computer security. For example, cryptography can help provide data confidentiality, integrity, electronic signatures, and advanced user authentication. Although modern cryptography relies upon advanced mathematics, users can reap its benefits without understanding its mathematical underpinnings. Cryptography is traditionally associated only with keeping data secret. However, modern cryptography can be used to provide many security services, such as electronic signatures and ensuring that data has not been modified. Cryptography relies upon two basic components: an algorithm (or cryptographic methodology) and a key. In modern cryptographic systems, algorithms are complex mathematical formulae and keys are strings of bits. For two parties to communicate, they must use the same algorithm (or algorithms that are designed to work together). In some cases, they must also use the same key. Many cryptographic keys must be kept secret; sometimes algorithms are also kept secret. There are two basic types of cryptography: secret key systems (also called symmetric systems) and public key systems (also called asymmetric systems). Symmetric encryption, also referred to as conventional encryption or single-key encryption, was the only type of encryption in use prior to the development of public key encryption in the 1970s. It remains by far the most widely used of the two types of encryption. In this chapter, we begin with a look at a general model for the symmetric encryption process; this will enable us to understand the context within which the algorithms are used. Before beginning, we define some terms. An original message is known as the plaintext , while the coded message is called the cipher text. The process of converting from plaintext to cipher text is known as enciphering or encryption ; restoring the plaintext from the cipher text is deciphering or decryption. The many schemes used for encryption constitute the area of study known as cryptography. Such a scheme is known as a cryptographic system or a cipher. Techniques used for

deciphering a message without any knowledge of the enciphering details fall into the area of cryptanalysis. Cryptanalysis is what the layperson calls “ breaking the code .” The areas of cryptography and cryptanalysis together are called cryptology.

2 .2 Private (Secret) Key Encryption

In secret key cryptography, two (or more) parties share the same key, and that key is used to encrypt and decrypt data. As the name implies, secret key cryptography relies on keeping the key secret. If the key is compromised, the security offered by cryptography is severely reduced or eliminated. Secret key cryptography assumes that the parties who share a key rely upon each other not to disclose the key and protect it against modification. Secret key cryptography has been in use for centuries. Early forms merely transposed the written characters to hide the message. The best known secret key system is the Data Encryption Standard (DES), published by NIST as Federal Information Processing Standard (FIPS) 46-2. Although the adequacy of DES has at times been questioned, these claims remain unsubstantiated, and DES remains strong. It is the most widely accepted, publicly available cryptographic system today. The American National Standards Institute (ANSI) has adopted DES as the basis for encryption, integrity, access control, and key management standards. The following figure shows the comparison between Symmetric (private key) cryptography and Asymmetric (public key) cryptography.

Figure 2 .1 Simplified Model of Symmetric Encryption We assume that it is impractical to decrypt a message on the basis of the cipher text plus knowledge of the encryption/decryption algorithm. In other words, we do not need to keep the algorithm secret; we need to keep only the key secret. This feature of symmetric encryption is what makes it feasible for widespread use. The fact that the algorithm need not be kept secret means that manufacturers can and have developed low-cost chip implementations of data encryption algorithms. These chips are widely available and incorporated into a number of products. With the use of symmetric encryption, the principal security problem is maintaining the secrecy of the key. Let us take a closer look at the essential elements of a symmetric encryption scheme, using Figure 3.2. A source produces a message in plain text, X=[X 1 , X 2 , X 3 ,……, XM]. The elements of are letters in some finite alphabet. Traditionally, the alphabet usually consisted of the 26 capital letters. Nowadays, the binary alphabet {0, 1} is typically used. For encryption, a key of the form K= [K 1 , K 2 , K 3 , ……, KJ] is generated. If the key is generated at the message source, then it must also be provided to the destination by means of some secure channel. Alternatively, a third party could generate the key and securely deliver it to both source and destination.

Figure 2 .2 Model of Symmetric Cryptosystem With the message and the encryption key as input, the encryption algorithm forms the cipher text Y= [Y 1 , Y 2 , Y 3 , ……,YN]. We can write this as Y = E(K, X) This notation indicates that is produced by using encryption algorithm E as a function of the plain text, with the specific function determined by the value of the key. The intended receiver, in possession of the key, is able to invert the transformation: X = D(K, Y) An opponent, observing Y but not having access to or K or X, may attempt to recover X or K or both X and K. It is assumed that the opponent knows the encryption (E) and decryption (D) algorithms. If the opponent is interested in only this particular message, then the focus of the effort is to recover X by generating a plaintext estimate X’. Often, however, the opponent is interested in being able to read future messages as well, in which case an attempt is made to recover K by generating an estimate K’.

Cryptography

Cryptographic systems are characterized along three independent dimensions:

  1. The type of operations used for transforming plaintext to ciphertext. All encryption algorithms are based on two general principles: substitution, in which each element in the plaintext (bit, letter, group of bits or letters) is mapped into another element, and transposition, in which elements in the plaintext are rearranged. The fundamental requirement is that no information be lost (that is, that all operations are reversible). Most systems, referred to as product systems, involve multiple stages of substitutions and transpositions.

Then the algorithm can be expressed as follows. For each plaintext letter P , substitute the cipher text letter C. C = E (3, p) = (p + 3) mod 26 A shift may be of any amount, so that the general Caesar algorithm is C= E (k, p) = (p + k) mod 26 (3.1) Where takes on a value in the range 1 to 25. The decryption algorithm is simply p = D (k, C) = (C - k) mod 26 (3.2)

2 .4 Symmetric Block Encryption Algorithms

The most commonly used symmetric encryption algorithms are block ciphers. A block cipher processes the plaintext input in fixed-sized blocks and produces a block of cipher text of equal size for each plaintext block. This section focuses on the three most important symmetric block ciphers: Data Encryption Standard (DES), Triple DES (3DES), and Advanced Encryption Standard (AES).

2 .4.1 Data Encryption Standard

The most widely used encryption scheme is based on the Data Encryption Standard (DES) issued in 1977, as Federal Information Processing Standard 46 (FIPS 46) by the National Bureau of Standards, now known as the National Institute of Standards and Technology (NIST). The algorithm itself is referred to as the Data Encryption Algorithm (DEA). The plaintext is 64 bits in length and the key is 56 bits in length; longer plaintext amounts are processed in 64-bit blocks. The DES structure is a minor variation of the Feistel network. There are 16 rounds of processing. From the original 56-bit key, 16 sub keys are generated, one of which is used for each round.

The process of decryption with DES is essentially the same as the encryption process. The rule is as follows: Use the cipher text as input to the DES algorithm, but use the sub keys Ki in reverse order. That is, use K 16 on the first iteration, K 15 on the second iteration, and so on until K 1 is used on the 16th^ and last iteration. THE STRENGTH OF DES : Concerns about the strength of DES fall into two categories: concerns about the algorithm itself and concerns about the use of a 56-bit key. The first concern refers to the possibility that cryptanalysis is possible by exploiting the characteristics of the DES algorithm. Over the years, there have been numerous attempts to find and exploit weaknesses in the algorithm, making DES the most-studied encryption algorithm in existence. Despite numerous approaches, no one has so far succeeded in discovering a fatal weakness in DES. A more serious concern is key length. With a key length of 56 bits, there are 256 possible keys, which is approximately 7.2 × 10^16 keys. Thus, on the face of it, a brute force attack appears impractical. Assuming that on average half the key space has to be searched, a single machine performing one DES encryption per microsecond would take more than a thousand years to break the cipher. Figure 2 .4.1.1 Structure of DES Algorithm Triple DES

Output- 64 bit

Cipher text

Input- 64 bit

plain text

With three distinct keys, 3DES has an effective key length of 168 bits. FIPS 46-3 also allows for the use of two keys, with K1= K3; this provides for a key length of 112 bits. FIPS 46-3 includes the following guidelines for 3DES. ▪ 3DES is the FIPS approved symmetric encryption algorithm of choice. ▪ The original DES, which uses a single 56-bit key, is permitted under the standard for legacy systems only. New procurements should support 3DES. ▪ Government organizations with legacy DES systems are encouraged to transition to 3DES. ▪ It is anticipated that 3DES and the Advanced Encryption Standard (AES) will coexist as FIPSapproved algorithms, allowing for a gradual transition to AES It is easy to see that 3DES is a formidable algorithm. Because the underlying cryptographic algorithm is DEA, 3DES can claim the same resistance to cryptanalysis or DEA. Furthermore, with a 168-bit key length, brute-force attacks are effectively impossible. Ultimately, AES is intended to replace 3DES, but this process will take a number of years. NIST anticipates that 3DES will remain an approved algorithm (for U.S. government use) for the foreseeable future.

2 .4.2 Advanced Encryption Standard (AES)

3DES has two attractions that assure its widespread use over the next few years. First, with its 168bit key length, it overcomes the vulnerability to brute-force attack of DEA. Second, the underlying encryption algorithm in 3DES is the same as in DEA. This algorithm has been subjected to more scrutiny than any other encryption algorithm over a longer period of time, and no effective cryptanalytic attack based on the algorithm rather than brute force has been found. Accordingly, there is a high level of confidence that 3DES is very resistant to cryptanalysis. If security were the only consideration, then 3DES would be an appropriate choice for a standardized encryption algorithm for decades to come. 3DES, which has three times as many rounds as DEA, is correspondingly slower. A secondary drawback is that both DEA and 3DES use a 64-bit block size. For reasons of both efficiency and security, a larger block size is desirable. Because of these drawbacks, 3DES is not a reasonable candidate for long-term use. As a replacement, NIST in 1997 issued a call for proposals for a new Advanced Encryption Standard (AES), which should have a security strength equal to or better than 3DES and significantly improved efficiency. In addition to these general requirements, NIST specified that AES must be a symmetric block cipher with a block

length of 128 bits and support for key lengths of 128, 192, and 256 bits. Evaluation criteria included security, computational efficiency, memory requirements, hardware and software suitability, and flexibility. OVERVIEW OF THE ALGORITHM AES uses a block length of 128 bits and a key length that can be 128, 192, or 256 bits. In the description of this section, we assume a key length of 128 bits, which is likely to be the one most commonly implemented. Figure 3.4.2 shows the overall structure of AES. The input to the encryption and decryption algorithms is a single 128-bit block. In FIPS PUB 197, this block is depicted as a square matrix of bytes. This block is copied into the State array, which is modified at each stage of encryption or decryption. After the final stage, State is copied to an output matrix. Similarly, the 128-bit key is depicted as a square matrix of bytes. This key is then expanded into an array of key schedule words: each word is four bytes and the total key schedule is 44 words for the 128-bit key. The ordering of bytes within a matrix is by column. So, for example, the first four bytes of a 128bit plaintext input to the encryption cipher occupy the first column of the in matrix, the second four bytes occupy the second column, and so on. Similarly, the first four bytes of the expanded key, which form a word, occupy the first column of the w matrix. The features of AES are as follows: ▪ Symmetric key symmetric block cipher ▪ 128 - bit data, 128/192/256-bit keys ▪ Stronger and faster than Triple-DES ▪ Provide full specification and design details ▪ Software implementable in C and Java AES is an iterative rather than Feistel cipher. It is based on ‘substitution– permutation network’. It comprises of a series of linked operations, some of which involve replacing inputs by specific outputs (substitutions) and others involve shuffling bits around (permutations).

(1) the length of the key and (2) the computational work involved in breaking a cipher. There is nothing in principle about either conventional or public-key encryption that makes one superior to another from the point of view of resisting cryptanalysis. A second misconception is that public-key encryption is a generalpurpose technique that has made conventional encryption obsolete. Public key cryptography is a modern invention and requires the use of advanced mathematics. Whereas secret key cryptography uses a single key shared by two (or more) parties, public key cryptography uses a pair of keys for each party. One of the keys of the pair is "public" and the other is "private." The public key can be made known to other parties; the private key must be kept confidential and must be known only to its owner. Both keys, however, need to be protected against modification. Public key cryptography is particularly useful when the parties wishing to communicate cannot rely upon each other or do not share a common key. There are several public key cryptographic systems. One of the first public key systems is RSA, which can provide many different security services. The Digital Signature Standard (DSS), described later in the chapter, is another example of a public key system. Symmetric cryptography was well suited for organizations such as governments, military, and big financial corporations were involved in the classified communication. With the spread of more unsecure computer networks in last few decades, a genuine need was felt to use cryptography at larger scale. The symmetric key (secret key cryptography) was found to be non-practical due to challenges it faced for key management. This gave rise to the public key cryptosystems. The most important properties of public key encryption scheme are: ▪ Different keys are used for encryption and decryption. This is a property which set this scheme different than symmetric encryption scheme. ▪ Each receiver possesses a unique decryption key, generally referred to as his private key. Receiver needs to publish an encryption key, referred to as his public key. ▪ Some assurance of the authenticity of a public key is needed in this scheme to avoid spoofing by adversary as the receiver. Generally, this type of cryptosystem involves trusted third party which certifies that a particular public key belongs to a specific person or entity only. ▪ Encryption algorithm is complex enough to prohibit attacker from deducing the plaintext from the cipher text and the encryption (public) key.

▪ Though private and public keys are related mathematically, it is not be feasible to calculate the private key from the public key. In fact, intelligent part of any public- key cryptosystem is in designing a relationship between two keys. A public-key encryption scheme has six ingredients: Plaintext : This is the readable message or data that is fed into the algorithm as input. Encryption Algorithm : The encryption algorithm performs various transformations on the plaintext. Public and Private Key : This is a pair of keys that have been selected so that if one is used for encryption, the other is used for decryption. The exact transformations performed by the encryption algorithm depend on the public or private key that is provided as input. Cipher Text : This is the scrambled message produced as output. It depends on the plaintext and the key. For a given message, two different keys will produce two different cipher texts. Decryption Algorithm : This algorithm accepts the cipher text and the matching key and produces the original plaintext. As the names suggest, the public key of the pair is made public for others to use, while the private key is known only to its owner. A general-purpose public-key cryptographic algorithm relies on one key for encryption and a different but related key for decryption. Figure 2 .5 The process of encryption and decryption in public Cryptography

  1. It is computationally easy for the receiver B to decrypt the resulting cipher text using the private key to recover the original message: M= D (PRb,C) =D[PRb, E(PUb ,M)]
  2. It is computationally infeasible for an opponent, knowing the public key, PUb, to determine the private key, PRb.
  3. It is computationally infeasible for an opponent, knowing the public key, PUb , and a cipher text, C , to recover the original message, M.
  4. Either of the two related keys can be used for encryption, with the other used for decryption. M = D[PUb, E(PRb, M )]= D[PRb,E(PUb, M )]

2 .5.3 RSA Cryptosystem

One of the first public-key schemes was developed in 1977 by Ron R ivest, Adi S hamir, and Len A dleman at MIT and first published in 1978 [RIVE78]. The RSA scheme has since that time reigned supreme as the most widely accepted and implemented approach to public-key encryption. RSA is a block cipher in which the plaintext and cipher text are integers between 0 and n-1 for some n. Encryption and decryption are of the following form period for some plaintext block M and cipher text block C: C=Me^ mod n M =Cd^ mod n ( M e)d^ mod n= M ed^ mod n Both sender and receiver must know the values of n and e, and only the receiver knows the value of d. This is a public-key encryption algorithm with a public key of KU {e,n} and a private key of KR {d,n}.For this algorithm to be satisfactory for public- key encryption, the following requirements must be met.

  1. It is possible to find values of e, d, n such that Med^ mod n=M for all M< n.
  2. It is relatively easy to calculate Me^ and Cd^ for all values of M< n.
  3. It is infeasible to determine d given e and n.

Figure 2 .5.3 RSA Cryptosystem Figure 3.5.3 summarizes the RSA algorithm. Begin by selecting two prime numbers p and q and calculating their product n, which is the modulus for encryption and decryption. Next, we need the quantity Ø(n), referred to as the Euler totient of n, which is the number of positive integers less than n and relatively prime to n. Then select an integer e that is relatively prime to Ø(n) [i.e., the greatest common divisor of e and Ø(n) is 1]. Finally, calculate d as the multiplicative inverse of e, modulo Ø(n). It can be shown that d and e have the desired properties. For this example, the keys were generated as follows:

  1. Select two prime numbers, p= 17 and q =
  2. Calculate n = pq =17 ×11=
  3. Calculate Ø(n)=( p- 1 )( q- 1 ) =16 ×10 =
  4. Select e such that e is relatively prime to Ø(n)=160 and less than Ø(n); we choose e =7.

Digital signature is a cryptographic value that is calculated from the data and a secret key known only by the signer. Similarly, a digital signature is a technique that binds a person/entity to the digital data. This binding can be independently verified by receiver as well as any third party. In real world, the receiver of message needs assurance that the message belongs to the sender and he should not be able to repudiate the origination of that message. This requirement is very crucial in business applications, since likelihood of a dispute over exchanged data is very high.

Secret Key Electronic Signatures

An electronic signature can be implemented using secret key message authentication codes (MACs). For example, if two parties share a secret key, and one party receives data with a MAC that is correctly verified using the shared key, that party may assume that the other party signed the data. This assumes, however, that the two parties trust each other. Thus, through the use of a MAC, in addition to data integrity, a form of electronic signature is obtained. Using additional controls, such as key notarization and key attributes, it is possible to provide an electronic signature even if the two parties do not trust each other.

Public Key Electronic Signatures

Another type of electronic signature called a digital signature is implemented using public key cryptography. Data is electronically signed by applying the originator's private key to the data. To increase the speed of the process, the private key is applied to a shorter form of the data, called a "Hash" or "Message Digest," rather than to the entire set of data. The resulting digital signature can be stored or transmitted along with the data. The signature can be verified by any party using the public key of the signer. This feature is very useful, for example, when distributing signed copies of virus-free software. Any recipient can verify that the program remains virus-free. If the signature verifies properly, then the verifier has confidence that the data was not modified after being signed and that the owner of the public key was the signer. As mentioned earlier, the digital signature scheme is based on public key cryptography. The model of digital signature scheme is depicted in the following illustration:

Figure 2 .6 Model of Digital Signature The following points explain the entire process in detail: ▪ Each person adopting this scheme has a public-private key pair. ▪ Generally, the key pairs used for encryption/decryption and signing/verifying are different. The private key used for signing is referred to as the signature key and the public key as the verification key. ▪ Signer feeds data to the hash function and generates hash of data. ▪ Hash value and signature key are then fed to the signature algorithm which produces the digital signature on given hash. Signature is appended to the data and then both are sent to the verifier. ▪ Verifier feeds the digital signature and the verification key into the verification algorithm. The verification algorithm gives some value as output. ▪ Verifier also runs same hash function on received data to generate hash value. ▪ For verification, this hash value and output of verification algorithm are compared. Based on the comparison result, verifier decides whether the digital signature is valid. ▪ Since digital signature is created by ‘private’ key of signer and no one else can have this key; the signer cannot repudiate signing the data in future. It should be noticed that instead of signing data directly by signing algorithm, usually a hash of data is created. Since the hash of data is a unique representation of data, it is sufficient to sign the hash in place of data. The most important reason of using hash instead of data directly for signing is efficiency of the scheme. Signing large data