Digital Signatures and Digital Certificates

Greg's Study Journal
24 followers
6 Video Views·Nov 8, 2022
Digital Signatures and Digital Certificates
Digital signatures rely on asymmetric key cryptography.
So before we talk about digital signatures,
let's quickly remind ourselves how asymmetric key cryptography works.
With asymmetric key cryptography, there's a pair of mathematically related keys.
If you encrypt a message with one of the keys,
then the other key, and only the other key, can be used to decrypt it.
This is Albert, and this is Sheila.
If Sheila wants Albert to send her a secret message,
she needs an asymmetric pair of keys.
A computer program can generate these for her.
She sends Albert a copy of one of the keys, and she keeps the other key to herself.
Instead of sending Albert a key,
she could put a key in a public place for him to go and fetch himself.
It doesn't matter if someone else gets a copy of the public key.
Albert uses the public key to encrypt his message.
When Albert has encrypted the message, he sends Sheila the ciphertext.
Only Sheila can decrypt the ciphertext,
because only Sheila has the matching key, the private key.
Truth be told, most people don't need to worry about what's really going on,
because the whole process is taken care of behind the scenes
by programs built into web browsers or email applications.
But what do asymmetric keys have to do with digital signatures?
Well, it so happens that it doesn't matter
which one of the pair of keys is made public, and which one is kept private.
If you encrypt a message with either one,
then the other, and only the other, can be used to decrypt it.
As long as she doesn't change her mind later,
Sheila can decide which one of the keys will be private, and which one will be public.
This is the crucial feature of asymmetric key cryptography
that makes digital signatures possible.
Now let's think about why we even need digital signatures.
This is Carol, and this is Bob.
Bob's a builder.
Carol has a leaky roof, and she asks Bob to fix it.
Carol agrees to pay Bob £1,000 to fix her roof.
Bob agrees to start work on Monday and have it finished by Wednesday.
Carol writes details of the agreement on a piece of paper,
and she signs it, and she sends it to Bob in the post.
No computers here.
Bob signs the piece of paper and sends a copy back to Carol in the post.
Carol sends Bob the money.
Bob writes a note to Carol to say he's got the money.
He signs this receipt and he sends it to Carol in the post.
On Monday, Bob doesn't turn up.
He's gone on holiday for a week to spend the money.
On Thursday, it rains all day, and all of Carol's furniture is destroyed.
Poor Carol.
Carol says it's Bob's fault, but Bob denies ever having agreed to do the work.
Carol takes Bob to court.
The judge looks at the contract and the receipt which Bob signed.
Bob is ordered to pay the money back to Carol
and to give her some more money for new furniture.
And Bob is sent to jail.
Where he belongs.
Once upon a time, not so long ago,
if you wanted proof that a document was sent to you by a particular person,
it needed a handwritten signature on it.
Only written signatures were legally binding.
But these days, it's possible to put a digital signature on a document.
This is Jack, and this is Jill.
Jack wants to send a document to Jill by email.
No paper this time.
Now let's be clear, there's nothing secret about the document.
Neither of them care if somebody else reads it.
Jill just wants to be sure that it definitely came from Jack
and that nobody else has made any changes to it on the way.
Before his document is sent,
some software on Jack's computer prepares the digital signature.
The purpose of this software is to create something called a hash of the document.
These days, most computers do this using an algorithm called SHA-256,
which was invented by the USA's National Security Agency.
SHA-256 takes a copy of the document text
and subjects it to a sequence of complex mathematical calculations
and other transformations.
Remember, as far as the computer is concerned,
the document consists of binary ones and zeros.
The result is called a hash value.
It's also referred to as a digest of the document.
The hashing process has been designed
so that even the tiniest difference in the original document
would result in a completely different hash value.
This part of the signing process is not encryption
because the transformations done by SHA-256
are practically impossible to reverse.
You can't take a hash value
and use it to work out what was in the original document.
Like baking a cake, hashing is a one-way process.
But if you were to apply the same process to the same document,
you would get exactly the same hash.
Some software on Jack's computer now encrypts the hash
using Jack's private key.
And the encrypted hash is embedded in the original document.
The document now has a digital signature.
Jack sends Jill a copy of the signed document.
He also sends her a copy of the public key.
Alternatively, he can put the public key on a website
for Jill to go and fetch.
Jill's computer decrypts the digital signature
using Jack's public key.
If she can decrypt it, she knows it came from Jack.
Jill's computer then uses SHA-256
to calculate the hash value again
using the text of the document.
If the hash value that Jill's computer calculates
is the same as the hash value that was sent by Jack,
she can be pretty sure that it hasn't been tampered with
since it was created.
Remember, Jack and Jill really don't care
if someone else has seen the signed document.
It's not a secret.
And it doesn't matter if someone else
gets a hold of Jack's public key.
Jill simply wants to be sure
that the document was sent by Jack.
Of course, anyone else could have been
pretending to be Jack from the start.
A criminal could create a fake document,
hash it with SHA-256,
and generate an asymmetric pair of keys
using their computer.
So how can Jill be really sure
that she's communicating with Jack?
Well, that's where digital certificates come in.
For a fee, Jack can apply for a digital certificate
to a well-known and well-trusted organisation
called a certification authority.
Certification authorities include companies like
VeriSign, GlobalSign, and Symantec,
to name but a few.
As part of the application process,
Jack's computer generates an asymmetric pair of keys,
and he sends the public key
to the certification authority,
along with various details about himself.
The certification authority carefully checks
that Jack is who he says he is.
Then they send him a special type of file
called a digital certificate.
This contains details about Jack,
along with information about the certification authority,
and an expiry date.
Bound to this digital certificate
is Jack's public key.
Jack still has the corresponding private key,
which never left his computer.
Jack must, of course, keep his private key safe.
So, now when Jack sends a signed document to Jill,
he can also send her a copy of the whole certificate,
or put it in a public place for her to go and get.
This means that when Jill wants to decrypt something
that Jack has encrypted,
she can inspect the certificate first,
and if she's happy to trust it,
she can use the public key within.
The public key that has been guaranteed
by the certification authority to belong to Jack.
Essentially, the certification authority
is vouching for Jack.
Needless to say,
applying to a certification authority
for a digital certificate
is itself a very secure process.
Anything the certification authority sent to Jack
was digitally signed by them
using their own digital certificate.
And this was provided
by an even higher certification authority.
In the year 2000,
a law was passed in the UK
called the Electronic Communications Act.
This law made digital signatures legally binding,
and this has allowed businesses to thrive on the web.
Since then, we've seen the rise of cryptocurrencies
like Bitcoin.
A cryptocurrency is fundamentally a secure list
of who paid who, how much.
Updating this list depends on digital signatures.
To summarise,
digital signatures rely on asymmetric key cryptography.
A document's contents are hashed to create a digest,
for example, using SHA-256.
The digest is encrypted by the sender
using their private key.
The digest is then embedded in the document
which can be sent.
The recipient decrypts the digest
using the sender's public key.
The recipient also calculates a hash
from the document's contents
using the same hash algorithm.
If the recalculated digest
matches the decrypted digest,
it can be assumed
that the document hasn't been tampered with
since it was sent.
A digital certificate
is issued by a certification authority
which guarantees the sender's identity.
The digital certificate contains a public key
along with other information about the sender
and an expiry date.
