Cryptography - History and Basics

Cryptography - Symmetric Key Algorithms

Cryptography - Asymmetric Key Algorithms

Cryptography - Hash Functions & Digital Signatures

Cryptography - Applications

Symmetric Key Algorithms - Definition

Symmetric Key Algorithms are based on a shared secret key which is distributed to all members participating in the encrypted communication. The key is used to encrypted and decrypt the message. The sender and receiver are both in the possession of a copy of the shared key.

When large keys are used, the symmetric encryption is very difficult to break. The primary use case for it is bulk encryption (eg. hard drives) with a high speed.

Alternative terms: private key cryptography or shared private key

a picture representing symmetry

Advantage of Symmetric Key Cryptography

Secure Symmetric Key Cryptography is extremely secure if it is used with a secure algorithm, and a large key.

Fast Encrypting and Decrypting symmetric key data is considerably faster than in asymmetric key algorithms

Disadvantages of Symmetric Key Cryptography

Key distribution is a major problem since parties must have a secure method of exchanging the secret key before communication can be established. The method of offline key distribution is called out-of-band exchange.

Nonrepudiation is not given since each party uses the same key to encrypt and decrypt. There is no way to prove the origin of a message.

Not scalable secure communication in a group can only be achieved if each possible combination of users exchanges a shared private key.

Number of Keys = (n(n-1)/2

Key regeneration all keys must be regenerated if one user leaves the group.

DES - Data Encryption Standard

The Data Encryption Standard or DES is a symmetric-key algorithm that was developed in the early 1970s. Its short key length of 56-bit (+8 bit parity) was criticized from the beginning. Nowadays, this algorithm is no longer recommended for use since intelligence agencies are believed to routinely decrypt DES-encrypted information. This algorithm is nevertheless important to understand because it is highly influential for the more advanced modern cryptography algorithms.

DES is the archetypal block cipher - an algorithm that takes a fixed-length string of plaintext bits (DES: 64-bit) and transforms it into a ciphertext string of the same length. In the case of DES, the transformation is accomplished by an exclusive OR (XOR) operation. This process is repeated 16 times for each encryption/decryption operation.

It supports 5 different modes:

Electronic Code Book Mode - ECB is the simplest mode and the least secure. Each time the algorithm processes a 64-bit block, it simply encrypts the block using the secret key. Encrypting the same block twice produces the same result. This makes the mode vulnerable to building a “code book”. After a sufficient number of encrypted blocks are gathered, cryptoanalytic techniques could decipher some of the blocks and break the encryption. ECB was only used for the exchange of small amounts of data such as keys or parameters or for encrypting the fields in a database.

Cipher Block Chaining Mode - CBC describes the mode in which each unencrypted block of text is XORed with the block of ciphertext preceding it before it is encrypted. The decryption process simply reverses this behavior. CBC introduces an initialization vector (IV) and XORs it with the first block of the to be encrypted message. This IV is sent to all recipients either in plaintext or by using ECB. The main problem of CBC is that errors in the message propagate. One corrupted block makes it impossible to decrypt the message.

Cipher Feedback Mode - CFB is simply the streaming version of CBC. It operates against data in real-time. Instead of working with 64-bit blocks of text is uses a memory buffer of the same block size. It encrypts the buffer once it is full and sends it to the recipients. CFB operates in the same fashion as CBC, it uses an IV and is chaining the blocks (buffers).

Output Feedback Mode - OFB operates on streaming data with buffers in the same way as CFB. However, instead of XORing the encrypted version of the previous block (buffer), it uses a seed value as the IV. Future seed values are derived by running the DES algorithm on the previous seed value. The biggest advantage of this mode is that there is no chaining function and therefore, errors do not propagate. This makes the mode more robust.

Counter Mode - CTR is similar to OFC but instead of creating the seed value for each encryption/decryption from the results of the previous seed values, it uses a simple counter and increments it for each operation. As with OFB mode, errors do not propagate in CTR mode. CTR also allows to break the operation (encryption/decryption) in multiple steps and is therefore well suited for parallel computing.

3DES - Triple DES

The 56-bit key of DES is no longer considered adequate in the times of modern cryptoanalytic and the availability of almost endless computational power (cloud). An adapted version of called Triple DES or 3DES uses the same algorithm to produce more secure encryption.

There are four versions of 3DES:

DES-EEE3 encrypts the plaintext 3 times using 3 different keys (K1, K2, and K3) and runs 3 encryption operations. It has an effective key length of 168-bit. (P = plaintext, E = encryption)

E(K1,E(K2,E(K3,P)))

DES-EDE3 uses also 3 keys but replaces the second encryption operation with a decryption operation. The key length is 168-bit.

E(K1,D(K2,E(K3,P)))

DES-EEE2 uses only 2 keys as follows and has an effective key length of 112-bit.

E(K1,E(K2,E(K1,P)))

DES-EDE2 uses 2 keys and replaces the second encryption operation with a decryption operation. The key length is 112-bit.

E(K1,D(K2,E(K1,P)))

IDEA - International Data Encryption Algorithm

IDEA was developed in response to the criticism of the insufficient key length of DES. Like DES it operates on 64-bit blocks or buffers of plaintext/ciphertext. It begins the operation with a 128-bit key which is broken up in 56x 16-bit subkeys. The subkeys are then used in a combination of XOR and modulus to produce the encrypted/decrypted version of the input message. IDEA is operating with the same five modes of DES: ECB, CBC, CFB, OFC, and CTR. One well-known implementation of IDEA is Phil Zimmerman’s Pretty Good Privacy (PGP).

Blowfish

Another alternative to DES and IDEA is Bruce Schneier’s Blowfish block cipher. It also operates with 64-bit blocks of text but allows to define the key length ranging from a relative insecure 32-bit to an extremely strong 448-bit. With longer keys, the encryption/decryption time obviously increases. Blowfish was released for public use and is built in a number of commercial and open source products (eg. SSH, or Linux).

Skipjack

This algorithm uses 64-bit blocks of text and an 80-bit key. It supports all modes of operation of DES and was adopted by the U.S. government. It has an added feature of supporting the escrow of encryption keys. Two government agencies (National Institute of Standards and Technology - NIST and Department of Treasury - DOT), hold a portion of the information required to reconstruct a Skipjack key. Law enforcements can obtain the pieces of keys, and decrypt Skipjack communication. This algorithm was obviously not embraced by the cryptographic community but is in wide use with the U.S. government.

RC2/RC5 - Rivest Cipher (RSA)

This is a symmetric key algorithm patented by Rivest-Shamir-Adleman (RSA) Data Security and is found in commercial products.

  • RC2 uses a block size of 64-bit and a key size of 128-bit.
  • RC5 uses a block size of 32, 64, or 128-bit and a variable key size ranging from 0 - 2040-bit

AES/Rijndael - Advanced Encryption Standard

AES allows three key strengths: 128 bits, 192 bits, and 256 bits and encrypts 128-bit blocks of text. The underlying block-cipher Rijndael exceeds the AES specification and allows to use a block size equal to the key length. The number of encryption rounds in AES depends on the key length:

  • 128-bit key -> 10 rounds of encryption
  • 192-bit key -> 12 rounds of encryption
  • 256-bit key -> 14 rounds of encryption

Twofish

The Twofish was also developed by Bruce Schneier and was a finalist in the AES contest. Twofish is a block cipher and operates on 128-bit blocks of data. It is capable of using key sizes ranging from 1 - 256-bit in length. Twofish introduces two new techniques which are not found in other algorithms:

Prewhitening is the process of XORing the plaintext with a separate subkey before the first round of encryption.

Postwhitening uses a similar operation after the 16th round of encryption.


Distribution of Symmetric Keys

One of the major challenges of symmetric encryption algorithms is the secure distribution the secret keys. There are three general methods used to exchange keys securely.

Offline Distribution This is the technically most simple method and requires the physical exchange of the key material in the meatspace. One party provides the other with a medium (e.g. sheet of paper, or flash drive) which contains the secret key.

Public Key Encryption Here we overcome the hassle of secret key distribution by using public key encryption for the initial setup of the communication (exchange of secret key). Once the secret key has been exchanged, the communication switches to a secret key algorithm to benefit from increased processing speed.

Diffie-Hellman There are use-cases where offline distribution is not feasible (no physical means) and public key encryption is not available (lack of public key infrastructure). In a situation like this so-called key exchange algorithms like Diffie-Hellmann are useful mechanisms to exchange the secret key to enable symmetric key communication.

1. Bob and Alice have to agree on two large numbers. P (prime number) and G (integer) such that:

1 < G < P

2. Bob now chooses a random large integer R and performs the following calculation:

B = G^R mod P

3. Alice chooses a random large integer S and performs the following calculation:

A = G^S mod P

4. Bob sends B to Alice and she sends A to Bob.

5. Bob performs the following calculation:

K = A^R mod P

6. Alice performs the following calculation:

K = B^S mod P

At this point both Bob and Alice have the same value K, and can use this for communication with a symmetric key algorithm.