SlideShare une entreprise Scribd logo
1  sur  203
Alice & Bob
                                  or:
                    public key cryptography - 101




Joshua Thijssen
http://www.adayinthelifeof.nl
jthijssen@4worx.com
Twitter: @jaytaph
whoami?
whoami?
Senior Software Engineer
4worx / Enrise
whoami?
Senior Software Engineer
4worx / Enrise

Development in php, python, perl, C,
C++, java, assembly
whoami?
Senior Software Engineer
4worx / Enrise

Development in php, python, perl, C,
C++, java, assembly

Certified MySQL DBE, MySQL DBA,
LPIC-1, LPIC-2, Zend PHP5, Zend
PHP5.3, Zend Framework, Ubuntu
professional and a dive instructor.
whoami?
Senior Software Engineer
4worx / Enrise

Development in php, python, perl, C,
C++, java, assembly

Certified MySQL DBE, MySQL DBA,
LPIC-1, LPIC-2, Zend PHP5, Zend
PHP5.3, Zend Framework, Ubuntu
professional and a dive instructor.
Blog: www.adayinthelifeof.nl
Twitter: @jaytaph
whoami?
Senior Software Engineer
4worx / Enrise

Development in php, python, perl, C,
C++, java, assembly

Certified MySQL DBE, MySQL DBA,
LPIC-1, LPIC-2, Zend PHP5, Zend
PHP5.3, Zend Framework, Ubuntu
professional and a dive instructor.
Blog: www.adayinthelifeof.nl
Twitter: @jaytaph

“Jack-of-all-trades, master of none”
Terminology
Terminology

Meet Alice,
Terminology

Meet Alice,
               and Bob.
Terminology


Fictional characters who are presenting
either side of the (communication) line.
Person A(lice) sending a message to person
B(ob)
Terminology
Terminology

Other actors (the bad guys):
Terminology

Other actors (the bad guys):
• Eve  (eavesdropper, does not change the
   message)
Terminology

Other actors (the bad guys):
• Eve  (eavesdropper, does not change the
   message)
• Mallory (malicious attacker, changes the
   message aka: man-in-the-middle)
Terminology
                Plaintext


The data that needs to be encrypted. Your “message”
Terminology
                               Ciphertext


The output from after encrypting the message. The actual data that is send over to Bob.
Terminology
                                 Cipher


The algorithm used for converting a plaintext into a ciphertext and/or vice versa
Terminology
                                          key


A block of data that is used as a parameter into a cipher for either encryption or decryption




     $ciphertext = cipher($message, $key)
     $message = cipher($ciphertext, $key)
Terminology
                                                    Encryption


         In cryptography, encryption is the process of transforming information (referred to as plaintext) using an
         algorithm (called cipher) to make it unreadable to anyone except those possessing special knowledge, usually
         referred to as a key.




                               Wikipedia says so, so it must be true..




http://en.wikipedia.org/wiki/Encryption
Bad encryptions

                 Before we look at
                 good encryptions,
                 let’s take a look at
                  some bad ones...




http://www.flickr.com/photos/wwworks/4612188594/sizes/m/in/photostream/
Bad encryptions

         “algorithm”:
A = 1, B = 2, C = 3, ...., Z = 26
Bad encryptions

         “algorithm”:
A = 1, B = 2, C = 3, ...., Z = 26


     Encrypted message:
         12, 1, 13, 5
Bad encryptions

         “algorithm”:
A = 1, B = 2, C = 3, ...., Z = 26


     Encrypted message:
         12, 1, 13, 5
              =
         L, A, M, E
Bad encryptions
       Caesar cipher:
   A = (A + key) mod 26,
   B = (B + key) mod 26
             ....
   Z = (Z + key) mod 26
            or:
    m = m + k mod 26
Bad encryptions
        Caesar cipher:
    A = (A + key) mod 26,
    B = (B + key) mod 26
              ....
    Z = (Z + key) mod 26
             or:
     m = m + k mod 26

  Message (key=1): M B N F
Bad encryptions
        Caesar cipher:
    A = (A + key) mod 26,
    B = (B + key) mod 26
              ....
    Z = (Z + key) mod 26
             or:
     m = m + k mod 26

  Message (key=1): M B N F
  Message (key=-1): K Z L D
Bad encryptions
        Caesar cipher:
    A = (A + key) mod 26,
    B = (B + key) mod 26
              ....
    Z = (Z + key) mod 26
             or:
     m = m + k mod 26

  Message (key=1): M B N F
  Message (key=-1): K Z L D
  Message (key=26): L A M E
Bad encryptions
        Caesar cipher:
    A = (A + key) mod 26,
    B = (B + key) mod 26
              ....
    Z = (Z + key) mod 26
             or:
     m = m + k mod 26

  Message (key=1): M B N F
  Message (key=-1): K Z L D
  Message (key=26): L A M E
  Message (key=0): L A M E
Bad encryptions
        Caesar cipher:
    A = (A + key) mod 26,
    B = (B + key) mod 26
              ....
    Z = (Z + key) mod 26
             or:
     m = m + k mod 26

  Message (key=1): M B N F
  Message (key=-1): K Z L D
  Message (key=26): L A M E
  Message (key=0): L A M E
  Message (key=13): Y N Z R   (ROT13)
Bad encryptions
        Caesar cipher:
    A = (A + key) mod 26,
    B = (B + key) mod 26
              ....
    Z = (Z + key) mod 26
             or:
                          A-1 = Z
     m = m + k mod 26 Z+1 = A
                          wraparound
  Message (key=1): M B N F
  Message (key=-1): K Z L D
  Message (key=26): L A M E
  Message (key=0): L A M E
  Message (key=13): Y N Z R (ROT13)
Possible problems
when dealing with those simple encryption algorithms
Possible problems
       when dealing with those simple encryption algorithms




•   Key is too simple (easy to guess, brute force)
Possible problems
       when dealing with those simple encryption algorithms




•   Key is too simple (easy to guess, brute force)

•   Key has to be send to Bob (so everybody knows
    the key, unless it too has been encrypted)
Possible problems
       when dealing with those simple encryption algorithms




•   Key is too simple (easy to guess, brute force)

•   Key has to be send to Bob (so everybody knows
    the key, unless it too has been encrypted)

•   Deterministic (same input generates always same
    output)
Possible problems
       when dealing with those simple encryption algorithms




•   Key is too simple (easy to guess, brute force)

•   Key has to be send to Bob (so everybody knows
    the key, unless it too has been encrypted)

•   Deterministic (same input generates always same
    output)

•   Prone to frequency analysis
Frequency Analysis
Frequency Analysis

• The usage of every letter in the English (or
  any other language) can be represented by
  a percentage.
Frequency Analysis

• The usage of every letter in the English (or
  any other language) can be represented by
  a percentage.
• ‘E’ is used 12.7% of the times in english
  texts, the ‘Z’ only 0.074%.
Edgar Allan Poe
                                                        “the raven”




http://www.gutenberg.org/cache/epub/14082/pg14082.txt
Edgar Allan Poe
                                                        “the raven”




http://www.gutenberg.org/cache/epub/14082/pg14082.txt
Let’s analyze:




A small bit of text can result in differences, but still there
            are some letters we can deduce..
Let’s analyze:




A small bit of text can result in differences, but still there
            are some letters we can deduce..
More text: better matching




We can deduce almost all letters just without even
   CARING about the crypto algorithm used.
Frequency analysis


This is not only true for single letters, but can also be
          used for complete text sentences.
Frequency analysis
   Frequency analysis made it possible
   to crack the nazi’s WW2 “enigma”
   encryption machine:




http://plus.maths.org/issue34/features/ellis/           http://upload.wikimedia.org/wikipedia/commons/a/ae/Enigma.jpg
Frequency analysis
   Frequency analysis made it possible
   to crack the nazi’s WW2 “enigma”
   encryption machine:


               “An die gruppe”




http://plus.maths.org/issue34/features/ellis/           http://upload.wikimedia.org/wikipedia/commons/a/ae/Enigma.jpg
Frequency analysis
   Frequency analysis made it possible
   to crack the nazi’s WW2 “enigma”
   encryption machine:


               “An die gruppe”
               “Keinebesondere Ereignisse”




http://plus.maths.org/issue34/features/ellis/           http://upload.wikimedia.org/wikipedia/commons/a/ae/Enigma.jpg
Frequency analysis
   Frequency analysis made it possible
   to crack the nazi’s WW2 “enigma”
   encryption machine:


               “An die gruppe”
               “Keinebesondere Ereignisse”
               And, off course:



http://plus.maths.org/issue34/features/ellis/           http://upload.wikimedia.org/wikipedia/commons/a/ae/Enigma.jpg
Frequency analysis
   Frequency analysis made it possible
   to crack the nazi’s WW2 “enigma”
   encryption machine:


               “An die gruppe”
               “Keinebesondere Ereignisse”
               And, off course:
               “Heil Hitler”


http://plus.maths.org/issue34/features/ellis/           http://upload.wikimedia.org/wikipedia/commons/a/ae/Enigma.jpg
Good encryptions
Good encryptions

• Have “open” algorithms.
Good encryptions

• Have “open” algorithms.
• Have (strong) mathematical proof.
Good encryptions

• Have “open” algorithms.
• Have (strong) mathematical proof.
• Knowing the algorithm doesn’t mean you
  can encrypt or decrypt with the key.
Encryption
Encryption

• Previous (bad) examples where
  symmetrical encryptions.
Encryption

• Previous (bad) examples where
  symmetrical encryptions.

• Key is used for both encryption and
  decryption (2-way street)
Encryption

• Previous (bad) examples where
  symmetrical encryptions.

• Key is used for both encryption and
  decryption (2-way street)
• Good symmetrical encryptions: AES,
  Blowfish, (3)DES
Encryption



Another encryption method: asymmetrical
  encryption or public key encryption.
Asymmetrical encryption




http://upload.wikimedia.org/wikipedia/commons/f/f9/Public_key_encryption.svg
Asymmetrical encryption


It is NOT possible to decrypt the message with the
key that is used for encryption. This is an very
IMPORTANT property for various reasons.
Asymmetrical encryption
Asymmetrical encryption


• Can be used for encryption
Asymmetrical encryption


• Can be used for encryption
• Can be used for validation and authentication (is
  the sender REALLY the sender and is the data not
  tampered with) (Signing)
Comparison
Symmetrical                   Asymmetrical
✓   Quick                     ✓   no need to send over the key
✓   Not resource intensive    ✓ can be used for encryption
                              and validation (signing)
✓ Useful for small (but not
too) and large messages       ✗   very resource intensive
✗ Need to send over the key   ✗   only useful for small messages
to the other side.
So let’s combine both:



Use symmetrical for the (large) message and
encrypt the key with asymmetrical encryption.
Hybrid encryption

✓   Quick
✓   Not resource intensive
✓Useful for small and large
messages
✓   Safely exchange key data
                               +
But we’re not talking about
    hybrid encryption
          (at least, not yet)
We’re talking about public
key encryption, which is
      asymmetrical
We will focus on RSA, but
   there are others:
 RSA, DH, DSS(DSA)
What is it?
What is it?
• Asymmetrical encryption
What is it?
• Asymmetrical encryption
• Uses a key-pair: private key + public key
What is it?
• Asymmetrical encryption
• Uses a key-pair: private key + public key
• Can be used for both encryption and
  validation (signing)
What is it?
• Asymmetrical encryption
• Uses a key-pair: private key + public key
• Can be used for both encryption and
  validation (signing)
• Keys should be very large
What is it?
• Asymmetrical encryption
• Uses a key-pair: private key + public key
• Can be used for both encryption and
  validation (signing)
• Keys should be very large
• Deterministic, so use with caution
Myths


• Key length doesn’t say anything about
  security when comparing different
  encryptions.
      AES256 (256bit) > RSA 1024bit
How does it work?

• Public key encryption works on the
  premise that it is almost impossible to
  (quickly) refactor a large primes back into 2
  separate other primes
• But there is no proof that it’s IMPOSSIBLE
  to do it quickly.
So are we just gambling?

http://farm1.static.flickr.com/43/80125882_3347a3ab46_z.jpg
Not really, but there are flaws

http://farm1.static.flickr.com/43/80125882_3347a3ab46_z.jpg
Not really, but there are flaws


• There is no proof that it’s impossible to
  refactor quickly (all tough it doesn’t look
  plausible)
• Brute-force decrypting is always lurking
  around (quicker machines, better
  algorithms).
• Good enough today != good enough
  tomorrow.
Let’s do the math
This is mathness!
No, this is RSAAAAAAAA
- p = (large) prime number
- p = (large) prime number
- q = (large) prime number (but not too close to p)
- p = (large) prime number
- q = (large) prime number (but not too close to p)
- n = p . q (= bit length of the rsa-key)
-   p = (large) prime number
-   q = (large) prime number (but not too close to p)
-   n = p . q (= bit length of the rsa-key)
-   φ = (p-1) . (q-1) (the φ thingie is called phi)
-   p = (large) prime number
-   q = (large) prime number (but not too close to p)
-   n = p . q (= bit length of the rsa-key)
-   φ = (p-1) . (q-1) (the φ thingie is called phi)
-   e = 1 < φ < gcd(e, φ)
-   p = (large) prime number
-   q = (large) prime number (but not too close to p)
-   n = p . q (= bit length of the rsa-key)
-   φ = (p-1) . (q-1) (the φ thingie is called phi)
-   e = 1 < φ < gcd(e, φ)
-   d = 1 < d < φ and e.d = 1 (mod φ)
-   p = (large) prime number
-   q = (large) prime number (but not too close to p)
-   n = p . q (= bit length of the rsa-key)
-   φ = (p-1) . (q-1) (the φ thingie is called phi)
-   e = 1 < φ < gcd(e, φ)
-   d = 1 < d < φ and e.d = 1 (mod φ)
-   public key = (n, e)
-   p = (large) prime number
-   q = (large) prime number (but not too close to p)
-   n = p . q (= bit length of the rsa-key)
-   φ = (p-1) . (q-1) (the φ thingie is called phi)
-   e = 1 < φ < gcd(e, φ)
-   d = 1 < d < φ and e.d = 1 (mod φ)
-   public key = (n, e)
-   private key = (n, d)
http://juggernautical.deviantart.com/art/don-t-panic-84005270
http://juggernautical.deviantart.com/art/don-t-panic-84005270
Math example
Math example

Step 1: select primes P and Q




                                P=?
                                Q=?
                                N=?
                                Phi = ?
                                E=?
                                D=?
Math example

Step 1: select primes P and Q
• P = 11

                                P=?
                                Q=?
                                N=?
                                Phi = ?
                                E=?
                                D=?
Math example

Step 1: select primes P and Q
• P = 11
• Q=3
                                P=?
                                Q=?
                                N=?
                                Phi = ?
                                E=?
                                D=?
Math example




               P = 11
               Q=3
               N=?
               Phi = ?
               E=?
               D=?
Math example

Step 2: create modulus n and create phi




                                          P = 11
                                          Q=3
                                          N=?
                                          Phi = ?
                                          E=?
                                          D=?
Math example

Step 2: create modulus n and create phi
• n = p . q = 11 . 3 = 33

                                          P = 11
                                          Q=3
                                          N=?
                                          Phi = ?
                                          E=?
                                          D=?
Math example

Step 2: create modulus n and create phi
• n = p . q = 11 . 3 = 33
• phi = (p-1) . (q-1) = 10 . 2 = 20
                                          P = 11
                                          Q=3
                                          N=?
                                          Phi = ?
                                          E=?
                                          D=?
Math example




               P = 11
               Q=3
               N = 33
               Phi = 20
               E=?
               D=?
Math example
Step 3: choose public exponent e




                                   P = 11
                                   Q=3
                                   N = 33
                                   Phi = 20
                                   E=?
                                   D=?
Math example
Step 3: choose public exponent e
• Use a Fermat prime for easy calculations:
   3, 17 or 65537



                                         P = 11
                                         Q=3
                                         N = 33
                                         Phi = 20
                                         E=?
                                         D=?
Math example
Step 3: choose public exponent e
• Use a Fermat prime for easy calculations:
   3, 17 or 65537
• e=3
                                         P = 11
                                         Q=3
                                         N = 33
                                         Phi = 20
                                         E=?
                                         D=?
Math example
Step 3: choose public exponent e
• Use a Fermat prime for easy calculations:
   3, 17 or 65537
• e=3
• check gdc(e, p-1) = 1 =>
   gdc(3, 10) = 1 (no common factors     P = 11
   except for 1)                         Q=3
                                         N = 33
                                         Phi = 20
                                         E=?
                                         D=?
Math example




               P = 11
               Q=3
               N = 33
               Phi = 20
               E=3
               D=?
Math example


Step 3: check gdc(e, phi) = 1
• gdc(3, 20) = 1 (there are no common
   factors except for 1)
                                        P = 11
                                        Q=3
                                        N = 33
                                        Phi = 20
                                        E=3
                                        D=?
Math example




               P = 11
               Q=3
               N = 33
               Phi = 20
               E=3
               D=?
Math example
Step 4: e . d = 1 (mod phi)




                              P = 11
                              Q=3
                              N = 33
                              Phi = 20
                              E=3
                              D=?
Math example
Step 4: e . d = 1 (mod phi)
• Extended Euclidean Algorithm gives 7


                                         P = 11
                                         Q=3
                                         N = 33
                                         Phi = 20
                                         E=3
                                         D=?
Math example
Step 4: e . d = 1 (mod phi)
• Extended Euclidean Algorithm gives 7
• brute force:

                                         P = 11
                                         Q=3
                                         N = 33
                                         Phi = 20
                                         E=3
                                         D=?
Math example
Step 4: e . d = 1 (mod phi)
• Extended Euclidean Algorithm gives 7
• brute force:
   3 . 1 = 3 mod 20 = 3




                                         P = 11
                                         Q=3
                                         N = 33
                                         Phi = 20
                                         E=3
                                         D=?
Math example
Step 4: e . d = 1 (mod phi)
• Extended Euclidean Algorithm gives 7
• brute force:
   3 . 1 = 3 mod 20 = 3
   3 . 2 = 6 mod 20 = 6




                                         P = 11
                                         Q=3
                                         N = 33
                                         Phi = 20
                                         E=3
                                         D=?
Math example
Step 4: e . d = 1 (mod phi)
• Extended Euclidean Algorithm gives 7
• brute force:
   3 . 1 = 3 mod 20 = 3
   3 . 2 = 6 mod 20 = 6
   3 . 3 = 9 mod 20 = 9




                                         P = 11
                                         Q=3
                                         N = 33
                                         Phi = 20
                                         E=3
                                         D=?
Math example
Step 4: e . d = 1 (mod phi)
• Extended Euclidean Algorithm gives 7
• brute force:
   3 . 1 = 3 mod 20 = 3
   3 . 2 = 6 mod 20 = 6
   3 . 3 = 9 mod 20 = 9
   3 . 4 = 12 mod 20 = 12




                                         P = 11
                                         Q=3
                                         N = 33
                                         Phi = 20
                                         E=3
                                         D=?
Math example
Step 4: e . d = 1 (mod phi)
• Extended Euclidean Algorithm gives 7
• brute force:
   3 . 1 = 3 mod 20 = 3
   3 . 2 = 6 mod 20 = 6
   3 . 3 = 9 mod 20 = 9
   3 . 4 = 12 mod 20 = 12
   3 . 5 = 15 mod 20 = 15


                                         P = 11
                                         Q=3
                                         N = 33
                                         Phi = 20
                                         E=3
                                         D=?
Math example
Step 4: e . d = 1 (mod phi)
• Extended Euclidean Algorithm gives 7
• brute force:
   3 . 1 = 3 mod 20 = 3
   3 . 2 = 6 mod 20 = 6
   3 . 3 = 9 mod 20 = 9
   3 . 4 = 12 mod 20 = 12
   3 . 5 = 15 mod 20 = 15
   3 . 6 = 18 mod 20 = 18
                                         P = 11
                                         Q=3
                                         N = 33
                                         Phi = 20
                                         E=3
                                         D=?
Math example
Step 4: e . d = 1 (mod phi)
• Extended Euclidean Algorithm gives 7
• brute force:
   3 . 1 = 3 mod 20 = 3
   3 . 2 = 6 mod 20 = 6
   3 . 3 = 9 mod 20 = 9
   3 . 4 = 12 mod 20 = 12
   3 . 5 = 15 mod 20 = 15
   3 . 6 = 18 mod 20 = 18
   3 . 7 = 21 mod 20 = 1 (<-- correct)
                                         P = 11
                                         Q=3
                                         N = 33
                                         Phi = 20
                                         E=3
                                         D=?
Math example
Step 4: e . d = 1 (mod phi)
• Extended Euclidean Algorithm gives 7
• brute force:
   3 . 1 = 3 mod 20 = 3
   3 . 2 = 6 mod 20 = 6
   3 . 3 = 9 mod 20 = 9
   3 . 4 = 12 mod 20 = 12
   3 . 5 = 15 mod 20 = 15
   3 . 6 = 18 mod 20 = 18
   3 . 7 = 21 mod 20 = 1 (<-- correct)
                                         P = 11
   3 . 8 = 24 mod 20 = 4                 Q=3
                                         N = 33
                                         Phi = 20
                                         E=3
                                         D=?
Math example
Step 4: e . d = 1 (mod phi)
• Extended Euclidean Algorithm gives 7
• brute force:
   3 . 1 = 3 mod 20 = 3
   3 . 2 = 6 mod 20 = 6
   3 . 3 = 9 mod 20 = 9
   3 . 4 = 12 mod 20 = 12
   3 . 5 = 15 mod 20 = 15
   3 . 6 = 18 mod 20 = 18
   3 . 7 = 21 mod 20 = 1 (<-- correct)
                                         P = 11
   3 . 8 = 24 mod 20 = 4                 Q=3
   3 . 9 = 27 mod 20 = 7
                                         N = 33
                                         Phi = 20
                                         E=3
                                         D=?
Math example




               P = 11
               Q=3
               N = 33
               Phi = 20
               E=3
               D=7
Math example


That’s it:




                            P = 11
                            Q=3
                            N = 33
                            Phi = 20
                            E=3
                            D=7
Math example


That’s it:
 • public key = (n, e) = (33, 3)
                                   P = 11
                                   Q=3
                                   N = 33
                                   Phi = 20
                                   E=3
                                   D=7
Math example


That’s it:
 • public key = (n, e) = (33, 3)
 • private key = (n, d) = (33, 7)
                                    P = 11
                                    Q=3
                                    N = 33
                                    Phi = 20
                                    E=3
                                    D=7
Math example


The actual math is much more complex,
since we use large, very large numbers, but it
all comes down to these (relatively simple)
calculations..
Encrypting and decrypting

 Encrypting a message:
 •  c = me mod n

 Decrypting a message:
 • m = cd mod n
Encrypting and decrypting

 Encrypting a message (private key = (n,e) = (33, 7):
 •  c = me mod n

 •    message = 10, 20, 15, 5
     c = 10^7 mod 33 = 10
     c = 20^7 mod 33 = 26
     c = 15^7 mod 33 = 27
     c = 5^7 mod 33 =14


     c = 10, 26, 27, 14 (Note: these are not ascii values or any kind. These are integers!)
Encrypting and decrypting

 Decrypting a message (public key = (n,d) = (33, 3):
 • m = cd mod n

 •   c = 10, 26, 27, 14
     m = 10^3 mod 33 = 10
     m = 26^3 mod 33 = 20
     m = 27^3 mod 33 = 15
     m = 14^3 mod 33 =5


     m = 10, 20, 15, 5
Encrypting and decrypting



 We can encrypt all integers ranging from 0 to n:
We can encrypt all integers ranging from 0 to n:
                (c = m7 mod 33)



0 => 0             11 => 11           22 => 22
1 => 1             12 => 12           23 => 23
2 => 29            13 => 7            24 =>18
3 => 9             14 => 20           25 => 31
4 => 16            15 => 27           26 => 5
5 => 14            16 => 25           27 => 3
6 => 30            17 => 8            28 => 19
7 => 28            18 => 6            29 => 17
8 => 2             19 => 13           30 => 24
9 => 15            20 => 26           31 => 4
10 => 10           21 => 21           32 => 32
RSA Messages


• A message must be between 2 and n-1.
• A message is an “int”, not a block of data.
PKCS#1


• Public Key Cryptography Standard #1
• Pads data with (random) bytes up to n bits
  in length
PKCS#1
                     Bob's 1024-bit RSA encryption key in hex format:

                n=
                A9E167983F39D55FF2A093415EA6798985C8355D9A915BFB1D01DA197026170F
                BDA522D035856D7A986614415CCFB7B7083B09C991B81969376DF9651E7BD9A9
                3324A37F3BBBAF460186363432CB07035952FC858B3104B8CC18081448E64F1C
                FB5D60C4E05C1F53D37F53D86901F105F87A70D1BE83C65F38CF1C2CAA6AA7EB
                e=010001 (65537)
                d=
                67CD484C9A0D8F98C21B65FF22839C6DF0A6061DBCEDA7038894F21C6B0F8B35
                DE0E827830CBE7BA6A56AD77C6EB517970790AA0F4FE45E0A9B2F419DA8798D6
                308474E4FC596CC1C677DCA991D07C30A0A2C5085E217143FC0D073DF0FA6D14
                9E4E63F01758791C4B981C3D3DB01BDFFA253BA3C02C9805F61009D887DB0319


                Data =4E636AF98E40F3ADCFCCB698F4E80B9F

                The encoded message block, EB, after encoding but before encryption, with random padding bytes shown in green,
                0002257F48FD1F1793B7E5E02306F2D3228F5C95ADF5F31566729F132AA12009
                E3FC9B2B475CD6944EF191E3F59545E671E474B555799FE3756099F044964038
                B16B2148E9A2F9C6F44BB5C52E3C6C8061CF694145FAFDB24402AD1819EACEDF
                4A36C6E4D2CD8FC1D62E5A1268F496004E636AF98E40F3ADCFCCB698F4E80B9F

                After RSA encryption, the output is
                3D2AB25B1EB667A40F504CC4D778EC399A899C8790EDECEF062CD739492C9CE5
                8B92B9ECF32AF4AAC7A61EAEC346449891F49A722378E008EFF0B0A8DBC6E621
                EDC90CEC64CF34C640F5B36C48EE9322808AF8F4A0212B28715C76F3CB99AC7E
                609787ADCE055839829E0142C44B676D218111FFE69F9D41424E177CBA3A435B




http://www.di-mgt.com.au/rsa_alg.html#pkcs1schemes
Signing a message
Signing a message
• Signing a message means adding a signature
  that authenticates the validity of a message.
Signing a message
• Signing a message means adding a signature
  that authenticates the validity of a message.
• Like md5 or sha1, so when the message
  changes, so should the signature.
Signing a message
• Signing a message means adding a signature
  that authenticates the validity of a message.
• Like md5 or sha1, so when the message
  changes, so should the signature.
• This works on the premise that Alice and
  only Alice has the private key that can
  encrypt the hash.
Signing a message
Signing a message

•   message m
Signing a message

•   message m

•   Alice gets Bob’s public key
Signing a message

•   message m

•   Alice gets Bob’s public key

•   Alice encrypts message m into c
Signing a message

•   message m

•   Alice gets Bob’s public key

•   Alice encrypts message m into c

•   Alice calculates the hash of m (Hm)
Signing a message

•   message m

•   Alice gets Bob’s public key

•   Alice encrypts message m into c

•   Alice calculates the hash of m (Hm)

•   Alice encrypts the hash with Alice’s private
    key => c(Hm)
Signing a message

•   message m

•   Alice gets Bob’s public key

•   Alice encrypts message m into c

•   Alice calculates the hash of m (Hm)

•   Alice encrypts the hash with Alice’s private
    key => c(Hm)

•   Alice sends c + c(Hm)
Signing a message
Signing a message
•   Bob receives c + c(Hm)
Signing a message
•   Bob receives c + c(Hm)

•   Bob decrypts c into m with it’s private key
Signing a message
•   Bob receives c + c(Hm)

•   Bob decrypts c into m with it’s private key

•   Bob decrypts c(Hm) into Hm with Alice’s public
    key
Signing a message
•   Bob receives c + c(Hm)

•   Bob decrypts c into m with it’s private key

•   Bob decrypts c(Hm) into Hm with Alice’s public
    key

•   Bob checks Hm against hash(m)
Signing a message
•   Bob receives c + c(Hm)

•   Bob decrypts c into m with it’s private key

•   Bob decrypts c(Hm) into Hm with Alice’s public
    key

•   Bob checks Hm against hash(m)

•   If equal, we know alice has send the message
    AND the message content is not tampered
    with.
Implementations of public key
                              algorithms in real life.
http://farm4.static.flickr.com/3538/3420164047_09ccc14e29.jpg
public key encryption in


    Web communication
          (aka: I never use my credit card for internet purchases. It’s not safe.
Instead, I give it to the waiter who walks away with it to the kitchen for 5 minutes..)
Back in time


Welcome to 1991: HTTP is plaintext.
Everybody can be trusted. This page is under
construction, here’s a photo of my cat and a
link to geocities.
Nowadays:
Nowadays:


• Free WiFi everywhere
Nowadays:


• Free WiFi everywhere
• Traffic snooping
Nowadays:


• Free WiFi everywhere
• Traffic snooping
• Authorization: Basic?
                    (yes,VERY basic)
HTTPS
HTTPS

• HTTP encapsulated by TLS (previously SSL).
HTTPS

• HTTP encapsulated by TLS (previously SSL).
• More or less: an encryption layer on top of
  http.
HTTPS

• HTTP encapsulated by TLS (previously SSL).
• More or less: an encryption layer on top of
  http.
• Hybrid encryption.
HTTPS
HTTPS

• Actual encryption methodology is decided
  by the browser and the server (highest
  possible encryption used).
• Symmetric encryption (AES-256, others)
• But both sides needs the same key, so we
  have the same problem as before: how do we
  send over the key?
HTTPS
HTTPS


• Key is exchanged in a public/private
  encrypted communication.
HTTPS


• Key is exchanged in a public/private
  encrypted communication.
• Which public and private key?
HTTPS


• Key is exchanged in a public/private
  encrypted communication.
• Which public and private key?
• They are stored inside the server’s SSL
  certificate
HTTPS
HTTPS

• Browser sends over it’s encryption methods.
HTTPS

• Browser sends over it’s encryption methods.
• Server decides which one to use.
HTTPS

• Browser sends over it’s encryption methods.
• Server decides which one to use.
• Server send certificate(s).
HTTPS

•   Browser sends over it’s encryption methods.
•   Server decides which one to use.
•   Server send certificate(s).
•   Client sends “session key” encrypted by the
    public key found in the server certificate.
HTTPS

•   Browser sends over it’s encryption methods.
•   Server decides which one to use.
•   Server send certificate(s).
•   Client sends “session key” encrypted by the
    public key found in the server certificate.
•   Server and client uses the “session key” for
    symmetrical encryption.
HTTPS
HTTPS


• Thus: Public/private encryption is only used
    in establishing a secondary
    (better!?)encryption.
•   SSL/TLS is a separate talk (It’s way more
    complex as this)
HTTPS

• Myths about self-signed certificates:
• HTTPS traffic is ALWAYS(*) encrypted no
    matter if the certificate is self-signed or not.
•   Self-signed certificates are NOT less safe
    than (expensive) signed certificates.
•   They are just annoying for end-users.
HTTPS

• Myths about self-signed certificates:
• HTTPS traffic is ALWAYS(*) encrypted no
    matter if the certificate is self-signed or not.
•   Self-signed certificates are NOT less safe
    than (expensive) signed certificates.
•   They are just annoying for end-users.
public key encryption in


             Email communication
(aka: the worst communication method invented when it comes to privacy or secrecy, except for yelling)
SMTP sucks

                       but it didn’t matter back then.
                 If you had a beard, you could be trusted.




http://farm1.static.flickr.com/179/375718254_31e1d7b5d3.jpg
Nowadays, not so much




http://torontoemerg.files.wordpress.com/2010/09/spam.gif   http://change-your-ip.com/wp-content/uploads/image/nigerian_419_scam.jpg
Did you ever get emails like this?
Questions:
Questions:

• Did Bill really send this email?
Questions:

• Did Bill really send this email?
• Do we know for sure that nobody has read
  this email (before it came to us?)
Questions:

• Did Bill really send this email?
• Do we know for sure that nobody has read
  this email (before it came to us?)
• Do we know for sure that the contents of
  the message isn’t tampered with?
We can answer these questions positively if
Bill had signed and encrypted his email with a
public key encryption (didn’t he got the
memo?)
Introduction a pretty-good-privacy
Introduction a pretty-good-privacy


• GPG / PGP: Lets you create asymmetrical
  keys for signing and/or encrypting data (or
  email).
Introduction a pretty-good-privacy


• GPG / PGP: Lets you create asymmetrical
  keys for signing and/or encrypting data (or
  email).
• Public keys can be send / found on PGP-
  servers so you don’t need to send your
  keys to everybody all the time.
Using a public key server
Using a public key server
But beware:


                       Stupidity trumps
                          everything:
                       Don’t loose your
                        private key(s)
                      (as I did on multiple occasions)




http://farm4.static.flickr.com/3231/2783827537_b4d2a5cc9a.jpg
Advantages
Advantages
• Everybody can send emails that ONLY YOU
  can read.
Advantages
• Everybody can send emails that ONLY YOU
  can read.

• Everybody can verify that YOU have send
  the email and that it is authentic.
Advantages
• Everybody can send emails that ONLY YOU
  can read.

• Everybody can verify that YOU have send
  the email and that it is authentic.

• Why is this not the standard?   (No really: why isn’t it?)
Advantages
• Everybody can send emails that ONLY YOU
  can read.

• Everybody can verify that YOU have send
  the email and that it is authentic.

• Why is this not the standard?   (No really: why isn’t it?)



• Try it yourself with Thunderbird’s Enigmail
  extension.
other fields

             PGP / GPG
  (encrypt / decrypt sensitive data)

             OpenSSH
(Secure connection to other systems)

              IPSEC
           (VPN tunnels)
Any questions?




http://farm1.static.flickr.com/73/163450213_18478d3aa6_d.jpg
Thank you


And thanks to all creative commons
contributors on flickr.com




Joshua Thijssen
http://www.adayinthelifeof.nl
jthijssen@4worx.com
Twitter: @jaytaph

Contenu connexe

En vedette

CNIT 141: 9. Elliptic Curve Cryptosystems
CNIT 141: 9. Elliptic Curve CryptosystemsCNIT 141: 9. Elliptic Curve Cryptosystems
CNIT 141: 9. Elliptic Curve CryptosystemsSam Bowne
 
Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)
Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)
Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)Entrust Datacard
 
Cryptography and Message Authentication NS3
Cryptography and Message Authentication NS3Cryptography and Message Authentication NS3
Cryptography and Message Authentication NS3koolkampus
 
symmetric key encryption algorithms
 symmetric key encryption algorithms symmetric key encryption algorithms
symmetric key encryption algorithmsRashmi Burugupalli
 
Cryptography
CryptographyCryptography
CryptographyAnandKaGe
 
Information and data security block cipher and the data encryption standard (...
Information and data security block cipher and the data encryption standard (...Information and data security block cipher and the data encryption standard (...
Information and data security block cipher and the data encryption standard (...Mazin Alwaaly
 
Block Cipher Modes of Operation And Cmac For Authentication
Block Cipher Modes of Operation And Cmac For AuthenticationBlock Cipher Modes of Operation And Cmac For Authentication
Block Cipher Modes of Operation And Cmac For AuthenticationVittorio Giovara
 
Ch03 block-cipher-and-data-encryption-standard
Ch03 block-cipher-and-data-encryption-standardCh03 block-cipher-and-data-encryption-standard
Ch03 block-cipher-and-data-encryption-standardtarekiceiuk
 
Different types of Symmetric key Cryptography
Different types of Symmetric key CryptographyDifferent types of Symmetric key Cryptography
Different types of Symmetric key Cryptographysubhradeep mitra
 
Information and data security block cipher operation
Information and data security block cipher operationInformation and data security block cipher operation
Information and data security block cipher operationMazin Alwaaly
 
Block cipher modes of operation
Block cipher modes of operation Block cipher modes of operation
Block cipher modes of operation harshit chavda
 
CS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITYCS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITYKathirvel Ayyaswamy
 
CS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITYCS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITYKathirvel Ayyaswamy
 
CS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITYCS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITYKathirvel Ayyaswamy
 
Cipher techniques
Cipher techniquesCipher techniques
Cipher techniquesMohd Arif
 
PUBLIC KEY ENCRYPTION
PUBLIC KEY ENCRYPTIONPUBLIC KEY ENCRYPTION
PUBLIC KEY ENCRYPTIONraf_slide
 

En vedette (20)

CNIT 141: 9. Elliptic Curve Cryptosystems
CNIT 141: 9. Elliptic Curve CryptosystemsCNIT 141: 9. Elliptic Curve Cryptosystems
CNIT 141: 9. Elliptic Curve Cryptosystems
 
Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)
Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)
Zero to ECC in 30 Minutes: A primer on Elliptic Curve Cryptography (ECC)
 
Cryptography and Message Authentication NS3
Cryptography and Message Authentication NS3Cryptography and Message Authentication NS3
Cryptography and Message Authentication NS3
 
symmetric key encryption algorithms
 symmetric key encryption algorithms symmetric key encryption algorithms
symmetric key encryption algorithms
 
Cryptography
CryptographyCryptography
Cryptography
 
Substitution Cipher
Substitution CipherSubstitution Cipher
Substitution Cipher
 
Substitution cipher
Substitution cipher Substitution cipher
Substitution cipher
 
Information and data security block cipher and the data encryption standard (...
Information and data security block cipher and the data encryption standard (...Information and data security block cipher and the data encryption standard (...
Information and data security block cipher and the data encryption standard (...
 
Public key cryptography and RSA
Public key cryptography and RSAPublic key cryptography and RSA
Public key cryptography and RSA
 
Ecc2
Ecc2Ecc2
Ecc2
 
Block Cipher Modes of Operation And Cmac For Authentication
Block Cipher Modes of Operation And Cmac For AuthenticationBlock Cipher Modes of Operation And Cmac For Authentication
Block Cipher Modes of Operation And Cmac For Authentication
 
Ch03 block-cipher-and-data-encryption-standard
Ch03 block-cipher-and-data-encryption-standardCh03 block-cipher-and-data-encryption-standard
Ch03 block-cipher-and-data-encryption-standard
 
Different types of Symmetric key Cryptography
Different types of Symmetric key CryptographyDifferent types of Symmetric key Cryptography
Different types of Symmetric key Cryptography
 
Information and data security block cipher operation
Information and data security block cipher operationInformation and data security block cipher operation
Information and data security block cipher operation
 
Block cipher modes of operation
Block cipher modes of operation Block cipher modes of operation
Block cipher modes of operation
 
CS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITYCS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITY
 
CS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITYCS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITY
 
CS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITYCS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITY
 
Cipher techniques
Cipher techniquesCipher techniques
Cipher techniques
 
PUBLIC KEY ENCRYPTION
PUBLIC KEY ENCRYPTIONPUBLIC KEY ENCRYPTION
PUBLIC KEY ENCRYPTION
 

Similaire à Alice & bob public key cryptography 101

Cryptography for developers
Cryptography for developersCryptography for developers
Cryptography for developersKai Koenig
 
Introductory Lecture on Cryptography and Information Security
Introductory Lecture on Cryptography and Information SecurityIntroductory Lecture on Cryptography and Information Security
Introductory Lecture on Cryptography and Information SecurityBikramjit Sarkar, Ph.D.
 
cryptography_priceton_university_fall_2007.ppt
cryptography_priceton_university_fall_2007.pptcryptography_priceton_university_fall_2007.ppt
cryptography_priceton_university_fall_2007.pptJohnree4
 
Awareness against hacking
Awareness against hackingAwareness against hacking
Awareness against hackingDipnarayan Das
 
amer-network-sihubconferances-security.ppt
amer-network-sihubconferances-security.pptamer-network-sihubconferances-security.ppt
amer-network-sihubconferances-security.pptnavidkamrava
 
introduction to cryptography (basics of it)
introduction to cryptography (basics of it)introduction to cryptography (basics of it)
introduction to cryptography (basics of it)neonaveen
 
Cs166 mynote
Cs166 mynoteCs166 mynote
Cs166 mynoteKaya Ota
 
Cryptography - Discrete Mathematics
Cryptography - Discrete MathematicsCryptography - Discrete Mathematics
Cryptography - Discrete MathematicsACM-KU
 
introduction to cryptography
introduction to cryptographyintroduction to cryptography
introduction to cryptographyPriyamvada Singh
 
Homomorphic Encryption
Homomorphic EncryptionHomomorphic Encryption
Homomorphic EncryptionGöktuğ Serez
 
Public-Key Protocols
Public-Key ProtocolsPublic-Key Protocols
Public-Key ProtocolsDavid Evans
 

Similaire à Alice & bob public key cryptography 101 (20)

Cryptography for developers
Cryptography for developersCryptography for developers
Cryptography for developers
 
Introductory Lecture on Cryptography and Information Security
Introductory Lecture on Cryptography and Information SecurityIntroductory Lecture on Cryptography and Information Security
Introductory Lecture on Cryptography and Information Security
 
cryptography_priceton_university_fall_2007.ppt
cryptography_priceton_university_fall_2007.pptcryptography_priceton_university_fall_2007.ppt
cryptography_priceton_university_fall_2007.ppt
 
Itt project
Itt projectItt project
Itt project
 
Awareness against hacking
Awareness against hackingAwareness against hacking
Awareness against hacking
 
Edward Schaefer
Edward SchaeferEdward Schaefer
Edward Schaefer
 
amer-network-sihubconferances-security.ppt
amer-network-sihubconferances-security.pptamer-network-sihubconferances-security.ppt
amer-network-sihubconferances-security.ppt
 
crypto1.ppt
crypto1.pptcrypto1.ppt
crypto1.ppt
 
introduction to cryptography (basics of it)
introduction to cryptography (basics of it)introduction to cryptography (basics of it)
introduction to cryptography (basics of it)
 
crypto.ppt
crypto.pptcrypto.ppt
crypto.ppt
 
needed.ppt
needed.pptneeded.ppt
needed.ppt
 
Cs166 mynote
Cs166 mynoteCs166 mynote
Cs166 mynote
 
Cryptography - Discrete Mathematics
Cryptography - Discrete MathematicsCryptography - Discrete Mathematics
Cryptography - Discrete Mathematics
 
introduction to cryptography
introduction to cryptographyintroduction to cryptography
introduction to cryptography
 
Ch02 classic nemo
Ch02 classic nemoCh02 classic nemo
Ch02 classic nemo
 
Crypt
CryptCrypt
Crypt
 
b
bb
b
 
1329 n 9460
1329 n 94601329 n 9460
1329 n 9460
 
Homomorphic Encryption
Homomorphic EncryptionHomomorphic Encryption
Homomorphic Encryption
 
Public-Key Protocols
Public-Key ProtocolsPublic-Key Protocols
Public-Key Protocols
 

Plus de Joshua Thijssen

Puppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 EditionPuppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 EditionJoshua Thijssen
 
Puppet for dummies - PHPBenelux UG edition
Puppet for dummies - PHPBenelux UG editionPuppet for dummies - PHPBenelux UG edition
Puppet for dummies - PHPBenelux UG editionJoshua Thijssen
 
15 protips for mysql users pfz
15 protips for mysql users   pfz15 protips for mysql users   pfz
15 protips for mysql users pfzJoshua Thijssen
 
Representation state transfer and some other important stuff
Representation state transfer and some other important stuffRepresentation state transfer and some other important stuff
Representation state transfer and some other important stuffJoshua Thijssen
 
Deploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APTDeploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APTJoshua Thijssen
 
15 protips for mysql users
15 protips for mysql users15 protips for mysql users
15 protips for mysql usersJoshua Thijssen
 
Sed & awk the dynamic duo
Sed & awk   the dynamic duoSed & awk   the dynamic duo
Sed & awk the dynamic duoJoshua Thijssen
 
PFZ WorkshopDay Linux - Advanced
PFZ WorkshopDay Linux - AdvancedPFZ WorkshopDay Linux - Advanced
PFZ WorkshopDay Linux - AdvancedJoshua Thijssen
 
PFZ WorkshopDay Linux - Basic
PFZ WorkshopDay Linux - BasicPFZ WorkshopDay Linux - Basic
PFZ WorkshopDay Linux - BasicJoshua Thijssen
 

Plus de Joshua Thijssen (12)

Moved 301
Moved 301Moved 301
Moved 301
 
Puppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 EditionPuppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 Edition
 
Cipher block modes
Cipher block modesCipher block modes
Cipher block modes
 
Puppet for dummies - PHPBenelux UG edition
Puppet for dummies - PHPBenelux UG editionPuppet for dummies - PHPBenelux UG edition
Puppet for dummies - PHPBenelux UG edition
 
15 protips for mysql users pfz
15 protips for mysql users   pfz15 protips for mysql users   pfz
15 protips for mysql users pfz
 
Representation state transfer and some other important stuff
Representation state transfer and some other important stuffRepresentation state transfer and some other important stuff
Representation state transfer and some other important stuff
 
Deploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APTDeploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APT
 
15 protips for mysql users
15 protips for mysql users15 protips for mysql users
15 protips for mysql users
 
Workshop unittesting
Workshop unittestingWorkshop unittesting
Workshop unittesting
 
Sed & awk the dynamic duo
Sed & awk   the dynamic duoSed & awk   the dynamic duo
Sed & awk the dynamic duo
 
PFZ WorkshopDay Linux - Advanced
PFZ WorkshopDay Linux - AdvancedPFZ WorkshopDay Linux - Advanced
PFZ WorkshopDay Linux - Advanced
 
PFZ WorkshopDay Linux - Basic
PFZ WorkshopDay Linux - BasicPFZ WorkshopDay Linux - Basic
PFZ WorkshopDay Linux - Basic
 

Dernier

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 

Dernier (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 

Alice & bob public key cryptography 101

  • 1. Alice & Bob or: public key cryptography - 101 Joshua Thijssen http://www.adayinthelifeof.nl jthijssen@4worx.com Twitter: @jaytaph
  • 4. whoami? Senior Software Engineer 4worx / Enrise Development in php, python, perl, C, C++, java, assembly
  • 5. whoami? Senior Software Engineer 4worx / Enrise Development in php, python, perl, C, C++, java, assembly Certified MySQL DBE, MySQL DBA, LPIC-1, LPIC-2, Zend PHP5, Zend PHP5.3, Zend Framework, Ubuntu professional and a dive instructor.
  • 6. whoami? Senior Software Engineer 4worx / Enrise Development in php, python, perl, C, C++, java, assembly Certified MySQL DBE, MySQL DBA, LPIC-1, LPIC-2, Zend PHP5, Zend PHP5.3, Zend Framework, Ubuntu professional and a dive instructor. Blog: www.adayinthelifeof.nl Twitter: @jaytaph
  • 7. whoami? Senior Software Engineer 4worx / Enrise Development in php, python, perl, C, C++, java, assembly Certified MySQL DBE, MySQL DBA, LPIC-1, LPIC-2, Zend PHP5, Zend PHP5.3, Zend Framework, Ubuntu professional and a dive instructor. Blog: www.adayinthelifeof.nl Twitter: @jaytaph “Jack-of-all-trades, master of none”
  • 11. Terminology Fictional characters who are presenting either side of the (communication) line. Person A(lice) sending a message to person B(ob)
  • 14. Terminology Other actors (the bad guys): • Eve (eavesdropper, does not change the message)
  • 15. Terminology Other actors (the bad guys): • Eve (eavesdropper, does not change the message) • Mallory (malicious attacker, changes the message aka: man-in-the-middle)
  • 16. Terminology Plaintext The data that needs to be encrypted. Your “message”
  • 17. Terminology Ciphertext The output from after encrypting the message. The actual data that is send over to Bob.
  • 18. Terminology Cipher The algorithm used for converting a plaintext into a ciphertext and/or vice versa
  • 19. Terminology key A block of data that is used as a parameter into a cipher for either encryption or decryption $ciphertext = cipher($message, $key) $message = cipher($ciphertext, $key)
  • 20. Terminology Encryption In cryptography, encryption is the process of transforming information (referred to as plaintext) using an algorithm (called cipher) to make it unreadable to anyone except those possessing special knowledge, usually referred to as a key. Wikipedia says so, so it must be true.. http://en.wikipedia.org/wiki/Encryption
  • 21. Bad encryptions Before we look at good encryptions, let’s take a look at some bad ones... http://www.flickr.com/photos/wwworks/4612188594/sizes/m/in/photostream/
  • 22. Bad encryptions “algorithm”: A = 1, B = 2, C = 3, ...., Z = 26
  • 23. Bad encryptions “algorithm”: A = 1, B = 2, C = 3, ...., Z = 26 Encrypted message: 12, 1, 13, 5
  • 24. Bad encryptions “algorithm”: A = 1, B = 2, C = 3, ...., Z = 26 Encrypted message: 12, 1, 13, 5 = L, A, M, E
  • 25. Bad encryptions Caesar cipher: A = (A + key) mod 26, B = (B + key) mod 26 .... Z = (Z + key) mod 26 or: m = m + k mod 26
  • 26. Bad encryptions Caesar cipher: A = (A + key) mod 26, B = (B + key) mod 26 .... Z = (Z + key) mod 26 or: m = m + k mod 26 Message (key=1): M B N F
  • 27. Bad encryptions Caesar cipher: A = (A + key) mod 26, B = (B + key) mod 26 .... Z = (Z + key) mod 26 or: m = m + k mod 26 Message (key=1): M B N F Message (key=-1): K Z L D
  • 28. Bad encryptions Caesar cipher: A = (A + key) mod 26, B = (B + key) mod 26 .... Z = (Z + key) mod 26 or: m = m + k mod 26 Message (key=1): M B N F Message (key=-1): K Z L D Message (key=26): L A M E
  • 29. Bad encryptions Caesar cipher: A = (A + key) mod 26, B = (B + key) mod 26 .... Z = (Z + key) mod 26 or: m = m + k mod 26 Message (key=1): M B N F Message (key=-1): K Z L D Message (key=26): L A M E Message (key=0): L A M E
  • 30. Bad encryptions Caesar cipher: A = (A + key) mod 26, B = (B + key) mod 26 .... Z = (Z + key) mod 26 or: m = m + k mod 26 Message (key=1): M B N F Message (key=-1): K Z L D Message (key=26): L A M E Message (key=0): L A M E Message (key=13): Y N Z R (ROT13)
  • 31. Bad encryptions Caesar cipher: A = (A + key) mod 26, B = (B + key) mod 26 .... Z = (Z + key) mod 26 or: A-1 = Z m = m + k mod 26 Z+1 = A wraparound Message (key=1): M B N F Message (key=-1): K Z L D Message (key=26): L A M E Message (key=0): L A M E Message (key=13): Y N Z R (ROT13)
  • 32. Possible problems when dealing with those simple encryption algorithms
  • 33. Possible problems when dealing with those simple encryption algorithms • Key is too simple (easy to guess, brute force)
  • 34. Possible problems when dealing with those simple encryption algorithms • Key is too simple (easy to guess, brute force) • Key has to be send to Bob (so everybody knows the key, unless it too has been encrypted)
  • 35. Possible problems when dealing with those simple encryption algorithms • Key is too simple (easy to guess, brute force) • Key has to be send to Bob (so everybody knows the key, unless it too has been encrypted) • Deterministic (same input generates always same output)
  • 36. Possible problems when dealing with those simple encryption algorithms • Key is too simple (easy to guess, brute force) • Key has to be send to Bob (so everybody knows the key, unless it too has been encrypted) • Deterministic (same input generates always same output) • Prone to frequency analysis
  • 38. Frequency Analysis • The usage of every letter in the English (or any other language) can be represented by a percentage.
  • 39. Frequency Analysis • The usage of every letter in the English (or any other language) can be represented by a percentage. • ‘E’ is used 12.7% of the times in english texts, the ‘Z’ only 0.074%.
  • 40. Edgar Allan Poe “the raven” http://www.gutenberg.org/cache/epub/14082/pg14082.txt
  • 41. Edgar Allan Poe “the raven” http://www.gutenberg.org/cache/epub/14082/pg14082.txt
  • 42. Let’s analyze: A small bit of text can result in differences, but still there are some letters we can deduce..
  • 43. Let’s analyze: A small bit of text can result in differences, but still there are some letters we can deduce..
  • 44. More text: better matching We can deduce almost all letters just without even CARING about the crypto algorithm used.
  • 45. Frequency analysis This is not only true for single letters, but can also be used for complete text sentences.
  • 46. Frequency analysis Frequency analysis made it possible to crack the nazi’s WW2 “enigma” encryption machine: http://plus.maths.org/issue34/features/ellis/ http://upload.wikimedia.org/wikipedia/commons/a/ae/Enigma.jpg
  • 47. Frequency analysis Frequency analysis made it possible to crack the nazi’s WW2 “enigma” encryption machine: “An die gruppe” http://plus.maths.org/issue34/features/ellis/ http://upload.wikimedia.org/wikipedia/commons/a/ae/Enigma.jpg
  • 48. Frequency analysis Frequency analysis made it possible to crack the nazi’s WW2 “enigma” encryption machine: “An die gruppe” “Keinebesondere Ereignisse” http://plus.maths.org/issue34/features/ellis/ http://upload.wikimedia.org/wikipedia/commons/a/ae/Enigma.jpg
  • 49. Frequency analysis Frequency analysis made it possible to crack the nazi’s WW2 “enigma” encryption machine: “An die gruppe” “Keinebesondere Ereignisse” And, off course: http://plus.maths.org/issue34/features/ellis/ http://upload.wikimedia.org/wikipedia/commons/a/ae/Enigma.jpg
  • 50. Frequency analysis Frequency analysis made it possible to crack the nazi’s WW2 “enigma” encryption machine: “An die gruppe” “Keinebesondere Ereignisse” And, off course: “Heil Hitler” http://plus.maths.org/issue34/features/ellis/ http://upload.wikimedia.org/wikipedia/commons/a/ae/Enigma.jpg
  • 52. Good encryptions • Have “open” algorithms.
  • 53. Good encryptions • Have “open” algorithms. • Have (strong) mathematical proof.
  • 54. Good encryptions • Have “open” algorithms. • Have (strong) mathematical proof. • Knowing the algorithm doesn’t mean you can encrypt or decrypt with the key.
  • 56. Encryption • Previous (bad) examples where symmetrical encryptions.
  • 57. Encryption • Previous (bad) examples where symmetrical encryptions. • Key is used for both encryption and decryption (2-way street)
  • 58. Encryption • Previous (bad) examples where symmetrical encryptions. • Key is used for both encryption and decryption (2-way street) • Good symmetrical encryptions: AES, Blowfish, (3)DES
  • 59. Encryption Another encryption method: asymmetrical encryption or public key encryption.
  • 61. Asymmetrical encryption It is NOT possible to decrypt the message with the key that is used for encryption. This is an very IMPORTANT property for various reasons.
  • 63. Asymmetrical encryption • Can be used for encryption
  • 64. Asymmetrical encryption • Can be used for encryption • Can be used for validation and authentication (is the sender REALLY the sender and is the data not tampered with) (Signing)
  • 65. Comparison Symmetrical Asymmetrical ✓ Quick ✓ no need to send over the key ✓ Not resource intensive ✓ can be used for encryption and validation (signing) ✓ Useful for small (but not too) and large messages ✗ very resource intensive ✗ Need to send over the key ✗ only useful for small messages to the other side.
  • 66. So let’s combine both: Use symmetrical for the (large) message and encrypt the key with asymmetrical encryption.
  • 67. Hybrid encryption ✓ Quick ✓ Not resource intensive ✓Useful for small and large messages ✓ Safely exchange key data +
  • 68. But we’re not talking about hybrid encryption (at least, not yet)
  • 69. We’re talking about public key encryption, which is asymmetrical
  • 70. We will focus on RSA, but there are others: RSA, DH, DSS(DSA)
  • 72. What is it? • Asymmetrical encryption
  • 73. What is it? • Asymmetrical encryption • Uses a key-pair: private key + public key
  • 74. What is it? • Asymmetrical encryption • Uses a key-pair: private key + public key • Can be used for both encryption and validation (signing)
  • 75. What is it? • Asymmetrical encryption • Uses a key-pair: private key + public key • Can be used for both encryption and validation (signing) • Keys should be very large
  • 76. What is it? • Asymmetrical encryption • Uses a key-pair: private key + public key • Can be used for both encryption and validation (signing) • Keys should be very large • Deterministic, so use with caution
  • 77. Myths • Key length doesn’t say anything about security when comparing different encryptions. AES256 (256bit) > RSA 1024bit
  • 78. How does it work? • Public key encryption works on the premise that it is almost impossible to (quickly) refactor a large primes back into 2 separate other primes • But there is no proof that it’s IMPOSSIBLE to do it quickly.
  • 79. So are we just gambling? http://farm1.static.flickr.com/43/80125882_3347a3ab46_z.jpg
  • 80. Not really, but there are flaws http://farm1.static.flickr.com/43/80125882_3347a3ab46_z.jpg
  • 81. Not really, but there are flaws • There is no proof that it’s impossible to refactor quickly (all tough it doesn’t look plausible) • Brute-force decrypting is always lurking around (quicker machines, better algorithms). • Good enough today != good enough tomorrow.
  • 84. No, this is RSAAAAAAAA
  • 85.
  • 86. - p = (large) prime number
  • 87. - p = (large) prime number - q = (large) prime number (but not too close to p)
  • 88. - p = (large) prime number - q = (large) prime number (but not too close to p) - n = p . q (= bit length of the rsa-key)
  • 89. - p = (large) prime number - q = (large) prime number (but not too close to p) - n = p . q (= bit length of the rsa-key) - φ = (p-1) . (q-1) (the φ thingie is called phi)
  • 90. - p = (large) prime number - q = (large) prime number (but not too close to p) - n = p . q (= bit length of the rsa-key) - φ = (p-1) . (q-1) (the φ thingie is called phi) - e = 1 < φ < gcd(e, φ)
  • 91. - p = (large) prime number - q = (large) prime number (but not too close to p) - n = p . q (= bit length of the rsa-key) - φ = (p-1) . (q-1) (the φ thingie is called phi) - e = 1 < φ < gcd(e, φ) - d = 1 < d < φ and e.d = 1 (mod φ)
  • 92. - p = (large) prime number - q = (large) prime number (but not too close to p) - n = p . q (= bit length of the rsa-key) - φ = (p-1) . (q-1) (the φ thingie is called phi) - e = 1 < φ < gcd(e, φ) - d = 1 < d < φ and e.d = 1 (mod φ) - public key = (n, e)
  • 93. - p = (large) prime number - q = (large) prime number (but not too close to p) - n = p . q (= bit length of the rsa-key) - φ = (p-1) . (q-1) (the φ thingie is called phi) - e = 1 < φ < gcd(e, φ) - d = 1 < d < φ and e.d = 1 (mod φ) - public key = (n, e) - private key = (n, d)
  • 97. Math example Step 1: select primes P and Q P=? Q=? N=? Phi = ? E=? D=?
  • 98. Math example Step 1: select primes P and Q • P = 11 P=? Q=? N=? Phi = ? E=? D=?
  • 99. Math example Step 1: select primes P and Q • P = 11 • Q=3 P=? Q=? N=? Phi = ? E=? D=?
  • 100. Math example P = 11 Q=3 N=? Phi = ? E=? D=?
  • 101. Math example Step 2: create modulus n and create phi P = 11 Q=3 N=? Phi = ? E=? D=?
  • 102. Math example Step 2: create modulus n and create phi • n = p . q = 11 . 3 = 33 P = 11 Q=3 N=? Phi = ? E=? D=?
  • 103. Math example Step 2: create modulus n and create phi • n = p . q = 11 . 3 = 33 • phi = (p-1) . (q-1) = 10 . 2 = 20 P = 11 Q=3 N=? Phi = ? E=? D=?
  • 104. Math example P = 11 Q=3 N = 33 Phi = 20 E=? D=?
  • 105. Math example Step 3: choose public exponent e P = 11 Q=3 N = 33 Phi = 20 E=? D=?
  • 106. Math example Step 3: choose public exponent e • Use a Fermat prime for easy calculations: 3, 17 or 65537 P = 11 Q=3 N = 33 Phi = 20 E=? D=?
  • 107. Math example Step 3: choose public exponent e • Use a Fermat prime for easy calculations: 3, 17 or 65537 • e=3 P = 11 Q=3 N = 33 Phi = 20 E=? D=?
  • 108. Math example Step 3: choose public exponent e • Use a Fermat prime for easy calculations: 3, 17 or 65537 • e=3 • check gdc(e, p-1) = 1 => gdc(3, 10) = 1 (no common factors P = 11 except for 1) Q=3 N = 33 Phi = 20 E=? D=?
  • 109. Math example P = 11 Q=3 N = 33 Phi = 20 E=3 D=?
  • 110. Math example Step 3: check gdc(e, phi) = 1 • gdc(3, 20) = 1 (there are no common factors except for 1) P = 11 Q=3 N = 33 Phi = 20 E=3 D=?
  • 111. Math example P = 11 Q=3 N = 33 Phi = 20 E=3 D=?
  • 112. Math example Step 4: e . d = 1 (mod phi) P = 11 Q=3 N = 33 Phi = 20 E=3 D=?
  • 113. Math example Step 4: e . d = 1 (mod phi) • Extended Euclidean Algorithm gives 7 P = 11 Q=3 N = 33 Phi = 20 E=3 D=?
  • 114. Math example Step 4: e . d = 1 (mod phi) • Extended Euclidean Algorithm gives 7 • brute force: P = 11 Q=3 N = 33 Phi = 20 E=3 D=?
  • 115. Math example Step 4: e . d = 1 (mod phi) • Extended Euclidean Algorithm gives 7 • brute force: 3 . 1 = 3 mod 20 = 3 P = 11 Q=3 N = 33 Phi = 20 E=3 D=?
  • 116. Math example Step 4: e . d = 1 (mod phi) • Extended Euclidean Algorithm gives 7 • brute force: 3 . 1 = 3 mod 20 = 3 3 . 2 = 6 mod 20 = 6 P = 11 Q=3 N = 33 Phi = 20 E=3 D=?
  • 117. Math example Step 4: e . d = 1 (mod phi) • Extended Euclidean Algorithm gives 7 • brute force: 3 . 1 = 3 mod 20 = 3 3 . 2 = 6 mod 20 = 6 3 . 3 = 9 mod 20 = 9 P = 11 Q=3 N = 33 Phi = 20 E=3 D=?
  • 118. Math example Step 4: e . d = 1 (mod phi) • Extended Euclidean Algorithm gives 7 • brute force: 3 . 1 = 3 mod 20 = 3 3 . 2 = 6 mod 20 = 6 3 . 3 = 9 mod 20 = 9 3 . 4 = 12 mod 20 = 12 P = 11 Q=3 N = 33 Phi = 20 E=3 D=?
  • 119. Math example Step 4: e . d = 1 (mod phi) • Extended Euclidean Algorithm gives 7 • brute force: 3 . 1 = 3 mod 20 = 3 3 . 2 = 6 mod 20 = 6 3 . 3 = 9 mod 20 = 9 3 . 4 = 12 mod 20 = 12 3 . 5 = 15 mod 20 = 15 P = 11 Q=3 N = 33 Phi = 20 E=3 D=?
  • 120. Math example Step 4: e . d = 1 (mod phi) • Extended Euclidean Algorithm gives 7 • brute force: 3 . 1 = 3 mod 20 = 3 3 . 2 = 6 mod 20 = 6 3 . 3 = 9 mod 20 = 9 3 . 4 = 12 mod 20 = 12 3 . 5 = 15 mod 20 = 15 3 . 6 = 18 mod 20 = 18 P = 11 Q=3 N = 33 Phi = 20 E=3 D=?
  • 121. Math example Step 4: e . d = 1 (mod phi) • Extended Euclidean Algorithm gives 7 • brute force: 3 . 1 = 3 mod 20 = 3 3 . 2 = 6 mod 20 = 6 3 . 3 = 9 mod 20 = 9 3 . 4 = 12 mod 20 = 12 3 . 5 = 15 mod 20 = 15 3 . 6 = 18 mod 20 = 18 3 . 7 = 21 mod 20 = 1 (<-- correct) P = 11 Q=3 N = 33 Phi = 20 E=3 D=?
  • 122. Math example Step 4: e . d = 1 (mod phi) • Extended Euclidean Algorithm gives 7 • brute force: 3 . 1 = 3 mod 20 = 3 3 . 2 = 6 mod 20 = 6 3 . 3 = 9 mod 20 = 9 3 . 4 = 12 mod 20 = 12 3 . 5 = 15 mod 20 = 15 3 . 6 = 18 mod 20 = 18 3 . 7 = 21 mod 20 = 1 (<-- correct) P = 11 3 . 8 = 24 mod 20 = 4 Q=3 N = 33 Phi = 20 E=3 D=?
  • 123. Math example Step 4: e . d = 1 (mod phi) • Extended Euclidean Algorithm gives 7 • brute force: 3 . 1 = 3 mod 20 = 3 3 . 2 = 6 mod 20 = 6 3 . 3 = 9 mod 20 = 9 3 . 4 = 12 mod 20 = 12 3 . 5 = 15 mod 20 = 15 3 . 6 = 18 mod 20 = 18 3 . 7 = 21 mod 20 = 1 (<-- correct) P = 11 3 . 8 = 24 mod 20 = 4 Q=3 3 . 9 = 27 mod 20 = 7 N = 33 Phi = 20 E=3 D=?
  • 124. Math example P = 11 Q=3 N = 33 Phi = 20 E=3 D=7
  • 125. Math example That’s it: P = 11 Q=3 N = 33 Phi = 20 E=3 D=7
  • 126. Math example That’s it: • public key = (n, e) = (33, 3) P = 11 Q=3 N = 33 Phi = 20 E=3 D=7
  • 127. Math example That’s it: • public key = (n, e) = (33, 3) • private key = (n, d) = (33, 7) P = 11 Q=3 N = 33 Phi = 20 E=3 D=7
  • 128. Math example The actual math is much more complex, since we use large, very large numbers, but it all comes down to these (relatively simple) calculations..
  • 129. Encrypting and decrypting Encrypting a message: • c = me mod n Decrypting a message: • m = cd mod n
  • 130. Encrypting and decrypting Encrypting a message (private key = (n,e) = (33, 7): • c = me mod n • message = 10, 20, 15, 5 c = 10^7 mod 33 = 10 c = 20^7 mod 33 = 26 c = 15^7 mod 33 = 27 c = 5^7 mod 33 =14 c = 10, 26, 27, 14 (Note: these are not ascii values or any kind. These are integers!)
  • 131. Encrypting and decrypting Decrypting a message (public key = (n,d) = (33, 3): • m = cd mod n • c = 10, 26, 27, 14 m = 10^3 mod 33 = 10 m = 26^3 mod 33 = 20 m = 27^3 mod 33 = 15 m = 14^3 mod 33 =5 m = 10, 20, 15, 5
  • 132. Encrypting and decrypting We can encrypt all integers ranging from 0 to n:
  • 133. We can encrypt all integers ranging from 0 to n: (c = m7 mod 33) 0 => 0 11 => 11 22 => 22 1 => 1 12 => 12 23 => 23 2 => 29 13 => 7 24 =>18 3 => 9 14 => 20 25 => 31 4 => 16 15 => 27 26 => 5 5 => 14 16 => 25 27 => 3 6 => 30 17 => 8 28 => 19 7 => 28 18 => 6 29 => 17 8 => 2 19 => 13 30 => 24 9 => 15 20 => 26 31 => 4 10 => 10 21 => 21 32 => 32
  • 134. RSA Messages • A message must be between 2 and n-1. • A message is an “int”, not a block of data.
  • 135. PKCS#1 • Public Key Cryptography Standard #1 • Pads data with (random) bytes up to n bits in length
  • 136. PKCS#1 Bob's 1024-bit RSA encryption key in hex format: n= A9E167983F39D55FF2A093415EA6798985C8355D9A915BFB1D01DA197026170F BDA522D035856D7A986614415CCFB7B7083B09C991B81969376DF9651E7BD9A9 3324A37F3BBBAF460186363432CB07035952FC858B3104B8CC18081448E64F1C FB5D60C4E05C1F53D37F53D86901F105F87A70D1BE83C65F38CF1C2CAA6AA7EB e=010001 (65537) d= 67CD484C9A0D8F98C21B65FF22839C6DF0A6061DBCEDA7038894F21C6B0F8B35 DE0E827830CBE7BA6A56AD77C6EB517970790AA0F4FE45E0A9B2F419DA8798D6 308474E4FC596CC1C677DCA991D07C30A0A2C5085E217143FC0D073DF0FA6D14 9E4E63F01758791C4B981C3D3DB01BDFFA253BA3C02C9805F61009D887DB0319 Data =4E636AF98E40F3ADCFCCB698F4E80B9F The encoded message block, EB, after encoding but before encryption, with random padding bytes shown in green, 0002257F48FD1F1793B7E5E02306F2D3228F5C95ADF5F31566729F132AA12009 E3FC9B2B475CD6944EF191E3F59545E671E474B555799FE3756099F044964038 B16B2148E9A2F9C6F44BB5C52E3C6C8061CF694145FAFDB24402AD1819EACEDF 4A36C6E4D2CD8FC1D62E5A1268F496004E636AF98E40F3ADCFCCB698F4E80B9F After RSA encryption, the output is 3D2AB25B1EB667A40F504CC4D778EC399A899C8790EDECEF062CD739492C9CE5 8B92B9ECF32AF4AAC7A61EAEC346449891F49A722378E008EFF0B0A8DBC6E621 EDC90CEC64CF34C640F5B36C48EE9322808AF8F4A0212B28715C76F3CB99AC7E 609787ADCE055839829E0142C44B676D218111FFE69F9D41424E177CBA3A435B http://www.di-mgt.com.au/rsa_alg.html#pkcs1schemes
  • 138. Signing a message • Signing a message means adding a signature that authenticates the validity of a message.
  • 139. Signing a message • Signing a message means adding a signature that authenticates the validity of a message. • Like md5 or sha1, so when the message changes, so should the signature.
  • 140. Signing a message • Signing a message means adding a signature that authenticates the validity of a message. • Like md5 or sha1, so when the message changes, so should the signature. • This works on the premise that Alice and only Alice has the private key that can encrypt the hash.
  • 142. Signing a message • message m
  • 143. Signing a message • message m • Alice gets Bob’s public key
  • 144. Signing a message • message m • Alice gets Bob’s public key • Alice encrypts message m into c
  • 145. Signing a message • message m • Alice gets Bob’s public key • Alice encrypts message m into c • Alice calculates the hash of m (Hm)
  • 146. Signing a message • message m • Alice gets Bob’s public key • Alice encrypts message m into c • Alice calculates the hash of m (Hm) • Alice encrypts the hash with Alice’s private key => c(Hm)
  • 147. Signing a message • message m • Alice gets Bob’s public key • Alice encrypts message m into c • Alice calculates the hash of m (Hm) • Alice encrypts the hash with Alice’s private key => c(Hm) • Alice sends c + c(Hm)
  • 149. Signing a message • Bob receives c + c(Hm)
  • 150. Signing a message • Bob receives c + c(Hm) • Bob decrypts c into m with it’s private key
  • 151. Signing a message • Bob receives c + c(Hm) • Bob decrypts c into m with it’s private key • Bob decrypts c(Hm) into Hm with Alice’s public key
  • 152. Signing a message • Bob receives c + c(Hm) • Bob decrypts c into m with it’s private key • Bob decrypts c(Hm) into Hm with Alice’s public key • Bob checks Hm against hash(m)
  • 153. Signing a message • Bob receives c + c(Hm) • Bob decrypts c into m with it’s private key • Bob decrypts c(Hm) into Hm with Alice’s public key • Bob checks Hm against hash(m) • If equal, we know alice has send the message AND the message content is not tampered with.
  • 154. Implementations of public key algorithms in real life. http://farm4.static.flickr.com/3538/3420164047_09ccc14e29.jpg
  • 155. public key encryption in Web communication (aka: I never use my credit card for internet purchases. It’s not safe. Instead, I give it to the waiter who walks away with it to the kitchen for 5 minutes..)
  • 156. Back in time Welcome to 1991: HTTP is plaintext. Everybody can be trusted. This page is under construction, here’s a photo of my cat and a link to geocities.
  • 158. Nowadays: • Free WiFi everywhere
  • 159. Nowadays: • Free WiFi everywhere • Traffic snooping
  • 160. Nowadays: • Free WiFi everywhere • Traffic snooping • Authorization: Basic? (yes,VERY basic)
  • 161. HTTPS
  • 162. HTTPS • HTTP encapsulated by TLS (previously SSL).
  • 163. HTTPS • HTTP encapsulated by TLS (previously SSL). • More or less: an encryption layer on top of http.
  • 164. HTTPS • HTTP encapsulated by TLS (previously SSL). • More or less: an encryption layer on top of http. • Hybrid encryption.
  • 165. HTTPS
  • 166. HTTPS • Actual encryption methodology is decided by the browser and the server (highest possible encryption used). • Symmetric encryption (AES-256, others) • But both sides needs the same key, so we have the same problem as before: how do we send over the key?
  • 167. HTTPS
  • 168. HTTPS • Key is exchanged in a public/private encrypted communication.
  • 169. HTTPS • Key is exchanged in a public/private encrypted communication. • Which public and private key?
  • 170. HTTPS • Key is exchanged in a public/private encrypted communication. • Which public and private key? • They are stored inside the server’s SSL certificate
  • 171. HTTPS
  • 172. HTTPS • Browser sends over it’s encryption methods.
  • 173. HTTPS • Browser sends over it’s encryption methods. • Server decides which one to use.
  • 174. HTTPS • Browser sends over it’s encryption methods. • Server decides which one to use. • Server send certificate(s).
  • 175. HTTPS • Browser sends over it’s encryption methods. • Server decides which one to use. • Server send certificate(s). • Client sends “session key” encrypted by the public key found in the server certificate.
  • 176. HTTPS • Browser sends over it’s encryption methods. • Server decides which one to use. • Server send certificate(s). • Client sends “session key” encrypted by the public key found in the server certificate. • Server and client uses the “session key” for symmetrical encryption.
  • 177. HTTPS
  • 178. HTTPS • Thus: Public/private encryption is only used in establishing a secondary (better!?)encryption. • SSL/TLS is a separate talk (It’s way more complex as this)
  • 179. HTTPS • Myths about self-signed certificates: • HTTPS traffic is ALWAYS(*) encrypted no matter if the certificate is self-signed or not. • Self-signed certificates are NOT less safe than (expensive) signed certificates. • They are just annoying for end-users.
  • 180. HTTPS • Myths about self-signed certificates: • HTTPS traffic is ALWAYS(*) encrypted no matter if the certificate is self-signed or not. • Self-signed certificates are NOT less safe than (expensive) signed certificates. • They are just annoying for end-users.
  • 181. public key encryption in Email communication (aka: the worst communication method invented when it comes to privacy or secrecy, except for yelling)
  • 182. SMTP sucks but it didn’t matter back then. If you had a beard, you could be trusted. http://farm1.static.flickr.com/179/375718254_31e1d7b5d3.jpg
  • 183. Nowadays, not so much http://torontoemerg.files.wordpress.com/2010/09/spam.gif http://change-your-ip.com/wp-content/uploads/image/nigerian_419_scam.jpg
  • 184. Did you ever get emails like this?
  • 186. Questions: • Did Bill really send this email?
  • 187. Questions: • Did Bill really send this email? • Do we know for sure that nobody has read this email (before it came to us?)
  • 188. Questions: • Did Bill really send this email? • Do we know for sure that nobody has read this email (before it came to us?) • Do we know for sure that the contents of the message isn’t tampered with?
  • 189. We can answer these questions positively if Bill had signed and encrypted his email with a public key encryption (didn’t he got the memo?)
  • 191. Introduction a pretty-good-privacy • GPG / PGP: Lets you create asymmetrical keys for signing and/or encrypting data (or email).
  • 192. Introduction a pretty-good-privacy • GPG / PGP: Lets you create asymmetrical keys for signing and/or encrypting data (or email). • Public keys can be send / found on PGP- servers so you don’t need to send your keys to everybody all the time.
  • 193. Using a public key server
  • 194. Using a public key server
  • 195. But beware: Stupidity trumps everything: Don’t loose your private key(s) (as I did on multiple occasions) http://farm4.static.flickr.com/3231/2783827537_b4d2a5cc9a.jpg
  • 197. Advantages • Everybody can send emails that ONLY YOU can read.
  • 198. Advantages • Everybody can send emails that ONLY YOU can read. • Everybody can verify that YOU have send the email and that it is authentic.
  • 199. Advantages • Everybody can send emails that ONLY YOU can read. • Everybody can verify that YOU have send the email and that it is authentic. • Why is this not the standard? (No really: why isn’t it?)
  • 200. Advantages • Everybody can send emails that ONLY YOU can read. • Everybody can verify that YOU have send the email and that it is authentic. • Why is this not the standard? (No really: why isn’t it?) • Try it yourself with Thunderbird’s Enigmail extension.
  • 201. other fields PGP / GPG (encrypt / decrypt sensitive data) OpenSSH (Secure connection to other systems) IPSEC (VPN tunnels)
  • 203. Thank you And thanks to all creative commons contributors on flickr.com Joshua Thijssen http://www.adayinthelifeof.nl jthijssen@4worx.com Twitter: @jaytaph

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n
  104. \n
  105. \n
  106. \n
  107. \n
  108. \n
  109. \n
  110. \n
  111. \n
  112. \n
  113. \n
  114. \n
  115. \n
  116. \n
  117. \n
  118. \n
  119. \n
  120. \n
  121. \n
  122. \n
  123. \n
  124. \n
  125. \n
  126. \n
  127. \n
  128. \n
  129. \n
  130. \n
  131. \n
  132. \n
  133. \n
  134. \n
  135. \n
  136. \n
  137. \n
  138. \n
  139. \n
  140. \n
  141. \n
  142. \n
  143. \n
  144. \n
  145. \n
  146. \n
  147. \n
  148. \n
  149. \n
  150. \n
  151. \n
  152. \n
  153. \n
  154. \n
  155. \n
  156. \n
  157. \n
  158. \n
  159. \n
  160. \n
  161. \n
  162. \n
  163. \n
  164. \n
  165. \n
  166. \n
  167. \n
  168. \n
  169. \n
  170. \n
  171. \n
  172. \n
  173. \n
  174. \n
  175. \n
  176. \n
  177. \n
  178. \n
  179. \n
  180. \n
  181. \n