Two requirements for secure use of conventional encryption:
A strong encryption algorithm
Sender and receiver must have obtained copies of the secret key in a secure fashion and must keep the key secure
Caesar Cipher
It is simplest and earliest known use of a substitution cipher
Algorithm can be expressed as: c=E(3,p)=(p+3)mod26
A shift may be of any amount, so that the general Caesar algorithm is: C=E(k,p)=(p+k)mod26
Where k takes on a value in the range 1 to 25; the decryption algorithm is simply: p=D(k,C)=(p−k)mod26
One-time Pad
Improvement to Vernam cipher:
In OTP, the key is as long as the message
OTP requires the key to be completely random
The key is used only once and then discarded
The scheme is unbreakable. Because the ciphertext (random output) contains no information whatsoever about the plaintext, there is simply no way to break the code
Let Zm=0,1,…,m−1 be the alphabet.
Plaintext space = Ciphtertext space = Key space = (Zm)n
Plaintext space = Ciphtertext space = Key space = {0,1}n
Bit AND: If there's a zero in calculation, then the result will be zero.
0 ∧ 0 = 0
0 ∧ 1 = 0
1 ∧ 0 = 0
1 ∧ 1 = 1
Bit OR: If there's a one in calculation, then the result will be one.
0 ∨ 0 = 0
0 ∨ 1 = 1
1 ∨ 0 = 1
1 ∨ 1 = 1
Bit XOR: If 2 numbers are same, then the result will be zero.
0 ⊕ 0 = 0
0 ⊕ 1 = 1
1 ⊕ 0 = 1
1 ⊕ 1 = 0
let P=11011011,K=01101001andE(P)=P∧K∴E(P)=01001001
Difficulty
The one-time pad offers complete security but, in practice, has two fundamental difficulties:
There is the practical problem of making large quantities of random keys. Any heavily used system might require millions of random characters on a regular
basis
Mammoth key distribution problem. For every message to be sent, a key of equal length is needed by both sender and
receiver
Although, The one-time pad is the only cryptosystem that exhibits perfect secrecy, because of these difficulties, the one-time pad is of limited utility, and it's primarily used for low-bandwidth channels requiring very high security.
Part 2: RSA Algorithm
Rivest-Shamir-Adleman (RSA) Algorithm
This algorithm was developed in 1977 at MIT by Ron Rivest, Adi Shamir & Len Adleman. It is the most widely used general-purpose approach to public-key encryption.
Before RSA, key distribution in cryptography required securely sharing a secret key between two parties. This was challenging because the secret key had to be shared privately, and if an attacker intercepted the key, the entire communication could be compromised.
RSA introduced the concept of public-key cryptography, where:
A pair of keys is generated: a public key (for encryption) and a private key (for decryption).
The public key can be shared freely, and only the private key can decrypt the messages.
RSA solves the need for a trapdoor function — a function that is easy to compute in one direction but hard to reverse without special information (probably "one-way"). They utilized the Modular arithmetic to solve the problem. The process of encrypting M to C is easy to compute. However, reversing this operation (finding Mfrom C) without knowing the private key requires factoring n back into p and q, which is computationally hard when n is very large (with thousands of bits)
C=MemodnM=Cdmodn
The combination of these 2 formula will be:
M=Me⋅dmodnThenMe⋅d−1≡1(modn)
However, this system was incomplete because they still didn't fully understand how e (the encryption exponent) and d (the decryption exponent) should relate to each other.
From Euler to RSA
The breakthrough came with the understanding of Euler's Totient Function ϕ(n), because it establishes the mathematical foundation for the relationship between the public and private keys.
Well, Euler can be a good solution.
aϕ(n)≡1(modn)Then(aϕ(n))k≡1k≡1(modn)
Replace the a with M
Mϕ(n)≡1(modn)Mk⋅ϕ(n)≡1(modn)
Then, combine these 2 formula:
Mk⋅ϕ(n)≡1(modn)Me⋅d−1≡1(modn)∴e⋅d=k⋅ϕ(n)+1modϕ(n) in the calculation:e⋅d≡1(modϕ(n))∴d is the inverse module ofe∴d≡e−1(modϕ(n)),andgcd(e,ϕ(n))=1
RSA Algorithm
RSA makes use of an expression with exponentials. Plaintext is encrypted in blocks with each block having a binary value less than some number n.
Assumen=1001(2)1111101001 in binary,e=3ifM=1111110000(2),(M>n)thenMewill be too large to calculate
If the binary value of the plaintext block is too large, the encrypted ciphertext may lose its original encryption properties, or the plaintext may not be correctly restored during decryption.
Encryption and decryption are of the following form, for some plaintext block M and ciphertext block C
C=MemodnM=Cdmodn=(Me)dmodn=Me⋅dmodn
Both sender and receiver must know the value of n. But, the sender knows the value of e, and only the receiver knows the value of d
Extended Question: What is C? and From C, what the M suppose to be?
Obviously, C=Memodn and M=Cdmodn
SOLUTION:Sincen=119,M=8,e=5ThusC=Memodn=85mod119=43ThusM=Cdmodn=4377mod119Simplify the complex formula:∵n=7×17{m1=4377mod7=(6×7+1)77mod7,(divide 43 by 7)m2=4377mod17=(17×2+9)(17−1)×4+13mod17,(divide 43 by 7)∵Fermat’s Throrem:ap−1≡1(modp)∴m2=913mod17=8{mmod7=1mmod17=8letm=17⋅x+8∴17⋅x+8≡1mod7(2×7+3)⋅x+(7+1)≡1mod73⋅x+1≡1mod7x≡0mod7∴xmod7=0ifx=0,xmod7=0∴m=17×0+8=8∴formula{8mod7=18mod17=8holds∴M=8
Part 3: Diffie-Hellman Algorithm
The Diffie-Hellman Algorithm
Requires two large numbers, one prime (P), and one primitive root (G) of P, and P and G are both publicly available numbers. (P is at least 512 bits)
Compute shared, private key:
ka=yamodpkb=xbmodp
Algebraically it can be shown that ka=kb. After exchanging, users will have a symmetric secret key for communications.
Example: Alice and Bob get public numbers, known that: P=23, G=9, a=4, and b=3.
Part 4: Public-Key Cryptography, Requirement, Factorization
Principles of Public-Key Cryptosystems
The concept of public-key cryptography evolved from an attempt to solve two of the most difficult problems associated with symmetric encryption:
Key distribution: How to secure communications in genral without having to trust a KDC (Key Distribution Centre) with your key. (The security cannot be promised if KDC has been attacted.)
Digital signatures: How to verify that a message comes intact from the claimed sender.
Whitfield Diffie and Martin Hellman from Stanford University achieved a breakthrough in 1976 by coming up with a method that addressed the key distribution problem.
Diffie–Hellman key exchange: It allows two parties to negotiate a shared key on an insecure network without the need for a trusted third party to distribute the key. The core of this algorithm is to use two large prime numbers and a primitive root. Each party chooses a private random number, and then calculates a public value. After the two parties exchange the public values, they obtain the same shared key through certain calculations.
RSA algorithm can address both problems.
Applications for Public-Key Cryptosystems
Public-key cryptosystems can be classified into three categories:
Encryption/Decryption: The sender encrypts a message with the recipient's public key
Digital Signature: The sender "sign" a message with its private key
Key Exchange: Two sides cooperate to exchange a session key
Some algorithms are suitable for all three applications, whereas others can be used only for one or two
algorithm
Encryption/Decryption
Digital Signature
Key Exchange
RSA
Yes
Yes
Yes
Elliptic
Yes
Yes
Yes
Diffie-Hellman
No
No
Yes
DSS
No
Yes
No
Public-Key Requirements
Firstly, It is computationally easy to:
generate a pair (public and private key) for party B
generate the corresponding ciphertext for sender A when knowing the public key and the message to be encrypted
decrypt the resulting ciphertext for receiver B using the private key to recover the original message
Secondly, It is computationally impossible to:
determine the private key for an attacker, when just knowing the public key
recover the original message for an attacker, when just knowing the public key and a ciphertext
Finally, the two keys can be applied in either order
Trap-door vs One-way Function
A one-way function
maps a domain into a range such that every function value has a unique inverse, with the condition that the calculation of the function is easy, whereas the calculation of the inverse is infeasible.
Y=f(X)easyX=f−1(Y)infeasible
A hash function, e.g., MD5, SHA256
A trap-door one-way function
A trap-door one-way function is a family of invertible functions fk such that:
Y=fk(X)easy, if known:k,XX=fk−1(Y)easy, if known:k,YX=fk−1(Y)infeasible, if known:Ybut unknown:k
A practical public-key scheme depends on a suitable trap-door one-way function
Basic Uses of Message Encryption
(a) Symmetric encryption: confidentiality
(b) Public-key encryption: confidentiality
(c) Public-key encryption: authentication and signature
(d) Public-key encryption: confidentiality, authentication, and signature