now the encryption is as follows, let there be a message x. We have
y=xemodn
The decryption:
x=yd=(xe)d=xed=x
It is not that obvious why e,φ(n) are coprime. So let’s think about it.
We know that
xφ(n)=1modn
for x and n coprime, therefore
xφ(n)+1=xmodn
we want
xed=x=xkφ(n)+1ed−kφ(n)=1
Assume that e,φ(n) aren’t coprime,
the left side would be divisible by some d
which implies that 1∣d, which is obviously wrong.
The decryption as shown with φ
wouldn’t work for x not coprime to n and there is a way
to show that the decryption is still possible through
CTR but in such case, there are other problems.
Mainly because n is publicly known, we can just compute
gcd(n,y)
Getting faster
Choosing small e. (3,17,216+1) — too small e is bad.
Decryption using CRT, smaller numbers faster arithmetic.
How to do it is described here
Important properties
Commutativity
E1(E2(x))=E2(E1(x))
it is not safe to interchange keys although possible.
Homomorphism (kind of)
Used in chosen-ciphertext attack
E(xy)=E(x)E(y)
allows for blind signatures.
What if there is some creature who loves to give signatures?
You can make it sign whatever you want!
Here is how:
you obviously know (d,n) that is public.
You create the following
xzd
where zd is a blinding factor.
And after the signature is finished
xez
and because z was chosen so that it has a multiplicative inversemodn it is easy.
Attacks
Small e
x<n1/e
Simply compute the eth root in Z.
Known φ(n)
We get the following system which we can solve
n=pqφ(n)=(p−1)(q−1)
Wiener
when
d<31n1/4
it is possible to calculate it from e with the continued fraction method.
How it works? This is interesting but not that simple.
But the idea is quite easy.
If attacker got φ(n),e we lost. Attacker knows
Ne
and with this he can approximate
φ(n)e
so that when d is small enough he can recover it.
Randomized algorithms for calculating φ(n)
When d,e are both known, it is possible to calculate φ(n).
Meet in the middle
Similar messages
Given c=me,c′=(m+δ)e and not that large
e we can recover m. Note that m is a root of the following polynomials.
p(x)=me−c,q(x)=(m+δ)e−c′
There is a good chance that
gcd(p,q)
is linear. If that is the case we won.
Partially known messages
All we need to know is to guess unknown bits. Untrivial.
Similar p,q
Let
q=p+2d
then
n=p2+2pd
This is similar to
(p+d)2=p2+2pd+d2d is guessable.
Chosen-ciphertext attack
Suppose the attacker wants to know the message
me
but can’t decrypt it.
Sometimes the victim will decrypt messages which look unsuspicious.
The attacker can then ask the victim to decrypt
mere
if she chose r∈Zn∗ she can then recover m like
m=mrr−1
Chosen-plaintext attack
RSA without padding is not semantically secure.
It is attackable by the chosen-plaintext attack, but this is impractical.
The same message but different moduly
We can use CRT. For e=3 for example
x3=a1modn1x3=a2modn2x3=a3modn3
This is solvable and we can obtain
x3∈Zn
finding the root is then easy.
Miscalculation
When using CRT it is possible to leak one of the primes
if encrypting the same message multiple times.
WTLOG when there is a mistake in calculating remaindermodp,
it gives out the multiple of q from the following
gcd(result−xemodn,n)
Semantic security
There does not exist a property efficiently testable from plaintext
that is contained in cipher text and is efficiently possible to test for it.
Jacobi symbol leak
Jacoby symbol is defined with Legendre symbol for a integer and n odd integer:
(na)=(p1a)e1⋅...⋅(pka)ek
where the primes are from the factorization of n.
It has some interesting properties similar to the Legendre symbol.
For example
(nab)=(na)(nb)
Some other properties
(nma)=(na)(ma)
And when a is a quadratic residue the Jacobi symbol is also 1.
But not necessarily the other way around.
This holds because when a is a quadratic residue in
n it must also be QR in all it’s prime factors.
Parity and half
if we knew how to compute parity or half function
from encrypted message (had oracle for it) we would be able to decrypt.
Half and parity are equivalent because.
Padding
We do pad because otherwise, it is possible that m is too small,
someone tries CPT against us and we are prone to multimoduly attacks.
PKCS #1
Public-Key Crypto Standard.
Bleichenbacher (million message attack) uses adaptive-chosen ciphertext
attack and padding oracle.
It usually takes around a day to recover the key.
There are no known padding oracle attacks on PKCS #1 v2.0.
Notes about the security of RSA
Be careful with using it.
It uses the hardness of factorization as its strength but is not equivalent to it.