In this lecture I want to show you how to symmetrically encrypt a file for our recipient and sign it
in one step.
This will attach the signatures to the encrypted file. To asymmetrically encrypt a file
you need the public key of the recipient who will decrypt the message with the corresponding private
key.
We've seen a lot of examples in the previous lectures.
I'm creating a new file called topsecret.txt.
I'm using an output redirection!
You can create the file in any way you want!
This is the file.
I'm gonna encrypt and sign the file for the other user on Kali Linux.
I've already imported its public key in the gpg keyring. Let's see the keyring gpg --list-keys
This is the public key.
Let's see its id.
And the keyid on the other machine!
We notice that this public key is also in the gpg keyring of the user on Kali Linux and I'm executing
gpg -e -r and the key id; - r comes from recipient
--sign and the file; it's asking for a confirmation and I'm choosing yes; the file will be signed
with my private key so I must unlock it.
The generated file called topsecret.txt.gpg is encrypted and contains the signature
of the original file. Let's transfer the encrypted and signed file to the recipient,
the one that has the private key to decrypt it.
This is the IP address
and I am checking if ssh is running; I'm gonna copy the file using asp and acp uses ssh; I am starting
ssh systems stl.
start ssh
ssh is running so acp, the file, Kali, the user at the IP address of the server.
And the file was copied.
It's in the home directory of user
kali, here; this is the file!
It's encrypted and signed! Let's decrypt and verified the signature of the file.
So gpg --decrypt and the name of the file topsecret.txt.gpg; the file will
be decrypted with the private key and I must unlock it.
-d or -- decrypt option will automatically verified the signature, if there is one,
detect if the symmetric or asymmetric encryption was used,
choose the appropriate private key, if available, and prompts for the passphrase,
if the encryption was symmetric and the private key is locked with a passphrase! Okay.
Perfect.
This is the information, the clear text content of the file,
top secret information and the signature is good.
If you want to create a new file that contains only the content you add -0 or --output
option like this.
Perfect!
It's a good signature in the new file called file.txt was created.
It contains the secret content,
the same content.