0% found this document useful (0 votes)
10 views8 pages

Security+ Lesson 3

The document provides a comprehensive guide on using AES Crypt and OpenSSL for file encryption and digital signatures. It includes step-by-step instructions for downloading the necessary tools, generating keys, encrypting and decrypting files, and creating and verifying digital signatures. Additionally, it outlines various use cases for digital signatures in enhancing security across different domains.

Uploaded by

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

Security+ Lesson 3

The document provides a comprehensive guide on using AES Crypt and OpenSSL for file encryption and digital signatures. It includes step-by-step instructions for downloading the necessary tools, generating keys, encrypting and decrypting files, and creating and verifying digital signatures. Additionally, it outlines various use cases for digital signatures in enhancing security across different domains.

Uploaded by

sir.rjd6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

By ENG AHMED FATOUH

encryption using aescrypt

Download tool from here -->


https://www.aescrypt.com/download/
Download This Version --> - [AES Crypt - Command-Line
(Windows 64-bit Intel/AMD)]
(https://www.aescrypt.com/download/v4/windows/aescrypt_cl
i-4.0.7-Windows-x86_64.zip) (64-bit stand-alone
executable)

Open PowerShell
cd .\Downloads\
cd .\AESCrypt_console_v310_x64\
notepad.exe example.txt
.\aescrypt.exe -e -p gaza123 .\example.txt
rm .\example.txt
.\aescrypt.exe -d -p gaza123 .\example.txt.aes

Install OpenSSL in windows


1. download openssl in windows from here
2. Run the Installer
3. open powershell as administrator
$env:Path += ";C:\Program Files\OpenSSL-Win64\bin"

[System.Environment]::SetEnvironmentVariable("Path",
$env:Path + ";C:\Program Files\OpenSSL-Win64\bin",
[System.EnvironmentVariableTarget]::Machine)

openssl
using Asymmatric to encrypt files

#### 1. Generating the Private Key


PS C:\Users\ABAD\Downloads> openssl genpkey -algorithm
RSA -out private_key.pem -pkeyopt rsa_keygen_bits:2048
- `openssl`: This is the command-line tool for using the
OpenSSL cryptography library.
- `genpkey`: This command generates a private key.
- `-algorithm RSA`: Specifies that we want to generate an
RSA key pair.
- `-out private_key.pem`: The generated private key will
be saved to a file named `private_key.pem`.
- `-pkeyopt rsa_keygen_bits:2048`: This sets the key size
to 2048 bits, which is a common and secure key length.

#### 2. Extracting the Public Key


PS C:\Users\ABAD\Downloads> openssl rsa -pubout -in
private_key.pem -out public_key.pem
- `openssl`: Again, the OpenSSL tool.
- `rsa`: This command is used to process RSA keys.
- `-pubout`: This flag tells the command to output the
public key.
- `-in private_key.pem`: Specifies the input file, which
contains the private key.
- `-out public_key.pem`: The extracted public key will be
saved to a file named `public_key.pem`.

### 3. Encrypt a File


PS C:\Users\ABAD\Downloads> openssl pkeyutl -encrypt -in
example.txt -pubin -inkey public_key.pem -out
example.txt.enc
- `openssl`: The OpenSSL tool.
- `pkeyutl`: This command is used for public key
cryptographic operations, such as encryption.
- `-encrypt`: Specifies that we want to encrypt data.
- `-in example.txt`: The file `example.txt` contains the
data we want to encrypt.
- `-pubin`: Indicates that the key provided is a public
key.
- `-inkey public_key.pem`: Specifies the public key file
to use for encryption.
- `-out example.txt.enc`: The encrypted data will be
saved to a file named `example.txt.enc`.

### 4. Decrypt the File


PS C:\Users\ABAD\Downloads> openssl pkeyutl -decrypt -in
example.txt.enc -inkey private_key.pem -out
decrypted_example.txt
- `openssl`: The OpenSSL tool.
- `pkeyutl`: Used for public key cryptographic
operations.
- `-decrypt`: Specifies that we want to decrypt data.
- `-in example.txt.enc`: The file `example.txt.enc`
contains the encrypted data.
- `-inkey private_key.pem`: Specifies the private key
file to use for decryption.
- `-out decrypted_example.txt`: The decrypted data will
be saved to a file named `decrypted_example.txt`.
Digital Signature

A digital signature is a way to ensure that a digital


message or document is authentic and hasn't been tampered
with. It works similarly to a handwritten signature, but
it's even more secure because it uses cryptography.

When you digitally sign a document, you use your private


key to create the signature. This signature is unique to
both the document and your key. Anyone who has your public
key can then verify the signature, confirming that it was
indeed signed by you and that the document hasn't been
altered since it was signed.

Use Cases for Digital Signatures


Email Security: Digital signatures can be used to sign
emails, ensuring that the email content is genuine and
that it comes from the stated sender.
Legal Documents: Contracts, agreements, and other legal
documents can be signed digitally, which makes the
process faster and more secure than using physical
signatures.
Software Distribution: Software developers can sign their
applications, ensuring that the software hasn't been
tampered with and that it comes from a legitimate
source.
Financial Transactions: Banks and financial institutions
use digital signatures to authorize transactions,
making online banking and digital payments secure.
Government and Public Services: Digital signatures are used
in e-governance for submitting forms, applications, and
other documents, ensuring authenticity and efficiency.
You can use OpenSSL to create and verify
digital signatures. Here’s a simple example
showing how to digitally sign a file and then
verify the signature using OpenSSL.

#### 1. Generate Private Key


PS C:\Users\ABAD\Downloads> openssl genpkey -algorithm
RSA -out private_key.pem -pkeyopt rsa_keygen_bits:2048

#### 2. Extract the Public Key


PS C:\Users\ABAD\Downloads> openssl rsa -pubout -in
private_key.pem -out public_key.pem

### 3. Sign the File


#### Create a SHA256 Hash of the File and Sign it
PS C:\Users\ABAD\Downloads> openssl dgst -sha256 -sign
private_key.pem -out document.txt.sig document.txt
- `dgst -sha256`: This specifies the hashing algorithm
(SHA-256) to use.
- `-sign private_key.pem`: Indicates that we are signing
the file with the private key.
- `-out document.txt.sig`: The resulting digital
signature will be saved in this file.
- `document.txt`: The file that you are signing.

### 4. Verify the Signature


PS C:\Users\ABAD\Downloads> openssl dgst -sha256 -verify
public_key.pem -signature document.txt.sig document.txt
- `dgst -sha256`: Specifies the hashing algorithm used.
- `-verify public_key.pem`: Indicates the use of the
public key to verify the signature.
- `-signature document.txt.sig`: The file containing the
signature to verify.
- `document.txt`: The original file to compare against
the signature.

You might also like