Cryptography is the conversion of communicated information into secret code that keeps the information confidential and private. Functions include authentication, data integrity, and nonrepudiation. The central function of cryptography is encryption, which transforms data into an unreadable form.
Encryption ensures privacy by keeping the information hidden from people who the information is not intended for. Decryption, the opposite of encryption, transforms encrypted data back into data; it won't make any sense until it has been properly decrypted.
I connected to a file server that is hosted on an Amazon Elastic Compute Cloud (Amazon EC2) instance. I configured the AWS Encryption command line interface (CLI) on the instance. I created an encryption key by using the AWS Key Management Service (AWS KMS). The key was used to encrypt and decrypt data. Next, I created multiple text files that were unencrypted by default. I then used the AWS KMS key to encrypt the files and viewed them while they were encrypted. I finished by decrypting the same files and viewing the contents.
After completion , I was able to:
In this task, I created an AWS KMS key that I later used to encrypt and decrypt data.
With AWS KMS, I could create and manage cryptographic keys and control their use across a wide range of AWS services and in my applications. AWS KMS is a secure and resilient service that uses hardware security modules (HSMs) that have been validated under the Federal Information Processing Standard (FIPS) Publication 140-2, or are in the process of being validated, to protect my keys.
In the console, I entered KMS in the search bar, and then chose Key Management Service.
I chose Create a key.
For Key type, I chose Symmetric, and then chose Next.
On the Add labels page, I configured the following:
I chose Next.
On the Define key administrative permissions page, in the Key administrators section, I searched for and selected the check box for voclabs and then chose Next.
On the Define key usage permissions page, in the This account section, I searched for and selected the check box for voclabs and then chose Next.
I reviewed the settings, and then chose Finish.
I chose the link for MyKMSKey, which I just created, and copied the ARN (Amazon Resource Name) value to a text editor.
I used this copied ARN later on.
In this task, I created a symmetric AWS KMS key and gave ownership of that key to the IAM role that was pre-created for this environment.
Before I could encrypt and decrypt data, I needed to set up a few things. To use my AWS KMS key, I configured AWS credentials on the File Server EC2 instance. After that, I installed the AWS Encryption CLI (aws-encryption-cli), which I used to run encrypt and decrypt commands.
In the console, I entered EC2 in the search bar, and then chose EC2.
In the Instances list, I selected the check box next for the File Server instance, and then chose Connect.
I chose the Session Manager tab, and then chose Connect.
To change to the home directory and create the AWS credentials file, I ran the following commands:
When prompted, I configured the following:
The AWS configuration file was created, and I updated it in a later step. The previous entries of 1 were temporary placeholders.
I navigated to the Vocareum console page, and chose the AWS Details button.
Next to AWS CLI, I chose Show.
I copied and pasted the code block, which starts with [default], into a text editor.
I returned to the browser tab where I was logged in to the File Server.
To open the AWS credentials file, I ran the following command:
In the ~/.aws/credentials file, I typed dd multiple times to delete the contents of the file.
I pasted in the code block that I copied from Vocareum.
To save and close the file, I pressed Escape, typed :wq and then pressed Enter.
To view the updated contents of the file, I ran the following command:
Now I installed the AWS Encryption CLI and exported my path. By doing this, I was able to run the commands to encrypt and decrypt data.
To install the AWS Encryption CLI and set my path, I ran the following commands:
In this task, I configured the AWS credentials file, which provides the ability to use the AWS KMS key that I created earlier. I then installed the AWS Encryption CLI, so that I could run encryption commands.
In this task, I created a text file with mock sensitive data in it. I then used encryption to secure the file contents. Then, I decrypted the data and viewed the file contents.
To create the text file, I ran the following commands:
To view the contents of the secret1.txt file, I ran the following command:
To create a directory to output the encrypted file, I ran the following command:
I copied and pasted the following command to a text editor:
In the text editor, I replaced (KMS ARN) with the AWS KMS ARN that I copied in task 1.
I ran the updated command in the File Server terminal.
To encrypt the secret1.txt file, I ran the following command:
The following information describes what this command does:
To determine whether the command succeeded, I ran the following command:
If the command succeeded, the value of $? is 0. If the command failed, the value is nonzero.
To view the newly encrypted file location, I ran the following command:
The output looked like the following:
To view the contents of the newly encrypted file, I ran the following command:
When data has been transformed into ciphertext, the plaintext becomes inaccessible until it's decrypted.
A symmetric key and algorithm are used to convert a plaintext message into ciphertext.
I pressed Enter.
Next, I decrypted the secret1.txt.encrypted file.
To decrypt the file, I ran the following commands:
To view the new file location, I ran the following command:
The secret1.txt.encrypted.decrypted file contained the decrypted contents from the secret1.txt.encrypted file.
To view the contents of the decrypted file, I ran the following command:
After successful decryption, I could now see the original plaintext contents of the secret1.txt.
I now have successfully: