**Cryptography- Part 4**

**Hashing **

Hash functions are primarily used to provide integrity. Hashing and cryptography have a very close relationship.

A one-way function ensures that the same key can’t encrypt and decrypt a message in an asymmetric key system. A one-way function’s purpose is to ensure confidentiality. A one-way hashing algorithm produces a hashing value (or message digest) that can’t be reversed; that is, it can’t be decrypted.

Hashing provides encryption by using an algorithm without use any key. It is called one-way hash functions because there is no way to reverse the encryption.

A variable-length plaintext is hashed into a fixed-length hash value, which is usually called a message digest or a hash.

Collisions: This means that one or more documents use the common hash.

**Hashing Algorithms Family**

- Message Digest (MD): It is a family of one-way hashing algorithms that includes MD (obsolete), MD2, MD3 (not widely used), MD4, MD5, and MD6.
- Secure Hash Algorithm (SHA): This family is more secure, and widely used hashing algorithm. There are several versions of this algorithm.

**Common Hashing Algorithms **

**MD5**: It is one of the most popular hashing algorithms.MD5 produces a 128-bit digest. Messages are processed in 512-bit blocks, using four rounds of transformation. The resulting hash is typically represented as a 32-digit hexadecimal number. MD5 is susceptible to collision.**MD6**: It uses very large input message blocks (up to 512 bytes) and produces variable-length digests (up to 512 bits).**SHA1**: Published in 1995, it takes a variable size input (message) and produces a fixed-size output (160-bit message digest, versus MD5’s 128-bit message digest). SHA-1 processes messages in 512-bit blocks and adds padding to a message length, if necessary, to produce a total message length that’s a multiple of 512. This algorithm is not stable, so it is recommended not to use it.**SHA2**: Published in 2001, it consists of four hash functions — SHA-224, SHA-256, SHA-384, and SHA-512 — that have digest lengths of 224, 256, 384, and 512 bits, respectively. SHA-2 processes messages in 512-bit blocks for the 224, 256, and 384 variants, and 1,024-bit blocks for SHA-512.**SHA3**: SHA-3: Published in 2015, SHA-3 includes SHA3-224, SHA3-256, SHA3-384, and SHA3-512, which produce digests of 224, 256, 384, and 512 bits, respectively. SHAKE128 and SHAKE256 are also variants of SHA3.

**Cryptanalytic Attacks **

These attacks mean compromising keys by means of decipherment to find out the keys. The goal of cryptanalysis is to decipher the private or secret key. Here are some examples of these attacks:

**Ciphertext-only attacks**: This refers to the availability of the ciphertext to the cryptanalyst. In this Attack, the cryptanalyst obtains the ciphertext of several messages, all encrypted by using the same encryption algorithm.The cryptanalyst then attempts to decrypt the data by searching for repeating patterns and using statistical analysis. This type of attack requires a large sample of ciphertext.**Chosen-cypher text attack**: This type of attack is used to obtain the plaintext by choosing a sample of ciphertext.**Chosen-plaintext attack:**This refers to the availability of the corresponding ciphertext to the block of plaintext chosen by the analyst.**Known-plaintext attack**:In this attack, the cryptanalyst has obtained the ciphertext and corresponding plaintext of several past messages, which he or she uses to decipher new messages.**Adaptive-chosen-plain text attack**: In this attack, cryptanalyst can choose the samples of plaintext based on the results of previous encryptions in a dynamic passion.**Adaptive-chosen-cypher text attack**: This is similar to the chosen ciphertext, but the samples of ciphertext are dynamically selected by the cryptanalyst.**Man-in-the-Middle Attack**: It involves an attacker intercepting messages between two parties on a network and potentially modifying the original message.

**Digital Rights Management (DRM)**

DRM is about the protection of data, such as spreadsheets and email messages. The solutions provide a common set of foundation features:

- Restrict viewing of a document to a defined set of people
- Expire a document (rendering it unreadable after a specified date)
- Restrict editing of a document to a defined set of people
- Provide portable document protection such that the protection
- Restrict printing of a document to a defined set of people

Also see: