OpenPGP/GnuPG Encryption


Published on

A talk I gave to the Triangle Linux Users Group ( ) on 11-April-2002 on Gnu Privacy Guard.

Published in: Technology
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

OpenPGP/GnuPG Encryption

  1. 1. RshqSJS/JqxSJ Hqfubswlrq Wdqqhu Oryhodfh Wuldqjoh Olqxa Xvhuv Jurxs 11-Dsulo-2002
  2. 2. OpenPGP/GnuPG Encryption Tanner Lovelace Triangle Linux Users Group 11-April-2002
  3. 3. What is Cryptography? <ul><li>Cryptography </li></ul><ul><ul><li>The science of using mathematics to encrypt and decrypt data. </li></ul></ul><ul><ul><li>A method of securely sending data over an insecure communications medium. </li></ul></ul><ul><li>Cryptanalysis </li></ul><ul><ul><li>The science of analyzing and breaking secure communications. </li></ul></ul><ul><li>Cryptology is the combination of the two. </li></ul>
  4. 4. <ul><li>There are two kinds of cryptography in this world: cryptography that will stop your kid sister from reading your files, and cryptography that will stop major governments from reading your files. </li></ul><ul><li>-- Bruce Schneier, Applied Cryptography </li></ul>
  5. 5. Why do you need cryptography? <ul><li>Privacy </li></ul><ul><ul><li>Keep communications secret </li></ul></ul><ul><li>Integrity </li></ul><ul><ul><li>Keep communications secure </li></ul></ul><ul><li>Authentication </li></ul><ul><ul><li>Know who you’re communicating with </li></ul></ul><ul><li>Nonrepudiation </li></ul><ul><ul><li>A sender shouldn’t be able to deny that they sent a message </li></ul></ul>
  6. 6. Cryptography Background <ul><li>Two main types of cryptography </li></ul><ul><ul><li>Symmetric </li></ul></ul><ul><ul><ul><li>Same key encrypts/decrypts </li></ul></ul></ul><ul><ul><ul><li>DES, AES, IDEA </li></ul></ul></ul><ul><ul><li>Asymmetric </li></ul></ul><ul><ul><ul><li>Different keys for encryption/decryption </li></ul></ul></ul><ul><ul><ul><li>Also called public key cryptography </li></ul></ul></ul><ul><ul><ul><li>RSA, Diffie-Hellman, ElGamal </li></ul></ul></ul>
  7. 7. Bits, bytes, and Key Lengths, oh my! <ul><li>Which is better? </li></ul><ul><ul><li>128 bit keys? </li></ul></ul><ul><ul><li>1024 bit keys? </li></ul></ul><ul><li>Answer: neither </li></ul><ul><ul><li>Symmetric encryption is much faster than asymmetric </li></ul></ul><ul><ul><li>Asymmetric makes communicating with people you don’t know much easier </li></ul></ul>
  8. 8. How does encryption work? Encryption Decryption Plaintext Ciphertext Original Plaintext Encryption Key Decryption Key <ul><li>Asymmetric </li></ul>Encryption Decryption Plaintext Ciphertext Original Plaintext Key Key <ul><li>Symmetric </li></ul>
  9. 9. How do I know this is secure? <ul><li>Symmetric </li></ul><ul><ul><li>The only way to decrypt without the key is to try all possible combinations. </li></ul></ul><ul><ul><ul><li>With a 128 bit key, there are 2 128 possible combinations </li></ul></ul></ul><ul><ul><ul><li>Comparison </li></ul></ul></ul><ul><ul><ul><ul><li>Our sun should go nova in approximately 2 30 years </li></ul></ul></ul></ul><ul><ul><ul><ul><li>The universe is only 2 34 years old. </li></ul></ul></ul></ul><ul><li>Asymmetric </li></ul><ul><ul><li>You don’t, but smart people think it is. </li></ul></ul>
  10. 10. Not Secure?!? What’s up? <ul><li>Asymmetric algorithms are built upon certain assumptions that have not been proved </li></ul><ul><ul><li>Factoring large numbers </li></ul></ul><ul><ul><li>Computing discrete logrithms </li></ul></ul><ul><li>These are similar to the P vs. NP problem in classical computer science </li></ul><ul><ul><li>Which is why you hear the press talking about the possibility of codes being broken easily. </li></ul></ul>
  11. 11. Public Key Algorithms <ul><li>Diffie-Hellman (key exchange) </li></ul><ul><ul><li>First public key algorithm published (1976) </li></ul></ul><ul><ul><ul><li>Whitfield Diffie and Martin Hellman </li></ul></ul></ul><ul><ul><li>Alice and Bob chose a large prime n and another number g . </li></ul></ul><ul><ul><li>Alice chooses a random large integer a and sends Bob X = g a mod n . </li></ul></ul><ul><ul><li>Bob chooses a random large integer b and sends Alice Y = g b mod n . </li></ul></ul><ul><ul><li>Alice computes k = Y a mod n . </li></ul></ul><ul><ul><li>Bob computes k’ = X b mod n . </li></ul></ul><ul><ul><li>k and k’ are equal ( g ab mod n ) and cannot be computed by someone watching the exchange! </li></ul></ul>
  12. 12. Public Key Algorithms <ul><li>RSA (Rivest, Shamir, and Adleman) [1977] </li></ul><ul><ul><li>Choose two random large prime numbers p and q . </li></ul></ul><ul><ul><li>Compute n = pq . </li></ul></ul><ul><ul><li>Choose a number e such that e is between 1 and pq and e is relatively prime to ( p – 1)( q – 1). </li></ul></ul><ul><ul><li>Compute d from e ( d = e -1 mod (( p -1)( q -1))) </li></ul></ul><ul><ul><ul><li>Multiplicative inverse </li></ul></ul></ul><ul><ul><li>To encrypt, calculate c = m e mod n . </li></ul></ul><ul><ul><li>To decrypt, calculate m = c d mod n . </li></ul></ul>
  13. 13. What is OpenPGP/GnuPG <ul><li>Pretty Good Privacy </li></ul><ul><ul><li>Encryption program written by Phill Zimmerman in 1991. </li></ul></ul><ul><ul><li>Zimmerman was later criminally charged with releasing it on the Internet. (Charges were eventually dropped.) </li></ul></ul><ul><li>OpenPGP </li></ul><ul><ul><li>A standard for encrypted/signed messages. </li></ul></ul><ul><ul><li>RFC 2440, November 1998 </li></ul></ul><ul><li>Gnu Privacy Guard </li></ul><ul><ul><li>An implementation of OpenPGP. </li></ul></ul><ul><ul><li>Does not use patented algorithms. </li></ul></ul>
  14. 14. What can PGP/GnuPG do? <ul><li>Encrypt / Decrypt </li></ul><ul><ul><li>Messages </li></ul></ul><ul><ul><li>Files </li></ul></ul><ul><li>Digital Signatures </li></ul><ul><li>Key management </li></ul><ul><ul><li>Create secret and public keys </li></ul></ul><ul><ul><li>Manage a list of keys </li></ul></ul><ul><ul><li>Certify keys </li></ul></ul><ul><ul><li>Revoke or disable keys </li></ul></ul>
  15. 15. Encryption <ul><li>PGP uses multiple forms of encryption to encrypt different parts of a message </li></ul><ul><ul><li>Symmetric encryption fast </li></ul></ul><ul><ul><li>Asymmetric encryption easy to distribute </li></ul></ul><ul><li>Message is encrypted with a symmetric algorithm </li></ul><ul><li>Symmetric session key is encrypted with an asymmetric algorithm. </li></ul><ul><li>In addition, the message is compressed beforehand, just to remove redundancy that could help cryptanalysis. </li></ul>
  16. 16. Encryption
  17. 17. Encryption <ul><li>To encrypt a file, you need to specify options </li></ul><ul><ul><li>Recepient (can be yourself) </li></ul></ul><ul><ul><li>Binary or ascii mode </li></ul></ul><ul><ul><li>Output filename </li></ul></ul><ul><ul><li>Input filename </li></ul></ul><ul><li>% gpg -r [UID]-a –o [outname] –e [file] </li></ul><ul><li>Will also work with streams. </li></ul>
  18. 18. Decryption <ul><li>Only need to specify the decrypt option </li></ul><ul><li>% gpg -d [file] </li></ul><ul><li>Will prompt for pass phrase </li></ul>
  19. 19. Signature <ul><li>Integrity </li></ul><ul><ul><li>Message is hashed </li></ul></ul><ul><ul><li>Hash is encrypted with private key </li></ul></ul><ul><ul><li>Message can be hashed again to prove it hasn’t changed. </li></ul></ul><ul><li>Authentication </li></ul><ul><ul><li>Hash can be decrypted with a public key </li></ul></ul><ul><ul><li>Proves that the private key was used to encrypt. </li></ul></ul><ul><ul><ul><li>But not necessarily that a particular person encrypted the message. What?!? </li></ul></ul></ul>
  20. 20. Signature <ul><li>Can be combined with encryption </li></ul><ul><li>Can be integrated or detached </li></ul><ul><li>% gpg –a --sign[file] </li></ul><ul><li>% gpg –a --detach-sign[file] </li></ul><ul><li>Detached signatures are useful for signing binary packages. </li></ul><ul><ul><li>Used with rpm (--addsign and –resign options) </li></ul></ul>
  21. 21. Key Management <ul><li>Session keys </li></ul><ul><ul><li>Created at use </li></ul></ul><ul><ul><li>Only used once </li></ul></ul><ul><ul><li>Need a very good source of randomness </li></ul></ul><ul><li>Asymmetric keys </li></ul><ul><ul><li>GPG allows you to create and manage </li></ul></ul><ul><ul><li>Public portion of key can be published </li></ul></ul>
  22. 22. Web of Trust <ul><li>How do you know what keys to trust? </li></ul><ul><ul><li>You can only physically check a finite number of keys </li></ul></ul><ul><li>PGP allows you to sign someone elses key. </li></ul><ul><ul><li>Done when you have verified that a key is valid. </li></ul></ul><ul><ul><li>Allows you to accept the validity of a key of someone you’ve never met. </li></ul></ul><ul><ul><ul><li>If Alice trusts Bob and Bob trusts Charles, then Alice can also trust Charles. </li></ul></ul></ul>
  23. 23. Web of Trust
  24. 24. GPG Key Creation <ul><li>% gpg --gen-key </li></ul><ul><li>Generates a public/private key pair. </li></ul><ul><ul><li>Because of the RSA patent, it defaults to using DH/ElGamal (Discrete Logorithm Problem) </li></ul></ul><ul><ul><li>Choose a key length (use at least 1024 bits) </li></ul></ul><ul><ul><li>User data (name, e-mail) </li></ul></ul><ul><ul><li>Pass phrase </li></ul></ul>
  25. 25. Key revocation <ul><li>Always generate a revocation certificate after creating a key! </li></ul><ul><ul><li>If you lose your pass phrase, will allow you to cancel your key. </li></ul></ul><ul><li>% gpg --gen-revoke [UID] </li></ul><ul><li>Need the pass phrase (to get to the secret key) </li></ul>
  26. 26. Key functions <ul><li>List keys and signatures </li></ul><ul><li>% gpg --list-keys </li></ul><ul><li>% gpg --list-sigs </li></ul><ul><li>% gpg --fingerprint </li></ul><ul><li>Import </li></ul><ul><li>% gpg --import [filename] </li></ul><ul><li>Export </li></ul><ul><li>% gpg --export [UID] </li></ul><ul><li>By default export is binary. Use “-a” to do ascii-armor. </li></ul>
  27. 27. Key servers <ul><li>You could exchange keys by e-mail or web page, but there is a better way. </li></ul><ul><li>PGP and GnuPG support a remote key server </li></ul><ul><li>Send </li></ul><ul><li>% gpg --keyserver [ks] --send-key [UID] </li></ul><ul><li>Receive </li></ul><ul><li>% gpg --keyserver [ks] --recv-key [UID] </li></ul><ul><li>Default key server can be put in options file. </li></ul><ul><ul><li>If default server set, gpg will automatically look there for new keys. </li></ul></ul>
  28. 28. Key signing <ul><li>ONLY SIGN A KEY WHEN YOU ARE ABSOLUTELY SURE IT IS AUTHENTIC!!! </li></ul><ul><li>Use the edit key function </li></ul><ul><li>% gpg --edit-key [UID] </li></ul><ul><ul><li>Will bring up a command prompt </li></ul></ul><ul><ul><li>Can sign, revoke, change trust, delete, etc… </li></ul></ul><ul><li>>sign </li></ul><ul><li>Make sure you send the newly signed key to a key server. </li></ul>
  29. 29. Conclusion <ul><li>GPG is a tool you can use to improve communication security. </li></ul><ul><ul><li>Don’t consider it an end result, but a link in a chain. </li></ul></ul><ul><li>It is integrated into a few packages, but the interface could be better </li></ul><ul><ul><li>Barrier to use </li></ul></ul><ul><li>Better when used all the time. </li></ul>
  30. 30. References <ul><li>Garfinkel, Simson, PGP, Pretty Good Privacy , 1995, O’Reilly & Associates. </li></ul><ul><li>Schneier, Bruce, Applied Cryptography , 1996, Wiley. </li></ul><ul><li>Various crypto links </li></ul><ul><ul><li> </li></ul></ul><ul><ul><li> </li></ul></ul><ul><ul><li> </li></ul></ul><ul><ul><li> </li></ul></ul><ul><ul><li> </li></ul></ul><ul><ul><li> </li></ul></ul><ul><ul><li> </li></ul></ul><ul><ul><li> </li></ul></ul><ul><ul><li> </li></ul></ul>