Experiment No. 8: Aim: Theory
Experiment No. 8: Aim: Theory
Theory:
Pretty Good Privacy (PGP) is a data encryption and decryption computer program
that provides cryptographic privacy and authentication for data communication.
PGP is often used for signing, encrypting, and decrypting texts, e-mails, files,
directories, and whole disk partitions and to increase the security of e-mail
Communications.
GPG:
GNU Privacy Guard (GnuPG or GPG) is a free software replacement for
Symantec’s PGP cryptographic software suite. GnuPG is a hybrid-encryption
software program because it uses a combination of conventional symmetric-key
cryptography for speed, and public-key cryptography for ease of secure key
exchange, typically by using the recipient’s public key to encrypt a session key
which is only used once. This mode of operation is part of the OpenPGP standard
and has been part of PGP from its first version.
GPG allows for the secure transmission of information and can be used to verify that the origin
of a message is genuine. Below are few commands that can be used:
Commands:
1. Generate key pair
$gpg --gen-key
2. Create revocation certificate
$gpg --gen -revoke [email protected]
3. Import others public key
$gpg --import public_key_file
4. Sign the key received from other person
$gpg --sign -key [email protected]
5. Send the signed key back to sender
$gpg --export --armor [email protected]
6. Import the received signed key
$gpg --import signed_key_file_name
7. List public keys
$gpg --list--keys
8. Update keys
$gpg --refresh-keys
9. Encrypt file for particular user
$gpg --encrypt --recipient [email protected] file.txt
10. Encrypt file for self
$gpg --encrypt --recipient [email protected] file.txt
11. Decrypt text/binary file
$gpg encrypted_file.gpg
Procedure:
Step1: Installation of gpg
$ sudo apt-get install gnupg
Conclusion:
GPG is used for authentication and privacy to messages over the internet. GPG
was originated to address the security concerns of plain email or text messages.
Gnupg is used to demonstrate usage of GPG.
Output:
Installation:
root@kali:~# sudo apt-get install gnupg
Reading package lists... Done
Building dependency tree
Reading state information... Done
gnupg is already the newest version (2.2.20-1).
gnupg set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Key Generation:
root@kali:~# gpg --gen-key
gpg (GnuPG) 2.2.20; Copyright (C) 2020 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Note: Use "gpg --full-generate-key" for a full featured key generation dialog.
We need to generate a lot of random bytes. It is a good idea to perform some other action (type
on the keyboard, move the mouse, utilize the disks) during the prime generation; this gives the
random number generator a better chance to gain enough entropy.
We need to generate a lot of random bytes. It is a good idea to perform some other action (type
on the keyboard, move the mouse, utilize the disks) during the prime generation; this gives the
random number generator a better chance to gain enough entropy.
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key 0861AFC411E95FCD marked as ultimately trusted
gpg: directory '/root/.gnupg/openpgp-revocs.d' created
gpg: revocation certificate stored as '/root/.gnupg/openpgp-
revocs.d/5277FDBEB8C5E8FAF27127150861AFC411E95FCD.rev'
public and secret key created and signed.
Listing Keys:
root@kali:~# gpg --list-keys
gpg: checking the trustdb
gpg: marginals needed: 3 completes needed: 1 trust model: pgp
gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
gpg: next trustdb check due at 2022-03-31
/root/.gnupg/pubring.kbx
------------------------
pub rsa3072 2020-03-31 [SC] [expires: 2022-03-31]
5277FDBEB8C5E8FAF27127150861AFC411E95FCD
uid [ultimate] tambe <[email protected]>
sub rsa3072 2020-03-31 [E] [expires: 2022-03-31]
mQGNBF6DSYcBDACxsWMmIQTfmnDUcA1/Zpius4pWo9XYdR/gZ97HjFFEKRN2OoyF
szORrC99yQdWb28fBZ3elFb2Y//pK90qh/brrUnncw7FuYD6FMyr87Itfxcb904q
pv+pjTnd3pIZmih9YEE+vDnAiU53gjOp9X05o80t3YdPnMV+zxCtpxHd9AW+Wz1l
vHCFiDUPoQvWv/jNOuXASYbO23UXABadv/lOAvrmN6xDs83D02WkSNDwnhkbFgRR
OfSICD0N8LlY1szgG25nkdnPHfj4djMUOQy6hpaDpE9Ax5kx5Tmo2HfN6SROiAml
re8F4/7NShjGFh7amuIZOzHJqPqxAH2eTg8fWse6+CI+KpGJy4bfzo7odmFoD1Wb
iikrZniikFs6HxUQVcR9Mc7dzAtWMNBiM5h0Juu4DmyubMM3Hr5GxYmZXLng0mvu
cEIB0buR33eWzGiqvOEX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5klyzEhEM/s7/Hqdg219EsKty1
kIwbp8h0wiTcPuDzco/WTw8ZCRJlcEiBPkewAMso28CkODjm4OwrOw1mhoRoG1vt
xmrZ32W+2ZqlqnaxOwexpgBVY1jgyWetmTcGTXp++FbaV91v82uhmUwxu7s46SnA
k20ScBj3TGBVQalwfAnanWumidMKsF774imm33w2qJfJ+J9g9bqIvMB00DkzXA6o
JtpZGwARAQABiQG8BBgBCgAmFiEEUnf9vrjF6PrycScVCGGvxBHpX80FAl6DSYcC
GwwFCQPCZwAACgkQCGGvxBHpX814Sgv/flFfA1zlwXLdKK29fxa/d0bokZLcAaK0
/s4711Ruy7WNzRDTky1CiHB7Y2C7m3K7qiU9Nk2WAVGog46a6GAxmSU03sQ+jqbH
n/gvB9qGxhMZshTPhboFecnCD0iAx6Xi/LXKBcbJ3LEm9lNpDZPVbj4IAUTUDDMk
wwfpByHn2UJusDLZdvdXXTRyYWwf3ZJLfjhPWvWZJa89YqM7QvCMRhsZUPmfdDwS
L4VhRodQw6g6GWy+PCOeSmq+Tgi6u9bZVPHmSV48X11NgORguRFJ6hzbppHTFFTz
stoXUi7vaMXR1G72RskCz0jJCGpxo8Lv/K9UWtDq+649VbJ32PoPA4gDUsVNdR2N
89wUNt/WqaYbNC4IxDidz3hoJr5+Os60ZO/JY7/ZTkXAAaJ2ZGCnGsUsrSK0PFnV
JavQpS70YCUp0uUMM/8VKFCnRoYtcB01a0IqCJhUikkZKBLmg4f16dQN2KJoXtGM
1P4EkxDzofoy5EZvacFvTzCHPA4ZsXmY =O1A/
-----END PGP PUBLIC KEY BLOCK-----
root@kali:~# gpg --gen-key
gpg (GnuPG) 2.2.20; Copyright (C) 2020 Free Software Foundation, Inc. This is free software:
you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by
law.
Note: Use "gpg --full-generate-key" for a full featured key generation dialog.
We need to generate a lot of random bytes. It is a good idea to perform some other action (type
on the keyboard, move the mouse, utilize the disks) during the prime generation; this gives the
random number generator a better chance to gain enough entropy.
gpg: key E2EAED01CD1F2B0A marked as ultimately trusted
gpg: revocation certificate stored as '/root/.gnupg/openpgp-
revocs.d/6BA0DD9A7D62FFF169D659FBE2EAED01CD1F2B0A.rev'
public and secret key created and signed.
Signing process:
root@kali:~# gpg --edit-key [email protected]
gpg (GnuPG) 2.2.20; Copyright (C) 2020 Free Software Foundation, Inc. This is free software:
you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by
law.
sec rsa3072/0861AFC411E95FCD
created: 2020-03-31 expires: 2022-03-31 usage: SC
trust: ultimate validity: ultimate
ssb rsa3072/5D158106022B0394
created: 2020-03-31 expires: 2022-03-31 usage: E
[ultimate] (1). tambe <[email protected]>
gpg> fpr
pub rsa3072/0861AFC411E95FCD 2020-03-31 tambe
<[email protected]>
Primary key fingerprint: 5277 FDBE B8C5 E8FA F271 2715 0861 AFC4
11E9 5FCD
gpg> sign
"tambe <[email protected]>" was already signed by key
0861AFC411E95FCD
Nothing to sign with key 0861AFC411E95FCD
gpg> quit
Encryption & Decryption:
root@kali:~# cat > secrets
Hello
stay safe
^C
Encryption:
root@kali:~# gpg --out secrets_shr --encrypt secrets
You did not specify a user ID. (you may use "-r")
Current recipients:
Current recipients:
rsa3072/5D158106022B0394 2020-03-31 "tambe <[email protected]>"