Classical Cryptography
Monoalphabetic cipher
Caesar cipher
- Replace each letter by an element of
, that is, an integer from 0 to 25 (A = 0, B = 1,... Z = 25) - Chose a
keyk < 26, we'll have a function f (encrypt) and g (decrypt):
INFO
INFO
Affine cipher
- We can generalize shift ciphers further to slightly enhance security by using a function of the form
INFO
Where bijection.
Prove: gcd(a, 26) = 1
- To find decrypt function
, we assume that , we'll show in term of => (1) - We can see that to solve the congruence equation (1), the gcd(a, 26) = 1 to obtain its
inverse(See 4_4) - (1) =>
Affine decryption
Block cipher
- Encryption methods of Caesar/Affine cipher are vulnerable to attacks based on the
analysis of letter frequencyin the ciphertext. - We can make it harder to successfully attack ciphertext by replacing blocks of letters with other blocks of letters instead of replacing individual characters with individual characters
Transposition cipher
A transposition cipher is a simple type of block cipher that encrypts a message by rearranging the positions of letters, rather than changing the letters themselves.
The
keyis a permutationof the set
- A permutation is a one-to-one function
- Encryption
- Split the plaintext into blocks of size
. - If the message length is not divisible by
, add random letters to complete the last block. - Rearrange letters using the permutation
.
- Split the plaintext into blocks of size
If the plaintext block is
then the ciphertext block is
- Decryption
- Use the inverse permutation
.
- Use the inverse permutation
Given ciphertext
we rearrange using
Cryptosystems
- A cryptosystem provides a general framework for defining encryption methods.
- A cryptosystem is a five-tuple
where
: set of plaintext strings : set of ciphertext strings : keyspace (set of all possible keys) : set of encryption functions : set of decryption functions
For each key
- encryption function:
- decryption function:
They satisfy
for every plaintext
This means decrypting an encrypted message returns the original plaintext.
Private Key Cryptography
INFO
All classical ciphers, including shift ciphers and affine ciphers, are examples of private key cryptosystems
The RSA Cryptosystem
Each user has an encryption key
INFO
Key Construction
- Choose two large primes
- Compute the modulus
Typically:
and each have about 300 digits has about 600 digits
- Choose an exponent
such that
This means
The RSA Encryption
Step 1: Convert letters to numbers
Each letter → two digits
Step 2: Create blocks
Let
Split the digit string into blocks of
This ensures each block
Pad the last block with X if needed.
Step 3: Encrypt
Each block
is encrypted using
(using fast modular exponentiation)
Result
Ciphertext:
RSA encrypts blocks of characters → blocks of numbers, so it is a block cipher.
The RSA Decryption
Cryptographic Protocols
Key exchange (Diffie–Hellman)
Diffie–Hellman là một a protocol that two parties can use to exchange a secret key over an insecure communications channel without having shared any information in the past
Public Parameters
Alice and Bob publicly choose:
- prime
- primitive root
of
The computations are done in
Protocol Steps
- Alice chooses a secret
and sends
to Bob.
- Bob chooses a secret
and sends
to Alice.
Compute Shared Key
Alice and Bob compute the shared key
Digital signature
Digital signatures allow a recipient to verify that a message really came from the claimed sender.
They provide:
- Authentication (who sent the message)
- Integrity (message was not altered)
Alice's RSA Keys
Alice has:
Public key:
Private key:
Signing a Message
Alice wants to send a message (M).
- Convert the message into numbers.
- Split it into blocks:
- Alice signs each block using her private key:
She sends the signature blocks:
Verifying the Signature
Anyone can verify the signature using Alice's public key.
They compute:
If the result equals the original message block, the signature is valid.