So far, we've been looking at cryptography as a way to protect data,
either as we transmit it or as we store it.
And we looked at two main types of processes,
protecting it using a symmetric algorithm or protecting its
confidentiality using an asymmetric algorithm.
The problem with asymmetric is it tends to be slow.
So you don't want to use it for a large message, for example.
But there's another benefit we have with asymmetric that we
didn't have with symmetric algorithms,
and that is the ability to provide for proof of origin.
Who did this message come from?
So let's say Alice is going to send a copy of a signed contract to Bob.
She can take that message,
run it through the same asymmetric algorithm, but in this time,
she's going to encrypt it with her private key,
the key she keeps secret and nobody else would have. That
will generate cipher text to that message that can be now
sent through that insecure channel.
And when Bob receives that, he can run that through the same crypto system
with the same asymmetric algorithm, but the only key in the world that will
decrypt this message would be Alice's public key.
He knows that Alice's public key is linked to Alice's private key.
So therefore, if he can decrypt it and read the message, he
knows it had to have come from Alice.
Now the problem this, of course, is that anyone with
Alice's public key could actually read it.
But in the case here, we're not talking about confidentiality.
We're talking about who sent it, proof of origin.
This allows us to establish something we talked about way back in
the first course, Nonrepudiation. Alice cannot deny having sent it
because it was open with her public key.
It had to have been encrypted with her private key.
This is very much linked to another process we're going to
look at here now called message integrity. Message integrity
uses message authentication codes.
In other words, the message is authentic.
It has not been changed or altered.
That means that we can store data such as a log.
We have a MAC code for it. And we know when you go back to look at it again,
there has not been a bit that's been changed or something
which has been altered from the original.
We can also use this in transmission where we know now that the
message was not affected by, say, noise or any interruption on the
network as it was being transmitted.
There's a number of different types of message
authentication codes we've used over the years.
You're familiar with many of them. If you ever did an old dial up modem,
you'd set things up for parity bits.
We know that there's been checksums.
We often saw this when we send a large file, and we'd have trailer
records that would have a total of the number of transactions and the
dollar value of those transactions in that record.
And we had things like cyclic redundancy checks built into, it used to be
when you loaded a game off of a disk. Then, it would see if there are any
errors in what we call the CRC 32 check.
But the main way we do this today is using a hash function, a hash
function such as Message Digest 5, Secure Hashing Algorithm 1, 2, or
3, or the European Standard RIPEMD‑160.
We also have something we called hash maccing and
sometimes also called keyed hashing.
So these are the main hash functions that we're using today.
We use these very often either to just prove that a message
hasn't been changed or to also prove who the message came from
and that the message was not changed.
This is something we call a digital signature. We'll
look at that in just a second.
How does a hash function work?
We take our message, and we run it through a system that has within it a hashing
algorithm. That generates something we will call a digest.
It's often sometimes called a thumbprint, a fingerprint.
But anyway, it's a value that was calculated from that message.
We can append that digest or attach it to the message itself.
Then, send a message through our transmission channel.
And when it's received,
the receiver will now have the message that they will hash. They will make
sure that the digest from the message they received is the same as the
digest that was sent along with the message.
This is very good because these hashing algorithms are very sensitive to any
change. Even if one bit was flipped in transmission, the digest would be at
least 48% different from what it had been originally.
So a massive change in the digest would be noticed.
And so this is one good way just to verify that there was not an error in,
say, communications. But we talked about a digital signature.
This is certainly a form of, not only message integrity, but
what we looked at before, nonrepudiation.
We can take that message and run it through a hashing algorithm.
We create the digest.
Maybe we use, for example, SHA‑2 for this. SHA‑2 generates a digest of 256,
384, or 512 bits depending on which setting we're using.
We then take that digest and encrypt it.
This time, we encrypt it with the sender's private key.
Just as like we did when Alice was sending the message to Bob,
she encrypted that message with her private key.
And when I do that encrypted digest with a private key.
I then generate something very special, a digital signature.
A digital signature is a combination of a hash
function and asymmetric cryptography.
And that means that I can now send this message through a completely
untrusted channel. When it's received at the far end, the person who
receives it has this message and the digital signature.
They can decrypt the digital signature, and we know the only key in the world
that would decrypt it would be the sender's public key.
They can take the message they received, and they can hash it using
the same hashing algorithm as the sender used. That will generate
the digest of the message received.
They can compare that with the digest that had been
decrypted from the digital signature.
And then we would know two things, one, that this message truly
came from that sender and, two, that the message was not altered as
it was transmitted through the network.
Now, you can notice that this does not provide confidentiality.
The message itself was not encrypted.
This is intended as a digital signature just to prove
proof of origin and message integrity.
So we have nonrepudiation. That message came from that person.
Nobody could have altered or changed that.
And this is a very useful tool, of course, in today's world.
And just to stress one thing here, a digital signature is created by
encrypting a hash of the message with a private key.
It has nothing to do with, say, for example,
encrypting the message itself, nor does it have anything to
do with a digitized signature, which is just basically a
scan of a person's autograph.
It's a very useful tool we use here.
The key points review. Hashing is primarily used to ensure integrity of data.
It is a one‑way function as well.
So if I have a hash of a message, it would be computationally infeasible to
figure out what the actual message it was just from the hash.
It's very accurate to even the smallest changes to the original message.