Hashing and Digital Signatures - CompTIA Security+ SY0-701 - 1.4

Professor Messer
2 Nov 202310:24

Summary

TLDRThis script delves into the world of cryptographic hashes, explaining their function as digital fingerprints for data integrity and verification. It contrasts hashing with encryption and illustrates the process using SHA256, highlighting the uniqueness of hashes even with minor text changes. The script warns against using MD5 due to collision issues and discusses practical applications like verifying downloads and securing passwords with salted hashes. It also explains digital signatures for authentication and non-repudiation, detailing the process from creation to verification.

Takeaways

  • 🔒 A cryptographic hash is a unique string that represents data, akin to a digital fingerprint, and is used for data verification and integrity.
  • 🔑 Hashing is not encryption; it's a one-way process from which the original data cannot be reconstructed.
  • 🔄 The SHA256 algorithm is a common hashing method that produces a 64-character hexadecimal string from the input data.
  • 📝 Even a minor change in the input text results in a significantly different output hash, highlighting the sensitivity of hashing algorithms.
  • 🚫 Collisions, where different inputs produce the same hash, are undesirable and rare in secure hashing algorithms.
  • ❌ MD5 is an example of an outdated hashing algorithm that has been compromised due to collision vulnerabilities.
  • 📥 Hashes are used to verify the integrity of downloaded files by comparing them with the hashes provided by the source.
  • 🔒 Storing passwords as hashes, with added salt, ensures they cannot be easily retrieved or cracked, enhancing security.
  • 🔄 Salting hashes with unique random data per user prevents the use of rainbow tables for reverse-engineering hashes.
  • 🖋️ Digital signatures use hashing and public/private key encryption to provide authentication, integrity, and non-repudiation.
  • 🔏 The process of creating a digital signature involves hashing the message, encrypting the hash with a private key, and sending it along with the message for verification.

Q & A

  • What is a cryptographic hash used for?

    -A cryptographic hash is used to represent data as a short string of text, often referred to as a message digest or fingerprint, to verify data integrity and authenticity without the need to store or transmit the original data.

  • How is a cryptographic hash different from encryption?

    -Unlike encryption, which is reversible and can recreate the original data, a cryptographic hash is a one-way function that cannot be used to recreate the original data from the hash value.

  • What is the purpose of using a hash to verify a downloaded document?

    -Hashes are used to ensure that the downloaded document matches the original one posted on a website, thus providing integrity and verifying that the document has not been altered.

  • What role do hashes play in the creation of digital signatures?

    -Hashes are used in the process of creating digital signatures to ensure the integrity and authenticity of a message, as well as to provide non-repudiation, which means the sender cannot deny having sent the message.

  • What is the SHA256 hashing algorithm and what does it produce?

    -The SHA256 hashing algorithm is a common cryptographic hash function that produces a 256-bit hash, represented as a 64-character hexadecimal string, from the input data.

  • Why is it significant that a small change in the input text results in a significantly different hash output?

    -This characteristic, known as the avalanche effect, ensures the security of the hash function by making it infeasible for an attacker to find two different inputs that produce the same hash, a situation known as a collision.

  • What is a collision in the context of hashing algorithms?

    -A collision occurs when two different inputs to a hashing algorithm produce the same hash output, which is undesirable as it compromises the uniqueness and security of the hash function.

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

    -The MD5 algorithm is no longer recommended due to the discovery of collision vulnerabilities in 1996, which makes it susceptible to attacks and not suitable for secure applications.

  • How are hashes used in the context of password storage?

    -Hashes are used to store passwords securely by converting the plain text passwords into a hash value, which is then stored instead of the actual password. This ensures that even if the storage is compromised, the plain text passwords are not directly exposed.

  • What is a salt in the context of password hashing?

    -A salt is a random piece of data added to the password before it is hashed. This ensures that even if two users have the same password, their hashes will be different due to the unique salt, making it more difficult for attackers to crack the passwords using pre-computed hash tables or rainbow tables.

  • How does the process of creating a digital signature ensure the integrity and authenticity of a message?

    -The process of creating a digital signature involves hashing the original message and then encrypting the hash with the sender's private key. The recipient can then decrypt the signature with the sender's public key and compare the resulting hash with the hash of the received message to verify its integrity and authenticity.

Outlines

00:00

🔒 Understanding Cryptographic Hashes

This paragraph introduces the concept of cryptographic hashes, which are short strings of text used to represent data, akin to fingerprints. It clarifies that hashes are not encryption and cannot be used to recreate the original data. The paragraph discusses the practical applications of hashes, such as verifying document integrity and creating digital signatures for authentication, non-repudiation, and integrity. The SHA256 hashing algorithm is highlighted, which generates a 64-character hexadecimal hash from input data. The importance of unique hashes for different inputs and the rarity of hash collisions are emphasized, with a mention of the MD5 algorithm's vulnerability to collisions.

05:01

🛡️ Hashing in Security and Password Storage

The second paragraph delves into the use of hashing in security practices, particularly in password storage. It explains the process of creating a salted hash to prevent the use of rainbow tables for reverse-engineering passwords. The paragraph illustrates how adding a salt to a password results in a unique hash for each user, even if the same password is used, enhancing security against brute force attacks. It also touches on the concept of digital signatures, comparing them to traditional signatures for integrity, authentication, and non-repudiation. The process of creating a digital signature using a private key and verifying it with a public key is outlined, emphasizing its role in confirming the authenticity and integrity of a message.

10:02

🗒️ Digital Signatures and Verification Process

The final paragraph focuses on the verification process of digital signatures. It describes a scenario where Alice sends a message to Bob with a digital signature to ensure the message's integrity and origin. The paragraph details the steps involved in creating a digital signature, including hashing the plaintext and encrypting the hash with a private key. Upon receipt, Bob's email client verifies the signature using Alice's public key, confirming the message's authenticity and integrity. The process highlights the cryptographic mechanisms at work behind common digital signature functionalities in email systems and other applications.

Mindmap

Keywords

💡Cryptographic Hash

A cryptographic hash is a fixed-size string of characters, derived from data using a hash function. It is used to represent data uniquely and is central to the video's theme of data integrity and security. In the script, it is likened to a fingerprint, emphasizing its uniqueness and role in verifying data's authenticity. The hash is used to ensure the integrity of documents and in digital signatures, where it helps to confirm that a message has not been altered.

💡Message Digest

A message digest is another term for a cryptographic hash. It is a summary of the data, which is used to ensure the data's integrity. The script mentions that the hash serves as a 'digest' of the original data, which helps in verifying that the downloaded document matches the one posted on a website, thus maintaining the integrity of the document.

💡Digital Fingerprint

A digital fingerprint is a unique, fixed-size representation of a larger piece of data, created using a cryptographic hash function. The script uses the analogy of human fingerprints to explain how a digital fingerprint can uniquely represent data, akin to how our fingerprints represent us. This concept is crucial for understanding the role of hashes in verifying the originality and integrity of data.

💡SHA256

SHA256 is a specific cryptographic hash function from the SHA-2 family, which produces a 256-bit hash value represented as a 64-character hexadecimal string. The script demonstrates the creation of a SHA256 hash from a simple text string to illustrate how hashes are generated and used to verify data integrity. It is a key example of how hashes are used in practical applications.

💡Hash Collision

A hash collision occurs when two different inputs produce the same hash output. The script warns against this phenomenon, stating that while it is extremely rare with a good hashing algorithm, it can compromise security. The example of MD5, which is susceptible to collisions, is given to highlight the importance of using robust hashing algorithms like SHA256.

💡MD5

MD5 is an older cryptographic hash function that has been found to have vulnerabilities, particularly with collisions. The script mentions MD5 as an example of a hashing algorithm that is no longer recommended due to its susceptibility to collisions, which can be exploited to create security issues.

💡Digital Signature

A digital signature is a cryptographic mechanism used to verify the authenticity and integrity of a digital message or document. The script explains that digital signatures are created using a private key and verified with a public key, providing a means to ensure that a message has not been altered and to confirm the identity of the sender. It is a key concept in the video's discussion of data security and authentication.

💡Authentication

Authentication is the process of verifying the identity of a person or system. In the context of the script, digital signatures provide authentication by confirming the identity of the sender of a message. The script illustrates this with the example of Alice sending a message to Bob, where the digital signature helps Bob verify that the message indeed came from Alice.

💡Non-repudiation

Non-repudiation is a security concept that ensures that the sender of data cannot deny having sent it. The script mentions non-repudiation in the context of digital signatures, where the signature serves as proof that the message was sent by the claimed sender, thus preventing the sender from later denying their actions.

💡Salt

In the context of hashing, a salt is a random piece of data added to a password before it is hashed, which adds an extra layer of security. The script explains the concept of salting as a way to make hashes more secure against attacks like rainbow table lookups. By adding a unique salt to each password, even identical passwords will result in different hashes, thus enhancing security.

💡Rainbow Table

A rainbow table is a precomputed table for reversing cryptographic hash functions, usually used to crack password hashes. The script discusses rainbow tables as a technique that can quickly reveal original passwords from non-salted hashes. By using salts, as explained in the script, the effectiveness of rainbow tables is diminished, making brute force attacks more time-consuming and less feasible.

Highlights

A cryptographic hash is used to represent data as a short string of text, also known as a message digest or fingerprint.

Cryptographic hashes are not encryption and cannot be used to recreate the original data from the hash.

Hashes can verify the integrity of a document by comparing it to the original hash posted on a website.

Digital signatures use hashes for authentication, non-repudiation, and integrity.

SHA256 is a common hashing algorithm that produces a 64-character hexadecimal hash.

Even minor changes in the input text result in a significantly different hash output.

Hash collisions, where different inputs produce the same hash, are extremely rare and undesirable.

MD5 is an example of a hashing algorithm with known collision problems, and its use is not recommended.

Hashing is commonly used to verify the integrity of downloaded files by comparing hashes.

Storing passwords as hashes, rather than plain text or encrypted forms, enhances security.

Salted hashes add a random element to the hashing process, making brute force attacks more difficult.

Rainbow tables are a technique used to reverse engineer non-salted hashes, which can be thwarted by salting.

Digital signatures are created using a private key and verified with a public key, ensuring the integrity and authenticity of a message.

The process of creating a digital signature involves hashing the plaintext, encrypting the hash with a private key, and attaching it to the message.

Digital signatures provide non-repudiation by confirming the message's source and ensuring it was not altered during transmission.

Using digital signatures in email involves a simple interface, but relies on complex cryptographic processes.

The verification of a digital signature involves decrypting it with the sender's public key and comparing the resulting hash to the original message's hash.

Transcripts

play00:01

A cryptographic hash is used to represent data

play00:04

as a short string of text.

play00:06

Sometimes you'll hear this referred to as a message

play00:09

digest or a fingerprint.

play00:11

Just like our fingerprints that can represent us,

play00:14

a digital fingerprint can represent data

play00:17

that is being stored elsewhere.

play00:18

Keep in mind that this cryptographic hash is not

play00:21

encryption.

play00:22

You can't somehow recreate the data if the only thing you have

play00:26

is the hash.

play00:27

For the same reason, you can't recreate a person when all you

play00:30

have is their fingerprint.

play00:32

In practical terms, we can use these hashes

play00:34

to verify that a document that we've downloaded

play00:37

matches the original document that was posted on a website.

play00:41

This provides us with integrity.

play00:43

We can also use these hashes during the process of creating

play00:46

a digital signature.

play00:47

And these digital signatures are used for authentication,

play00:50

non-repudiation, and integrity.

play00:53

Let's create some hashes.

play00:55

We're going to use a very common hashing algorithm

play00:57

called the SHA256 hashing algorithm.

play01:00

This will produce 256 bits of information

play01:03

that we will represent as 64 hexadecimal characters.

play01:07

So let's create a hash from a very simple text string.

play01:10

This text string says, "My name is Professor Messer."

play01:13

And there's a period at the end of that sentence.

play01:15

If we were to put this into an application

play01:17

to create a SHA256 hash from that sentence,

play01:20

we would get this long string of characters

play01:23

that you see right here.

play01:24

Let's now make one change to this sentence.

play01:27

This now says, "My name is Professor Messer."

play01:29

But instead of it ending in a period,

play01:31

it's now ending in an exclamation mark.

play01:33

So there's really only one character that's been changed.

play01:36

This is a very common characteristic of hashing,

play01:39

where you make one minor change to the input text.

play01:42

And the output hash is very different from each other.

play01:46

One of the things we'd like to avoid when creating a hash

play01:48

is to make sure the hashes are very different for all types

play01:52

of input.

play01:53

In practical use, we should never run into a situation

play01:56

where this hash is duplicated.

play01:57

If we're putting different inputs

play01:59

into the hashing algorithm, we should

play02:01

expect to see different outputs as well.

play02:04

If, for some reason, we do have different inputs

play02:07

and those inputs create exactly the same hashing value,

play02:11

then we've created a collision.

play02:13

In practical use, you're probably

play02:14

never going to run into one of these collisions.

play02:16

And your hashing algorithm should

play02:18

be created so that collisions are

play02:20

an extremely rare occurrence.

play02:22

Unfortunately, there have been hashing algorithms,

play02:24

through the years, that did have problems with collisions.

play02:27

One good example of this is the hashing algorithm MD5.

play02:31

This collision problem was found in 1996.

play02:34

And because of that, we highly recommend

play02:36

that you use a different hashing algorithm than MD5.

play02:40

Here's how this MD5 collision works.

play02:42

Here, we have a string of input.

play02:44

This is text that we're going to put into a hashing algorithm.

play02:48

And we're going to take another string of text that's

play02:50

almost the same.

play02:51

You can see these almost match up.

play02:53

But every place there is a red character

play02:56

means there's a slight difference between each

play02:59

of these inputs.

play03:00

But if we take both of those inputs

play03:02

and put them into the MD5 algorithm,

play03:05

we get exactly the same hash.

play03:07

This is a collision.

play03:08

And this is the reason we no longer recommend using

play03:11

MD5 as a hashing algorithm.

play03:14

We use hashing for many different purposes.

play03:16

And you might run into hashing multiple times

play03:19

through a normal workday.

play03:20

For example, you may need to verify

play03:22

that a file that you've downloaded

play03:24

matches the file that happens to be posted on a website.

play03:27

You'll often see this on sites where

play03:29

you're downloading very important files like a Linux

play03:32

distribution.

play03:33

And you can see that each distribution

play03:34

has been associated with a particular hash.

play03:37

This means that you can download the ISO file,

play03:39

run the same hashing algorithm on the file you downloaded,

play03:43

and compare it to the hash that's posted on the website.

play03:46

If your hash matches the one that's on the website,

play03:48

then you've downloaded the same file that exists on that site.

play03:52

Another common use of hashing is to store passwords.

play03:56

Ideally, we would never store someone's password

play03:58

in plain text.

play03:59

And we would not encrypt passwords,

play04:01

because then, someone could potentially decrypt and gain

play04:04

access to your passwords.

play04:05

Instead, we provide a hash for all of the passwords

play04:09

that someone stores.

play04:10

In reality, it's a hash plus a little extra information called

play04:14

a salted hash.

play04:15

This way, we're able to store everyone's password

play04:17

as a hash, which means we have no idea what

play04:20

the actual password might be.

play04:22

During the login process, the password you input

play04:25

is changed to a hash, compared to the one that's

play04:28

stored on the server.

play04:29

And if they match, you've gained access to that system.

play04:33

I mentioned earlier that when we're storing passwords,

play04:35

we might want to add some additional information to make

play04:38

it more difficult to brute force.

play04:40

We refer to this extra information as assault.

play04:43

This is random information that we

play04:45

add during the hashing process to modify or randomize

play04:48

the resulting hash.

play04:50

Every user gets a different random salt

play04:52

to go along with their password, which means if everyone's

play04:55

using the same password, we'll still

play04:57

see very different hashes stored for every single user.

play05:01

There's a technique for reverse engineering

play05:03

hashes called a rainbow table.

play05:05

This is a pre-compiled set of every possible input

play05:09

and the series of hashes associated with those inputs.

play05:13

This makes it very easy for someone

play05:15

to get a non-salted hash and very quickly

play05:17

be able to determine what the original password might be.

play05:20

But if you're adding a random salt to everyone's password,

play05:23

these rainbow tables will no longer work.

play05:26

This would certainly slow things down

play05:28

for an attacker that's trying to find everyone's password

play05:31

by performing a brute force.

play05:33

A rainbow table can find this information

play05:35

in a matter of seconds.

play05:36

But brute forcing can take days, weeks, or even longer

play05:39

to find someone's password.

play05:41

Let's take some user passwords.

play05:43

We'll add some salt to each password.

play05:45

And let's see what the resulting hash looks like.

play05:48

Let's take the password of "dragon."

play05:50

And if we're not using any salting,

play05:51

this is the hash that results from that password of dragon.

play05:55

But now, let's add some additional random text

play05:58

onto this password of dragon.

play05:59

And as we add the different randomization

play06:02

for each one of these, you can see

play06:04

that we have a very different hash that we're storing.

play06:07

If someone was to gain access to our hashed database,

play06:10

they would think that there were five different passwords being

play06:13

used, when in reality, there's a single password

play06:16

with a number of different salts added to that password.

play06:20

Hashes are also used during the process of creating

play06:23

a digital signature.

play06:24

A digital signature is very similar to a signature

play06:27

you might use on any other document.

play06:29

But this one is a digital version

play06:31

of the signature that proves that the message that you

play06:34

received was not somehow changed during the process of sending

play06:37

that message to you.

play06:38

From that perspective, digital signatures provide integrity.

play06:42

The digital signature will also help you prove

play06:44

the source of the message.

play06:46

This provides authentication.

play06:48

And if others want to prove that the message really

play06:50

was sent by the person who says they sent it,

play06:53

we can confirm that with the digital signature.

play06:55

That's also referred to as non-repudiation.

play06:58

The process for creating a digital signature

play07:01

is almost the opposite as encrypting data.

play07:04

For digital signature, the person signing the document

play07:07

will use their private key to create the digital signature.

play07:11

When that signature is sent to another party,

play07:13

they're able to confirm that private key was

play07:16

used by verifying it with the public key for that user.

play07:20

If we receive a digital signature

play07:22

and go through the verification process

play07:24

and find that the public key of the sender

play07:26

is not able to verify the digital signature,

play07:29

then something in that document has changed.

play07:32

And we can no longer trust the information

play07:34

that we've received.

play07:35

If you're using a digital signature process built

play07:38

into your email system, or you're using a third party

play07:41

utility to provide digital signatures,

play07:43

then it's as simple as clicking a button or checkbox

play07:46

to include a digital signature with the information

play07:49

that you're sending.

play07:50

But behind the scenes, there's a great deal of cryptography

play07:52

that's going on.

play07:53

Let's step through the process of creating a digital signature

play07:57

so that you can see what happens when you select that checkbox.

play08:01

We'll start with Alice, who would

play08:02

like to send a message to Bob that says, "You're hired, Bob."

play08:05

We refer to this original message as the plaintext.

play08:08

Alice is going to click that check box that tells her email

play08:11

program to include a digital signature

play08:13

with this email message.

play08:15

Behind the scenes, the email client

play08:16

is going to look at the plain text of, "You're hired, Bob,"

play08:19

and send it through a hashing algorithm

play08:22

to create a hash of that plaintext.

play08:24

The email application is then going

play08:26

to encrypt the hash that's been created

play08:29

with Alice's private key.

play08:31

And since Alice is the only one that has her private key,

play08:35

she's the only one that could have created

play08:37

this final digital signature.

play08:39

Just like a digital signature is a bit of information

play08:42

you add to the end of a document,

play08:44

we can do exactly the same thing with this email.

play08:47

So, "You're hired, Bob," is still

play08:49

sent through the network in plaintext.

play08:51

We're not doing any type of encryption

play08:53

in this specific example.

play08:55

But we do include the digital signature, usually

play08:58

as an attachment or at the end of the email.

play09:01

Bob now checks his email.

play09:03

And he's got a message from Alice

play09:04

that has a message that says, "You're hired, Bob,"

play09:06

and it includes that same digital signature.

play09:09

Now, Bob wants to really verify that the message he received

play09:13

is really the message that was originally sent.

play09:16

And he wants to confirm that it really came from Alice.

play09:19

The first thing he's going to do is load that message

play09:21

into his email client.

play09:23

And generally, the email client will

play09:25

recognize there's a digital signature

play09:27

and will perform a verification and tell Bob

play09:29

that this is either verified or not verified.

play09:32

Behind the scenes, what's really happening

play09:34

is that the email client is looking

play09:36

at the digital signature.

play09:37

And it decrypts that digital signature

play09:40

using Alice's public key.

play09:42

Remember that the keys are mathematically related.

play09:45

So if you encrypt with one key, you can decrypt with the other.

play09:48

The result of this decryption ends up

play09:50

being a hash of the original plain text.

play09:53

Now we simply perform the same hash

play09:56

that was done originally to the plaintext

play09:58

to see what the results are.

play10:00

And if both of those hashes match,

play10:02

then we know that the digital signature verifies,

play10:05

and that not only is the document exactly what

play10:08

was originally sent, but we can confirm

play10:10

that it really came from Alice.

Rate This

5.0 / 5 (0 votes)

Related Tags
Cryptographic HashData IntegrityDigital SignatureSHA256 AlgorithmHashing CollisionMD5 VulnerabilityPassword StorageSalted HashRainbow TableAuthenticationNon-repudiation