A E D C B # Symmetric Keys = n*(n-1)/2 F 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
B 9 1 6 8 7 A 2 C 10 3 5 4 11 12 13 F D 14 15 E # - - PowerPoint PPT Presentation
B 9 1 6 8 7 A 2 C 10 3 5 4 11 12 13 F D 14 15 E # - - PowerPoint PPT Presentation
B 9 1 6 8 7 A 2 C 10 3 5 4 11 12 13 F D 14 15 E # Symmetric Keys = n*(n-1)/2 # Symmetric Keys = n*(n-1)/2 # Public/Private Keys = 2 n public private B 9 1 6 8 7 A 2 C 10 3 public private 5 4 public
A E D C B F 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
public private public private
public private public private public private
public private
# Symmetric Keys = n*(n-1)/2 # Public/Private Keys = 2n
RSA
- Chose two random large prime numbers p & q (of
equal length is best)
- Compute their product n = pq
- Randomly choose an encryption key e :
e and (p-1)(q-1) are relatively prime (gcd=1)
- Calculate the decryption key d :
d = e-1 mod ((p-1)(q-1)) (-1 is modular inverse)
RSA encryption
Split up the message into blocks less than n ci = mie mod n Decryption is similar di = cid mod n
RSA Example
p=47 , q=71, n=pq=3337 Choose e : no factors common with 𝞆 =(p-1)(q-1) = 46*70 = 3220 randomly choose e to be 3 Then d=3-1 mod 3337 = 2147
RSA Example (continued)
- Message M
H E L L O W O R L D ! 72 69 76 76 79 32 87 79 82 76 68 33
- Treat each letter as a block
72 69 76 76 79 32 87 79 82 76 68 33 m1 m2 m3 m4 m5 m6 m7 m8 m9 ma mb mc
- Encrypt each block
723 mod 3337 = 2841 = c1 2841 1483 1829 1829 2500 2735 c1 c2 c3 c4 c5 c6 1114 2500 763 1829 754 2567 c7 c8 c9 ca cb cc
Using Matlab™ or https://defuse.ca/big-number-calculator.htm
RSA Example (continued)
- Ciphertest C
2841 1483 1829 1829 2500 2735 1114 2500 763 1829 754 2567
- Treat each number as a block
- Decrypt each block
2841 2147 mod 3337 = 72 = m1
Using matlab™ or https://defuse.ca/big-number-calculator.htm
As long as factoring is hard …
me mod N ≡ ? is easy ?e mod N ≡ c is hard!
RSA is secure
Symmetric Key Signatures
1
Alice uses kA to encrypt the document going to Bob and sends it to Trent
2
Trent decrypts the document with kA
3
Trent appends a statement that he received it from Alice
4
Trent encrypts the bundle with kB
5
Trent sends the encrypted bundle to Bob
6
Bob decrypts the bundle with kB , and can read the message and Trent’s certification
Public Key Signatures
1
Alice encrypts the document with her private key
2
Alice sends the encrypted (signed) document to Bob
3
Bob decrypts the document with Alice’s public key
Cryptographic Hashes
SHA-1(” The red fox jumps over the blue dog”) = 0x12d6ae1b4a5c1c99ba6e4d60c22c42abe56d0e08b3111222880606 a12a9b5aab SHA-1(” The red foy jumps over the blue dog”) = 0xc1b02530f4cf6867e606abebf1bd05bc608d27db147a4589934404e6 7c19911c SHA-1(” The red fxo jumps over the blue dog”) = 0x9a9bed6ca1a3333989b7c7b849f99ba2da685494865201ee3729d3 ad09560c03 fox=0x66 6F 78 foy=0x66 6F 79 fxo=66 78 6F
Public Key Signature with Timestamp
1
Alice adds a timestamp to the document
2
Alice encrypts the document with her private key
3
Alice sends the encrypted (signed) document to Bob
4
Bob takes the check to the bank
5
Bank decrypts the document with Alice’s public key
6
Bank stores the check information and the timestamp in a database
7
If Bob tries to deposit the check again, its information will match the database
Multiple Signatures
1
Alice signs a hash of the document
2
Bob signs a hash of the document
3
Bob sends his signature to Alice
4
Alice sends the document, her signature, and Bob’s signature to Carol
5
Carol can verify both signatures
Digital signatures
- a file to be signed
- proof that the file has not been altered
- indication of who applied the signature
- validation that the signature is authentic
(i.e., belongs to the signer)
- connection of the signature to the file
Digital Signatures and Encryption (to protect the file)
1
Alice encrypts the file with her private key *
2
Alice computes a hash of the encrypted file
3
Alice encrypts the hash with her private key
4
Alice sends the encrypted message, encrypted hash, and her identity to Bob, encrypted with his public key
5
Bob decrypts the entire message with his private key
6
Bob obtains the public key associated with the identity in the message
2
Bob decrypts the encrypted hash with Alice’s public key
3
Bob calculates a hash of the encrypted message and verifies that it matches the hash in the signature
4
Bob decrypts the encrypted message with Alice’s public key * - if the message is large, a symmetric cipher and key should be used
Digital Signature Optimizations
Message is not secret Message is secret Message is small
encrypt only the hash with Private Key encrypt the message AND the hash with Private Key
Message is large
encrypt only the hash with Private Key encrypt message with symmetric key and hash with public key
Digital Signatures and Encryption typical notation
Alice Bob
SA (M) EB (SA (M) ) DB (EB (SA (M))) = SA(M) VA (SA (M)) = M
Needham-Schroeder Protocol
MITM Attack on N-S
The Fix
Note that Alice obtained Bob’s public key by sending his identity B to a Certificate Authority.
Note that Alice obtained Bob’s public key by sending his identity B to a Certificate Authority. Alice also verifies his identity B.