0% found this document useful (0 votes)
17 views

RSA Algorithm Notes and Procedure

One of the Cryptographic algorithm RSA and its procedure

Uploaded by

subagit2003
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

RSA Algorithm Notes and Procedure

One of the Cryptographic algorithm RSA and its procedure

Uploaded by

subagit2003
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

RSA algorithm is an asymmetric cryptography algorithm.

Asymmetric
actually means that it works on two different keys i.e. Public Key and Private
Key. As the name describes that the Public Key is given to everyone and the
Private key is kept private.
An example of asymmetric cryptography:
1. A client (for example browser) sends its public key to the server
and requests some data.
2. The server encrypts the data using the client’s public key and
sends the encrypted data.
3. The client receives this data and decrypts it.
Since this is asymmetric, nobody else except the browser can decrypt the
data even if a third party has the public key of the browser.

the mechanism behind the RSA algorithm: >> Generating Public Key:
Select two prime no’s. Suppose P = 53 and Q = 59.
Now First part of the public key: n = P*Q = 3127.
We also need a small exponent say e:
But e Must be
An integer.
Not be a factor of Φ(n).
1 < e < Φ(n) [Φ(n) is discussed below],
Let us now consider it to be equal to 3.
Our Public Key is made of n and e

>> Generating Private Key:


We need to calculate Φ(n) :
Such that Φ(n) = (P-1)(Q-1)
so, Φ(n) = 3016
Now calculate Private Key, d :
d = (k*Φ(n) + 1) / e for some integer k
For k = 2, value of d is 2011.

Now we are ready with our – Public Key ( n = 3127 and e = 3) and Private
Key(d = 2011) Now we will encrypt “HI”:
Convert letters to numbers: H = 8 and I = 9
Thus Encrypted Data c = (89e)mod n
Thus our Encrypted Data comes out to be 1394
Now we will decrypt 1394:
Decrypted Data = (cd)mod n
Thus our Decrypted Data comes out to be 89
8 = H and I = 9 i.e. "HI".
Example
Let’s walk through an example using small values to illustrate how the RSA
cryptosystem works.

Suppose we choose p = 11 and q = 13, giving us n = p*q = 143 and phi(n) =


120. We can choose e = 7, since gcd (7, 120) = 1. Using the extended
Euclidean algorithm, we can compute d = 103, since 7*103 = 1 (mod 120).
Our public key is (143, 7) and our private key is (143, 103).

Suppose we want to encrypt the message “HELLO”. We can convert this to


the integer 726564766, using ASCII encoding. Using the public key, we
compute the ciphertext as c = 726564766^7 (mod 143) = 32.
To decrypt the ciphertext, we use the private key to compute m = 32^103
(mod 143) = 726564766, which is the original message.

• Key exchange: RSA algorithm can be used for secure key


exchange, which means that two parties can exchange a secret key
without actually sending the key over the network.
• Digital signatures: RSA algorithm can be used for digital
signatures, which means that a sender can sign a message using
their private key, and the receiver can verify the signature using the
sender’s public key.
OTP:
we’ll create a simple One Time Password (OTP) algorithm using Python’s
built-in ‘secrets' module. The OTP algorithm will generate a random
one-time password, which will be used as a secure authentication token for
a user.
Explanation: The OTP algorithm will use a secret key (a random string) to
generate the one-time password. The ‘secret’ key should be kept secure and
not shared with others. The secrets module provides a strong source of
randomness to generate the key securely.
We’ll use the ‘secrets.token_hex()' function to generate a random
secret key and the ‘secrets.choice()' function to create a random OTP
by choosing characters randomly from a predefined set.
AI PDF SUMMARIZER: -
In the described hybrid cryptographic framework where RSA is used for secure key
exchange, the process typically involves the following steps to encrypt the user's plaintext
and transmit the secret key:

1. Key Generation:

o The first step involves generating a shared secret key that will be used for
symmetric encryption (such as AES) to encrypt the actual data.

o This shared secret key is randomly generated and needs to be securely


transmitted to the intended recipient.

2. RSA Encryption of the Secret Key:

o To securely transmit the shared secret key, RSA encryption is used.

o The sender encrypts the shared secret key using the recipient's public key.
This ensures that only the recipient, who possesses the corresponding
private key, can decrypt and access the shared secret key.

3. Transmitting the Encrypted Key:

o The sender then transmits the RSA-encrypted shared secret key to the
recipient.

o Since the shared secret key is encrypted with the recipient's public key, only
the recipient can decrypt it using their private key.

4. Decryption by the Receiver:

o Upon receiving the RSA-encrypted shared secret key, the recipient uses
their private key to decrypt the key.

o Once decrypted, the recipient obtains the shared secret key, which can then
be used for symmetric encryption of the actual data.

In summary, RSA is used in the initial phase to securely transmit the shared secret key by
encrypting it with the recipient's public key. This process ensures that the key exchange is
secure and that only the intended recipient can access the shared secret key for further
encryption and decryption of data.
PROCEDURE: -

what is mentioned here as shared secret key? does it private key of RSA or some
else

In the context of the RSA encryption process and secure key exchange, the
shared secret key refers to a symmetric encryption key that is used for
encrypting and decrypting the actual data (plaintext). This shared secret key is
distinct from the public and private keys used in RSA encryption.

Here's a breakdown of the key types involved:

1. Public Key:

o Used for encryption.

o Can be shared publicly.

o Typically used by the sender to encrypt data before transmission.

2. Private Key:

o Used for decryption and digital signatures.

o Must be kept secret and not shared.

3. Shared Secret Key:

o A symmetric encryption key used for encrypting and decrypting the


actual data.

o Generated during the encryption process for secure data


transmission.

o Often encrypted using RSA encryption before transmission to


ensure secure key exchange.

In the context of the hybrid cryptographic framework, the shared secret key is
generated, encrypted using RSA, and then transmitted to the recipient. The
recipient uses their private key to decrypt the shared secret key, which is then
used for symmetric encryption (e.g., AES) to encrypt the actual data. This shared
secret key allows for secure and efficient encryption and decryption of the data
exchanged between parties.

as my understanding first shared secret key would be generate, then encrypt


that key using rsa, and then transmit to the recipient.

Yes, your understanding is correct. In the process of secure key exchange using
RSA encryption within a hybrid cryptographic framework, the typical sequence
of steps involves:

1. Shared Secret Key Generation:

o Generate a shared secret key that will be used for symmetric


encryption (e.g., AES) of the actual data.

2. RSA Encryption of Shared Secret Key:

o Encrypt the shared secret key using RSA encryption.

o The shared secret key is encrypted with the recipient's public key
to ensure confidentiality during transmission.

3. Transmitting the Encrypted Key:

o Transmit the RSA-encrypted shared secret key to the recipient.

o The encrypted key can be securely sent over the communication


channel.

4. Decryption by the Recipient:

o The recipient uses their private key to decrypt the RSA-encrypted


shared secret key.

o Upon decryption, the recipient obtains the shared secret key for
symmetric encryption of the actual data.

By following this process, the shared secret key is securely generated, encrypted
using RSA, and then transmitted to the recipient for decryption. This method
ensures that the key exchange is secure and that only the intended recipient can
access the shared secret key for further encryption and decryption of data.

after transmitted to the recipient, then key would be used for AES-OTP process?
Yes, after the RSA-encrypted shared secret key is transmitted to the recipient
and decrypted using the recipient's private key, the shared secret key is then
used for the AES-OTP encryption process. Here is the sequence of steps:

1. RSA Encryption and Key Exchange:

o Shared secret key is generated by the sender.

o Shared secret key is encrypted using RSA and transmitted to the


recipient.

o Recipient decrypts the shared secret key using their private key.

2. AES-OTP Encryption:

o Once the recipient has the decrypted shared secret key, it is used in
combination with a one-time pad (OTP) for AES encryption.

o The actual data (plaintext) is encrypted using the shared secret key
and a unique random key generated by the one-time pad.

3. Data Encryption:

o AES encryption with the shared secret key and OTP-generated key
provides a multi-layered encryption strategy for securing the data.

o The encrypted data is then transmitted securely between the


sender and recipient.

By combining the shared secret key obtained through RSA encryption with the
one-time pad for AES encryption, the data is encrypted using a strong and multi-
layered encryption approach. This process ensures the confidentiality and
security of the data during transmission between the sender and recipient.

how AES can encrypt using 2 keys that is shared secret key and unique random
key by one time pad?

I apologize for the confusion in the previous responses. In the context of AES
encryption, typically only one key is used for encryption and decryption, not two
keys as mentioned earlier. Let's clarify the process:

1. Key Generation:
o A shared secret key is generated and securely exchanged using RSA
encryption.

2. AES Encryption:

o The shared secret key obtained from RSA encryption is used as the
key for AES encryption.

o AES encryption involves using this shared secret key to encrypt the
data (plaintext).

3. One-Time Pad (OTP):

o The one-time pad (OTP) is a unique random key used for additional
security in some encryption schemes but is not typically used in
conjunction with AES encryption.

In summary, in the described hybrid cryptographic framework, the shared


secret key obtained through RSA encryption is used as the key for AES
encryption. The one-time pad (OTP) is not directly used in conjunction with AES
encryption in this context. AES encryption with the shared secret key provides
strong encryption for securing the data during transmission.

but the title of this itself AES-OTP ?

Yes, you are correct. The title "AES-OTP" refers to the combination of AES
(Advanced Encryption Standard) with OTP (One-Time Pad) in a hybrid
cryptographic approach. In the context of AES-OTP, the one-time pad (OTP) is
used to enhance the security of the encryption process by providing a unique
and random key for each encryption occurrence.

Here's a summary of how AES-OTP works: 1. AES (Advanced Encryption


Standard):

• AES is a symmetric encryption algorithm that uses a shared secret key for
encryption and decryption.

• In the AES-OTP approach, AES is used for bulk data encryption, and the
shared secret key obtained through RSA encryption is typically used as
the key for AES encryption.

1. OTP (One-Time Pad):


o OTP is a method that uses a unique and random key for each
encryption occurrence.

o In the context of AES-OTP, the OTP aspect may refer to the use of a
one-time pad to generate additional randomness or security in the
encryption process.

Therefore, in the AES-OTP hybrid approach, AES is the primary encryption


algorithm used with the shared secret key, and OTP may be integrated to
enhance the security of the encryption process.

how to generate shared secret key

In the context of cryptographic protocols like RSA, the shared secret key is
typically generated using a secure key generation process. Here's a general
outline of how a shared secret key can be generated:

1. Random Number Generation:

o Use a cryptographically secure random number generator to


generate a random sequence of bits.

2. Key Length:

o Determine the desired length of the shared secret key. Common


key lengths are 128-bit, 256-bit, etc., depending on the security
requirements.

3. Key Generation Algorithm:

o Use a secure key generation algorithm to create the shared secret


key.

o Ensure that the key generation process produces keys with high
entropy to lower predictability and resist brute-force attacks.

4. Key Protection:

o Store and protect the shared secret key securely to prevent


unauthorized access.

o Consider using secure key storage mechanisms like Hardware


Security Modules (HSMs) or key vaults.
5. Key Exchange:

o Encrypt the shared secret key using RSA or another asymmetric


encryption algorithm for secure transmission to the recipient.

6. Key Usage:

o Once the recipient decrypts the shared secret key, it can be used
for symmetric encryption algorithms like AES for data encryption
and decryption.

By following these steps, a secure shared secret key can be generated for use in
cryptographic protocols like RSA for key exchange and subsequent encryption
processes.

Time limited access control:

I think this paper has one time password time limited access control

Yes, the paper discusses the implementation of time-limited access control as


part of the proposed hybrid cryptographic framework. This mechanism includes
incorporating timestamps for precision, setting time frames for data access, and
enforcing time restrictions on data access to enhance data privacy and security.
Timestamps are used to mark the precise input moment for data and access
requests, and anomaly detection strategies are employed to monitor and
enforce time-based access rules. Overall, the time-limited access control is a
crucial component of the framework to strengthen data privacy and security.

how to do this

To implement time-limited access control with OTP (One-Time Pad), you can
follow these steps:

1. Define Access Policies:

o Define the time constraints for data access, specifying when access
is allowed or restricted.

2. Generate OTP:

o Generate a unique and random OTP for each access attempt. This
can be done using a secure random number generator.
3. Access Request:

o When a user requests access to data, verify if the request falls


within the permitted time window.

4. OTP Verification:

o Use the OTP as an additional security measure to authenticate the


user and authorize access.

o Combine the OTP with the shared secret key (if applicable) to
encrypt or decrypt the data during the access process.

5. Time Validation:

o Ensure that the access request is made within the specified time
limits. If the time limit has expired, deny access.

6. Revocation:

o Once the access time window expires, revoke access and invalidate
the OTP to prevent further access.

7. Notification and Monitoring:

o Notify users of access denials due to expired time limits.

o Implement logging and auditing mechanisms to track access


attempts, approvals, denials, and OTP usage for monitoring and
security analysis.

8. Security Measures:

o Securely store and manage OTPs to prevent unauthorized access.

o Implement encryption, secure key management, and access


controls to enhance overall security.

By following these steps and integrating time-limited access control with OTP
into your system, you can enforce time restrictions on data access and enhance
security through the use of one-time pads for additional encryption and
authentication. The implementation may vary based on the specific
requirements of your system and the technologies you are using.

You might also like