Cryptography and Network Security
Cryptography and Network Security
RSA ALGORITHM
The RSA algorithm is an asymmetric cryptography algorithm; this means that it
uses a public key and a private key (i.e two different, mathematically linked
keys). As their names suggest, a public key is shared publicly, while a private
key is secret and must not be shared with anyone.
The RSA algorithm is named after those who invented it in 1978: Ron Rivest,
Adi Shamir, and Leonard Adleman.
Key Generation:
• Step 1: Choose two distinct prime numbers, p and q.
• Step 2: Compute their product, n = p * q. The value of n is used as the
modulus for both the public and private keys.
• Step 3: Compute Euler's totient function, φ(n) = (p-1)(q-1), which
represents the count of numbers less than n that are coprime with n.
• Step 4: Choose an integer e such that 1 < e < φ(n) and e is coprime with
φ(n). This integer serves as the public exponent.
• Step 5: Compute the modular multiplicative inverse d of e modulo φ(n).
In other words, find d such that (d * e) mod φ(n) = 1. This d is the private
exponent.
Encryption and Decryption:
• Encryption: To encrypt a message m, the sender uses the recipient's
public key (n, e) to compute c ≡ m^e (mod n). The ciphertext c is then
transmitted to the recipient.
• Decryption: The recipient, who possesses the private key (d), computes
m ≡ c^d (mod n) to recover the original message.
Key Length:
• The security of RSA depends on the length of the modulus (n) and the
choice of prime numbers (p and q).
• As computing power increases, longer key lengths are recommended to
maintain security against brute-force attacks.
Advantages:
• RSA offers strong security guarantees based on the difficulty of factoring
large numbers, making it suitable for various cryptographic applications.
• It provides a versatile solution for secure communication, digital
signatures, and key exchange.
Application :
• Secure Communication: RSA is used for secure transmission of data
over insecure networks, ensuring confidentiality.
• Digital Signatures: RSA allows for the creation and verification of
digital signatures, providing authentication and non-repudiation.
• Key Exchange: RSA facilitates secure key exchange between parties
without the need for a pre-shared secret.
Key Exchange:
• Symmetric cryptography excels in encrypting large volumes of data
efficiently. However, the challenge lies in securely exchanging the
symmetric keys between parties.
• Asymmetric cryptography addresses this challenge by providing a secure
mechanism for key exchange. Parties can use asymmetric encryption to
securely transmit symmetric keys.
Hybrid Encryption:
• In a hybrid encryption scheme, asymmetric encryption is used for key
exchange, while symmetric encryption is used for encrypting the actual
data.
• The sender generates a symmetric key for encrypting the message and
encrypts this symmetric key using the recipient's public key.
• The recipient decrypts the symmetric key using their private key and
uses it to decrypt the encrypted message.
• This approach combines the efficiency of symmetric encryption with the
security of asymmetric encryption.
Secure Communication:
• By combining symmetric and asymmetric cryptography, secure
communication channels can be established.
• Asymmetric encryption is used for initial key exchange and
authentication, while symmetric encryption is employed for encrypting
the actual data transmission.
Examples:
Transport Layer Security (TLS): TLS protocols often use a hybrid
approach, where asymmetric encryption is used for key exchange (e.g.,
RSA or Diffie-Hellman) and symmetric encryption (e.g., AES) is used for
data transmission.
Pretty Good Privacy (PGP): PGP combines symmetric and asymmetric
encryption for secure email communication, file encryption, and digital
signatures.
DIGITAL SIGNATURE
Digital signatures are a cryptographic technique used to verify the authenticity
and integrity of digital messages or documents. They provide a way for the
recipient of a message to ensure that the message was created by a known
sender and that it has not been altered in transit.
Working of Digital Signature :
• Key Generation: The sender generates a key pair consisting of a private
key and a public key. The private key is kept secret, while the public key is
shared with others.
• Signing: To sign a message, the sender uses a cryptographic algorithm to
create a unique digital signature based on the message and their private
key. The signature is appended to the message.
• Verification: The recipient of the message uses the sender's public key to
verify the digital signature. They apply the same cryptographic algorithm
to the message and the signature, using the public key. If the result
matches the signature, the message is considered authentic and has not
been altered.
• A message digest has a fixed numeric size. If you count the number of
characters in the hashes provided in the image above, you see that
they both have 32 characters. Each hash algorithm produces a hash
of a fixed numeric size. MD5 hashes have 32 characters, while SHA1
hashes have 40 characters.
• It is impossible for two messages to have the same message digest.
• The message digest hashing algorithm is a one-way cryptographic
function. This means that it cannot be reversed and it is almost
impossible to get the original message from the hash.
Message digests are used to protect, verify, and ensure the integrity of a
message. They are designed to identify and discover changes made to the
message. They are used in different fields to protect copyrights and prove
ownership.
1. Data Integrity Verification: Message digests are used to verify that data
has not been altered or corrupted during transmission or storage. By
comparing the digest of received data with the original digest, one can
determine if the data has been tampered with.
2. Digital Signatures: In digital signatures, a message digest of the
document or message is created and then encrypted with the sender's
private key. The recipient can decrypt the digest using the sender's
public key and compare it with a newly computed digest of the received
message to verify the sender's identity and the integrity of the message.
3. Password Storage: Message digests are often used to securely store
passwords. Instead of storing the actual passwords, systems store the
message digests of passwords. When a user enters a password, the
system computes the message digest of the entered password and
compares it with the stored digest.
4. File Integrity Checking: Message digests can be used to verify the
integrity of files. By computing the message digest of a file and
comparing it with a previously computed digest, one can verify that the
file has not been modified or corrupted.
5. Cryptographic Protocols: Message digests are used in various
cryptographic protocols, such as SSL/TLS, to ensure the integrity and
authenticity of data exchanged over insecure channels.
Hash Function:
Definition: A hash function is a mathematical algorithm that takes an input (or
message) of arbitrary size and produces a fixed-size output, known as the hash
value or hash digest.
• Properties:
CONCLUSION
These cryptographic concepts form the foundation of secure communication,
data protection, and trust in digital transactions. Understanding and
implementing these concepts are essential for safeguarding sensitive
information and ensuring the security of digital systems in various domains,
including cybersecurity, finance, and ecommerce.