Unit 2 Symmetric Key
Unit 2 Symmetric Key
Unit 2 Symmetric Key
&
Public Key Cryptography
CSE436
BLOCKCHAIN Unit 2
Symmetric
Cryptography
Cryptography
Keyless primitives
Symmetric cryptography
Data Encryption Standard (DES)
Advanced Encryption Standard (AES)
Cryptography
Alice Bob
(Sender) (Receiver)
M M
K E E K
C C
Channel
Adversary
Integrity
Integrity is the assurance that information is modifiable only by authorized entities.
Authentication
Authentication provides assurance about the identity of an entity or the validity of a message.
1. Entity Authentication
2. Data Origin Authentication
Cryptography
Non-repudiation
Non-repudiation is the assurance that an entity cannot deny a previous commitment or action by providing incontrovertible
evidence.
Accountability
Accountability is the assurance that actions affecting security can be traced back to the responsible party.
Cryptographic primitives
Digital Signature: Digitally sign the data so that no one can “deny” about their own activities. Also, others can
check whether it is authentic.
Cryptographic Hash Functions
Takes any arbitrarily sized string as input
Input M: The message
Efficiently computable
Cryptographic Hash Function: Properties
Deterministic
Always yield identical hash value for identical input data
Collision-Free
If two messages are different, then their digests also differ
Hiding
Hide the original message; remember about the avalanche effect
Puzzle-friendly
Given X and Y, find out k such that - used to solve the mining puzzle in Bitcoin Proof of Work
Hash as A Message Digest
If we observe , it is safe to assume
We need to remember just the hash value rather than the entire message – we call this as the message digest
H(M,KA),M,KA H(M,KA),M,KA
KA is the public key of Alice – A public identity that only Alice can
have
Puzzle Friendly
Say is chosen from a widely spread distribution; it is computationally difficult to compute , such that , where
and are known a priori.
Puzzle friendly property implies that random searching is the best strategy to solve the above puzzle
Secure Hash Algorithms
SHA-0: This is a 160-bit function introduced by the U.S. National Institute of Standards and Technology (NIST) in
1993.
SHA-1: SHA-1 was introduced in 1995 by NIST as a replacement for SHA-0.
This is also a 160‑bit hash function.
SHA-1 is used commonly in SSL and TLS implementations.
SHA-1 is now considered insecure, and it is being deprecated by certificate authorities.
SHA-2: This category includes four functions defined by the number of bits of the hash:
SHA‑224, SHA-256, SHA-384, and SHA-512.
SHA-3:
• This is the latest family of SHA functions. SHA3-224, SHA3-256, SHA3-384, and SHA3 ‑512 are members of
this family.
• SHA3 is a NIST-standardized version of Keccak.
• Keccak uses a new approach called sponge construction instead of the commonly used Merkle- Damgard
transformation.
RIPEMD:
• RIPEMD is the acronym for RACE Integrity Primitives Evaluation Message Digest.
• It is based on the design ideas used to build MD4.
• There are multiple versions of RIPEMD, including 128-bit, 160-bit, 256-bit, and 320-bit.
Whirlpool:
• This is based on a modified version of the Rijndael cipher known as W.
• It uses the Miyaguchi-Preneel compression function, which is a type of one-way function used for the
compression of two fixed-length inputs into a single fixed-length output.
• It is a single block length compression function.
Hash Function – SHA256
SHA256 is used in Bitcoin mining – to construct the Bitcoin blockchain
Secure Hash Algorithm (SHA) that generates 256 bit message digest
A part of SHA-2, a set of cryptographic hash functions designed by United States National Security Agency
(NSA)
SHA256 Algorithm - Preprocessing
Pad the message such that the message size is a multiple of 512
Suppose that the length of the message M is and
Append the bit “1” at the end of the message
Append zero bits, where is the smallest non-negative solution to the equation
Append the 64-bit block which is equal to the number written in binary
The total length gets divisible by 512
Partition the message into 512-bit blocks , ,…,
Every 512 bit block is further divided into 32 bit sub-blocks , ,…,
SHA-256 Algorithm
The message blocks are processed one at a time
Sequentially compute ; is the SHA-256 compression function and + means mod addition. is the hash of .
Pre-processing
1. Padding of the message is used to adjust the length of a block to 512 bits if it is smaller than the required
block size of 512 bits.
2. Parsing the message into message blocks, which ensures that the message and its padding is divided into
equal blocks of 512 bits.
3. Setting up the initial hash value, which consists of the eight 32-bit words obtained by taking the first 32
bits of the fractional parts of the square roots of the first eight prime numbers.
• These initial values are fixed and chosen to initialize the process.
• They provide a level of confidence that no backdoor exists in the algorithm.
Hash computation
4. Each message block is then processed in a sequence, and it requires 64 rounds to compute the full hash
output. Each round uses slightly different constants to ensure that no two rounds are the same.
9. Finally, after repeating steps 5 through 8 until all blocks (chunks of data) in the input message
• As shown in the preceding diagram, SHA-256 is a Merkle Damgard
construction that takes the input message and divides it into equal blocks
(chunks of data) of 512 bits.
• Initial values (or initial hash values) or the initialization vector are composed
of eight 32 bit words (256 bits) that are fed into the compression function
with the first message.
• Subsequent blocks are fed into the compression function until all blocks are
processed and finally, the output hash is produced.
• a, b, c, d, e, f, g, and h are the registers for 8 working variables.
• Maj and Ch functions are applied bitwise. Σ0 and Σ1 perform bitwise rotation.
• The round constants are Wj and Kj, which are added in the main loop (compressor function) of the ha
function,
which runs 64 times.
Open SSL
https://www.cryptool.org/en/cto/openssl
OpenSSL example of hash functions
Patterns of Hashing Data
Independent hashing
Repeated hashing
Combined hashing
Sequential hashing
Hierarchical hashing
Types of Hashing
Independent hashing
Repeated hashing
Types of Hashing
Combined hashing
Sequential hashing
Types of Hashing
Hierarchical hashing
Hash Pointer
A Cryptographic Hash Pointer (Often called Hash Reference) is a pointer to a location where
Some information is stored
Hash of the information is stored
DATA
Hash Pointer
Tamper Detection using Hash Pointer
Making Tampering a Hash Chain
Computationally Challenging
Detect Tampering from Hash Pointers -
Hashchain
L1 Hash L1 Hash
H0= Hash(H00+H01) H1=Hash(H10+H11)
T1 T2 T3 T4
Blockchain as a Hashchain
Block Header Block Header Block Header
nonce:
• This is a number that can be used only once in a cryptographic protocol.
• It must not be reused.
• Nonces can be generated from a large pool of random numbers or they can also be sequential.
• The most common use of nonces is to prevent replay attacks in cryptographic protocols.
salt:
• Salt is a cryptographically strong random value that is typically used in hash functions to provide defense
against
dictionary or rainbow attacks.
• Using dictionary attacks, hashing-based password schemes can be broken by trying hashes of millions of
words from a dictionary in a brute-force manner and matching it with the hashed password.
• If a salt is used, then a dictionary attack becomes difficult to run because a random salt makes each password
unique, and secondly, the attacker will then have to run a separate dictionary attack for random salts, which
is quite unfeasible.
Message authentication codes (MACs)
• Block ciphers
• Stream ciphers
RC4 and A5
Stream ciphers
Stream ciphers are encryption algorithms that apply encryption algorithms on a bit-by-bit basis (one bit at a
time) to plaintext using a keystream.
Block ciphers
• break up the text to be encrypted (plaintext) into blocks of a fixed length and apply the encryption block by
block.
• built using a design strategy known as a Feistel cipher
• block ciphers such as AES (Rijndael) have been built using a combination of substitution and permutation
called a
• Substitution-Permutation Network (SPN).
• Feistel networks operate by dividing data into two blocks (left and right) and processing these blocks via
keyed
• round functions in iterations to provide sufficient pseudorandom permutations.
• achieve desirable cryptographic properties known as confusion and diffusion.
• Confusion
• Diffusion
Various modes of operation for block ciphers are :
most straightforward mode, but it should not be used in practice as it is insecure and can reveal information:
Cipher block chaining
IV be randomly chosen
Counter mode
• works by utilizing a nonce (N) and a counter (C) that feed into the block cipher
encryption function.
• The block cipher encryption function takes the secret key (KEY) as input and
produces a keystream (a stream of pseudorandom or random characters), which,
when XORed with the plaintext (P), produces the ciphertext (C).
Message authentication mode
• cryptographic checksum that provides an integrity
• method to generate a MAC using block ciphers is CBC-MAC
• block ciphers are used in the cipher block chaining mode (CBC mode)
to generate a MAC
• used to check if a message has been modified by an unauthorized
entity
• can be achieved by encrypting the message with a key using the
• resulting message and the MAC of the message, once received by the receiver, are
MAC functionchecked by encrypting the message received, again with the key, and comparing
it with the MAC received from the sender.
• If they both match, then it means that the message has not been modified by some
unauthorized entity, thus an integrity service is provided.
• If they don't match, then it means that the message has been altered by some
unauthorized entity during transmission.
Cryptographic hash mode
• This problem was addressed with the introduction of Triple DES (3DES),
which proposed the use of a 168-bit key by means of three 56-bit keys and the
same number of executions of the DES algorithm, thus making bruteforce
attacks almost impossible.
• However, other limitations, such as slow performance and 64- bit block size,
were not desirable.
Advanced Encryption Standard (AES)
2. SubBytes: This is the substitution step where a lookup table (S-box) is used to replace all bytes of the
state array.
3. ShiftRows: This step is used to shift each row to the left, except for the first one, in the state array in a
cyclic and incremental manner.
4. MixColumns: Finally, all bytes are mixed in a linear fashion (linear transformation), column-wise.
https://www.google.com/search?q=aes+animation&rlz=1C1JZAP_enIN872IN872&source=lnms&tbm=vid&sa
=X&ved=2ahUKEwidw9KHsun8AhXkR2wGHWZ0CVUQ_AUoAXoECAEQAw&biw=1280&bih=569&dpr=
1.5#fpstate=ive&vld=cid:a2b15287,vid:gP4PqVGudtg