This repository demonstrates basic cryptographic concepts using simplified implementations of Diffie-Hellman and RSA algorithms. It showcases key exchange, encryption, decryption, and digital signing processes, highlighting the roles of Alice, Bob, and Eve (an eavesdropper) in each scenario.
IMPORTANT: The implementations in this repository are greatly simplified and use small numbers for demonstration purposes only. They are NOT secure and should NEVER be used in real-world applications. This code is purely for educational purposes to illustrate basic cryptographic concepts.
Diffie-Hellman vs. RSA Encryption Algorithms- What's the Difference- - YouTube https://www.youtube.com/watch?v=VY4EouzyJS0
Demonstrates how two parties can establish a shared secret over an insecure channel.
Principles:
- Uses the difficulty of the discrete logarithm problem
- Allows key agreement without prior shared secret
Steps:
- Alice and Bob agree on public parameters (prime p and base g)
- Each generates a private key
- Each computes and exchanges public keys
- Each computes the shared secret
Process:
- Alice and Bob: Can compute the shared secret
- Eve: Can see all public information but cannot compute the shared secret
Shows how RSA can be used to exchange a symmetric key securely.
Principles:
- Uses the difficulty of factoring large numbers
- Allows secure key transmission using public-key cryptography
Steps:
- Alice and Bob generate RSA key pairs
- They exchange public keys
- Bob generates a symmetric key
- Bob encrypts the symmetric key with Alice's public key
- Bob sends the encrypted key to Alice
- Alice decrypts the key with her private key
Process:
- Alice: Can decrypt the symmetric key
- Bob: Can create and encrypt the symmetric key
- Eve: Can see the encrypted key but cannot decrypt it
Demonstrates secure message transmission using RSA.
Principles:
- Asymmetric encryption
- Message confidentiality
Steps:
- Bob prepares a message
- Bob encrypts the message with Alice's public key
- Bob sends the encrypted message to Alice
- Alice decrypts the message with her private key
Process:
- Alice: Can decrypt the message
- Bob: Can encrypt the message
- Eve: Can see the encrypted message but cannot decrypt it
Illustrates digital signature creation and verification.
Principles:
- Message integrity
- Non-repudiation
- Sender authentication
Steps:
- Alice prepares a message
- Alice signs the message with her private key
- Alice sends the message and signature to Bob
- Bob verifies the signature using Alice's public key
Process:
- Alice: Can sign messages
- Bob: Can verify Alice's signatures
- Eve: Can see signed messages and verify signatures, but cannot forge Alice's signature
Remember, never implement your own cryptography for real-world applications. Always use well-vetted, standard cryptographic libraries.