85 min total

Information Security

RSA and public-key cryptography

RSA and public-key cryptography

RSA clarification: the public modulus N is not the trapdoor; the secret factorization and private exponent enable inversion. Textbook RSA is an educational building block, not a secure encryption scheme on its own. The size comparisons below refer to the modulus, not to the size of each prime. Claims that a key size “cannot be broken” are not guarantees.

2.1 Symmetric encryption (see for full description)

Symmetric Cryptosystems (Revisit)

Same key is used for both encryption and decryption.

secure exchange of keys must happen before any secure communication can occur.

Problems:

  • secure communication relies on the secure exchange of the key, which itself requires a secure method.
  • When multiple parties are involved, the number of unique symmetric keys required: As the number of participants increases, the number of keys required grows quadratically.

Alternative:

Asymmetric Cryptography

Asymmetric Cryptography

Has two keys

  • Public key pk (K+) = enables encryption but no decryption
  • Private/secret key (K–) = used for decryption only

Benefits:

  • No need for secure key exchange, since the public key can be shared without compromising security
  • (n parties), each party only manages their own public key, leading to linear growth of public keys (n public keys).

Real world applications:

  • Session Setup and Key Generation: Alice generates a public key (K+) and a secret key (K-). Bob sends the encrypted message using the function E(K+), message).
  • Non-Interactive Applications: (Emails), Bob encrypts his message to Alice using (), ensuring that only Alice can decrypt it with her private key.

Hard problems in Cryptography

  • Integer factorization: process of determining the prime factors of a composite integer n, such that
  • Discrete logarithm: Finding the exponent x such that , given integers a, b, and n.

No polynomial time algorithms known yet, these hard problems provide the secure cryptographic algorithms

One way function: Given input x, we compute F(x). Based on a hard problem, is easy to compute forward but hard to reverse backward. Just like asymmetric encryption.

Trapdoor One-Way Functions: Given y and some secret: easy to find x considering F(x)=y. Allows for easier computation in one direction when provided with a secret (trapdoor). e.g. knowing the prime factors enables easy reversal to find the original composite integer. Just like asymmetric decryption

Public Key encryption

public-key encryption system is defined as a set of three algorithms

  • G( )

Randomized algorithm that generates a pair of keys
a public key pk and a private (or secret) key sk.

  • E(pk, m)
    encryption algorithm and inputs pk and message m, outputs c.
  • D(sk, c)
    decryption algorithm that inputs cipher text and outputs m

RSA

Public-key cryptosystem that enables secure communication over insecure channels by using Public and private keys.

Process:

  • Choose random primes p, q (1024 bits)
  • compute N = p.q, N serves as 'trapdoor' in RSA
  • Compute Euler function
  • Choose random Encryption key e with GCD( e, ) = 1
  • Compute Decryption key d =
  • Pk = (N, e)
  • Sk = (N, d)

Example:

  • Calculate d, .
  • Public key (e, n) = (7, 33)
  • Private key (d, n) = (3, 33)
  • Now message = 2

Security considerations

  • Attack 01: decrypting ciphertext without private key. Requires solving modular roots to find message m, which is computationally difficult without private key
  • Attack 02: deriving private key d. Requires factoring modulus N, which too is computationally difficult
  • RSA can be broken if prime numbers up to 768 bits.
    RSA cannot be broken with current tech, if prime numbers more than 2048 bits.

Textbook RSA how insecure:

RSA is not a complete, secure encryption system on its own

  • For same message m, ciphertext will always be same, which makes it vulnerable to ciphertext attack. Without randomization, many attacks (e.g., replay or chosen-plaintext attacks) become feasible.

How to secure RSA:

a hybrid encryption scheme is used, which combines the TDF with symmetric encryption.

  • Choose a random value x and compute y=F(pk,x) using the public key pk.
  • Derive a symmetric encryption key k from x by hashing x with a hash function H.
  • Encrypt the message m with the symmetric encryption algorithm and the key k to get c.
  • The final ciphertext is the pair (y,c), where y is the result of applying the TDF and c is the symmetrically encrypted message.
  • To decrypt (y,c) the recipient:

Uses their private key to reverse the TDF, recovering

Uses x to derive the symmetric key k=H(x)

Decrypts c with k to recover the message m.

Whats a GCD and How to Calculate it?

Greatest Common Divisior of two int is largest int that divides both numbers without leaving a remainder

e.g.

Divisors of 28 are: 1, 2, 4, 7, 14, 28

Divisors of 35 are: 1, 5, 7, 35

Common divisors are: 1, 7

GCD = 7

Euclidean algorithm:

3768 = 1701 . 2 + 366

1701 = 366 . 4 + 237

366 = 237 . 1 + 129

237 = 129 . 1 + 108

129 = 108 . 1 + 21

108 = 21 . 5 + 3

21 = 3 . 7 + 0

To generate Cipher key of size:n trapdoor ka size required:
80 bits1024 bits
128 bits3072 bits
256 bits15360 bits

Attacks on RSA:

  • Timing Attack: Measures the time taken to compute to infer the private key d
  • Power Attack: Analyzes power consumption patterns during the computation of to reveal the private key d
  • Fault Attack: Induces faults during computation to obtain information about the private key d.