Introduction to Public-key Cryptography and GPG

|

Public-key cryptography is an encryption method that uses two keys, one public and one private, to securely communicate with others. Messages are encrypted using the recipient’s public key, but the message can only be decrypted using the corresponding private key. Think of the public key as secure mailbox with a small slit into which anyone can put letters. But only the owner of the mailbox can retrieve letters by opening it with her private key. The security of the encryption scheme is based on the fact that it’s computationally infeasible to calculate private from public keys.

Longer key lengths are better, but only up to a point. AES will have 128-bit, 192-bit, and 256-bit key lengths. This is far longer than needed for the foreseeable future. In fact, we cannot even imagine a world where 256-bit brute force searches are possible. It requires some fundamental breakthroughs in physics and our understanding of the universe…brute-force attacks against 256-bit keys will be infeasible until computers are built from something other than matter and occupy something other than space.

Let’s say there are two individuals, David and Nette. They want to send each other messages without a counterparty, let’s call him Enessay, eavesdropping. Both David and Nette would generate their own key pairs. Luckily there’s a free software program called GnuPG that they can use.

gpg --gen-key

They exchange public keys so that David can encrypt messages to Nette and vice versa.

gpg --armor --export [email associated with generated key pair]

David writes a message titled super_secret_message and encrypts it using Nette’s public key.

gpg --output super_secret_message.gpg --encrypt --recipient nette@internetz.com super_secret_message

He attaches super_secret_message.gpg to an email and sends it to Nette who decrypts it.

gpg --decrypt super_secret_message.gpg

Tada! That simple. And although Enessay can intercept the encrypted super_secret_message.gpg file, he cannot crack the code and read the message. David and Nette are safe.

Here’s my public key:

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2

mQINBFVC85ABEAC5mLRUB3co8n8kBHJ/QsoQS6xyQtHCm3T7ClY2z87Jr2tYNntT
uMag+Xv0BPGKZa0Ry+s0dO2KBUVoVu6jvSDnIfz3FHdEefZhTAa2Wj7ZcxyTV8iw
8QPjKFZUA8hc+DuEWA5Y72b/9W1esX3v+1zxujSldViPtlOa7/4v86x6CoTf1olO
o+PbIX5wO8FBcclJdkfj9JJZVjL/hL4j/bXnrHv56fpFB3MZwBEX/vpiig76GKmu
I0A29A5ytDhfLB2N6tn8eb3m8HjpvvYzwL15xMB3F8yf4p77oxYt1h7izjUy3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