# Practical 5 – RSA Public-Key Authentication: Generate Keys
# Install: pip install cryptography
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import rsa

private = rsa.generate_private_key(public_exponent=65537, key_size=2048)
public = private.public_key()
with open("client_private.pem", "wb") as file:
    file.write(private.private_bytes(
        serialization.Encoding.PEM,
        serialization.PrivateFormat.TraditionalOpenSSL,
        serialization.NoEncryption(),
    ))
with open("client_public.pem", "wb") as file:
    file.write(public.public_bytes(
        serialization.Encoding.PEM,
        serialization.PublicFormat.SubjectPublicKeyInfo,
    ))
print("RSA key pair saved.")

# What this code does: creates and saves an RSA private/public key pair for
# the client authentication demonstration.
