Hashing and Digital Signatures - SY0-601 CompTIA Security+ : 2.8

Professor Messer
7 Mar 202110:51

Summary

TLDRThe video explains how hashing algorithms convert any input—like files or passwords—into a fixed-size, unique string called a hash, which acts like a digital fingerprint. Hashing is a one-way process, meaning the original data cannot be reconstructed from the hash. It's used for secure password storage, data integrity verification, and digital signatures. Collisions, where two different inputs generate the same hash, are rare but problematic. Salting, which adds randomization to passwords, makes them more secure. The video also covers how digital signatures verify message authenticity and integrity using hashing and encryption.

Takeaways

  • 🔐 A hash is a unique string generated from any type of input (document, audio, video, etc.), acting like a fingerprint for the data.
  • 🛑 A hash is a one-way function, meaning you cannot recreate the original file from the hash.
  • 🔑 Hashing is commonly used for securely storing passwords by converting them into a hash, preventing access to the original password.
  • 🔍 Hashing ensures data integrity by verifying that two copies of the same file have identical hashes.
  • 🧾 Digital signatures use hashing in combination with encryption to authenticate data sources and confirm integrity.
  • 🚫 Collisions, where different inputs create the same hash, are rare but occurred with the MD5 algorithm, making it less reliable.
  • 🧂 Adding a 'salt' (a random value) to a hash prevents attackers from using precomputed 'rainbow tables' to crack passwords.
  • ⚡ Even a small change in the input will result in a completely different hash, showcasing the sensitivity of hashing algorithms.
  • 🗝️ Digital signatures involve encrypting a hash with a private key, and recipients verify the signature using the sender's public key.
  • 🛠️ Hashing algorithms like SHA256 create fixed-length outputs, regardless of the input size, providing consistency for verification.

Q & A

  • What is a hash, and what is its primary purpose?

    -A hash is a function that converts any input, such as a document, audio, video, or file of any size, into a unique string of text called a message digest. Its primary purpose is to create a fixed-size representation (or fingerprint) of the data, ensuring data integrity and secure storage of sensitive information like passwords.

  • Why is hashing considered a one-way process?

    -Hashing is considered a one-way process because once data is converted into a hash, it's impossible to reverse-engineer the original data from the hash. This property makes hashing ideal for securely storing passwords and ensuring data integrity.

  • How is hashing used to store passwords securely?

    -When a password is hashed, the original password is transformed into a fixed-size hash value. This hash is stored instead of the plain text password. When a user logs in, the system hashes the input password and compares it to the stored hash. If they match, access is granted. This prevents storing passwords in plain text and protects against unauthorized access.

  • What is the purpose of adding 'salt' to a hash, and how does it improve security?

    -Adding 'salt' to a hash involves introducing a random value to each password before hashing it. This ensures that even if two users have the same password, their stored hash values will be different. This process prevents attackers from using precomputed hash values, known as rainbow tables, to crack passwords.

  • What is a hash collision, and why is it problematic?

    -A hash collision occurs when two different inputs produce the same hash value. This is problematic because it undermines the uniqueness of the hash function, potentially allowing malicious data to be validated as authentic or causing confusion in data integrity checks.

  • Why is the MD5 hashing algorithm no longer recommended for use?

    -The MD5 hashing algorithm is no longer recommended because it is vulnerable to hash collisions. In 1996, it was discovered that MD5 could generate the same hash for different inputs, which compromises its security and integrity.

  • How does hashing ensure the integrity of a file during transfer?

    -To ensure file integrity during transfer, a hash of the original file is created before the transfer. After the file is received, the same hashing algorithm is applied to the transferred file. If the resulting hash matches the original hash, the file has not been altered during transfer.

  • What role does hashing play in digital signatures?

    -In digital signatures, hashing is used to create a unique hash of a document. This hash is then encrypted with the sender's private key to create the digital signature. The recipient can decrypt the signature with the sender's public key and compare the resulting hash with the hash of the received document to verify the authenticity and integrity of the message.

  • What is the difference between a public key and a private key in digital signatures?

    -A private key is used by the sender to sign a document, creating a digital signature, while a public key is used by the recipient to verify the signature. The private key is kept secret and known only to the sender, while the public key is shared openly.

  • How does a digital signature verify the sender's identity and message integrity?

    -A digital signature verifies the sender's identity and message integrity by using the sender's private key to encrypt a hash of the message. The recipient decrypts the signature using the sender's public key and compares the hash with a newly generated hash of the message. If they match, it confirms the sender's identity and that the message has not been altered.

Outlines

00:00

🔒 Understanding Hash Functions and Their Role

A hash function converts any type of input, whether a document, video, or other file, into a unique string of text called a 'message digest' or fingerprint. This one-way process means it's impossible to recreate the original data from the hash. Hashes are commonly used for storing passwords securely since it's difficult to derive the original password from the hash. They also help verify file integrity, ensuring that files copied or transferred are exact replicas by comparing their hashes. Hashing is often used with encryption to create digital signatures, enhancing data authenticity and integrity. If two inputs produce the same hash, it's called a 'collision,' which indicates a flaw in the algorithm.

05:01

🔑 Hashing Passwords: Salt and Rainbow Tables

When storing passwords, hashing with added 'salt' is used to avoid identical hashes for users with the same password. Salt adds randomization to the hash, ensuring that even identical passwords result in different hashes. This extra step prevents attackers from using rainbow tables—precomputed tables of hash values—to crack passwords. Although brute force attacks can still be used, adding salt significantly increases the time required for such attacks. By using a salt for each password, identical passwords appear as different hashes, making it harder for attackers to exploit identical passwords across accounts.

10:02

📜 How Digital Signatures Ensure Authenticity

Digital signatures use hashing and encryption to confirm the authenticity of a message. For example, Alice sends a message to Bob saying 'You're hired, Bob,' and wants to prove its authenticity. She first hashes the message, then encrypts the hash using her private key, creating a digital signature. This signature is attached to the plain message and sent to Bob. To verify the signature, Bob uses Alice's public key to decrypt the signature and retrieves the hash. He then compares it with the hash he computes from the received message. If both hashes match, Bob knows the message is authentic and unaltered.

🔏 Verifying Integrity with Hashing

When Bob receives the digitally signed message, 'You're hired, Bob,' he needs to verify its integrity. First, he decrypts the digital signature using Alice's public key, retrieving the original hash that Alice created. Next, he performs the same hashing algorithm on the plain text message and compares both hashes. If the hashes are identical, it confirms that the message is legitimate, from Alice, and has not been altered during transmission. This process ensures both the authenticity of the sender and the integrity of the message.

Mindmap

Keywords

💡Hash

A hash is a string of text generated from input data, such as a document or file, using a hashing algorithm. It serves as a 'fingerprint' of the input, providing a unique identifier for any type of file or data. In the video, the hash is described as a one-way process that cannot be reversed to retrieve the original data, making it a secure method for tasks like password storage and file integrity checks.

💡Message Digest

A message digest is another term for a hash value, often used to describe the result of a hashing process. It is a fixed-size output created from variable-sized data. In the video, the message digest is likened to a fingerprint that uniquely represents the input data, ensuring that even a small change in the input will produce a completely different digest.

💡Collision

A collision occurs when two different inputs produce the same hash value, which is undesirable in secure hashing. The video highlights an example involving the MD5 algorithm, where such collisions were discovered, leading to its reduced use for security purposes. Collisions undermine the reliability of a hashing algorithm by compromising its uniqueness.

💡SHA256

SHA256 is a secure 256-bit hashing algorithm that produces a 64-character hexadecimal hash. It is used to generate unique hashes for inputs of varying sizes, ensuring data integrity and security. In the video, SHA256 is used as an example of how even a small change in the input, such as a punctuation mark, can result in a completely different hash.

💡Password Hashing

Password hashing is the process of converting a password into a hash for secure storage. The video explains how passwords are hashed to prevent direct access to the original passwords, even if the hash data is exposed. By using hash functions, authentication systems can verify users without storing their actual passwords.

💡Salt

Salt refers to the random value added to a password before it is hashed. This process ensures that even identical passwords result in different hashes, enhancing security. The video explains how salt prevents attackers from using pre-computed tables (rainbow tables) to crack hashes and adds an extra layer of protection to password storage.

💡Digital Signature

A digital signature is a cryptographic tool that verifies the authenticity and integrity of a message or document. It is created by hashing the data and then encrypting the hash with the sender's private key. In the video, Alice uses a digital signature to prove that her message to Bob is legitimate, ensuring it hasn’t been tampered with and that it truly came from her.

💡Public Key

A public key is part of a cryptographic key pair used in asymmetric encryption. It is openly shared and used to verify digital signatures created by a corresponding private key. In the video, Bob uses Alice’s public key to verify the digital signature on the message, confirming its authenticity and that it originated from Alice.

💡Integrity

Integrity in the context of hashing refers to ensuring that data has not been altered or tampered with. The video explains how hashing is used to verify the integrity of files by comparing hash values before and after data transfer. If the hashes match, it confirms that the file is unchanged.

💡Non-repudiation

Non-repudiation is a security principle that ensures an individual cannot deny the authenticity of their signature on a document or a message they sent. In the video, non-repudiation is guaranteed by the use of digital signatures, as only the person with the private key (e.g., Alice) could have signed the message, making it impossible to deny the origin.

Highlights

A hash creates a unique string from any input, such as documents, audio, video, or small files.

Hashes are often referred to as message digests or fingerprints, which uniquely represent data.

A hash is a one-way function, meaning it cannot be reversed to retrieve the original data.

Hashes provide a secure method for storing passwords since the original password can't be retrieved from the hash.

Hashes can ensure file integrity by comparing the hash of a copied file to the original.

Digital signatures combine hashing and encryption to verify the source, integrity, and authenticity of a message.

Hashes are unique for a specific input, and different inputs should never generate the same hash.

A 'collision' occurs when two different inputs create the same hash, a problem identified with the MD5 algorithm.

The MD5 algorithm had a collision issue discovered in 1996, making it less reliable for modern hashing.

When downloading a file, users can compare the provided hash with the hash of their downloaded file to verify its authenticity.

Salting adds random data to hashes, ensuring even identical passwords generate different hashes.

Rainbow tables are precomputed hash values, but salting renders them ineffective due to added randomization.

Digital signatures allow for authentication by verifying that a message truly came from the claimed sender.

A private key is used to create a digital signature, while a public key verifies it, ensuring that only the owner could have sent the message.

The process of verifying a digital signature involves comparing the hash of the plain text message with the decrypted signature hash to ensure integrity.

Transcripts

play00:02

A hash is designed to take any type of input,

play00:04

whether that's a document, some audio, a video file, a very

play00:09

large file, or a very small file and create

play00:12

a very specific unique string of text that's

play00:15

associated with that file.

play00:17

This is sometimes referred to as a message digest,

play00:20

and you can think of it as a fingerprint.

play00:22

If you take a fingerprint and look at it,

play00:25

we know where that fingerprint came from.

play00:27

We know there's only one thing that

play00:29

can be associated with that fingerprint

play00:31

and that no other person has that particular fingerprint.

play00:34

Just like you're not able to recreate an entire person based

play00:38

on their fingerprint, you can't recreate an entire file

play00:41

based on the hash.

play00:43

This hash is a one-way trip.

play00:45

Once we take the hashing algorithm

play00:47

and apply it to some data, that hash

play00:49

provides us with some output that does not

play00:52

allow us to go the other direction

play00:54

and somehow recreate the data based on that hash.

play00:57

Because of that, it's a perfect solution for storing passwords.

play01:01

We can take a password, which really no one should

play01:03

have access to, create a hash of that password,

play01:07

and then refer to the hash every time we want to authenticate.

play01:11

This allows us to store the password securely.

play01:13

And if somebody did gain access to those hashed passwords,

play01:17

they wouldn't have any idea what the original password was.

play01:21

We can often use hashing to provide integrity.

play01:23

So we can take a hash of a file, we

play01:25

can copy that file somewhere else,

play01:27

we can perform that same hashing algorithm,

play01:30

and then compare the hash that we got on both ends.

play01:33

If the hashes are identical, then the file that we copied

play01:35

is exactly the same file as the original.

play01:38

We also use hashing in combination with encryption

play01:42

to create digital signatures.

play01:43

That provides authentication, which tells us

play01:46

where this data came from, non-repudiation,

play01:49

which means we can tie it back to a specific person,

play01:52

and of course, the integrity feature is still

play01:54

part of that hashing algorithm.

play01:57

One unique aspect of a hash is that there is always

play02:00

a unique hash for a particular kind of input.

play02:03

You will never have two different kinds of input

play02:06

create the same hashing value.

play02:08

If you do find that two different inputs are creating

play02:11

the same hash in the output, then you've found a collision,

play02:14

and this is something you would not

play02:16

want to have with a hashing algorithm.

play02:19

Let's have a look at some hashes.

play02:20

We'll perform a SHA256 hash, which

play02:23

is a 256-bit hashing algorithm.

play02:26

It outputs the equivalent of 64 hexadecimal characters.

play02:30

And we'll take a single sentence.

play02:32

My name is Professor Messer with a period at the end.

play02:35

If we hash that single sentence, we get this entire value

play02:39

as the SHA256 hash.

play02:42

Let's create a hash of a similar input.

play02:44

We'll have an input of My name is

play02:46

Professor Messer with an exclamation mark

play02:48

at the end of it.

play02:50

You'll notice that the hashing value of this second input

play02:53

is very different than the hashing value we

play02:55

had on the original input.

play02:57

In fact, almost every single character of that hash

play03:00

is a different value even though the input

play03:03

for each of those hashing algorithms

play03:05

only was changed by one single character.

play03:08

This is a good example of the differences

play03:10

that you'll see in a hashing output

play03:12

when using two different kinds of input.

play03:15

We mentioned earlier that the only time

play03:17

we should see an identical hashing value

play03:20

is if the input values were identical.

play03:22

With a hash, we're taking an input

play03:24

of any size, any type of file, and we're creating a fixed size

play03:28

string from that that we're calling a message digest,

play03:31

a checksum, or a fingerprint.

play03:33

Each one of these hash values should be unique

play03:36

if it is a unique type of input, and we should never

play03:38

have a hash appear that's identical to another

play03:41

if there are different inputs involved.

play03:43

There have been cases, however, where a hashing algorithm did

play03:47

create the same hash for different types of input.

play03:50

This occurred with the MD5 algorithm.

play03:53

They found this collision problem in 1996.

play03:56

This is one type of input that was used for MD5,

play04:00

and here's the second input.

play04:02

You'll notice that these inputs are almost the same,

play04:04

but all of the characters marked in red

play04:07

are the differences between these two different inputs.

play04:10

If we hash the first input and hash the second input,

play04:13

we should get two different hash values.

play04:15

But with MD5, we got exactly the same hash value,

play04:20

and that is a collision, and it's

play04:21

another reason why we usually don't use MD5

play04:25

to be able to perform a hash.

play04:28

We mentioned earlier that it's very common

play04:30

to use hashing to verify the integrity of information.

play04:34

For example, you may go out to an internet website

play04:36

and download a file, and along with the file name

play04:39

at that site, it may provide you with a list of hashes

play04:43

associated with these files.

play04:44

This means that you could download the file

play04:46

from their website and perform the same hashing algorithm

play04:50

to the file that you've downloaded.

play04:51

If you then compare the hash that you created with the hash

play04:54

on the website and those two hashes are identical,

play04:57

then you have an exact duplicate of the file that was originally

play05:00

posted on that site.

play05:02

And as we mentioned earlier, it's

play05:03

very common to use hashing when storing passwords.

play05:06

Instead of storing your password in plain text,

play05:09

we store your password as a hash,

play05:11

and we can create and compare that hash

play05:13

every time someone logs in.

play05:16

Storing passwords is an interesting use case

play05:18

for hashing.

play05:19

It could be that you have hundreds of thousands

play05:22

of user accounts on a website, and statistically, it

play05:25

could be that multiple users happen to be

play05:28

using the exact same password.

play05:30

If you're storing those hashes in a file,

play05:33

you could see that there are multiple users that are using

play05:36

exactly the same password.

play05:38

We don't know what that password is,

play05:39

but we do know if we perform a brute force on that hash

play05:43

and we're able to determine what that password is, then

play05:46

that same password will work for every single one

play05:49

of those identical hashes.

play05:51

To be able to avoid this, we want to add some randomization

play05:54

to these hashes.

play05:55

We call this random value salt, and it

play05:57

allows us to add some randomization

play06:00

during the hashing process so that if even everyone was using

play06:04

the same password, every single one of the stored hashes

play06:07

would be very different.

play06:08

Each user might be using the same password,

play06:11

but each one of those passwords would

play06:13

have a different random salt associated with it

play06:16

and therefore, a different hash would be stored.

play06:19

This means that if we had already created some rainbow

play06:21

tables based on these hashes, and rainbow tables are

play06:24

pre-computed hash values, we would not

play06:27

be able to use those rainbow tables

play06:29

because this extra randomization of salt

play06:32

has been added to every single one of those hashes.

play06:35

If an attacker understands the process that's

play06:37

used to add the salt, then they could still

play06:39

go through a brute force process to try

play06:42

to determine what that password is,

play06:44

but that is a much longer process to go through

play06:46

than looking up information in a rainbow table,

play06:49

and the goal here is to slow down the attacker

play06:51

as much as possible.

play06:53

Let's take a scenario where everyone

play06:55

is using exactly the same password,

play06:58

but we're going to store that password information along

play07:01

with a salted hash.

play07:03

Let's take our password.

play07:04

In this case, we'll use the password of dragon,

play07:07

and the hash for dragon looks like this.

play07:09

Let's say that everyone is using the password of dragon,

play07:13

but for each account, we're going

play07:15

to add an extra piece of salt to that, which of course is going

play07:19

to give us a different hash in every single one

play07:21

of those scenarios.

play07:23

So if an attacker was able to get a copy of our hash file,

play07:26

they would see what they thought were five different passwords.

play07:30

In reality, it's the same password

play07:33

with the salt added for that randomization.

play07:37

Another useful function of hashing

play07:39

can be found with digital signatures.

play07:41

Digital signatures allow us to send information

play07:44

to another party and have that person confirm

play07:46

that what they received is exactly the information

play07:49

that we originally sent.

play07:51

These digital signatures proved the source of the message

play07:54

and where this came from.

play07:56

We can verify that the digital signature isn't fake,

play07:59

it hasn't been modified, and it really

play08:01

came from that original person.

play08:03

And because the digital signature

play08:04

was made with the private key from the original user,

play08:08

we know that this document could not

play08:09

have come from someone else.

play08:11

Because the digital signature is created with the private key,

play08:15

it's verified with the public key.

play08:17

If I was to sign a document with my private key

play08:20

and send it to you, you would use

play08:22

my public key, which of course is available to everyone,

play08:25

to verify the contents of that message.

play08:28

This also confirms that it came from me

play08:31

because the only person who could have digitally signed

play08:33

this is the person with the private key,

play08:35

and I'm the only one who has my private key.

play08:39

Let's look at how a digital signature is created.

play08:42

We'll take a scenario where Alice is hiring Bob,

play08:44

and she wants to send Bob a message that

play08:46

says, you're hired, Bob.

play08:48

But she wants to make sure that Bob

play08:50

is able to verify that this message is legitimate

play08:53

and that it really came from Alice.

play08:55

Alice is going to perform a hashing algorithm

play08:57

on this entire plain text message, and out of that,

play09:01

we'll get a hash of the plain text.

play09:03

The person receiving this message

play09:05

could look at the hash to at least verify

play09:07

the integrity of the message, but we

play09:09

don't want somebody modifying anything in the middle

play09:12

of the conversation.

play09:13

So the next step is for Alice to encrypt that hash that she

play09:17

created with her private key.

play09:19

And of course, the only person with Alice's private key

play09:22

is Alice.

play09:23

The results of that are what we call a digital signature.

play09:27

And we can attach that digital signature

play09:29

to the original plain text and send that entire message

play09:33

to the recipient.

play09:35

On the other side, we have Bob, who has received this message

play09:38

from Alice.

play09:38

The message says, you're hired, Bob.

play09:40

And of course, we didn't encrypt the message.

play09:42

We simply created a digital signature

play09:44

and attached that signature to the message.

play09:46

And of course, you can see at the bottom,

play09:48

there's our digital signature.

play09:50

To be able to verify this digital signature,

play09:53

Bob is going to reverse the process that Alice created.

play09:56

So the first thing he'll do is use Alice's public key

play09:59

to decrypt the digital signature that she sent,

play10:02

which of course is simply an encrypted version of the hash.

play10:05

After that decryption has been performed,

play10:08

Bob is left with the hash of the plain text.

play10:11

Now he wants to perform exactly the same hashing function

play10:14

that Alice originally did, so he'll

play10:17

take that plain text of you're hired, Bob,

play10:19

run it through the same hashing algorithm

play10:21

that Alice did to see if he can get a hash of that plain text,

play10:26

and then compare those hashes to make sure

play10:28

that they are the same.

play10:30

And if those hashes match, then he

play10:31

knows that this message is legitimate.

play10:34

It really did come from Alice, and nothing

play10:37

has been changed with that message

play10:38

while this message was being sent to Bob.

Rate This

5.0 / 5 (0 votes)

Связанные теги
HashingCybersecurityFile IntegrityDigital SignaturesPassword SecurityEncryptionData IntegrityAuthenticationNon-repudiationSalting
Вам нужно краткое изложение на английском?