SHA 256 | SHA 256 Algorithm Explanation | How SHA 256 Algorithm Works | Cryptography | Simplilearn

Simplilearn
22 Jul 202114:49

Summary

TLDRThis video delves into Secure Hash Algorithms (SHA), crucial for secure communication in the digital age. It explains hashing's role in scrambling data irreversibly and the SHA family's evolution from SHA-0 to SHA-3. The script outlines how hashing secures passwords, verifies data integrity, and is integral to digital signatures and SSL handshakes. It also details the SHA algorithm's process, from padding messages to generating digests, emphasizing its security against brute force attacks.

Takeaways

  • 📝 Hashing is the process of transforming data into a scrambled format using algorithms to ensure data security.
  • đŸ’Č The primary difference between hashing and encryption is that hashing is irreversible, meaning the original data cannot be retrieved from the hash.
  • đŸ’” Hash functions like SHA are crucial for secure communication and data transmission, playing a significant role in modern technology.
  • đŸ’Č Websites commonly use hashing to store user passwords securely, preventing plain text passwords from being exposed.
  • đŸ’” Hashing verifies data integrity by comparing hash values before and after data transmission, ensuring the data has not been altered.
  • đŸ’Č The SHA (Secure Hash Algorithm) family, developed by NIST and NSA, includes SHA-0, SHA-1, SHA-2, and SHA-3, each with varying bit lengths and security features.
  • đŸ’” SHA-256 and SHA-512 are part of the SHA-2 family, with SHA-256 using 32-bit words and SHA-512 using 64-bit words, offering different levels of security.
  • đŸ’Č SHA-3 was chosen after a public competition and differs significantly in structure from the other SHA family members, providing enhanced security.
  • đŸ’” The SHA algorithm involves several steps including padding the message, initializing variables, processing blocks, and iterating through rounds to produce a hash digest.
  • đŸ’Č Hash functions are designed to be irreversible and resistant to collisions, making them essential for secure storage and transmission of sensitive data.

Q & A

  • What is the primary purpose of hashing?

    -The primary purpose of hashing is to scramble a piece of information or data beyond recognition using hash functions, which are algorithms that perform mathematical operations on the original plain text.

  • How does hashing differ from encryption?

    -Hashing differs from encryption in that hashes are irreversible; no decryption key can convert a digest back to its original plain text value.

  • What is the Secure Hash Algorithm (SHA) family?

    -The Secure Hash Algorithm family is a set of cryptographic hash functions published by the National Institute of Standards and Technology along with the NSA.

  • What are the different families of hash functions within the SHA family?

    -The SHA family includes SHA-0 (160-bit), SHA-1 (160-bit), SHA-2 (with functions like SHA-256 and SHA-512), and SHA-3 (also known as Keccak).

  • How does the SHA algorithm ensure data integrity?

    -SHA algorithms ensure data integrity by generating a fixed-size hash value (digest) from variable-sized data, which can be compared before and after data transit to verify that the data has not been corrupted.

  • Why is hashing used for storing passwords?

    -Hashing is used for storing passwords to prevent plain text passwords from being stored on servers, thereby enhancing security and protecting user privacy in the event of a data breach.

  • What is the significance of the padding process in the SHA algorithm?

    -The padding process in the SHA algorithm ensures that the plain text message is compatible with the hash function by making the total number of bits a multiple of 512, which is necessary for the hashing process.

  • How does the SHA algorithm handle different lengths of plain text?

    -The SHA algorithm handles different lengths of plain text by padding the message to ensure the total number of bits is a multiple of 512, and then processing the message in 512-bit blocks.

  • What are the characteristics that SHA family functions must follow while generating a digest?

    -SHA family functions must ensure that the digest appears random, is irreversible, and that even a slight change in the plaintext triggers a drastic difference in the digest to prevent hash collisions.

  • How does the SHA algorithm contribute to secure web browsing sessions?

    -The SHA algorithm contributes to secure web browsing sessions by being part of the SSL handshake process, which involves agreeing on encryption keys and hashing authentication to prepare a secure connection between web browsers and servers.

  • What are the advantages of using SHA hash algorithms over storing data in plain text?

    -Using SHA hash algorithms over plain text storage provides advantages such as enhanced security through irreversible hash values, protection against data tampering, and the ability to verify the authenticity of digital signatures.

Outlines

00:00

🔒 Introduction to Hashing and SHA Algorithms

This paragraph introduces the concept of hashing, explaining it as a process to scramble data using hash functions, which are algorithms that perform mathematical operations on plain text to generate a hash value or digest. It differentiates hashing from encryption by emphasizing the irreversibility of hashes. The paragraph also covers the application of hashing in password storage and data integrity verification. It introduces the Secure Hash Algorithms (SHA) family, which includes SHA-0, SHA-1, SHA-2, and SHA-3, and their origins from the National Institute of Standards and Technology (NIST) and the NSA. The paragraph sets the stage for a deeper exploration of hashing and the SHA algorithms.

05:02

🔧 How SHA Hash Functions Work

This paragraph delves into the mechanics of the SHA hash functions, detailing the process of creating a hash digest from plain text. It explains how the input message is prepared by padding bits to make it compatible with the hash function, ensuring the length is a multiple of 512 bits. The paragraph outlines the initialization of chaining variables and the processing of message blocks into 512-bit chunks, which are then further divided into 16 sub-blocks. It describes the four rounds of operations performed on each sub-block, involving 80 iterations with the use of a constant array and a non-linear function. The paragraph also touches on the importance of digest length and the characteristics that a cryptographically secure hash function should possess, such as producing random-looking digests and preventing hash collisions.

10:05

đŸ›Ąïž Benefits and Applications of SHA Hashing

The final paragraph highlights the advantages of using the SHA hash algorithm. It discusses how hashes are used in digital signatures for document verification, the secure storage of passwords to prevent unauthorized access, and the SSL handshake process for secure web browsing. The paragraph also mentions the role of hash functions in detecting file corruption by comparing hash values before and after data transmission. It concludes by emphasizing the reliability of hash functions to consistently produce the same output for the same input, which aids in ensuring data integrity and security.

Mindmap

Keywords

💡Hashing

Hashing is a process that transforms data into a fixed-size string of characters, which is typically a digest or hash value. In the context of the video, hashing is used to secure data by making it irreversible, ensuring that once data is hashed, it cannot be easily converted back to its original form. This is crucial for applications like password storage, where the original password should not be retrievable from the stored hash.

💡Secure Hash Algorithms (SHA)

The Secure Hash Algorithms (SHA) are a family of cryptographic hash functions published by the National Institute of Standards and Technology (NIST) and NSA. They are designed to take an input (or 'message') and return a fixed-size string of bytes. The video explains that SHA algorithms are used to ensure the security and integrity of data, with different versions like SHA-1, SHA-256, and SHA-512 catering to various security needs.

💡Cryptographic Hash Function

A cryptographic hash function is a special kind of hash function that is designed to be a one-way function, meaning it is infeasible to reverse it. The video emphasizes the importance of cryptographic hash functions in creating secure channels for data transmission, where the hash value appears random and any change in the input data results in a significantly different hash value.

💡Data Integrity

Data integrity refers to the accuracy and consistency of data over its entire life cycle. In the video, hashing is used to verify data integrity by comparing hash values before and after data transmission. If the hash values match, it confirms that the data has not been altered or corrupted during transit.

💡Password Storage

Password storage is a critical aspect of cybersecurity. The script explains how websites use hashing to store user passwords securely. When a user creates an account, their password is hashed and the hash is stored, not the password itself. This protects user privacy and prevents unauthorized access to plain text passwords.

💡Hash Collision

A hash collision occurs when two different inputs produce the same hash output. The video highlights the importance of avoiding hash collisions in cryptographic hash functions, as they can be exploited by attackers. SHA algorithms are designed to minimize the likelihood of collisions to maintain security.

💡Digital Signatures

Digital signatures are a security measure used to verify the authenticity of a document or file. The video mentions that hash algorithms like SHA-256 and SHA-512 play a significant role in creating digital signatures, which use asymmetric encryption to ensure that the document or file has not been tampered with.

💡SSL Handshake

The SSL handshake is a process that establishes a secure connection between a web server and a client, such as a web browser. The video explains that SHA functions are used during the SSL handshake to authenticate and agree on encryption keys, ensuring the confidentiality of data transmitted over the internet.

💡Non-linear Process

A non-linear process in the context of the SHA algorithm refers to the complex mathematical operations that are used to transform the data during the hashing process. The video describes how these operations, which vary with each round of processing, contribute to the security of the hash function by making it resistant to brute force attacks.

💡Padding

Padding is a technique used in the hashing process to ensure that the input data is of the correct length required by the hash function. The video script explains how padding is applied to the data before it is processed by the SHA algorithm, making it a crucial step in preparing the data for hashing.

💡Cryptographically Secure

Cryptographically secure refers to the property of a cryptographic system that makes it very difficult for an attacker to break. The video emphasizes that SHA hash functions are designed to be cryptographically secure by meeting requirements such as being irreversible and resistant to hash collisions.

Highlights

Technology dependency has increased due to advancements in communication and data transmission security.

Cryptography, encryption, and algorithms like DSA, RSA, AES are essential for secure communication.

Today's focus is on the Secure Hash Algorithms (SHA) family, the most advanced hash functions.

Hashing is the process of scrambling data beyond recognition using hash functions.

Hash functions generate a fixed-size string (hash value) from input data, which is irreversible.

Hashing is used for password storage and integrated verification to enhance security.

Websites use hashing to store user passwords securely without plaintext storage.

Hashing ensures data integrity by allowing verification of file contents during transit.

The SHA algorithm is a cryptographic hash function published by NIST and NSA.

SHA has four families: SHA-0, SHA-1, the SHA-2 family (SHA-256 and SHA-512), and SHA-3.

SHA-1 is a 160-bit hash function resembling the MD5 algorithm, designed for digital signatures.

SHA-2 uses different word sizes with SHA-256 using 32-bit words and SHA-512 using 64-bit words.

SHA-3, also known as Keccak, was chosen after a public competition and differs structurally from other SHAs.

Hash functions aim to produce random-looking digests and meet two main security requirements.

The SHA family has characteristics like fixed input text length and irreversible digests.

The SHA algorithm involves multiple steps including padding, initializing variables, and processing blocks.

The process includes 80 rounds of operations using a non-linear function and constant array.

The advantages of SHA include secure password storage, SSL handshake support, and file integrity checks.

SHA ensures data hasn't been tampered with, maintaining the same output for the same input.

Transcripts

play00:08

we use our wi-fi every day for work and

play00:10

we use the internet for entertainment

play00:12

and communication

play00:14

the dependency on technology is at an

play00:16

all-time high thanks to the radical

play00:18

developments and innovation in these

play00:20

last two decades

play00:22

a big portion of this belongs to

play00:24

ensuring secure channels of

play00:25

communication and data transmission

play00:28

we have already covered videos on

play00:30

cryptography encryption and other

play00:32

algorithms such as the dsa rsa aes etc

play00:38

today we will be covering the most

play00:39

advanced hash functions known today

play00:42

the secure hash algorithms family or sha

play00:46

let's take a look at the topics to be

play00:47

covered in today's video

play00:50

we take a look at what is hashing and

play00:52

its principles examples and applications

play00:55

we learn about the origin of the sha

play00:57

algorithm along with its methodology

play01:01

there are some distinct characteristics

play01:03

of the sha family that we cover as well

play01:05

we take a look at the steps needed to

play01:07

create hashed values using the sha

play01:09

algorithm and then finally learn about

play01:12

the prospective advantages for the same

play01:15

let's first get acquainted with the

play01:16

concept of hashing and its applications

play01:19

hashing is the process of scrambling a

play01:22

piece of information or data beyond

play01:24

recognition

play01:25

we can achieve this using hash functions

play01:28

which are essentially algorithms that

play01:30

perform mathematical operations on the

play01:32

main plain text

play01:33

the value generated after passing the

play01:35

plain text information through the hash

play01:37

function is called as the hash value

play01:39

digest or in general just hash of the

play01:42

original data

play01:44

while this may sound similar to

play01:45

encryption the major difference is that

play01:48

hashes are made to be irreversible

play01:50

no decryption key can convert a digest

play01:53

back to its original plain text value

play01:56

however a few hashing algorithms have

play01:58

been broken down due to the increase in

play02:00

computational complexity of the new

play02:03

generation computers and processors

play02:05

there are new algorithms that still

play02:07

stand the test of time and are being

play02:09

used among multiple areas for password

play02:11

storage integrated verification etc

play02:15

like we discussed earlier websites use

play02:17

hashing to store user passwords so how

play02:20

do they make use of these hashed

play02:21

passwords

play02:22

when a user signs up to a new account

play02:25

the password is then run through the

play02:26

hash function and the resulting digest

play02:29

is stored on the servers

play02:31

so the next time a user logs into the

play02:33

account the same password he enters is

play02:35

passed through the hash function again

play02:38

if the digest matches with the one

play02:40

stored on the server then he is allowed

play02:42

to login to the account

play02:44

this way no plain text password gets

play02:46

stored preventing both the owner from

play02:48

snooping on user data and protecting the

play02:51

user privacy in the unfortunate event of

play02:53

a data breach or a hack

play02:55

we also use hashing when it comes to

play02:57

verifying data integrity

play03:00

when a user uploads a file onto the

play03:02

internet he or she can pass the file

play03:04

through a hash function and upload its

play03:06

digest as well

play03:08

when a new user downloads the file for

play03:10

personal use they can again pass the

play03:13

file through the same hash function

play03:15

the digest values are then compared

play03:17

within the newly generated value and the

play03:20

value uploaded by the user

play03:23

if the values match then the data

play03:25

integrity is verified and the value was

play03:28

not corrupted in transit

play03:30

to generate these hash digests from a

play03:32

standard input we use hash functions

play03:35

such an example of a hash function is

play03:37

the sha algorithm

play03:39

let us learn more about it in our main

play03:41

focus for the thing

play03:44

the secure hash algorithm are a family

play03:46

of cryptographic hash functions that are

play03:49

published by the national institute of

play03:51

standards and technology along with the

play03:54

nsa

play03:55

it was passed as a federal information

play03:57

processing standard also known as fips

play04:00

it has four different families of hash

play04:02

functions

play04:03

ssj0 is a 160 bit hash function

play04:06

published in 1993 and it was closed down

play04:09

later after an undisclosed significant

play04:12

flaw

play04:13

sha-1 is also a 160-bit hash function

play04:16

which resembles the earlier md5

play04:18

algorithm this was designed by the nsa

play04:21

to be a part of the digital signature

play04:22

algorithm

play04:24

sga2 is a family of two similar hash

play04:27

functions with different block sizes

play04:29

known as the sha-256 and the sha-512

play04:33

they differ in the word size

play04:35

ssh-256 uses 32-bit words while sha-512

play04:39

uses 64-bit words

play04:42

sha-3 is a hash function properly known

play04:44

as kcac it was chosen in 2012 after a

play04:48

public competition among non-nsa

play04:50

designers

play04:51

it supports the same hash lengths as

play04:53

hsj2 and its internal structure differs

play04:56

significantly from the rest of the sha

play04:58

family

play04:59

as we have already iterated the process

play05:01

is straightforward we pass a plain text

play05:04

message to the sha hash function which

play05:06

in turn performs certain mathematical

play05:08

operations on the clear text to scramble

play05:10

the data

play05:11

the 160 bit digest received from this is

play05:14

going to be radically different from the

play05:15

plain text

play05:17

the goal of any hash function is to

play05:19

produce digests that appear to be random

play05:22

to be considered cryptographically

play05:23

secure the hash function should meet two

play05:26

requirements

play05:27

first that it is impossible for an

play05:29

attacker to generate a message that

play05:31

matches a specific hash value

play05:33

and second it should be impossible for

play05:36

an attacker to create two messages

play05:38

producing the exactly same hash value

play05:40

even a slight change in the plaintext

play05:42

should trigger a drastic difference in

play05:44

the two digest

play05:46

this goes a long way in preventing hash

play05:48

collisions which takes place when two

play05:50

different plane tests have the same

play05:51

digest

play05:53

the sha family functions have some

play05:55

characteristics that they need to follow

play05:57

while generating the digest

play05:59

let's go through a few of them

play06:05

the length of the clear text should be

play06:07

less than 2 to the power 64 bits in the

play06:09

case of sha 1 and s h 256

play06:12

this is essential to keep the plain text

play06:15

compatible with the hash function and

play06:17

the size needs to be in comparison area

play06:19

to keep the digest as random as possible

play06:24

the length of the hash digest should be

play06:26

256 bits in the sha-256 algorithm 512

play06:30

bits in the sha 512 algorithm and so on

play06:34

bigger digest usually suggests

play06:36

significantly more calculations at the

play06:38

cost of speed and space

play06:41

we typically go for the longest digest

play06:42

to bolster security but there must be a

play06:45

definite balance between the speed and

play06:47

security of a hash function

play06:53

by design all hash functions of the sha

play06:56

512 she-256

play06:58

are irreversible

play07:00

you should neither get a plain text when

play07:02

you have the digest beforehand

play07:05

nor should the digest provide the

play07:06

original value when you pass it through

play07:08

the same hash function again

play07:10

another case of protection is that when

play07:12

the hash digest is passed into the sha

play07:15

function for a second time we should get

play07:17

a completely different digest from the

play07:19

first instance

play07:20

this is done to reduce the chance of

play07:22

brute force attacks

play07:25

to achieve this level of intricacy there

play07:27

are a number of steps to be followed

play07:29

before we receive the digest

play07:31

let us take a look at the detailed

play07:32

procedure as to how the sha algorithm

play07:35

works

play07:37

the first step is to make the plain text

play07:39

compatible with the hash function

play07:41

to do this we need to pad the bits in

play07:43

the message

play07:44

when you receive the input string you

play07:46

have to make sure the size is 64 bit

play07:49

short of a multiple of 512.

play07:51

when it comes to padding the bits you

play07:53

must add one first followed by the

play07:55

remaining zeros to round out the extra

play07:57

characters

play07:59

this prepares our string to have a

play08:00

length just 64 bits less than any

play08:03

multiple of 512

play08:06

here on out we can proceed to the next

play08:08

step where we have to pad the length

play08:09

bits

play08:10

initially in the first step we appended

play08:12

the message in such a way that the total

play08:15

number of bits in the message was 64 bit

play08:17

short from becoming a multiple of 512.

play08:21

now we add the length of bits in such a

play08:23

way that the total number of bits in the

play08:25

message is a perfect multiple of 512

play08:28

that means 64 bits plus the length of

play08:31

the original message becomes a multiple

play08:33

of 512. this becomes a final string that

play08:36

needs to be hashed

play08:40

in the next step we have to initialize

play08:42

this chaining variables

play08:44

the entire plain text message can now be

play08:46

broken down into blocks of 512 bits each

play08:50

unlike other hash algorithms like md5

play08:53

which use 4 registers or buffers sha

play08:56

family use 5 buffers of 32 bits each

play08:59

they are named a b c d and e these

play09:03

registers go through multiple rounds of

play09:05

operation but the first iteration has

play09:07

fixed hexadecimal values as can be seen

play09:10

in the screen

play09:12

moving on we have to process each of the

play09:14

512-bit blocks by breaking each of them

play09:17

into 16 sub-blocks of 32 bits each

play09:20

each of them goes through four rounds of

play09:22

operation that use the entire register

play09:25

and have the 512-bit block along with

play09:27

the constant array out of those four

play09:30

rounds each round has 20 iterations so

play09:33

in general we have 80 rounds sum total

play09:37

the constant value of k is an array of

play09:39

80 elements

play09:41

of those 80 16 elements are being used

play09:44

each round so that comes out to 80

play09:46

rounds for each of those elements

play09:49

the value of t differs by the number of

play09:51

rounds as can be seen in the table below

play09:56

a single formula is necessary to

play09:58

calculate the output of each round and

play10:00

iteration

play10:01

the formula can be b c d e register is

play10:04

equal to e plus a non-linear process b

play10:08

along with a circular shift of a plus wt

play10:11

plus kt

play10:13

in this formula abcd is the register

play10:15

value of the chaining variables as we

play10:17

discussed before

play10:19

p is the logical process which has a

play10:21

different formula for each round

play10:24

s5 is a circular shift by 5 bits

play10:27

and wt is a 32-bit string derived from

play10:30

the existing sub-block

play10:32

this can be calculated depending on the

play10:34

iteration at hand

play10:36

kt signifies a single element of the 80

play10:39

character element array which changes

play10:42

depending on the particular round at

play10:44

hand

play10:44

for the values of wt the first 16 values

play10:48

are the same as that of the sub blocks

play10:50

so there is no extra calculation needed

play10:53

for the next 64 elements the value of wt

play10:56

can be calculated as shown in the

play10:58

formula here to better understand this

play11:01

let's take a look at how each of this

play11:03

goes in a sequential process we have our

play11:05

initial register using the 5 words of 32

play11:07

bits each in the first step we put the

play11:10

values of a b c and d to the subsequent

play11:14

register as the output

play11:17

next we use a non-linear process p that

play11:20

changes depending on the round and uses

play11:22

the values of b c and d as input

play11:26

whatever output is generated from the

play11:28

non-linear process it is added with the

play11:30

value of the e register

play11:33

next the value of a is circular shifted

play11:36

by 5 bits and is added with the output

play11:38

generated in the previous step

play11:41

the next step is adding the value of wt

play11:44

and the constant element of kt the

play11:46

current output is then stored in the

play11:48

register a similarly this iteration is

play11:51

repeated every round and for each sub

play11:54

block in the process once all the

play11:56

registers are complete and all the sub

play11:58

blocks are joined together to form the

play12:00

single ciphertext message we will have

play12:02

our hashed output regarding the

play12:04

non-linear process p that uses the

play12:06

values of b c and d as input the formula

play12:10

changes every round to maintain a

play12:12

complexity of the program that can

play12:14

withstand brute force attacks

play12:17

depending on the round the values are

play12:19

passed through a logical operation which

play12:21

is then added with the values of wt kt

play12:24

and so on

play12:25

now that we understand how to get our

play12:27

hash digest from the plain text let us

play12:29

learn about the advantages we obtain

play12:31

when using the sha hash algorithm

play12:34

instead of relying on data in a plain

play12:36

text format

play12:38

digital signatures follow asymmetric

play12:40

encryption methodology to verify the

play12:42

authenticity of a document or a file

play12:45

hash algorithms like ssh 256 and the

play12:48

industry standard sha 512 go a long way

play12:52

in ensuring the verification of

play12:53

signatures

play12:56

passwords need not be stored in a plain

play12:58

text format which makes them accessible

play13:00

to hackers and other malicious actors

play13:03

when using digest the database security

play13:06

also gets a boost since the size of all

play13:08

hash values will be the same

play13:10

in the event of a hack or a breach the

play13:13

malicious actor will only receive the

play13:15

hash values with no way to regenerate

play13:17

the plain text

play13:18

in this case the plain text would be

play13:20

user credentials

play13:22

since the hash functions are

play13:23

irreversible by design it has become a

play13:26

compulsion when storing passwords on the

play13:28

servers

play13:30

the ssl handshake is a crucial segment

play13:32

of the web browsing sessions and it's

play13:34

done using sha functions

play13:36

it consists of your web browsers and the

play13:38

web servers agreeing on encryption keys

play13:41

and hashing authentication to prepare a

play13:43

secure connection

play13:45

it relies on a combination of symmetric

play13:47

and asymmetric algorithms which ensure

play13:49

the confidentiality of the data

play13:51

transmitted between a web server and a

play13:53

web client like the browsers

play13:57

you can monitor file corruption by

play13:59

comparing hash values before and after

play14:01

transit

play14:02

once the hashes match file integrity

play14:05

checks are valid and data corruption is

play14:07

avoided

play14:08

hash functions will always give the same

play14:10

output for the same input irrespective

play14:12

of the iteration parameters

play14:14

it also helps in ensuring that the data

play14:17

hasn't been tampered with on route to

play14:19

the receiver of the message hope you

play14:21

learned something interesting today if

play14:23

you have any queries regarding the topic

play14:25

feel free to ask us in the comments

play14:26

section and we will get back to you as

play14:28

soon as possible subscribe to our

play14:30

channel for more amazing content like

play14:32

this and thank you for watching

play14:38

hi there if you like this video

play14:39

subscribe to the simply learn youtube

play14:41

channel and click here to watch similar

play14:44

videos turn it up and get certified

play14:46

click here

Rate This
★
★
★
★
★

5.0 / 5 (0 votes)

Étiquettes Connexes
CryptographyHash FunctionsData SecurityEncryptionSHA AlgorithmsPassword StorageData IntegrityDigital SignaturesTech InnovationSecure Channels
Besoin d'un résumé en anglais ?