









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










Website Address : n = 123444 e = 3 s = 234
If we hear the word cryptography our first associations might be e-mail encryption, secure website access, smart cards for banking applications or code breaking during World War II, such as the famous attack against the German Enigma encryption machine. Cryptography seems closely linked to modern electronic communication. However, cryptography is a rather old business, with early examples dat- ing back to about 2000 B.C. Scytale of Sparta
Cryptology splits into two main branches:
Cryptography is the science of secret writing with the goal of hiding the meaning of a message.
Cryptanalysis is the science and sometimes art of breaking cryptosys- tems.
Definition 1.1 (Kerckhoffs’ Principle). A cryptosystem should be se- cure even if the attacker (Oscar) knows all details about the system, with the exception of the secret key.
We now introduce another historical cipher, the shift cipher. It is ac- tually a special case of the substitution cipher and has a very elegant mathematical description.
Encoding of letters for the shift cipher
A B C D E F G H I J K L M 0 1 2 3 4 5 6 7 8 9 10 11 12 N O P Q R S T U V W X Y Z 13 14 15 16 17 18 19 20 21 22 23 24 25
Definition 1.2. Shift Cipher Let x, y, k ∈ Z 26. Encryption: ek(x) ≡ x + k mod 26. Decryption: dk(y) ≡ y − k mod 26.
Proof. Correctness proof
dk(ek(x)) = dk(x + k) = x
Example 1.1. Let the key be k = 17, and the plaintext is:
x A T T A C K x 0 19 19 0 2 10 y 17 10 10 17 19 1 y r k k r t b
Since there are only 26 different keys (shift positions), one can easily launch a brute-force attack by trying to decrypt a given ciphertext with all possible 26 keys.
Definition 1.3 (Substitution cipher). The idea is very simple: We sub- stitute each letter of the alphabet with another one.
A → D, B → E, C → F · · ·
Example 1.2.
A B C D E R S T U R E S U C T B A D
the key space is = 26! ∼ 288
Definition 1.4. (Exhaustive Key Search or Brute-force Attack) Let (x, y) denote the pair of plaintext and ciphertext. A brute-force attack checks for every ki ∈ K if dki (y) =?x.
If the equality holds, a possible correct key is found.
56–64 bits short term: a few hours or days 112–128 bits long term: several decades in the absence of quantum computers 256 bits long term: several decades, even with quantum computers that run the currently known quantum computing algorithms
E about 12.7%
T about 9.1% A about 8.2%
O,I,N about 6.7% − 7 .5%
Exercise 1.1 (Affine Cipher.). Let x, y, a, b ∈ Z 26 Encryption: ek(x) = y = ax + b mod 26. Decryption: dk(y) = x = a−^1 (y − b) mod 26. with the key: k = (a, b), which has the restriction: gcd(a, 26) = 1.
correctness proof.
Key space.
Example 1.3. Let the key be k = (a, b) = (9, 13), and the plaintext be “ATTACK”. Then ek(x) = 9x + 13
x A T T A C K x 0 19 19 0 2 10 y 13 2 2 13 5 25 y n c c n f z
Definition 1.5 (Vigen`ere cipher ). Let m ∈ N and x, y, k ∈ Zm 26. Encryption: ek(x) ≡ x + k. Decryption: dk(y) ≡ y − k.
Let m = 3 and the key be k = key, and the plaintext be “ATTACK”. Then
Letter Dec Hex Binary A 65 41 0100 0001 B 66 42 0100 0010 C 67 43 0100 0011 D 68 44 .. .
Explain symmetric algorithms
nfusion : encryption operation where the relationship between key and cipher- text is obscured.
Diffusion encryption operation where the influence of one plaintext symbol is spread over many ciphertext symbols.
DES is a cipher which encrypts blocks of length of 64 bits with a key of size of 56
Encryption+Key Schedule.
Round encryption:
y = DESk 3 (DESk 2 (DESk 1 (x)))
Sbox : F 28 −→ F 28 x −→ M x−^1 + b
b^ =
x := α^2 x−^1 = ea^3 M x−^1 + b = α^3
Then Sbox(α^2 ) = α^3. Now we compute all this
0 1 2 3 0 30 12 01 22 1 02 32 13 10 2 03 23 11 33 3 21 00 20 31
Symmetric Asymmetric Fast Slow Used to transmit big data. Used to transmit small data. A single key for encryption and decryption diffrent key for encryption and decryption
What is our goal?
Extended GCD.
Fast Exponentiation algorithm.
Fermat and Euler theorem.
Theorem 3.1. Let a be an integer and p be a prime, then:
ap^ ≡ a.
Theorem 3.2. Let a and m be integers with gcd(a,m) = 1, then:
aϕ(m) = 1(modm).
Theorem 3.3.
f : Zn → Zn 1 Zn 2 x 7 → (x, x)
is a ring isomorphism.
Proof.
x
In 1977, Ronald Rivest, Adi Shamir and Leonard Adleman proposed a scheme which became the most widely used asymmetric cryptographic scheme, RSA.
Definition 4.1. Given a finite cyclic group G with multiplication group operation and a generator g, the discrete logarithm problem for G is to express given element α of G in the form gx, where x is an integer.
The integer x is called the discrete logarithm of α to the base g, and we can formally write: x = loggα logg(αβ) = logg(α) + logg(β)
Example 4.1. We consider a discrete logarithm in the group Z∗ 47 , in which g = 5 is a primitive element. For α = 41 the discrete logarithm problem is: Find the positive integer x such that
5 x^ ≡ 41 mod 47
Example 4.2. p = 29 and α = 2
Alice Bob choose p = 29 and g = 2 choose d = 13 compute β = 2^13 = 14 choose e = 17 ← (p, g, β) ← publish public key. compute α = g^1 7 = 21 Km = βe^ = 24 → α = 21 → Km = αd^ = 24. pass= 22 x = 22 ∗ 24 = 6 x ∗ K m−^1 = 22 =pass
Alice Bob generate kpr,B kpr publish public key. sign message: s = sigkpr(x). (x, s) send msg and signature verkpub,B (x, s) = true/f alse
♦ Arbitrary message size h(x) can be applied to messages x of any size.
♦ Fixed output length h(x) produces a hash value z of fixed length.
♦ Efficiency h(x) is relatively easy to compute.
♦ Preimage resistance : For a given output z, it is impossible to find any input x such that h(x) = z, i.e, h(x) is one-way.
♦ Second preimage resistance Given x 1 , and thus h(x 1 ), it is computa- tionally infeasible to find any x 2 such that h(x 1 ) = h(x 2 ).
♦ Collision resistance It is computationally infeasible to find any pairs x 1 ̸= x 2 such that h(x 1 ) = h(x 2 )
There are two general types of hash functions:
Example 4.3. Let
e(k 1 ,k 2 ,k 3 )(x 1 , x 2 , x 3 ) = (x 1 , x 2 , x 3 ) + (k 1 , k 2 , k 3 )
we use Hi = eXi (Hi− 1 ).
S=LETTHISBEAMESSAGE
11 4 19 19 7 8 18 1 4 0 12 4 18 18 0 6 4 20 20 09
Then Hash(LET T HISBEAM ESSAGE) = U U J
4.2.1 Security Services
Confidentiality: Information is kept secret from all but authorized parties.
Integrity: Messages have not been modified in transit. Message Authentication: The sender of a message is authentic. An alternative term is data origin authentication.
Nonrepudiation: The sender of a message can not deny the creation of the message.
4.2.2 Message Authentication Code
keyed hash function
4.2.3 RSA signature
compute signature: s ≡ xd^ mod n verify: x′^ ≡ se^ mod n
x′
≡ x mod n =⇒ valid signature ̸≡ x mod n =⇒ invalid signature Example 4.4. Alice Bob p = 11, q = 5 n = pq = 55 ϕ(n) = (4 − 1)(11 − 1) = 40 choose e = 3 compute d = 27 ← kpr = (3, 55) ← publish public key. hash(x) = 27 = message s = 27^27 = 3
se^ = x′^ =? x ← (x, s) = (x, 3) ←
Attacks :
4.2.4 Digital certificate
4.2.5 Elgamal Signature
Alice BOB x −−→
Theorem 5.1 (Hadamard and de la Vall´ee Poussin). As x → ∞,
π(x) ∼
x ln(x)
ith a given basis of the first few prime numbers B =
{p 1 , p 2 , · · · }, the “first turn” of the wheel consists of:
{i : i ∈ [1, · · · , B] | gcd(B, i) = 1}
Example 5.1. Let B =
{ 2 , 3 , 5 } = 30. Then the first wheel is
W 1 := { 1 , 7 , 11 , 13 , 17 , 19 , 23 , 29 }
W 2 := { 31 , 37 , 41 , 43 , 47 , 49 , 53 , 59 }
If one can write n in the form a^2 − b^2 , where a, b are nonnegative integers, then one can immediately factor n as (a + b)(a − b). If a − b > 1, then the factorization is nontrivial. Indeed, if n is odd and n = uv, where u, v are positive integers, then n = a^2 − b^2 with a = 12 (u + v) and b = 12 |u − v|. To formalize this as an algorithm, we take trial values of the number a from the sequence
n,
n + 1,... and check whether a^2 − n is a square. If it is, say b^2 , then we have n = a^2 − b^2 = (a + b)(a − b).
Theorem 5.2. In a set of n randomly chosen people, the probability of at least two share a birthday is
356! (365 − 23)!
Consider a random function f from S to S, where S = { 0 , 1 , · · · , l − 1 }. Let s ∈ S be a random element, and consider the sequence
s, f (s), f (f (s)), · · ·
Since f takes values in a finite set S, then f (j)(s) = f (k)(s).
Example 5.2. S = F 23 and f (x) = x^2 + 1 mod p and s = 0
1 , 2 , 5 , 3 , 10 , 9 , 13 , 9
Let l = k − j, so that for any
f (m)(s) ≡ f (m+l)(s) ≡ f (m+2l)(s) ≡ · · · mod p.
So the basic idea of the Pollard rho method is to compute the sequence gcd(f (i)(s) − f (2i)(s), n) for i = 1, 2 , · · · , and this should terminate with a nontrivial factorization of n in O(
p).
Example 5.3. Let n = 55, f (x) = x^2 + 1 and x 0 ∈ { 1 , 2 , 3 }
i xi x 2 i gcd(xi, x 2 i) 1 2 5 1 2 5 17 1 3 26 6 5
i xi x 2 i gcd(xi, x 2 i) 1 6 38 1 2 38 38 55
i xi x 2 i gcd(xi, x 2 i) 1 12 37 5
Example 5.4. Let n = 416832574423, and let f (x) = x^2 + 1 and a = 1 then this algorithm take 124 step to get that
n = 515857 × 808039.
Even if you know all primes up to 515857 you will need 42729.
We know from Fermat’s little theorem that if p is an odd prime, then
2 p−^1 ≡ 1(modp).
Further, if p − 1 |M , then
2 M^ ≡ 1(modp).
There are two way to choose M. The first one is to choose M = B!. Or
M (k + 1) =
M (k) if k+1 is not prime pM (k) if k+1 is pa
Example 5.5. Let n = 1496347, and we choose B = 5, then we calculate
2 B!^ mod n = 25!^ =
Now we have gcd(38918 − 1 , n) = 1. No factor found we can increase B to B = 7
We have gcd(345079 − 1 , 1496347) = 1009 and factor is found. Note that if we choose B = 11 then
Gcd(211!^ − 1 , n) = n.
Therefore, we need to decrease B.
Lenstra Algorithm : The Lenstra elliptic-curve factorization method to find a factor of a given natural number n works as follows:
Pick a random elliptic curve over Zn with equation of the form y^2 = x^3 + ax + b together with a non-trivial point (x 0 , y 0 ).
Choose a limit M as we do with
Calculate M · P until we find.
Example 5.6. Let n = 247 and we set M := 2 ∗ 5 = 10, To choose a curve we first select point let (x 0 , y 0 ) = (1, 1) and a = 3, then b = y^2 −x^3 −ax = 1^2 − 13 −3 = − 3 then our curve is y^2 = x^3 +3x− 3
now we ∆ = 4a^3 + 27b^2 , we have Gcd(Delta, n) = 13.
We choose another curve (0, 0) and a = 4 then b = 0, then our curve is y^2 = x^3 + 4x we have ∆ = 4 ∗ 43 + 27 ∗ (0)^2 = 9 Gcd(9, n) = 1
2(0, 0) = (0, 0) + (0, 0) = (x 3 , y 3 ) = P∞ (3) We choose another curve (0, 5) and a = 5 then b = 5^2 − x^3 − 5 ∗ x = 25, then our curve is y^2 = x^3 + 5x + 25 we have ∆ = 4 ∗ 53 + 27 ∗ (25)^2 = 85 Gcd(85, n) = 1
2(0, 5) = (0, 5) + (0, 5) = (x 3 , y 3 ) (4) m := (5)
Consider the cyclic group (G, ∗) of order n and generated by the element g, with an arbitrary element h in G. The discrete logarithm problem seeks to find the exponent x such that
h = gx. The algorithm reframes this problem by expressing x as the sum of two integers, i and mj, with m as an integer parameter:
x = i + j ∗ m 0 ≤ i ≤ m − 1 , 0 ≤ j ≤
n m
Then the logarithm discrete logarithm problem become gi^ = h(g−m)j
Table 5: Giant Step Table
j 0 1 2 3 4 5 (75, 90) + j(−mG) (75, 90) (106, 120) (73, 24) (171, 231) (247, 88) P∞