Basics of Cryptography

The term cryptography is derived from a Greek word that means "hidden." In computing, cryptography refers to the methods used to "hide," or secure, communications from unauthorized access. Cryptography is also known as encryption. Encryption is done using established encryption algorithms or procedures. These algorithms may include symmetric, asymmetric, or hashing algorithms. Encryption algorithms further lay the foundation for a PKI, which is one of the widely used methods to secure network communications. This section includes a discussion of important encryption terms, algorithms, and Public Key Infrastructure.

Tip

The terms cryptography and encryption are used interchangeably in the following text.

An algorithm is defined as a procedure or a well-defined set of instructions to accomplish a task when the initial state of the problem is given. In encryption methods, the term encryption algorithm is used to define the process of creating a scrambled or unreadable text (known as cyphertext), from a given readable text (known as plaintext), using the defined procedure. Encryption is used as a protective cover for the data transmitted over network media from one computer to another. Encryption keeps the data secure from unauthorized access by users and by professional hackers. Encryption algorithms lay the foundation for such security mechanisms as confidentiality, authentication, digital signatures, and public key cryptography. They are used to calculate a secret key, which is used to encrypt and decrypt messages. Only the persons who possess the key can encrypt or decrypt messages. Encryption algorithms fall into the following main categories:

Symmetric algorithms, or symmetric key algorithms, use one key for both encryption and decryption of messages. One copy of the key is known to each end of the communication. It is also commonly known as secret key encryption, or shared secret encryption. In some implementations, and for the Security+ exam, symmetric key encryption is referred to as private key encryption. Symmetric key encryption is widely used for encryption because of its simplicity, ease of implementation, and speed. The strength of the key is determined by its size. The larger the key, the stronger the encryption.

Symmetric algorithms are prone to brute force attacks. In a brute force attack, the attacker attempts to break the key by guessing it. He may use a number of mechanisms to guess the key until the key is able to decrypt the message. Symmetric algorithms are also vulnerable to plain-text attacks. The keys need to be chosen, stored, and distributed using secure methods. Symmetric keys must be changed frequently to protect them from being compromised.

Symmetric algorithms are divided into stream ciphers and block ciphers. Stream ciphers encrypt bits of the message, one at a time. Block ciphers take blocks of bits, usually 64 bits at a time, and encrypt them as one unit. Some of the popular symmetric algorithms are DES, 3DES, AES, and IDEA, as discussed in the following sections.

Asymmetric algorithms are commonly used for public key cryptography. Asymmetric algorithms use two keys—one for encryption (public key) and the other for decryption (private key). The encryption key can be freely distributed, but the private key must be held in strict confidence. The two keys are generated together, but the private key cannot be derived from a public key. Figure 11-14 shows how message encryption and decryption are accomplished using public key cryptography.

Asymmetric algorithms are much slower than symmetric algorithms. The process puts a significant load on the computer's processor and memory. Aside from this, the keys used for asymmetric encryption are much larger than those used for symmetric encryption. Asymmetric keys are used only for encrypting small amounts of data. The most common application of asymmetric keys is for ensuring confidentiality of data. Public key digital signatures are used for authentication and non-repudiation of the sender. These terms are explained later in the section "Concepts of Cryptography."

The sections that follow cover asymmetric encryption algorithms.

The Diffie-Hellman algorithm, or the Diffie-Hellman key exchange, is used for a secure key exchange. It allows two parties to establish a shared secret key over an insecure communication channel. This key can then be used to establish a secure encrypted communication using a symmetric key encryption. The messages encrypted by one party can be decrypted only by the other party that possesses the secret key. This algorithm is used only for the transportation of secret keys and not for encrypting data. The following steps are involved in a key exchange:

If the initial numbers are chosen carefully, the Diffie-Hellman key exchange can be a strong algorithm for protecting the shared secret key because both the private key and the public key are actually very large integers. IPSec uses the Diffie-Hellman key exchange along with RSA authentication for exchanging session keys. This algorithm is considered secure against eavesdropping and MITM attacks.

A hashing algorithm (also called a hash function) is the process of creating a small and unique digital "fingerprint" from any kind of data. The fingerprint is known as the hash value. The hash value is represented as a short string of random letters and numbers. If the original data changes even by one character, the hash function will produce a different hash value. Thus, the receiver will know that original data has changed. The hash function is also known as a one-way process, because it is not possible to create the original text using any reverse hashing function. Figure 11-15 shows an example of the hashing function.

Hashing algorithms are used to provide integrity and authentication of data sent over network media from one computer to another. A good hashing algorithm is the one that will not produce the same hash values for any two inputs, which is a property known as collisions.

It is common to store encrypted passwords as hashes in secure networks. When a user sets her password, it is passed through a hashing function, and only the encrypted hash is stored. When the user logs on to the network, her password is hashed again and the two hash values are compared. If a match is found, the user is granted access; otherwise, she is denied. The following are two commonly used hashing algorithms:

The terms cryptography and encryption are used interchangeably. Encryption is the process of applying a procedure, known as an algorithm, to plain text in order to produce an unreadable text. This unreadable text can be read only if someone has the key to decrypt the message and convert it back to plain text. For all others, the encrypted text remains useless. The following are some of the concepts behind using encryption in network transmissions.

A PKI enables an organization to securely exchange messages through the insecure public network (such as the Internet). It enables users to securely exchange confidential data using public and private keys obtained through a trusted authority. This section covers a summary of different terms and concepts used in the public key cryptography infrastructure.

A certificate, or a digital certificate, is based on the X.509 standard and is used to identify an individual or an organization. It is issued by a CA to bind a public key to an individual or an organization. The name of the individual or the organization appears as a distinguished name, an email address, or a DNS name. An organization may use certificates for a variety of purposes such as encryption of email messages, doing business on the Internet, or digitally signing software applications.

When downloading software from the Internet or when making online purchases, you may check the validity of the digital certificate of the organization (or its web site) by clicking the little lock sign that appears on the righthand bottom corner of the web browser. Follow the steps given here to view the details of a digital certificate:

  1. Open a web site where you can do some online shopping. For example, go to www.oreilly.com.

  2. Choose a book and click the Add to Cart button. You are taken to the secure web site, https://epoch.oreilly.com.

  3. The next page shows a little yellow lock sign in the righthand bottom corner of the web browser.

  4. Double-click the lock sign. This opens the Certificate window and displays the general properties of the certificate.

  5. Click the Details tab to view the details of the certificate.

  6. Click OK to close the window.

Figure 11-16 shows a sample certificate issued to O'Reilly's web site, www.oreilly.com.

A certificate provides critical information about the certificate, its owner, and the issuing authority. The essential components of information provided on the certificate is as follows:

PKI can be implemented in one of the following trust models:

There are a number of tasks associated with the creation and management of certificates and keys. The tasks related to the entire lifecycle of keys include storage, distribution, revocation, suspension, expiration, and renewal of certificates, are jointly known as key management. The administrators managing the CAs are responsible for key management processes.

Management of keys can be accomplished in a centralized or in a decentralized manner. In a centralized method, all certificates and keys are stored in a centralized location and managed from a single point of administration. In large organizations, where the number of users requiring certificates and keys is very large, the management of keys is a daunting task. In such situations, the key management tasks can be decentralized. For example, if an organization has over 10,000 employees, it will not be possible to manage keys from a single location. The organization can decentralize the key management functions based on the locations of the organization or on different units of the organization.

Sometimes it becomes necessary to revoke the certificate of an individual or an organization. Circumstances that may lead to this include the following:

When a certificate is revoked, the information is sent to the CA and the CA authenticates the request and advertises the revoked certificate in the Certificate Revocation List (CRL). The administrator of CA can also manually revoke the certificate of a user without receiving or authenticating any request from the user.

The status of certificates can be checked with CAs in one of the two following methods:

Certificate Revocation List (CRL)

A CRL is maintained by the CA to keep a record of all revoked and suspended certificates. When a certificate is revoked, information in the CRL is updated. There are two main forms of CRLs: Simple and Delta. A Simple CRL contains the list of all revoked certificates, the date and time when the CRL was last published, and the next date and time when the next CRL will be published. Delta CRLs are used in large organizations where the revocation of certificates occurs in large numbers, and the size of the Simple CRL file becomes a limitation. When Delta CRLs are used, a base CRL is sent to all parties to initiate their copies of CRLs. Once this is done, further updates are periodically sent to these parties as Delta CRLs, which contain only the new and updated information.

Online Certificate Status Protocol (OSCP)

OSCP is a modified method of checking the status of revoked certificates. OSCP eliminates the need to transfer large CRL files when a party needs to check the status of revoked certificates. When the CRL receives a status request for a particular certificate over HTTP protocol, the CA responds only with the status of that particular certificate. The status information contains the status of the certificate (good, revoked, or unknown), the last update on the status, the next update of the status, and the time when the status response was sent to the requesting party. The main limitation of OSCP is that it can return the status of only a single certificate about which information is requested.