Monday, August 6, 2012

GnuPG [Encryption/Decryption messages]

GnuPG is a tool for secure communication.

GnuPG uses public-key cryptography so that users may communicate securely. In a public-key system, each user has a pair of keys consisting of a private key and a public key. A user's private key is kept secret; it need never be revealed. The public key may be given to anyone with whom the user wants to communicate. GnuPG uses a somewhat more sophisticated scheme in which a user has a primary keypair and then zero or more additional subordinate keypairs. The primary and subordinate keypairs are bundled to facilitate key management and the bundle can often be considered simply as one keypair.




N.Bs,
  • It's a PUBLIC/PRIVATE  key ENCRYPTION/DECRYPTION communication.
  • You generate public and private keys by one command.
  • You give the public key to others so that they communicate with you and you have your OWN private one.
  • Encryption with public keys, Decryption with private keys.
  • So, for example, if a SENDER on the other side wants to give you a message or email, he would simply use your public key (that you already EXPORTED to him). you decrypt it with your private key ;)
  • Passphrase(password) is used only to decrypt messages by the private key by the receiver(generator).
  • The key is exported in a binary format, but this can be inconvenient when the key is to be sent though email or published on a web page. GnuPG therefore supports a command-line option --armor that that causes output to be generated in an ASCII-armored format similar to uuencoded documents. In general, any output from GnuPG, e.g., keys, encrypted documents, and signatures, can be ASCII-armored by adding the --armor option.

DEMOs
The Environment;
backtrack machine to generate the key pair >> GnuPG 
windows machine to >> GPA (GNU Privacy Assistance )

[case one]backtrack is the RECEIVER, Windows is the SENDER

on backtrack;

generating the key

root@bt:~/gpg# gpg --gen-key



root@bt:~/gpg# gpg --list-secret-keys



Exporting the public key;


root@bt:~/gpg# gpg --output eaglepublickey.gpg --export   \\exports it as non-readable binary format

root@bt:~/gpg# gpg --output eaglepublickey.txt --export --armor \\exports it as readable ascii format


This is the key that you give to others so they could message you.

On Windows;

Copy the key from backtrack to windows 
Run "gpg4win" program (right)
Import
Select the files to encrypt: Windows tab >> File Manager (left)



To Decrypt the message;

You have only one private key, so you won't specify it, unlike encryption where you must specify(you would have many public keys)

[Case two]

On Windows (GPA);

keys tab >> new key >> [name: eaglewindows]
Keys tab >> export key >>

On backtrack;

copy the key to backtrack
root@bt:~/gpg# gpg --import /root/Desktop/key
root@bt:~/gpg# gpg --output encryptedmessage.gpg --encrypt --recipient eaglewindows
root@bt:~/gpg# gpg --output encryptedmessage.gpg --encrypt --recipient eaglewindows messagetowindows

On Windows;

Windows tab >> File Manager 
decrypt
put your password












No comments:

Post a Comment