Asymmetric Encryption Flashcards
What are the pros and cons of asymettric encryption?
Pros
-No preshared secret
- Keys independent of sender
- Anyone who wants to encrypt to Alice can do so
- Only a single private key to keep secret
Cons
- 2-3 orders of magnitude slower than symmetric
-No data orgin authentication or integrity
- risk of impersonation attacks
What are some characteristics of asymmetric encryption?
- Goal: confidentiality
- Keep private key sk absolutely secret.
- Public key pk is inadvertently public. (also known by the adversary)
- The private key sk cannot be deduced from pk.
- Publish pk by distributing it with integrity
What is the weakest point for asymmetric encryption? whatt cand be done to solve that issue?
The weakest point is the public key (Integrity/ Authenticity problem), can be solved with digital signatures
What is the security property for the chosen-plaintext attack security?
Adversary gets the public key so he can encrypt and also gets access to the encryption routine which means the adversary can do arbitrary encryptions
the adversary can choose two arbitrary messages
we are encrypting one of the two messages and giving it back to the adversary The adversary has to decide which of the ones we encrypted in the ciphertext
How does hybrid encryption work?
The disadvantage of symmetric encryption is that you need a pre-shared secret key and with asymmetric encryption the disadvantage is that it is highly inefficient
Two primitives involved here:
one asymmetric enc scheme under some public key to get the benefits of key distribution
one symmetric cipher which takes the bits string as the key as input
We have the asymmetric encryption scheme setup with its key material. We chose an ephemeral random symmetric key. We encrypt the symmetric key with the asymmetric encryption scheme. We use the symmetric cipher with the ephemeral symmetric key to encrypt the plaintext message.
Correct. The freshly generated random symmetric key in encrypted with the asymmetric encryption. The Symmetric cipher encrypts the plaintext.
What is the encryption and decryption formula for Textbook RSA?
Enc: c=m^e (mod N)
Dec: m = c^d (mod N)
How do you generate keys for textbook RSA? given p and q
Compute
N = p.q
phi(N) = (p-1) . (q-1)
choose a random integer e that gcd(e, phi(N)) = 1
compute e’s inverse d: d.e = 1 (mod phi(N))
Output:
Pk = (N, e)
Sk = (N, d)
Given
p = 2357
q = 2551
e = 3674911
m = 5234673
find the RSA private key and secret key. Perform textbook RSA Encryption and check if its correct.
phi_n = 6007800
d = 422191
c = 3650502
m = 5234673
from sympy import mod_inverse
p = 2357
q = 2551
e = 3674911
m = 5234673
N = p * q
phi_n = (p-1) * (q-1)
print(phi_n)
d = mod_inverse(e, phi_n)
print(d)
c = (me) % N
m1 = (cd)% N
print(c)
print(m1)
Is textbook RSA Secure?
Textbook RSA is not secure at all and not even a proper encryption. Why? Its not an encryption scheme its a Pseudo-Random Trapdoor Permutation
Why is textbook RSA flawed? What are the attacks?
- Encrypting with small e
If the modulus is small, the cube of the message might be smaller than the modulus size, which means this operation doesnt wrap around the modulus. - Common modulus attack
Using same modulus is a really bad idea
Whenever you have the modulus and a keypair, you can break the entire system
We know that the public and private exponent are multiplicative inverses of one another, intimately related once you a have a keypair and N you have enough information to calculate the group order. - Mangling Ciphertext
RSA is homomorphic: if i multiply two ciphertexts together, im getting an encryption of the two plaintext that were encrypted
as an adversary, I could invent any multiplier, encrypt it and multiply the users ciphertext and this will increase the bid(mangle the ciphertext) - Small Decryption exponent
If the decryption exponent (d) is less than N^(0.3) one can compute d from e and N so choose d large enough d> N^(1/2) - RSA itself is deterministic
Cannot fulfil CPA security because if you’re encrypting the same message twice, you’re raising the same message to the same public exponent which leads to the same ciphertext. So an adversary encrypt two ciphertexts and check
How does introducing padding to textbook RSA help?
- Pad message to modulus length
- Introduce randomization (Makes it not deterministic)
- Create structure (detects mangling)
What are the 4 pillars of public key encryption?
- Key distribution must be authentic
- c indistinguishable from random (CPA-secure)
- Must be randomized
- Efficient with hybrid encryption
What are the three factors that lead to the attacks on textbook RSA?
- Plaintext is too short, not using full modulus length
- Textbook RSA is not random, need to infuse with fresh random bits
- RSA is homophorbic, you can manipulate ciphertexts
What is the structure of RSA with PKCS #1 v1.5 Padding? What are the benefits?
(2 (16 bit) Random padding r 0 (8 bit) m)^e (mod N)
Benefits
- always be the size of the modulus
- introduces randomness
- creating structure, not homophorbic anymore
(CPA secure)
Briefly describe RSA OAEP encryption and decryption
Encryption:
What we need: Choose random r in {0,1}^; Hash functions G and H; and XOR
we get the message and introduce structure by padding with lots of zeros and get the message m’. We XOR that m’ with G(r) and obtain m1. The final output is m1 || r xor H(m1). We get this and (m1 || r xor H(m1))^e = c
Decryption:
What we need: m1 || r xor H(m1) we get this after we c^d
First we hash m1 and xor it with (r xor H(m1)) to get r. After we get r we do G(r) XOred with m1 to obtain m’ and from that we can obtain m after removing the zero paddings