lect20
lect20
Cryptography
1
Cryptography
Crypto + graphy = secret + writing
• to make information secret, use a cipher, an algorithm that converts
plain text to ciphertext, which is gibberish unless you have a key that
undo the cipher.
• encryption: the process of making text secret
• decryption: the reverse process, unscrambling gibberish text to
plaintext
Julius Caesar uses a Caesar cipher; he shifts all of the letters forward by
three.
• A becomes D and “brutus” becomes “euxwxv”.
• to decipher, you need both the algorithm and the shift number, which
acts as the key. In this case, the key is 3.
• The Caesar cipher uses 26 keys and is easy to break.
2
Substitution Cipher
Caesar cipher is an example of a larger class of ciphers called substitution
cipher.
• every letter is replaced by a different letter.
• one drawback of basic substitution cipher is letter frequency is preserved.
• the letter e is the most common letter in English. If cipher translates e to x, then x
would be the most common letter in ciphertext.
• it was the breaking of a substitution cipher that led to the execution of Mary,
Queen of Scots, in 1587, for plotting to kill Queen Elizabeth.
3
Enigma(optional)
In the 1900s, cryptography was performed using machines.
The German Enigma was an example of one such machine. It encrypt wartime
communication.
The Enigma was a typewriter-like machine with a keyboard with the full alphabet
and configurable rotors that were the key to the encryption.
4
5
The Enigma(optional)
To prevent it from being simple substitution cipher, after every letter, the
rotor rotate by one, changing both the cipher and key.
• For example “AAA” might be encoded as “BDK”
Back in 1977, no one has the computing power to brute force that many keys.
7
AES(optional)
In 2001, Advanced Encryption Standard(AES) was published
• uses up to 256 bits, brute force is virtually impossible.
• For example, even with 128 bits, if you use every computer on the planet, it’ll take trillion of
years to try every combination of keys. With 256 bits, it would take up about the age of the
universe to crack.
AES chops data into 16-byte chunks, perform a series of permutations and
substitutions and other operations to obscure the message, then repeat 10 or
more times.
• No fancy math, unlike the other popular alternative, RSA.
8
Symmetric Encryption
Cryptographic techniques so far rely on keys known by both sender and receiver. The
sender encrypt message with a key and the receiver decrypt it with the same key.
Symmetric encryption: encryption technique that uses the same key for both
encryption and decryption.
• For example, in the Caesar cipher, if encryption is shifting right by 3 letters, decryption
is shifting left by 3 letters. Both uses the key = 3. Thus the Caesar cipher is a
symmetric encryption technique.
In the old days, keys are shared physically or by voice.
• Germans use codebooks with daily settings for Enigma machines.
9
Key Exchange(optional)
Solution is to use key exchange.
10
Key Exchange(optional)
Alice and Bob want to establish a shared secret key for encryption/decryption.
Each starts with a secret color.
Eve is listening.
(Eve for "eavesdrops")
1. Bob’s
1. Alice’s secret
secret color
color
11
Key Exchange(optional)
Eve is listening.
1. Alice’s 1. Bob’s
secret secret
color color
2. Mix in
2. Mix in
public
public
color
color
12
Key Exchange(optional)
Eve is listening.
1. Bob’s
1. Alice’s
secret
secret
color
color
2. Mix in
2. Mix in public
public color
color
3. Send 3. Send
to Bob to Alice
13
Key Exchange(optional)
Eve is listening.
1. Bob’s
1. Alice’s
secret
secret
color
color
2. Mix in
2. Mix in public
public color
color
3. Send 3. Send
to Bob to Alice
4. Mix in 4. Mix in
secret secret
color color
Each then adds in his/her secret color to obtain a shared secret color(key).
The key is then used for symmetric encryption.
14
Diffie-Helman(optional)
Diffie-Helman key exchange uses modular exponentiation as its one-way
function.
15
Diffie-Helman (optional)
Modular exponentiation is a one-way function because it is easy to raise a
power but hard to invert.
For example, it is easy to compute 3^5=26 mod 31.(One line of Python code.) But
it’s hard to find x such that 3^x=26 mod 31 if the base and modulo are very large
integers(hundreds of digits long).
• This is called the discrete logarithm problem.
The base that is used for the modulo is a large prime(hundreds of digits long).
Solve this:
298742039473927847494324^x = 7646787876034389839493034 mod
85620542843242379862561534532898765235
Diffie-Helman is an algorithm that uses this one-way function of modular
exponentiation to do key exchange. The process is similar to the painting example
earlier. 16
Diffie-Helman Key Exchange (optional)
Eve is listening.
Public:
Base B 1. Bob’s
1. Alice’s Secret Secret
Modulo M secret
secret Exponent Exponent
exponent
exponent X Y
3. Send 3. Send
B^Y mod M B^X mod M
to Bob to Alice
4. Compute 4. Compute
(B^Y)^X mod M) (B^X)^Y mod M)
B^{XY} mod M B^{XY} mod M
<latexit sha1_base64="ZuC19/d2dLPnkoHxPNJTdSc65k8=">AAAB6HicdZDNSgMxFIXv1L9a/6ou3QSL4GrI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VYYTTcamTappgMsR92rZUYkF1kE2TjtGBVXooipUtadBUnZ/IsNB6JELbKbAZ6J9eLv7ltVMTnQQZk0lqqCSzRVHKkYlRfjbqMUWJ4SNLMFHMZkVkgBUmxj6nNP+E/4l/VD2tupdepX4MMxRhD/bhEDyoQR0uoAE+EIjgDh7g0Rk6986TM5m1FpzPmV34BuflA3rWkUg=</latexit>
sha1_base64="YOry+Flwf9K65SsBXK++daSf86o=">AAAB6HicdVDLSgNBEOyNrxhfUY9eBoPgKeyKED0Z8OIximsCyRJmJ73JkNnZZWZWCCF/4MWDSm7iX/gb3vwbJ4lCfBU0FFXddHWHqeDauO67k1tYXFpeya8W1tY3NreK2zs3OskUQ58lIlGNkGoUXKJvuBHYSBXSOBRYD/vnE79+i0rzRF6bQYpBTLuSR5xRY6Urr9IulryyOwVxf5Evq3T2Oh4/A0CtXXxrdRKWxSgNE1TrpuemJhhSZTgTOCq0Mo0pZX3axaalksaog+E06YgcWKVDokTZkoZM1fmJIY21HsSh7Yyp6emf3kT8y2tmJjoJhlymmUHJZouiTBCTkMnZpMMVMiMGllCmuM1KWI8qyox9TmH+Cf8T/6h8WnYvvVL1GGbIwx7swyF4UIEqXEANfGAQwR08wKPTd+6dJ2c8a805nzO78A3OywcfXo+D</latexit>
2. Compute
3. Send 3. Send
to Bob to Alice
4. Compute 4. Compute
15 13
12
<latexit sha1_base64="7lG64OqRns/P7krPrmElVgasE9E=">AAAB8HicbZDNSgMxFIXv1L9a/6ou3QSL4KpMiqIuxIIblxUcW2zHkkkzbWgmMyQZoQx9CzcVVNz6Br6GO9/GtHWhrQcCH+fcS+69QSK4Nq775eQWFpeWV/KrhbX1jc2t4vbOrY5TRZlHYxGrRkA0E1wyz3AjWCNRjESBYPWgfznO6w9MaR7LGzNImB+RruQhp8RY6w5X7jN8PDzHbrtYcsvuRGge8A+ULj5GYz3V2sXPViemacSkoYJo3cRuYvyMKMOpYMNCK9UsIbRPuqxpUZKIaT+bTDxEB9bpoDBW9kmDJu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h/5Hz8AHlXkUc=</latexit>
sha1_base64="8ksD8kqs6k01epykCmnbec85v2I=">AAAB6HicbZDLSgMxFIbP1Futt6pLN8EiuCozIlRXFty4rOLYQjuUTHqmDc1khiQjlNI3cONCpTvxLXwNd76N6WWhrT8EPv7/HHLOCVPBtXHdbye3srq2vpHfLGxt7+zuFfcPHnSSKYY+S0SiGiHVKLhE33AjsJEqpHEosB72ryd5/RGV5om8N4MUg5h2JY84o8Zad16lXSy5ZXcqsgzeHEpXn+PxOwDU2sWvVidhWYzSMEG1bnpuaoIhVYYzgaNCK9OYUtanXWxalDRGHQynk47IiXU6JEqUfdKQqfu7Y0hjrQdxaCtjanp6MZuY/2XNzEQXwZDLNDMo2eyjKBPEJGSyNulwhcyIgQXKFLezEtajijJjj1OwR/AWV14G/6x8WXZvvVL1HGbKwxEcwyl4UIEq3EANfGAQwRO8wKvTd56dN2c8K805855D+CPn4wcd34+C</latexit>
6
<latexit sha1_base64="Js26AUGbtFGjC+3mdYkSuxqmbzk=">AAAB73icbZDLSgMxFIbPeK31VnXpJlgEV2VGxctCLLhxWcGxlXYsmTTThiaZIckIZehTuFFRcesj+BrufBvTy0Jbfwh8/P855JwTJpxp47rfzszs3PzCYm4pv7yyurZe2Ni80XGqCPVJzGNVC7GmnEnqG2Y4rSWKYhFyWg27F4O8ek+VZrG8Nr2EBgK3JYsYwcZat0d3mXfQP/PcZqHoltyh0DR4Yyiefz4N9FxpFr4arZikgkpDONa67rmJCTKsDCOc9vONVNMEky5u07pFiQXVQTYcuI92rdNCUazskwYN3d8dGRZa90RoKwU2HT2ZDcz/snpqopMgYzJJDZVk9FGUcmRiNNgetZiixPCeBUwUs7Mi0sEKE2NvlLdH8CZXngZ/v3Racq+8YvkQRsrBNuzAHnhwDGW4hAr4QEDAA7zAq6OcR+fNeR+Vzjjjni34I+fjB8ZIk7M=</latexit>
sha1_base64="7zPBBouY6GtF8tV5Q0+OeVuFX9M=">AAAB73icbZDLSgMxFIbP1Futt6pLN8Eiu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o8Zad16lXSy5ZXcqsgzeHEpXn+PxOwDU2sWvVidhWYzSMEG1bnpuaoIhVYYzgaNCK9OYUtanXWxalDRGHQynk47IiXU6JEqUfdKQqfu7Y0hjrQdxaCtjanp6MZuY/2XNzEQXwZDLNDMo2eyjKBPEJGSyNulwhcyIgQXKFLezEtajijJjj1OwR/AWV14G/6x8WXZvvVL1HGbKwxEcwyl4UIEq3EANfGAQwRO8wKvTd56dN2c8K805855D+CPn4wcd34+C</latexit>
Thus, the secret shared key is 10. For example, key = 10 can be used in the
Caesar cipher by shifting/unshifting by 10
18
Diffie-Helman (optional)
One shortcoming of the Diffie-Helman key exchange is that it uses
communication overhead to established a shared key.
• Alice and Bob sends back and forth different results of their calculations.
19
Asymmetric Encryption
James Ellis, a British Engineer, was working on a non-secret encryption in 1977.His
idea is clever yet simple: lock and unlock are inverses. Use this as a one-way
function!
• Easy to lock, but hard to unlock.
Someone can encrypt a message with the public key but only the recipient with
their private key can decrypt.
• the public key is use for encryption, the private key for decryption.
• the reverse is also useful, private key to encrypt and and public key to decrypt(see
digital signatures later in these slides)
The most famous example of asymmetric encryption is RSA named after their inventors
Rivest, Shamir and Adleman.The math behind RSA is beyond scope of the class. There’s an
20
optional video that you can watch at the end of the slides.
Alice has a private key and a lockbox(public key).
She wishes to receive an encrypted message from Bob.
Alice sends Bob the lockbox(public key).
21
Bob put his message inside the lockbox.
Lock it(one-way function, easy to lock)
Sends it back.
22
Alice can open it with her private key and receives the message. (even if the
lockbox is intercepted, it cannot be opened without the private key)
If Alice is a bank, she can duplicates the lockbox(public key) and sends them to
everyone she wishes to receive encrypted messages.
She only has to manage one private key.
23
Digital Signatures
A public digital key can encrypt something that can only be decrypted by a private
digital key.
The reverse is also possible: encrypting with the private key something that can be
decrypted with a public key.
• Use for digital signatures
• Server encrypts data with private key.
• Anyone can decrypt it using the server’s public key.
• This acts as an unforgeable signature that only the owner, using the private key, can encrypt.
• This proves that you’re getting data from the right server/website, not an imposter.
• This is how your browser knows that you are at the correct bankamerica.com and not a fake bank of
America website. The brower knows Bank of America’s public key and can verify. If it’s successful, it
gives you the green padlock confirmation.
Since data(file, images, audio, video) can be encoded into a string of 0's and 1's, a hash function
is simply a function f(x) which accepts a string input of any length and returns a fixed-length
string output. Here's an implementation of such a hash function using the popular SHA256
algorithm(outputs 256-bit strings):
import hashlib
def hash(mystring):
hash_object= hashlib.sha256(mystring.encode())
return hash_object.hexdigest()
print(hash("hello")) a small change to a message should change
print(hash("Hello")) the hash value extensively
Output:
'2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'
'185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969'
25
Properties of Hash Functions(optional)
The ideal cryptographic hash function has the following main properties:
• it is deterministic meaning that the same message always results in the same
hash
• it is quick to compute the hash value for any given message
• it is infeasible to generate a message that yields a given hash value i.e. to
reverse the process that generated the given hash value. This problem is hard to
solve:
Given
y = 'e3824dba5fb0a30e26e8352ac5b9e29e1b161e5c1fa7425e73043362938b9829'
It is hard to find x so that hash(x) = y.
• it is infeasible to find two different messages with the same hash value
• a small change to a message should change the hash value so extensively that a
new hash value appears uncorrelated with the old hash value
26
Digital Signature
When a signer electronically signs a document, the signature is created using the
signer’s private key, which is always securely kept by the signer.
The mathematical algorithm acts like a cipher, creating data matching the signed
document using the hash function and encrypting that data.
The resulting encrypted data is the digital signature. The signature is also marked
with the time that the document was signed.
If the document changes after signing, the digital signature is invalidated. The
image in the next slide explains this process.
27
Digital Signatures Attach the encrypted
Hash the document Encrypt the hash value hash value to document.
to get hash value. using private key.
28
How HTTPS Work
The “key” parts of modern cryptography:
• symmetric encryption
• key exchange
• public-key cryptography
When you connect to a secure website, such as Facebook, using HTTPS that has the
green padlock, you know that cryptography was used to encrypt data.
When information is sent over regular HTTP, the information is broken into packets of
data that can be easily “sniffed” using free software. This makes communication over
the an unsecure medium, such as public Wi-Fi, highly vulnerable to interception.
In fact, all communications that occur over HTTP occur in plain text, making them
highly accessible to anyone with the correct tools, and vulnerable to on-path attacks.
Technically speaking, HTTPS is not a separate protocol from HTTP. It is simply using
TLS/SSL encryption over the HTTP protocol. 29
How HTTPS Work
Here's how HTTPS work:
cryptocurrency:
• decentralized currency
• Bitcoin was the first, established in 2009. Since then, other coins have been established, called
altcoins.
• Bitcoin was invented by Satoshi Nakamoto.(Even today, no one knows who he is.)
• Uses public-key cryptography to make, secure transactions, verify ownerships, etc...
• Security is guaranteed by a concept known as "proof of work". Bitcoin miners are rewarded
with bitcoins for this proof of work.
• Uses advanced math(elliptic curves) to do encryption.
34