CS 150 – Computing: From Ada to the Web
-
Upload
dai-herring -
Category
Documents
-
view
67 -
download
0
description
Transcript of CS 150 – Computing: From Ada to the Web
![Page 1: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/1.jpg)
CS 150 – Computing: From Ada to the Web
Cryptography
![Page 2: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/2.jpg)
Protecting Information
• Frame message– Indicates what the message is
• Outer message– Tells how to interpret the message
• Inner message– The content of the message
• How do we protect the message from eavesdropping?
![Page 3: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/3.jpg)
At War
• The earliest need for encryption came from war.
• Sending orders by carrier that could be captured was dangerous at best.
• Need to protect the message!• (Another early use: the Kama Sutra describes
it as a way to have an affair without “inconvenient discovery.”)
![Page 4: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/4.jpg)
The Caesar Cipher
• The network: The Roman roads• The message: Orders to Roman troops• Also known as a Rotation Cipher, you simply
replace a letter with another letter that is a certain number of letters away.
• Technically, a Caesar Cipher is a Rotation Cipher where n = 3.
• Popularly, you can find this cipher today as a simple “decoder ring.”
![Page 5: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/5.jpg)
Rotation Cipher
ABCDEFGHIJKLMNOPQRSTUVWXYZ
JIDKQACRSHLGWNFEXUZVTPMYOB
encrypt decr
ypt
CS DZ
![Page 6: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/6.jpg)
Worked okay for 44BC, but…
• Language is not random!• Random strings: the probability of two letters
in the two messages matching is 1/26 (number of letters in alphabet)
• Same-encrypted strings: the output letters will match when the input letters match– This happens much more frequently because
some letters (e.g., “e” is ~13% of all letters) are more common
![Page 7: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/7.jpg)
Vigenere Cipher
• Blaise de Vigenère in the 19th century• Used during the Confederacy during the Civil
War• Keyword rotational cipher• Plaintext: ATTACKATDAWN• Key: LEMONLEMONLE• Ciphertext: LXFOPVEFRNHR
![Page 8: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/8.jpg)
Enigma• Invented commercially, 1923• German Navy, Army, Air Force• About 50,000 in use (many were
captured by Allies)• Modified throughout WWII, Germans
believed perfectly secure• Kahn’s Codebreakers (1967) didn’t
know it was broken• Turing’s 1940 Treatise on Enigma
declassified in 1996
Enigma machine at Bletchley Park
![Page 9: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/9.jpg)
Rotor WheelsSimplesubstitution
Latch turns next rotor once per rotation
![Page 10: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/10.jpg)
Imag
e fro
mht
tp://
en.w
ikip
edia
.org
/wik
i/Im
age:
Enig
ma-
actio
n.pn
g
![Page 11: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/11.jpg)
Enigma’s Rotating Substitutions
ABCDEFGHIJKLMNOPQRSTUVWXYZ
JIDKQACRSHLGWNFEXUZVTPMYOB
SQHLZNYKXUWVJRDFBETIMOGACP
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Whe
el 1
: Ro
tate
one
po
sitio
n ev
ery
lette
r
Whe
el 2
: Ro
tate
one
po
sitio
n ev
ery
26 le
tters
ABCDEFGHIJKLMNOPQRSTUVWXYZUAVGRDCBESYHLZOQKXTIMNJWFP
Whe
el 3
: Ro
tate
one
po
sitio
n wh
en
whee
l 2 c
ycle
s
![Page 12: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/12.jpg)
Enigma’s Problems
• Each day, a new set of initial settings were used…– …and these were stored in a book that was stolen.
• Each network had a different setup for the machine…– …which was also stolen.
• For each message, a random set of three characters would be used to decipher the text…– …but people were lazy and used the same letters and
also repeated them at the beginning of the message
![Page 13: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/13.jpg)
The best thing about bad encryption?
• We won WWII.• D-Day would not have happened without the
cracking of the Enigma.
![Page 14: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/14.jpg)
Modern Ciphers
• RSA – popular public key cryptographic algorithm
• Found in common products• Not “perfect,” but “good enough” if the key is
long enough• Each entity needs a public and private key
![Page 15: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/15.jpg)
RSA Key Generation• Choose two distinct large random prime numbers p and q• Compute n = pq
– n is used as the modulus for both the public and private keys• Compute the totient: φ(n) = (p − 1)(q − 1).• Choose an integer e such that 1 < e < φ(n), and e and φ(n)
share no factors other than 1 (i.e. e and φ(n) are coprime)– e is released as the public key exponent – 2^16 + 1 = 65537 is a
popular choice• Compute d such that d*e = 1 + kφ(n) for some integer k.
– d is kept as the private key exponent• Public key = (n, e)
![Page 16: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/16.jpg)
Encrypting and Decrypting
• Encrypt: c = m^e mod n• Decrypt: m = c^d mod n
![Page 17: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/17.jpg)
Example• Choose two prime numbers
– p = 61 and q = 53
• Compute n = p q– n = 61 * 53 = 3233
• Compute φ (n) = (p-1)(q-1) – φ(n) = (61 - 1)(53 - 1) = 3120
• Choose e > 1 coprime to 3120– e = 17
• Compute d, such that d*e = 1 + kφ(n) – d = 2753– 17 * 2753 = 46801 = 1 + 15 * 3120.
![Page 18: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/18.jpg)
Example• The public key is (n = 3233, e = 17). For a message m, the
encryption function is:– c = m^e mod n= m^{17} mod {3233}.
• The private key is (n = 3233, d = 2753). The decryption function is:– m = c^d mod n = c^{2753} mod {3233}.
• For example, to encrypt m = 123, we calculate– c = 123^{17} mod {3233} = 855.
• To decrypt c = 855, we calculate– m = 855^{2753} mod {3233} = 123.
![Page 19: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/19.jpg)
Key Exchange
• Alice comes up with a key– She puts the key in a box and locks it with her padlock
• Alice sends the box to Bob– Bob can’t get in the box, but he adds his padlock to
the box• Bob sends the box back to Alice– Alice removes her padlock
• Alice sends the box one more time to Bob– Bob removes his padlock and gets the key
![Page 20: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/20.jpg)
Key Exchange
• PGP– Pretty Good Privacy– Usually used for email– Uses RSA (sometimes)
• X.509– Server certificate keys– Can generate your own, or get one from a
certificate authority
![Page 21: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/21.jpg)
Point-to-point security
• Using this type of exchange provides point-to-point security for traffic
• But what if the other end doesn’t support any encryption?
• http://gmail.com vs https://gmail.com• Both are valid – one is encrypted!
![Page 22: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/22.jpg)
Tunneling
• If you don’t trust the network you’re on (such as open wireless or hotspot) tunneling might be a good option.
• Create a secure connection through which all traffic passes through.
• SSH and VPN use this concept.• You connect to a computer and network you
do trust and then release your traffic.
![Page 23: CS 150 – Computing: From Ada to the Web](https://reader035.fdocuments.in/reader035/viewer/2022070502/56813046550346895d95eba4/html5/thumbnails/23.jpg)
SSH and VPN
• SSH is a secure shell connection that can tunnel other traffic.
• VPN stands for Virtual Private Network• Hotspotvpn is a good option• Back to my Mac is another