If you send a message and its hash, all you prove is that you know how to calculate a hash!
Instead, send the message and the result of encrypting
its hash with your private key.
That result is called
a digital signature.
The digital signature is:
E( H(message), Kprivate )
Anyone can calculate the hash of the received message. They can also use your public key to decrypt the digital signature. Then they compare those two results. If the two are the same, you are the sender, and the message wasn't altered.
Digitally signing a message:
+---------+
{ | Message |
+----------------------------> { | body |
| { | |
| +---+ +---+ +---------+
Message -+-->| H |-->| E |--> Digital --> |Signature|
+---+ +---+ signature +---------+
^
|
kpriv
Verifying a digitally signed message:
+---------+ +---+
| Message | }--->| H |------------+
| body | } +---+ |
| | } |
+---------+ +---+ v
|Signature| }--->| D |----> Are they the same?
+---------+ +---+ If so, the message is valid
^ and the sender is legitimate!
|
kpub
Firefox users may find that "monospace" isn't really a constant-width
font, and Courier works much better for ASCII art.
For an application of this technology, see my page explaining how to use this to verify downloaded software and operating systems.
For a less technical explanation of how this can be used with e-mail messages, see my page referenced in my .signature file, explaining it to people puzzled by their clueless mail tool's report of "unknown attachment".
I use The GNU Privacy Guard, or GnuPG. It can be used from the command line, where the gpg command does pretty much everything. And it can be used as a plug-in for mail tools.
One of four things must happen when you attempt to verify a digitally signed message or data file:
The sender and receiver share a secret key. HMAC is formed as hash(message+key). Sender transmits message and HMAC. Receiver performs same hash(received+key) to verify message integrity and sender authentication.
Generating HMAC:
+----------+
| | }
| Message | } +---+
| | }--->| H |---> HMAC
+----------+ } +---+
|Secret Key| }
+----------+
Transmit only the message and HMAC to the receiver.
Sender Receiver
+----------+
| |
| Message | =================>
| |
+----------+
+----------+
| HMAC | =================>
+----------+
Verifying HMAC:
+----------+
| Received | }
| Message | } +---+
| | }--->| H |---> hash
+----------+ } +---+ ^
|Secret Key| } |
+----------+ |
|
+----------+ |
| Received | <--------------Compare these.
| HMAC | If equal, then this was a valid
+----------+ message from the authentic sender.
Note that a digital signature requires a hash of the entire message followed by an encryption of the hash. If you are only sending one large message, the work required for the hash overwhelms that for the encryption, and there is no real computational advantage to an HMAC.
An HMAC requires only a hash. If you are sending a large number of small messages, an HMAC has a computational advantage.
So, digitally sign an electronic mail message, but use HMAC within IPsec to verify all IP datagrams.
None of this makes much sense if you cannot be absolutely certain who you are talking to!
A digital certificate is a message that says, "The public key of so-and-so is such-and-such", with that message digitally signed by an entity called a Certificate Authority (CA). Attributes of a CA:
For instance, Verisign, Thawt, and others are CAs whose public keys have been coded into your web browsers by the software developers (and so you must absolutely trust your software providers, too).
When you download a secure page via HTTPS:
X.509v3 is simply the format of digital certificate that everyone uses.
Also be aware that a digital certificate is proof of identity, but not proof of intent or good will! Anyone could get a digital certificate for the bogus-and-dishonest-bank.com domain, set up a web server, and get you to tell it your credit card numbers over an SSL/TLS connection.
I have a page explaining how to create and install keys and X.509v3 certificates for a secure Apache web server.
|
|
|
|
|||||||||
|
|||||||||
|
| © Bob Cromwell Feb 2012. Created with /bin/vi and ImageMagick, hosted on OpenBSD with Apache. Root password available here, privacy policy here. |