Modern-Day Techniques
Before examining modern-day techniques, you need to understand what algorithms and ciphers are. Generally, an algorithm is a systematic list of instructions for accomplishing a task. The task can be anything that has a recognizable result. Often, some of the instructions are to be repeated, and different algorithms can sometimes produce the same result. You can think of an algorithm as a procedure made up of a finite number of steps that are used to solve a mathematical problem. For example, if you have an equation such as 2x + 3 = 7 2x , you can use the algorithm in Table 4-1 to calculate x .
Algorithm | Procedure |
---|---|
2x + 3 = 7 2x | Original equation |
2x + 2x = 7 3 | Bring all components with x to one side and all components without x to the other side |
4x = 4 | Calculate the new values |
x = 4/4 | Calculate x |
x = 1 | Result |
Symmetric Key Algorithms
As shown in Figure 4-1, a symmetric key algorithm is an algorithm used for cryptography using the same cryptographic key to encrypt and decrypt the message.
Figure 4-1. Symmetric Key Algorithm

Data Encryption Standard
The Data Encryption Standard (DES) has been the worldwide encryption standard for a long time. IBM developed DES in 1975, and it has held up remarkably well against years of cryptanalysis. DES is a symmetric encryption algorithm with a fixed key length of 56 bits. The algorithm is still good, but because of the short key length, it is susceptible to brute-force attacks that have sufficient resources.DES usually operates in block mode, whereby it encrypts data in 64-bit blocks. The same algorithm and key are used for both encryption and decryption.Because DES is based on simple mathematical functions, it can be easily implemented and accelerated in hardware. The mathematical functions of DES are outside the scope of this book, so they are not explained here.
Triple Data Encryption Standard
With advances in computer processing power, the original 56-bit DES key became too short to withstand an attacker with even a limited budget. One way of increasing the effective key length of DES without changing the well-analyzed algorithm itself is to use the same algorithm with different keys several times in a row.The technique of applying DES three times in a row to a plain text block is called Triple DES (3DES). The 3DES technique is shown in Figure 4-2. Brute-force attacks on 3DES are considered unfeasible today. Because the basic algorithm has been tested in the field for more than 25 years, it is considered to be highly trustworthy.
Figure 4-2. 3DES
[View full size image]

Step 1. | The message is encrypted with the first 56-bit key, K1. |
Step 2. | The data is decrypted with a second 56-bit key, K2. |
Step 3. | The data is again encrypted with the third 56-bit key, K3. |
The EDE procedure provides encryption with an effective key length of 168 bits. If keys K1 and K3 are equal (as in some implementations), a less secure encryption of 112 bits is achieved.To decrypt the message, you must use the following procedure, which is the opposite of the EDE method:
Step 1. | Decrypt the ciphertext with key K3. |
Step 2. | Encrypt the data with key K2. |
Step 3. | Finally, decrypt the data with key K1. |
Encrypting the data three times with three different keys does not significantly increase security. The EDE method has to be used. Encrypting three times in a row with different 56-bit keys equals an effective 58-bit key length and not the full 128-bit, as expected.NOTECompare the relative strength of DES, 2-key DES, and 3-key DES.DES :
256 keys = 7.2 x 1016 key combinations2-key DES :
2112 keys = 5.2 x 1033 key combinations3-key DES :
2168 keys = 3.7 x 1050 key combinations
AES
For a number of years, specialists have recognized that DES would eventually reach the end of its useful life. In 1997, the AES initiative was announced, and the public was invited to propose candidate encryption schemes, one of which could be chosen as the encryption standard to replace DES.On October 2, 2000, The U.S. National Institute of Standards and Technology (NIST) announced the selection of the Rijndael cipher as the AES algorithm. This cipher, developed by Joan Daemen and Vincent Rijmen, has a variable block length and key length. The algorithm currently specifies how to use keys with a length of 128, 192, or 256 bits to encrypt blocks with a length of 128, 192, or 256 bits (all nine combinations of key length and block length are possible). Both block and key length can be extended easily to multiples of 32 bits.NOTEFor more information on AES, visit its official website at http://www.nist.gov/aes or visit its author's website at http://www.esat.kuleuven.ac.be/~rijmen/rijndael/.AES was chosen to replace DES and 3DES because they are either too weak (DES, in terms of key length) or too slow (3DES) to run on modern, efficient hardware. AES is more efficient and much faster, usually by a factor of 5 compared to DES on the same hardware. AES is also more suitable for high throughput, especially if pure software encryption is used. However, AES is a relatively young algorithm, and as the golden rule of cryptography states, "A more mature algorithm is always more trusted."
Asymmetric Key Algorithms
An asymmetric key algorithm uses a pair of different cryptographic keys to encrypt and decrypt the plain text, as shown in Figure 4-3. The two keys are related mathematically. A message encrypted by the algorithm using one key can be decrypted by the same algorithm using the other. In a sense, one key locks a lock (encrypts), and a different key is required to unlock it (decrypts).
Figure 4-3. Asymmetric Key Algorithms

Diffie-Hellman
Whitfield Diffie and Martin Hellman developed the Diffie-Hellman algorithm in 1976. Its security stems from the difficulty of calculating the discrete logarithms of huge numbers. The protocol allows two users to exchange a secret key over an insecure medium without any prior secrets.The protocol has two system parameters, p and g . They are both public and may be used by everybody. Parameter p is a prime number, and parameter g (usually called a generator) is an integer that is smaller than p , but with the following property: For every number n between 1 and p 1 inclusive, there is a power k of g such that n = gk mod p .The following steps describe the Diffie-Hellman exchange:
Step 1. | Alice and Bob agree on generator g and modulus p . |
Step 2. | Alice chooses a random number A and sends Bob its public value A ' = gA mod p . |
Step 3. | Bob chooses a random number B and sends Alice his public value B ' = gB mod p . |
Step 4. | Alice computes k = (B ')A mod p . |
Step 5. | Bob computes k ' = (A ')B mod p . |
Step 6. | Both k and k ' are equal to gAB mod p . |
Alice and Bob now have a shared secret (k = k ' ), and even if people have listened on the untrusted channel, there is no way they could compute the secret from the captured information (assuming that computing a discrete logarithm of A or B is practically unfeasible).
Rivest, Shamir, Adelman
Rivest, Shamir, Adelman (RSA) was a patented public key algorithm invented by Ron Rivest, Adi Shamir, and Len Adelman in 1977. The patent expired in September 2000, and the algorithm is now in the public domain. Compared to other algorithms, RSA is by far the easiest to understand and implement.The RSA algorithm is very flexible and has a variable key length where, if necessary, speed can be traded for the level of security of the algorithm. The RSA keys are usually 512 to 2048 bits long. RSA has withstood years of extensive cryptanalysis. Although those years neither proved nor disproved RSA's security, they attest to a confidence level in the algorithm. RSA security is based on the difficulty of factoring very large numbers. If an easy method of factoring these large numbers were discovered, the effectiveness of RSA would be destroyed.To generate an entity's RSA keys, you would follow these steps:
The numbers d and n are also relatively prime. The numbers e and n are the public key. The number d is the private key. The numbers p and q are no longer needed. They were used only to calculate the other values and can be discarded but never revealed.
Pretty Good Privacy
Pretty Good Privacy (PGP) is a software package originally developed by Philip R. Zimmermann that provides cryptographic routines for e-mail and file storage applications. It is based on existing cryptographic protocols, and it can run on multiple platforms. PGP provides message encryption, data compression, and digital signatures.
Hashing Algorithms
Hashing is one of the mechanisms used for data integrity assurance. Hashing is based on a one-way mathematical function, which is relatively easy to compute but significantly harder to reverse. Breaking a glass is a good example of a one-way function. It is easy to smash a glass into thousands of pieces, but almost impossible to put all the tiny pieces back together to rebuild the original piece.The hashing process shown in Figure 4-4 uses a hash function, which is a one-way function to input data to produce a fixed-length digest (fingerprint) of output data. The digest is cryptographically strong; that is, it is impossible to recover input data from its digest. If the input data changes just a little, the digest (fingerprint) changes substantially in what is called an avalanche effect.
Figure 4-4. Hashing

- Message Digest 5 (MD5) with 128-bit digest
- Secure Hash Algorithm 1 (SHA-1) with 160-bit digest
Message Digest 5
The Message Digest 5 (MD5) algorithm is a ubiquitous algorithm developed by Ron Rivest. It is used in a variety of Internet applications today.As the name suggests, MD5 is a one-way function with which it is easy to compute the hash from the given input data, but it is unfeasible to compute input data given only a hash. MD5 is also collision resistant, which means that two messages with the same hash are very unlikely to occur.MD5 is considered less secure than SHA-1 because MD5 has some weaknesses, the explanation of which is beyond the scope of this book. SHA-1 also uses a stronger, 160-bit digest, which makes MD5 the second choice as hash methods are concerned.
SHA-1
The NIST developed the Secure Hash Algorithm (SHA). SHA-1 is a revision to the SHA that was published in 1994. Its design is similar to MD5. The algorithm takes a message of less than 264 bits in length and produces a 160-bit message digest. This algorithm is slightly slower than MD5.NOTEMore information on SHA-1 can be found at the following URL: http://csrc.nist.gov/publications/fips/fips180-2/fips1802.pd.
Secure Socket Layer and Transport Layer Security
Netscape originally developed Secure Socket Layer (SSL), but it is now accepted by the World Wide Web as the standard for authenticated and encrypted communication between clients and servers. The SSL protocol is application independent, allowing protocols such as HTTP, FTP, and Telnet to be layered on top of it transparently.The SSL protocol is able to negotiate encryption keys and authenticate the server before data is exchanged by the higher-level application. The SSL protocol maintains the security and integrity of the transmission channel by using encryption, authentication, and message authentication codes.The SSL Handshake Protocol consists of two phases: server authentication and optional client authentication. In the first phase, the server, in response to a client's request, sends its certificate and its cipher preferences. The client then generates a master key, which it encrypts with the server's public key, and transmits the encrypted master key to the server. The server recovers the master key and authenticates itself to the client by returning a message authenticated with the master key. Subsequent data is encrypted and authenticated with keys derived from this master key. In the optional second phase, the server sends a challenge to the client. On the challenge, the client authenticates itself to the server by returning the client's digital signature and its public-key certificate.The Transport Layer Security (TLS) is based on SSL. It is an improved version of SSL, but the industry has not made the shift to this new standard yet. SSL is still the method supported by all web servers and web browsers.NOTEFor more information about TLS, you can read the RFC at the following URL: http://www.faqs.org/rfcs/rfc2246l.NOTEFor more information on SSL and TLS, check these URLs:http://home.netscape.com/eng/ssl3/169ftp://ftp.isi.edu/in-notes/rfc2246.txt
Digital Certificates
Key management is often considered the most difficult task in designing and implementing cryptographic systems. Businesses can simplify some of the deployment and management issues that are encountered with secured data communications by employing a Public Key Infrastructure (PKI). Because corporations often move security-sensitive communications across the Internet, an effective mechanism must be implemented to protect sensitive information from the threats presented on the Internet.The three primary security vulnerabilities associated with communicating over a publicly accessible network are as follows:
- Identity theft
Intruder gains illegitimate access by posing as an individual who actually can access secured resources. - Eavesdropping
Intruder "sniffs" the data transmission between two parties during communications over a public medium. - Man-in-the-middle
Intruder interrupts a dialogue and modifies the data between the two parties. In an extreme case, the intruder takes over the entire session.
Characteristics of Digital Certificates
PKI provides a hierarchical framework for managing the digital security attributes. Each PKI participant holds a digital certificate that has been issued by a CA. The certificate contains a number of attributes that are used when parties negotiate a secure connection. These attributes must include the certificate validity period, end-host identity information, encryption keys that will be used for secure communications, and the signature of the issuing CA. Optional attributes may be included, depending on the requirements and capability of the PKI.A CA can be a trusted third party, such as VeriSign or Entrust, or a private (in-house) CA that you establish within your organization.Digital signatures, enabled by public key cryptography, provide a means to digitally authenticate devices and individual users. In public key cryptography, such as the RSA encryption system, each user has a key-pair containing both a public key and a private key. The keys act as complements, and anything encrypted with one of the keys can be decrypted with the other. In simple terms, a signature is formed when data is encrypted with a user's private key. The receiver verifies the signature by decrypting the message with the sender's public key.The fact that the message could be decrypted using the sender's public key means that the holder of the private key created the message. This process relies on the receiver having a copy of the sender's public key and knowing with a high degree of certainty that it really does belong to the sender and not to someone pretending to be the sender.To validate the CA's signature, the receiver must know the CA's public key. Normally, this is handled out-of-band or through an operation performed during installation of the certificate. For instance, most web browsers are configured with the root certificates of several CAs by default.
Enrolling in a CA
The enrollment process of obtaining a certificate is shown in Figure 4-5. Enrollment is enacted between the end host desiring the certificate and the authority in the PKI that is responsible for providing certificates. The hosts that participate in a PKI must obtain a certificate, which they present to the parties with whom they communicate when they need a secured communications channel.
Figure 4-5. Enrollment Procedure
[View full size image]

- The end host generates a private-public key pair.
- The end host generates a certificate request, which it forwards to the CA.
- Manual human intervention is required to approve the enrollment request, which is received by the CA.
- After the CA operator approves the request, the CA signs the certificate request with its private key and returns the completed certificate to the end host.
- The end host writes the certificate into a nonvolatile storage area (PC hard disk or NVRAM on Cisco routers).