tanszek:oktatas:techcomm:rsa_encryption
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tanszek:oktatas:techcomm:rsa_encryption [2024/10/07 13:21] – knehez | tanszek:oktatas:techcomm:rsa_encryption [2024/11/26 08:25] (current) – [Example] knehez | ||
---|---|---|---|
Line 1: | Line 1: | ||
==== The Basic Model of Public Key Systems ==== | ==== The Basic Model of Public Key Systems ==== | ||
- | |||
- | === Basic communication model === | ||
{{: | {{: | ||
Line 39: | Line 37: | ||
* Choose two large prime numbers: \( p \) and \( q \). | * Choose two large prime numbers: \( p \) and \( q \). | ||
* Calculate \( N = p \times q \). | * Calculate \( N = p \times q \). | ||
- | * Compute Euler’s totient function \( \phi(N) = (p-1) \times (q-1) \). | + | * Compute Euler’s totient function \( \phi(N) = (p-1) \times (q-1) \). ([[https:// |
* Choose a public exponent \( e \) such that \( e \) is relatively prime to \( \phi(N) \) (i.e., \( 1 < e < \phi(N) \) and \( \gcd(e, \phi(N)) = 1 \)). | * Choose a public exponent \( e \) such that \( e \) is relatively prime to \( \phi(N) \) (i.e., \( 1 < e < \phi(N) \) and \( \gcd(e, \phi(N)) = 1 \)). | ||
* Compute the private key \( d \), which is the modular multiplicative inverse of \( e \), meaning \( d \times e \equiv 1 \mod \phi(N) \). | * Compute the private key \( d \), which is the modular multiplicative inverse of \( e \), meaning \( d \times e \equiv 1 \mod \phi(N) \). | ||
Line 61: | Line 59: | ||
The RSA algorithm depends on the correct choice of prime numbers \( p \) and \( q \), the calculation of \( N \), and the mathematical relationship between the exponents \( e \) (public key) and \( d \) (private key). Without these specific conditions, the encryption and decryption process will not work properly. | The RSA algorithm depends on the correct choice of prime numbers \( p \) and \( q \), the calculation of \( N \), and the mathematical relationship between the exponents \( e \) (public key) and \( d \) (private key). Without these specific conditions, the encryption and decryption process will not work properly. | ||
- | Your original description was generally correct, but the conditions governing | + | ==== Example ==== |
+ | |||
+ | === Step 1: Key Generation === | ||
+ | |||
+ | 1.) **Choose two large prime numbers** \( p \) and \( q \): | ||
+ | * \( p = 61 \) | ||
+ | * \( q = 53 \) | ||
+ | |||
+ | 2.) **Compute \( N \)** (the modulus): | ||
+ | |||
+ | \[ | ||
+ | N = p \times q = 61 \times 53 = 3233 | ||
+ | \] | ||
+ | So, \( N = 3233 \). | ||
+ | |||
+ | 3.) **Compute Euler’s totient function** \( \phi(N) \): | ||
+ | |||
+ | \[ | ||
+ | | ||
+ | \] | ||
+ | So, \( \phi(N) = 3120 \). | ||
+ | |||
+ | 4. **Choose a public exponent** | ||
+ | * Let’s choose \( e = 17 \), which is relatively prime to 3120. | ||
+ | |||
+ | 5. **Calculate the private exponent** | ||
+ | \[ | ||
+ | d \times e \equiv 1 \mod \phi(N) | ||
+ | \] | ||
+ | Using the extended Euclidean algorithm, we find that \( d = 2753 \). | ||
+ | |||
+ | === Step 2: Encryption === | ||
+ | |||
+ | Now that the keys are set, let’s encrypt a message. Suppose our message is a number \( m = 65 \). | ||
+ | |||
+ | 1.) **Public key** is \( (e, N) = (17, 3233) \). | ||
+ | |||
+ | 2.) **Encryption formula**: | ||
+ | \[ | ||
+ | c = m^e \mod N | ||
+ | \] | ||
+ | * \( m = 65 \), \( e = 17 \), \( N = 3233 \). | ||
+ | * Compute \( 65^{17} \mod 3233 \): | ||
+ | |||
+ | Using modular exponentiation: | ||
+ | \[ | ||
+ | | ||
+ | \] | ||
+ | |||
+ | So, the **ciphertext** \( c = 2790 \). | ||
+ | |||
+ | === Step 3: Decryption === | ||
+ | |||
+ | Now, Alice receives the ciphertext \( c = 2790 \) and uses her private key \( d = 2753 \) to decrypt the message. | ||
+ | |||
+ | 1.) **Private key** is \( (d, N) = (2753, 3233) \). | ||
+ | |||
+ | 2.) **Decryption formula**: | ||
+ | \[ | ||
+ | m = c^d \mod N | ||
+ | \] | ||
+ | * \( c = 2790 \), \( d = 2753 \), \( N = 3233 \). | ||
+ | * Compute \( 2790^{2753} \mod 3233 \): | ||
+ | |||
+ | Again, using modular exponentiation: | ||
+ | \[ | ||
+ | | ||
+ | \] | ||
+ | |||
+ | Thus, Alice successfully decrypts the message and retrieves the original plaintext **65**. | ||
+ | |||
+ | === Summary of the RSA Example: === | ||
+ | |||
+ | * Public key: \( (e = 17, N = 3233) \) | ||
+ | * Private key: \( (d = 2753, N = 3233) \) | ||
+ | * Message to encrypt: \( m = 65 \) | ||
+ | * Ciphertext: \( c = 2790 \) | ||
+ | * Decrypted message: \( m = 65 \) | ||
+ | |||
+ | This is a simple RSA example. In real-world applications, |
tanszek/oktatas/techcomm/rsa_encryption.1728307308.txt.gz · Last modified: 2024/10/07 13:21 by knehez