0% found this document useful (0 votes)
33 views6 pages

For Your Assignment Involving OpenSSL For Encrypting and Decrypting Data Using AES With Different Operating Modes

Uploaded by

Hari varsha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views6 pages

For Your Assignment Involving OpenSSL For Encrypting and Decrypting Data Using AES With Different Operating Modes

Uploaded by

Hari varsha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

For your assignment involving OpenSSL for encrypting and decrypting data using AES with different

operating modes, and timing those operations, here’s a structured approach on how to complete
the assignment. I'll guide you through the steps required to achieve the goals and prepare your
submission files (`[Link]` and `[Link]`).

### **Assignment Preparation**

1. **Ensure OpenSSL is Installed:**

Make sure the OpenSSL utility is installed on your Linux instance. You can verify this by running:

```bash

openssl version

```

2. **Prepare Your Environment:**

Set up the necessary directories and files for encryption and decryption tests. Create a sample text
file to use as input data:

```bash

echo "This is a test message for AES encryption and decryption." > [Link]

```

### **1. Encrypt and Decrypt Data Using OpenSSL**

**a. AES Encryption and Decryption Commands:**

You need to use OpenSSL commands to encrypt and decrypt data with AES in different modes (e.g.,
CBC, ECB, GCM). Below are the commands for different modes:

- **AES-256-CBC Encryption:**

```bash

openssl enc -aes-256-cbc -in [Link] -out encrypted_aes256_cbc.enc -pass pass:yourpassword

```

- `-aes-256-cbc`: Specifies AES with a 256-bit key in CBC mode.

- `-in [Link]`: Specifies the input file.


- `-out encrypted_aes256_cbc.enc`: Specifies the output encrypted file.

- `-pass pass:yourpassword`: Specifies the password for encryption.

- **AES-256-CBC Decryption:**

```bash

openssl enc -d -aes-256-cbc -in encrypted_aes256_cbc.enc -out decrypted_aes256_cbc.txt -pass


pass:yourpassword

```

- `-d`: Specifies decryption.

- **AES-256-ECB Encryption:**

```bash

openssl enc -aes-256-ecb -in [Link] -out encrypted_aes256_ecb.enc -pass pass:yourpassword

```

- `-aes-256-ecb`: Specifies AES with a 256-bit key in ECB mode.

- **AES-256-ECB Decryption:**

```bash

openssl enc -d -aes-256-ecb -in encrypted_aes256_ecb.enc -out decrypted_aes256_ecb.txt -pass


pass:yourpassword

```

- **AES-256-GCM Encryption:**

```bash

openssl enc -aes-256-gcm -in [Link] -out encrypted_aes256_gcm.enc -pass


pass:yourpassword -aes-256-gcm -p

```

- `-aes-256-gcm`: Specifies AES with a 256-bit key in GCM mode.

- `-p`: Print the initialization vector (IV) and tag used for GCM mode.

- **AES-256-GCM Decryption:**

```bash
openssl enc -d -aes-256-gcm -in encrypted_aes256_gcm.enc -out decrypted_aes256_gcm.txt -pass
pass:yourpassword -aes-256-gcm -p

```

**b. Save Commands in `[Link]`:**

Create `[Link]` and include the OpenSSL commands you used for encryption and decryption in
different modes. For each mode, list the commands with explanations.

Example `[Link]` content:

```

# AES-256-CBC Encryption

openssl enc -aes-256-cbc -in [Link] -out encrypted_aes256_cbc.enc -pass pass:yourpassword

# AES-256-CBC Decryption

openssl enc -d -aes-256-cbc -in encrypted_aes256_cbc.enc -out decrypted_aes256_cbc.txt -pass


pass:yourpassword

# AES-256-ECB Encryption

openssl enc -aes-256-ecb -in [Link] -out encrypted_aes256_ecb.enc -pass pass:yourpassword

# AES-256-ECB Decryption

openssl enc -d -aes-256-ecb -in encrypted_aes256_ecb.enc -out decrypted_aes256_ecb.txt -pass


pass:yourpassword

# AES-256-GCM Encryption

openssl enc -aes-256-gcm -in [Link] -out encrypted_aes256_gcm.enc -pass pass:yourpassword


-aes-256-gcm -p

# AES-256-GCM Decryption

openssl enc -d -aes-256-gcm -in encrypted_aes256_gcm.enc -out decrypted_aes256_gcm.txt -pass


pass:yourpassword -aes-256-gcm -p

```
### **2. Timing AES Operations**

**a. Time AES Operations:**

Use the `time` command to measure the duration of encryption and decryption operations. For
example:

- **AES-256-CBC Encryption Timing:**

```bash

time openssl enc -aes-256-cbc -in [Link] -out encrypted_aes256_cbc.enc -pass


pass:yourpassword

```

- **AES-256-CBC Decryption Timing:**

```bash

time openssl enc -d -aes-256-cbc -in encrypted_aes256_cbc.enc -out decrypted_aes256_cbc.txt -


pass pass:yourpassword

```

Repeat these commands for each AES mode you tested. Record the times reported by the `time`
command.

**b. Save Timing Results in `[Link]`:**

Create `[Link]` and include the timing results for each AES operation. Provide a brief summary
of the results, indicating the time taken for encryption and decryption in each mode.

Example `[Link]` content:

```

# Timing for AES-256-CBC Encryption

real 0m0.002s

user 0m0.001s
sys 0m0.001s

# Timing for AES-256-CBC Decryption

real 0m0.002s

user 0m0.001s

sys 0m0.001s

# Timing for AES-256-ECB Encryption

real 0m0.002s

user 0m0.001s

sys 0m0.001s

# Timing for AES-256-ECB Decryption

real 0m0.002s

user 0m0.001s

sys 0m0.001s

# Timing for AES-256-GCM Encryption

real 0m0.003s

user 0m0.002s

sys 0m0.001s

# Timing for AES-256-GCM Decryption

real 0m0.003s

user 0m0.002s

sys 0m0.001s

```

### **Submission**

1. **Create `[Link]`** with the OpenSSL commands used.


2. **Create `[Link]`** with the timing results of AES operations.

3. **Submit** both `[Link]` and `[Link]` as per your assignment submission guidelines.

By following these steps, you will be able to effectively demonstrate your ability to use OpenSSL for
AES encryption and decryption, and accurately report the performance of these operations.

You might also like