Cryptography 101 (with math)

647 views

Published on

Jesse Pollak's talk on Cryptography 101 (with math) at WordCamp Minneapolis

  • Be the first to comment

  • Be the first to like this

Cryptography 101 (with math)

  1. 1. hi y’all, i’m jesse
  2. 2. hi y’all, i’m jesse @jessepollak co-founder at clef
  3. 3. cryptography
  4. 4. cRyPtOgRaPhY
  5. 5. cryptography
  6. 6. goals
  7. 7. goals give you a basic knowledge of what crypto is and how it works.
  8. 8. goals give you a basic knowledge of what crypto is and how it use real, live examples you can understand
  9. 9. goals give you a basic knowledge of what crypto is and how it use real, live examples you can understand help you realize that crypto isn’t scary.
  10. 10. goals give you a basic knowledge of what crypto is and how it works. use real, live examples you can understand help you realize that crypto isn’t scary.
  11. 11. again, i’m jesse @jessepollak co-founder at clef
  12. 12. crypto 101
  13. 13. cryptography the art of writing or solving codes
  14. 14. cryptography the art of writing or solving codes the practice and study of techniques to communicate securely in the presence of third-parties.
  15. 15. cryptography the art of writing or solving codes the practice and study of techniques to communicate securely in the presence of third-parties. how we communicate online without hackers stealing our secrets
  16. 16. core problem
  17. 17. how can two people communicate securely? alicebob
  18. 18. two subproblems
  19. 19. “your message” 1
  20. 20. “fd64$%533#$$1” “your message” 1
  21. 21. “your message” “fd64$%533#$$1” “your message” 1
  22. 22. encryption 1 alicebob
  23. 23. 2 bob
  24. 24. 2 “your message” “fd64$%533#$$1” “your message” bob
  25. 25. 2 alicebob
  26. 26. 2 “your message” bob alice
  27. 27. 2 “your message” “fd64$%533#$$1” bob alice
  28. 28. 2 “your message” “fd64$%533#$$1” bob “fd64$%533#$$1” alice
  29. 29. 2 “your message” “fd64$%533#$$1” “your message” bob “fd64$%533#$$1” ? alice
  30. 30. 2 alicebob key exchange
  31. 31. encryption
  32. 32. I have a message that I want to keep secret
  33. 33. I have an encryption key that only I know
  34. 34. I have an encryption key that only I know
  35. 35. I have an encryption key that only I know
  36. 36. I have an encryption key that only I knowwhat is this thing?
  37. 37. I have an encryption key that only I knowwhat is this thing?
  38. 38. I have an encryption key that only I knowwhat is this thing? “secret message” “secret key”
  39. 39. “the message I want to keep secret”
  40. 40. “the message I want to keep secret” “my secret key”+
  41. 41. “the message I want to keep secret” “my secret key”+
  42. 42. “the message I want to keep secret” “my secret key”+ “dkjf8#654&(@)(5335jJkdfd8(%&jfdc”=
  43. 43. “the message I want to keep secret” “my secret key”+ “the message I want to keep secret”= encrypted
  44. 44. “the message I want to keep secret” “my secret key”+ “dkjf8#654&(@)(5335jJkdfd8(%&jfdc”=
  45. 45. “dkjf8#654&(@)(5335jJkdfd8(%&jfdc” “my secret key”+
  46. 46. “dkjf8#654&(@)(5335jJkdfd8(%&jfdc” “my secret key”+
  47. 47. “dkjf8#654&(@)(5335jJkdfd8(%&jfdc” “my secret key”+ “the message I want to keep secret”=
  48. 48. “the message I want to keep secret” “my secret key”+ decrypted “the message I want to keep secret”=
  49. 49. “dkjf8#654&(@)(5335jJkdfd8(%&jfdc” “my secret key”+ “the message I want to keep secret”= “the message I want to keep secret” “my secret key”+
  50. 50. “dkjf8#654&(@)(5335jJkdfd8(%&jfdc” “my secret key”+ “the message I want to keep secret”= “the message I want to keep secret” “my secret key”+
  51. 51. encryption decryption
  52. 52. encryption…? decryption…?
  53. 53. how does encryption actually work?
  54. 54. how does encryption actually work? how does data actually work?
  55. 55. how does encryption actually work? “secret”
  56. 56. how does encryption actually work? “secret” s e c r e t
  57. 57. how does encryption actually work? “secret” s e c r e t 01110011 01100101 01100011 01110010 01100101 01110100
  58. 58. how does encryption actually work? “secret” s e c r e t 01110011 01100101 01100011 01110010 01100101 01110100 bit
  59. 59. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t
  60. 60. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t encryption
  61. 61. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 00000001 00000100 00001101 00010110 00001010 00011001
  62. 62. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 00000001 00000100 00001101 00010110 00001010 00011001 % ! ( 5 q 6
  63. 63. how does encryption actually work? encryption means turning 1s and 0s into other 1s and 0s that are random
  64. 64. so, how does encryption actually work?
  65. 65. how does encryption actually work? xor
  66. 66. how does encryption actually work? xor two bits in, one bit out
  67. 67. how does encryption actually work? 0 xor 1 = 1 0 xor 0 = 0 1 xor 1 = 0 1 xor 0 = 1
  68. 68. how does encryption actually work? 1 if two bits are different 0 if two bits are the same
  69. 69. so, how does encryption actually work?
  70. 70. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t
  71. 71. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 r a n d o m
  72. 72. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 xor
  73. 73. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 0
  74. 74. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 00
  75. 75. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 000
  76. 76. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 0000
  77. 77. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 00000
  78. 78. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 000000
  79. 79. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 0000000
  80. 80. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 00000001
  81. 81. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 00000001 00000100 00001101 00010110 00001010 00011001
  82. 82. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 % ! ( 5 q 6 00000001 00000100 00001101 00010110 00001010 00011001
  83. 83. how does encryption actually work? encryption!
  84. 84. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 00000001 00000100 00001101 00010110 00001010 00011001 % ! ( 5 q 6
  85. 85. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 00000001 00000100 00001101 00010110 00001010 00011001 01110010 01100001 01101110 01100100 01101111 01101101 r a n d o m
  86. 86. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 00000001 00000100 00001101 00010110 00001010 00011001 01110010 01100001 01101110 01100100 01101111 01101101 xor
  87. 87. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 00000001 00000100 00001101 00010110 00001010 00011001 01110010 01100001 01101110 01100100 01101111 01101101 0
  88. 88. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 00000001 00000100 00001101 00010110 00001010 00011001 01110010 01100001 01101110 01100100 01101111 01101101 01
  89. 89. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 00000001 00000100 00001101 00010110 00001010 00011001 01110010 01100001 01101110 01100100 01101111 01101101 011
  90. 90. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 00000001 00000100 00001101 00010110 00001010 00011001 01110010 01100001 01101110 01100100 01101111 01101101 0111
  91. 91. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 00000001 00000100 00001101 00010110 00001010 00011001 01110010 01100001 01101110 01100100 01101111 01101101 01110
  92. 92. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 00000001 00000100 00001101 00010110 00001010 00011001 01110010 01100001 01101110 01100100 01101111 01101101 011100
  93. 93. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 00000001 00000100 00001101 00010110 00001010 00011001 01110010 01100001 01101110 01100100 01101111 01101101 0111001
  94. 94. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 00000001 00000100 00001101 00010110 00001010 00011001 01110010 01100001 01101110 01100100 01101111 01101101 01110011
  95. 95. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 00000001 00000100 00001101 00010110 00001010 00011001 01110010 01100001 01101110 01100100 01101111 01101101 01110011 01100101 01100011 01110010 01100101 01110100
  96. 96. how does encryption actually work? 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 01110010 01100001 01101110 01100100 01101111 01101101 00000001 00000100 00001101 00010110 00001010 00011001 01110010 01100001 01101110 01100100 01101111 01101101 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t
  97. 97. how does encryption actually work? decryption!
  98. 98. how does encryption actually work? why does this work?
  99. 99. how does encryption actually work? 0 xor 1 1
  100. 100. how does encryption actually work? impossible to know whether 1 or 0 came from the key or the secret message
  101. 101. how does encryption actually work? 0 xor 1 1 ? ?
  102. 102. how does encryption actually work? to encrypt a message, we xor it with a secret key
  103. 103. caveat how does encryption actually work? this is very simplified
  104. 104. encryption 1 alicebob
  105. 105. 2 alicebob key exchange
  106. 106. key exchange
  107. 107. alicebob how we get the same encryption key
  108. 108. alicebob how we get the same encryption key without me finding out
  109. 109. alicebob how we get the same encryption key without me finding out or me
  110. 110. alicebob how we get the same encryption key without me finding out or meor me
  111. 111. alicebob how we get the same encryption key without me finding out or meor me
  112. 112. alicebob how we get the same encryption key without me finding out or meor me all communication is public
  113. 113. problem how do two people share an encryption key when they can’t communicate privately.
  114. 114. solution diffie-hellman!
  115. 115. solution diffie-hellman…?
  116. 116. solution math!
  117. 117. solution math…?
  118. 118. solution colors
  119. 119. solution colors!
  120. 120. diffie-hellman key exchange
  121. 121. diffie-hellman key exchange with no math and lots of colors!
  122. 122. imagine that we have an infinite number of colors
  123. 123. imagine that we have an infinite number of colors
  124. 124. imagine that we have an infinite number of colors
  125. 125. imagine that we have an infinite number of colors
  126. 126. imagine that we have an infinite number of colors
  127. 127. imagine that we have an infinite number of colors
  128. 128. imagine that we have an infinite number of colors
  129. 129. imagine that we have an infinite number of colors
  130. 130. imagine that we have an infinite number of colors
  131. 131. imagine that we have an infinite number of colors
  132. 132. some rules
  133. 133. some rules easy to mix two colors to get a third
  134. 134. some rules + easy to mix two colors to get a third
  135. 135. some rules + easy to mix two colors to get a third =
  136. 136. some rules + easy to mix two colors to get a third = impossible to figure out mixed colors
  137. 137. some rules + easy to mix two colors to get a third = impossible to figure out mixed colors =
  138. 138. some rules + easy to mix two colors to get a third = impossible to figure out mixed colors = +
  139. 139. some rules + easy to mix two colors to get a third = impossible to figure out mixed colors = + ?
  140. 140. some rules + easy to mix two colors to get a third = impossible to figure out mixed colors = + ?
  141. 141. bob hi
  142. 142. alicebob hi hey
  143. 143. alicebob
  144. 144. alicebob
  145. 145. alicebob
  146. 146. alicebob
  147. 147. alicebob
  148. 148. alicebob
  149. 149. alicebob
  150. 150. alicebob
  151. 151. alicebob “I NEED TO TELL YOU A SECRET!”
  152. 152. alicebob “I NEED TO TELL YOU A SECRET!” “LET’S DO A KEY EXCHANGE!”
  153. 153. alicebob bob’s knowledge alice’s knowledge everyone’s knowledge
  154. 154. alicebob bob’s knowledge alice’s knowledge everyone’s knowledge bob and alice agree on a random color publicly
  155. 155. alicebob bob’s knowledge alice’s knowledge everyone’s knowledge
  156. 156. alicebob bob’s knowledge alice’s knowledge everyone’s knowledge bob chooses a color and tells no one
  157. 157. alicebob bob’s knowledge alice’s knowledge everyone’s knowledge alice chooses a color and tells no one
  158. 158. alicebob bob’s knowledge alice’s knowledge everyone’s knowledge bob mixes his secret color with the public color and send the combination to alice
  159. 159. alicebob bob’s knowledge alice’s knowledge everyone’s knowledge
  160. 160. alicebob bob’s knowledge alice’s knowledge everyone’s knowledge alice mixes her secret color with the public color and send the combination to bob
  161. 161. alicebob bob’s knowledge alice’s knowledge everyone’s knowledge
  162. 162. alicebob bob’s knowledge alice’s knowledge everyone’s knowledge bob and alice mix their secret colors with their partner’s blend to get a new secret color
  163. 163. alicebob bob’s knowledge alice’s knowledge everyone’s knowledge secret message
  164. 164. everyone else secret
  165. 165. + = secret everyone else wrong
  166. 166. + = secret wrong + = wrong everyone else
  167. 167. + = secret wrong + = wrong + = wrong everyone else
  168. 168. alicebob bob’s knowledge alice’s knowledge everyone’s knowledge secret message
  169. 169. 2 alicebob key exchange
  170. 170. combination
  171. 171. 2 alicebob key exchange
  172. 172. diffie-hellman key exchange with no math and lots of colors!
  173. 173. diffie-hellman key exchange with a little math and no colors
  174. 174. some rules
  175. 175. alicebob bob’s knowledge alice’s knowledge everyone’s knowledge bob and alice agree on a random number 5
  176. 176. alicebob bob’s knowledge alice’s knowledge everyone’s knowledge 5 5 5
  177. 177. alicebob bob’s knowledge alice’s knowledge everyone’s knowledge 5 5 5 bob chooses a prime number and tells no one 7
  178. 178. alicebob bob’s knowledge alice’s knowledge everyone’s knowledge 5 5 5 alice chooses a prime number and tells no one 7 3
  179. 179. alicebob bob’s knowledge alice’s knowledge everyone’s knowledge 5 5 5 7 3 bob “mixes” his secret number with the public number and shares the result with alice 5 7
  180. 180. alicebob bob’s knowledge alice’s knowledge everyone’s knowledge 5 5 5 7 3 bob “mixes” his secret number with the public number and shares the result with alice 5 7 7
  181. 181. alicebob bob’s knowledge alice’s knowledge everyone’s knowledge 5 5 5 7 3 alice “mixes” her secret number with the public number and shares the result with bob 5 7 7 5 3
  182. 182. alicebob bob’s knowledge alice’s knowledge everyone’s knowledge 5 5 7 3 5 7 7 5 3 5 3
  183. 183. bob’s knowledge alice’s knowledge everyone’s knowledge 5 5 7 (5 ) 3 5 3 bob and alice mix their secret numbers with their partner’s mix to get a new secret number 7 (5 ) 7 3
  184. 184. bob’s knowledge alice’s knowledge everyone’s knowledge 5 5 7 5 (3 * 7) 5 3 5 (3 * 7)
  185. 185. bob’s knowledge alice’s knowledge everyone’s knowledge 5 5 7 5 21 5 3 5 21
  186. 186. everyone else secret 5 21 5 5 7 5 3
  187. 187. everyone else secret 5 21 5 5 7 5 3 • 5 = 25
  188. 188. everyone else secret 5 21 5 5 7 5 3 • 5 = 25 • 5 = 5 8
  189. 189. everyone else secret 5 21 5 5 7 5 3 • 5 = 25 • 5 = 5 8 • = 55 7 10
  190. 190. everyone else secret 5 21 5 5 7 5 3 • 5 = 25 • 5 = 5 8 • = 55 7 10
  191. 191. bob’s knowledge alice’s knowledge everyone’s knowledge 5 5 7 5 21 5 3 5 21
  192. 192. encryption 1 alicebob
  193. 193. “secret”
  194. 194. “secret” s e c r e t
  195. 195. “secret” s e c r e t 01110011 01100101 01100011 01110010 01100101 01110100
  196. 196. 5 21
  197. 197. 5 21 476837158203125
  198. 198. 5 21 476837158203125 11011000 11010111 00100110 10110111 00010111 01111010 1
  199. 199. 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t bob
  200. 200. 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 11011000 11010111 00100110 10110111 00010111 01111010 1 5 bob 21
  201. 201. 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 11011000 11010111 00100110 10110111 00010111 01111010 1 bob
  202. 202. 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 11011000 11010111 00100110 10110111 00010111 01111010
  203. 203. 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t xor 11011000 11010111 00100110 10110111 00010111 01111010 bob
  204. 204. 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 1 11011000 11010111 00100110 10110111 00010111 01111010 bob
  205. 205. 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 10 11011000 11010111 00100110 10110111 00010111 01111010 bob
  206. 206. 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 101 11011000 11010111 00100110 10110111 00010111 01111010 bob
  207. 207. 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 1010 11011000 11010111 00100110 10110111 00010111 01111010 bob
  208. 208. 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 10101 11011000 11010111 00100110 10110111 00010111 01111010 bob
  209. 209. 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 101010 11011000 11010111 00100110 10110111 00010111 01111010 bob
  210. 210. 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 1010101 11011000 11010111 00100110 10110111 00010111 01111010 bob
  211. 211. 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 10101011 11011000 11010111 00100110 10110111 00010111 01111010 bob
  212. 212. 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 10101011 11011000 11010111 00100110 10110111 00010111 01111010 bob
  213. 213. 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t 10101011 10110010 01000101 11000101 01110010 00001010 11011000 11010111 00100110 10110111 00010111 01111010 bob
  214. 214. encryption!
  215. 215. alicebob 10101011 10110010 01000101 11000101 01110010 00001010
  216. 216. 10101011 10110010 01000101 11000101 01110010 00001010 alice
  217. 217. 10101011 10110010 01000101 11000101 01110010 00001010 alice 11011000 11010111 00100110 10110111 00010111 01111010 5 21
  218. 218. 10101011 10110010 01000101 11000101 01110010 00001010 alice 11011000 11010111 00100110 10110111 00010111 01111010 xor
  219. 219. 10101011 10110010 01000101 11000101 01110010 00001010 alice 11011000 11010111 00100110 10110111 00010111 01111010 01110011 01100101 01100011 01110010 01100101 01110100 s e c r e t
  220. 220. decryption!
  221. 221. alicebob
  222. 222. alicebob we did it!

×