Cryptography and Cryptographic Algorithms
Cryptography and Cryptographic Algorithms
Cryptographic Algorithms
Cryptography:
● Cryptography is the technique of converting ordinary plain text into
unintelligible text and vice-versa.
● It is the practice and study of techniques for secure communication in the
presence of third parties.
● It is also referred by the terms Cryptology and Cryptanalysis.
● It is a method of storing and transmitting data in a particular form so that only
those for whom it is intended can read and process it.
● Cryptology is about constructing and analyzing protocols that prevent third
parties or the public from reading private messages.
● Cryptography is most often associated with scrambling plaintext into cipher
text (a process called encryption), then back again (known as decryption).
Encryption:
● Encryption is the process of encoding a message or information in such a way
that only authorized parties can access it and those who are not authorized
cannot.
● Encryption does not itself prevent interference, but denies the intelligible
content to a would-be interceptor.
Decryption:
● Decryption is the process of taking encoded or encrypted text or other data
and converting it back into text that you or the computer can read and
understand (original form).
● It is generally a reverse process of encryption. It decodes the encrypted
information so that an authorized user can only decrypt the data because
decryption requires a secret key or password.
Cont.
Plain text: Plaintext or cleartext is unencrypted information.
Cipher text: Ciphertext is encrypted text. Plaintext is what you have before encryption, and
ciphertext is the encrypted result. The term “cipher” is sometimes used as a synonym for
ciphertext, but it more properly means the method of encryption rather than the result.
Transposition cipher: A transposition cipher rearranges the characters in the plaintext to form
ciphertext. The letters are not changed.
e.g. HELLO WORLD
HLOOL ELWRD
The rearrangement of the text is based on the permutation. It just rearranges the given
information without modifying it.
Substitution cipher: A substitution cipher changes characters in the plaintext to produce the
ciphertext.
e.g. HELLO WORLD
KHOOR ZRUOG (key 3)
Data Encryption Standard
● The Data Encryption Standard(DES) works by using the same key to encrypt
and decrypt a message, so both the sender and the receiver must know and
use the same private key.
● DES is an outdated symmetric-key method of data encryption.
● DES has been upgraded by the more secure Advanced Encryption Standard
(AES) algorithm.
● Originally designed by researchers at IBM in the early 1970s, DES was
adopted by the U.S. government as an official Federal Information Processing
Standard (FIPS) in 1977 for the encryption of commercial and sensitive yet
unclassified government computer data.
● It was the first encryption algorithm approved by the U.S. government for
public disclosure.
Cont.
● The Data Encryption Standard is a block cipher, meaning a cryptographic key
and algorithm are applied to a block of data simultaneously rather than one bit
at a time.
● To encrypt a plaintext message, DES groups it into 64-bit blocks. Each block
is enciphered using the secret key into a 64-bit ciphertext by means
transposition and substitution.
● The process involves 16 rounds and encrypting blocks individually or making
each cipher block is dependent on all the previous blocks.
● DES has an effective key length of 56 bits, since 8 of the 64 bits of the key
are not used by the encryption algorithm (function as check bits only).
● The check bits or parity bits are used to check if the key was indeed correctly
retrieved.
Cont.
Cont.
Cont.
● The output text of each round is the input to next round.
● The keys for each round is separate which is just the result of left circular shift
operation of the original key.
● The round key generator is the component which is responsible to generate
16 sub keys for 16 rounds.
● The round operation is nothing but the XOR operation between the plain text
and the key.
● The final key to the ciphertext is the resulting key at the end of 16 rounds.
● Decryption is simply the inverse of encryption, following the same steps but
reversing the order in which the keys are applied.
Cont.
● It would take a maximum of 2^56, or 72,057,594,037,927,936 attempts to find
the correct key.
● For any cipher, the most basic method of attack is brute force, which involves
trying each key until you find the right one.
● Even though few messages encrypted using DES encryption are likely to be
subjected to this kind of code-breaking effort, many security experts felt the
56-bit key length was inadequate even before DES was adopted as a
standard.
● Thus, DES is upgraded to more secure Advanced Encryption Standard (AES).
Symmetric Key Cryptography
● Symmetric-key algorithms are the algorithms for cryptography that use the
same cryptographic keys for both encryption of plaintext and decryption of
ciphertext.
● Symmetric-key systems are simpler and faster, but their main drawback is
that the two parties must somehow exchange the key in a secure way.
● Public-key cryptology, which utilizes two keys - a public key to encrypt
messages and a private key to decrypt them.
Stream Cipher:
● A stream cipher is a symmetric key cipher where plaintext digits are combined
with a keystream.
● A keystream is a stream of random characters that are combined with a
plaintext message to produce an encrypted message.
● In a stream cipher, each plaintext digit is encrypted one at a time with the
corresponding digit of the keystream, to give a digit of the ciphertext stream.
Block cipher:
● A block cipher is an encryption method that applies a deterministic algorithm
along with a symmetric key to encrypt a block of text, rather than encrypting
one bit at a time.
● Block cipher is widely used to implement encryption of bulk data.
● A block cipher consists of two paired algorithms, one for encryption, E, and
the other for decryption, D.
● Both algorithms accept two inputs: an input block of size n bits and a key of
size k bits; and both yield an n-bit output block.
● The decryption algorithm D is defined to be the inverse function of encryption.
Cont.
● Message authentication assures that data received are exactly as sent (i.e., there is no modification,
insertion, deletion, or replay).
● In many cases, there is a requirement that the authentication mechanism assures that purported
identity of the sender is valid.
● When a hash function is used to provide message authentication, the hash function value is often
referred to as a message digest.
● The essence of the use of a hash function for message integrity is as follows.
○ The sender computes a hash value as a function of the bits in the message and transmits both
the hash value and the message. The receiver performs the same hash calculation on the
message bits and compares this value with the incoming hash value.
○ If there is a mismatch, the receiver knows that the message (or possibly the hash value) has
been altered.
Cont.
● The hash value must be transmitted in a secure fashion. That is, the hash value must be protected
so that if an adversary alters or replaces the message, it is not feasible for adversary to also alter
the hash value to fool the receiver. This type of attack is shown in Figure
Cont.
● In this example, Alice transmits a data block and attaches a hash value. Darth intercepts the
message, alters or replaces the data block, and calculates and attaches a new hash value.
Bob receives the altered data with the new hash value and does not detect the change. To
prevent this attack, the hash value generated by Alice must be protected.
Message Authentication Functions:
Any message authentication mechanism has two levels of functionality. At the lower level,
there must be some sort of function that produces an authenticator: a value to be used to
authenticate a message. This lower-level function is then used as a primitive in a higher-level
authentication protocol that enables a receiver to verify the authenticity of a message.
There are three types of functions that may be used to produce an authenticator.
● Hash function: A function that maps a message of any length into a fixed- length hash
value, which serves as the authenticator.
● Message encryption: The ciphertext of the entire message serves as its authenticator.
● Message authentication code (MAC): A function of the message and a secret key
that produces a fixed-length value that serves as the authenticator.
Message Encryption
Message encryption by itself can provide a measure of authentication. The analysis differs
for symmetric and public-key encryption schemes
Message Authentication Code (MAC):
A authentication technique that involves the use of a secret key to generate a small
fixed-size block of data that is appended to the message is known as Message
Authentication Code (MAC). This technique assumes that two communicating parties, say A
and B, share a common secret key K. When A has a message to send to B, it calculates the
MAC as a function of the message and the key:
MAC = C (K, M)
where
M = input message
C = MAC function
The message plus MAC are transmitted to the intended recipient. The recipient performs the
same calculation on the received message, using the same secret key, to generate a new
MAC. The received MAC is compared to the calculated MAC.
Cont
Cryptographic Hash Function:
● A cryptographic hash function (CHF) is a hash function that is suitable for use in
cryptography.
● It is a mathematical algorithm that maps data of arbitrary size (often called the "message") to
a bit string of a fixed size (the "hash value", "hash", or "message digest") and is a one-way
function, that is, a function which is practically infeasible to invert.
● Ideally, the only way to find a message that produces a given hash is to attempt a brute-force
search of possible inputs to see if they produce a match, or use a table of matched hashes.
● Cryptographic hash functions are a basic tool of modern cryptography
Properties of Hash Function
The ideal cryptographic hash function has the following main properties:
● it is deterministic, meaning that the same message always results in the same hash
● it is quick to compute the hash value for any given message
● it is infeasible to generate a message that yields a given hash value (Pre-Image Resistant)
● it is infeasible to find two different messages with the same hash value (Collision Resistance)
● A small change to a message should change the hash value so extensively that the new
hash value appears uncorrelated with the old hash value (avalanche effect)
Applications of Hash Function
Given that the hash depends on the input to the hash function and will change with the input hash
functions are used
● to ensure that messages have not been tampered with (message authentication, digital
signatures, checksums) and
● to check for equality while preserving secrecy / efficiently (for example, checking if password
is correct without storing the actual password, or checking for duplicates in lists of large
items).
● They are also used as proof-of-work (for example, in cryptocurrencies like bitcoin), error-
correcting codes, randomization and to make cryptographic algorithms more efficient.