{"id":2623,"date":"2013-10-29T13:41:40","date_gmt":"2013-10-29T17:41:40","guid":{"rendered":"http:\/\/www.kaspersky.co.in\/blog\/?p=2623"},"modified":"2020-02-26T20:27:17","modified_gmt":"2020-02-26T14:57:17","slug":"gpg-strong-encryption-and-digital-signing-made-easy","status":"publish","type":"post","link":"https:\/\/www.kaspersky.co.in\/blog\/gpg-strong-encryption-and-digital-signing-made-easy\/2623\/","title":{"rendered":"GPG, Strong Encryption And Digital Signing Made Easy"},"content":{"rendered":"<p>Recent revelations about government surveillance have once more brought two-decade old <a href=\"https:\/\/www.kaspersky.com\/blog\/pgp-reliable-privacy-security-and-authentication-for-everyone\/\" target=\"_blank\" rel=\"noopener nofollow\">PGP software<\/a> \u00a0into the spotlight, as it remains a quite robust and secure mechanism for communications. \u00a0However, progress in the computing industry requires using longer keys to keep attacks on key pairs less possible. Therefore, my objective is to provide you with the information necessary to create a new RSA key pair with a length of more than 4096 bits. The longer the lifetime of your data the longer your key should be. However, nothing is free, and each time you double your key length the decryption becomes 6 or 7 times slower. Therefore, we\u2019ve chosen a key length of 8192 bits for this article.<\/p>\n<p><a href=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/05094843\/pgp.jpeg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2781\" alt=\"pgp\" src=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23102005\/pgp-1.jpeg\" width=\"640\" height=\"420\"><\/a><\/p>\n<p>Not many tools that are currently available support this key size by default, so in order to create our new key we are going to download and modify the latest GnuPG version (currently 1.4.15). We\u2019ll use Ubuntu Linux for this example since nowadays it\u2019s a pretty popular distribution and it will allow you to follow these steps in a simple and straightforward manner. As an alternative you could also use <a href=\"http:\/\/www.cygwin.com\/\" target=\"_blank\" rel=\"noopener nofollow\">Cygwin<\/a>, which is a good way to have a basic Linux-like environment in your Windows OS.<\/p>\n<p align=\"center\">\u00a0<a href=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/05084503\/pgp-screenshot-01.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2784\" alt=\"pgp-screenshot-01\" src=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23102010\/pgp-screenshot-01-1.png\" width=\"595\" height=\"328\"><\/a><\/p>\n<p>Once you have created your key with the following guide, you can use one of the many tools available for your chosen OS to manage it. For example in Mac OSX you have <a href=\"https:\/\/gpgtools.org\/index.html\" target=\"_blank\" rel=\"noopener nofollow\">GPG Suite<\/a> and in Windows you can download <a href=\"http:\/\/www.gpg4win.org\/\" target=\"_blank\" rel=\"noopener nofollow\">GP4Win<\/a>, both allow key generation, key management and all the basic operations you will usually perform everyday with PGP.<\/p>\n<p>On the one hand you have Gpg4win (GNU Privacy Guard for Windows), which is maintained by the developers of GnuPG and provides encryption and digital signing software for files and emails protecting your valuable information and communications. It\u2019s free software and highly recommended for all Windows users.<\/p>\n<p>On the other hand, if you have GPG Suite for Mac OSX, which integrates nicely with your OS, providing an open source plugin for Apple Mail and enabling you to encrypt and sign your messages easily. There is also an application to manage your keychain and a command line version of GPG to further explore all the alternatives this tool has to offer.<\/p>\n<p style=\"text-align: center;\" align=\"center\"><a href=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/05084502\/pgp-screenshot-02-1024x335.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-2785\" alt=\"pgp-screenshot-02\" src=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23102509\/pgp-screenshot-02-1024x335-1.png\" width=\"857\" height=\"280\"><\/a><\/p>\n<p>We\u2019ll start by getting the GnuPG sources and decompressing them into a folder in our hard disk. It\u2019s recommended first that we verify the SHA1 signature for this file to check that everything is correct and we\u2019ve downloaded the verified version of the software. For that, we can use the already installed utility \u201csha1sum\u201d and if the calculated hash matches the one available on the GnuPG website, we are good to go.<\/p>\n<p align=\"center\">\u00a0<a href=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/05084501\/pgp-screenshot-03.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2786\" alt=\"pgp-screenshot-03\" src=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23102026\/pgp-screenshot-03-1.png\" width=\"723\" height=\"459\"><\/a><\/p>\n<p>For this guide we are going to modify a couple source files, but I promise it\u2019s not too complex and the rewards will be enough to justify this effort.<\/p>\n<p>I\u2019m going to download the gzip compressed GnuPG 1.4.15 source file and with the help of the \u201ctar xvzf [filename]\u201d command, I will obtain a decompressed folder with the original contents of the file. <i>You have to replace the [filename] part of the command with the actual name of the downloaded archive. No square brackets are needed in the actual command.<\/i><\/p>\n<p align=\"center\">\u00a0<a href=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/05084459\/pgp-screenshot-04.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2787\" alt=\"pgp-screenshot-04\" src=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23102030\/pgp-screenshot-04-1.png\" width=\"725\" height=\"465\"><\/a><\/p>\n<p>Next, we need to browse the recently extracted directory by doing a \u201ccd [gnupg-folder]\u201d. There we will find the contents we need for building our GnuPG binary. The first step involves modifying the \u201ckeygen.c\u201d file located in the \u201cg10 directory\u201d.<\/p>\n<p align=\"center\">\u00a0<a href=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/05084457\/pgp-screenshot-05.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2788\" alt=\"pgp-screenshot-05\" src=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23102035\/pgp-screenshot-05-1.png\" width=\"728\" height=\"466\"><\/a><\/p>\n<p>You can edit the \u201ckeygen.c\u201d file using \u201cgedit\u201d, for example, and when shown the contents you can search for the string \u201c4096\u201d, which is the current maximum key size that GnuPG has set up by default. We\u2019ll change that value to \u201c8192\u201d for our purposes in line 1572. Don\u2019t forget to save your changes. Make sure you haven\u2019t introduced any other changes!<\/p>\n<p align=\"center\">\u00a0<a href=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/05084456\/pgp-screenshot-06.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2789\" alt=\"pgp-screenshot-06\" src=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23102039\/pgp-screenshot-06-1.png\" width=\"650\" height=\"526\"><\/a><\/p>\n<p>After we have made this simple modification we are ready to compile our new version of GnuPG. For that the usual \u201c.\/configure\u201d and \u201cmake\u201d commands should be enough. Moreover, if we want to replace the GPG version that Ubuntu ships with by default we\u2019ll execute a \u201csudo make install.\u201d For the moment we\u2019ll use our newly created binary locally in order to set up our RSA 8192 bits key pair.<\/p>\n<p align=\"center\">\u00a0<a href=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/05084455\/pgp-screenshot-07.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2790\" alt=\"pgp-screenshot-07\" src=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23102044\/pgp-screenshot-07-1.png\" width=\"725\" height=\"463\"><\/a><\/p>\n<p>Before executing \u201cgpg\u201d we\u2019ll modify the gpg.conf file located in your Home directory, in this case \u201c\/home\/Giuliani\/.gnupg\/gpg.conf\u201d. By default it won\u2019t have any content but we\u2019ll add our choice of preference for cipher, digest and compression algorithms and hashing mechanisms.<\/p>\n<p>For this particular case I\u2019m going to add at the end of the file the following contents (you can of course change this to your preferences\/needs):<\/p>\n<p>personal-cipher-preferences AES256 TWOFISH AES192 AES<\/p>\n<p>personal-digest-preferences SHA512 SHA384 SHA256<\/p>\n<p>personal-compress-preferences ZLIB ZIP<\/p>\n<p align=\"center\"><a href=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/05084455\/pgp-screenshot-08.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2791\" alt=\"pgp-screenshot-08\" src=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23102048\/pgp-screenshot-08-1.png\" width=\"720\" height=\"462\"><\/a><\/p>\n<p>After all this hard work we are finally ready to create our key, we\u2019ll execute the \u201c.\/gpg \u2013gen-key\u201d command from the \u201cg10\u201d directory (where we previously modified the \u201ckeygen.c\u201d file\u201d) and will follow the instructions on the screen. The process is pretty simple, we choose the first option to create a key pair that will be used for signing and encrypting and we\u2019ll select 8192 bits as the key size.<\/p>\n<p align=\"center\"><a href=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23101915\/pgp-screenshot-09.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2792\" alt=\"pgp-screenshot-09\" src=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23102052\/pgp-screenshot-09-1.png\" width=\"723\" height=\"463\"><\/a><\/p>\n<p>Just to add a little more realism to the example, I\u2019m going to set the expiration date for this key too. We\u2019ll use \u201c5y\u201d to tell \u201cgpg\u201d that this key will expire in 5 years.<\/p>\n<p align=\"center\">\u00a0<a href=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23101921\/pgp-screenshot-10.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2793\" alt=\"pgp-screenshot-10\" src=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23102056\/pgp-screenshot-10-1.png\" width=\"724\" height=\"461\"><\/a><\/p>\n<p>Then we add the name, email address and comment (optional) for this identity. We can add more identities later so don\u2019t worry if you have multiple email addresses you want to include in this key pair.<\/p>\n<p align=\"center\"><a href=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23101925\/pgp-screenshot-11.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2794\" alt=\"pgp-screenshot-11\" src=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23102100\/pgp-screenshot-11-1.png\" width=\"720\" height=\"463\"><\/a><\/p>\n<p>You will then be prompted to enter your password or passphrase (depending on your personal preferences you should choose one here). There are some good <a href=\"http:\/\/www.ephesus.com\/Encryption\/Passphrase.html\" target=\"_blank\" rel=\"noopener nofollow\">guidelines on choosing a good passphrase<\/a> that will keep your key secure and also will simplify the task of remembering it. If you want more information you can review some <a href=\"http:\/\/www.iusmentis.com\/security\/passphrasefaq\/\" target=\"_blank\" rel=\"noopener nofollow\">FAQs<\/a> available online.<\/p>\n<p>Remember that if you want to change your password\/passphrase later you can do so without the need to recreate your key or distribute the public one to your contacts again.<\/p>\n<p>After all the information is entered the process of creating the key pair will begin, GPG will start collecting random bytes in order to improve the random number generation process. Keep using your PC until this process finishes (it can take a while depending on the computer you are using, in my I5 PC with 8 gigs of RAM it took about 15 minutes to complete).<\/p>\n<p align=\"center\">\u00a0<a href=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23101931\/pgp-screenshot-12.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2795\" alt=\"pgp-screenshot-12\" src=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23102104\/pgp-screenshot-12-1.png\" width=\"723\" height=\"463\"><\/a><\/p>\n<p>Finally, the key creation process is finished. GPG will show the fingerprint for the key, expiration date and all the information you entered previously. Make sure everything is correct before distributing the public key to your contacts.<\/p>\n<p align=\"center\">\u00a0<a href=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23101936\/pgp-screenshot-13.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2796\" alt=\"pgp-screenshot-13\" src=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23102110\/pgp-screenshot-13-1.png\" width=\"726\" height=\"466\"><\/a><\/p>\n<p>You can use the GPG \u201clist\u201d command (\u2013list-keys) to check all the available keys in your system and export the ones you need. We are going to export the public key for our recently created identity \u201cJoe Doe\u201d the result will be the key file which you can later upload manually to one of the available PGP key servers or distribute it directly to your contacts. The easiest way to do this is by typing \u201cgpg \u2013export \u2013a [username] &gt; [public-key-filename]\u201d.<\/p>\n<p align=\"center\"><a href=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23101944\/pgp-screenshot-14.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2797\" alt=\"pgp-screenshot-14\" src=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23102601\/pgp-screenshot-14-1.png\" width=\"867\" height=\"460\"><\/a><\/p>\n<p>If you want to upload your public key from the command line you can do so by using the \u201cgpg \u2013keyserver [serverurl] \u2013send-keys [keyID]\u201d command.<\/p>\n<p align=\"center\">\u00a0<a href=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23101953\/pgp-screenshot-15.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2798\" alt=\"pgp-screenshot-15\" src=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23102609\/pgp-screenshot-15-1.png\" width=\"866\" height=\"459\"><\/a><\/p>\n<p>You can also import public keys using the \u201c\u2014recv-keys\u201d switch instead. All within the comfort of your own command line interface.<\/p>\n<p>Finally, we are going to create a backup of our private key. Be very careful with this and remember not to share this file with anyone. The process is very similar to what we have seen previously and we can back up our key using \u201cgpg export-secret-key \u2013a [username] &gt; [private-key-filename]\u201d<\/p>\n<p align=\"center\">\u00a0<a href=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23102001\/pgp-screenshot-16.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2799\" alt=\"pgp-screenshot-16\" src=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/36\/2013\/10\/23102617\/pgp-screenshot-16-1.png\" width=\"921\" height=\"463\"><\/a><\/p>\n<p>Now you have your brand new PGP key pair, which you can use to enjoy a whole new world of secure communications and data privacy. Welcome!<\/p>\n<div class=\"pullquote\">\u201cA journey of a thousand miles begins with a single step.\u201d \u2013 Lao Tzu<\/div>\n<p>Having taken our first step with PGP I hope that you will come back to check in on further updates about this topic. In the meantime, you can play around with one of the many <a href=\"http:\/\/stuff.imeos.org\/persistent\/gpg-cheatsheet.pdf\" target=\"_blank\" rel=\"noopener nofollow\">GPG Cheat sheets<\/a> available, which will enable you to adjust the encryption\/decryption functionality, file and message signing and much more.<\/p>\n<div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Recent revelations about government surveillance have once more brought two-decade old PGP software \u00a0into the spotlight, as it remains a quite robust and secure mechanism for communications. \u00a0However, progress in<\/p>\n","protected":false},"author":313,"featured_media":2622,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[5],"tags":[189,475],"class_list":{"0":"post-2623","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-news","8":"tag-data-security","9":"tag-gpg"},"hreflang":[{"hreflang":"en-in","url":"https:\/\/www.kaspersky.co.in\/blog\/gpg-strong-encryption-and-digital-signing-made-easy\/2623\/"},{"hreflang":"en-ae","url":"https:\/\/me-en.kaspersky.com\/blog\/gpg-strong-encryption-and-digital-signing-made-easy\/2515\/"},{"hreflang":"en-us","url":"https:\/\/usa.kaspersky.com\/blog\/gpg-strong-encryption-and-digital-signing-made-easy\/2783\/"},{"hreflang":"en-gb","url":"https:\/\/www.kaspersky.co.uk\/blog\/gpg-strong-encryption-and-digital-signing-made-easy\/2619\/"},{"hreflang":"x-default","url":"https:\/\/www.kaspersky.com\/blog\/gpg-strong-encryption-and-digital-signing-made-easy\/3036\/"},{"hreflang":"ja","url":"https:\/\/blog.kaspersky.co.jp\/gpg-strong-encryption-and-digital-signing-made-easy\/1900\/"},{"hreflang":"en-au","url":"https:\/\/www.kaspersky.com.au\/blog\/gpg-strong-encryption-and-digital-signing-made-easy\/3036\/"},{"hreflang":"en-za","url":"https:\/\/www.kaspersky.co.za\/blog\/gpg-strong-encryption-and-digital-signing-made-easy\/3036\/"}],"acf":[],"banners":"","maintag":{"url":"https:\/\/www.kaspersky.co.in\/blog\/tag\/data-security\/","name":"data security"},"_links":{"self":[{"href":"https:\/\/www.kaspersky.co.in\/blog\/wp-json\/wp\/v2\/posts\/2623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kaspersky.co.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kaspersky.co.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kaspersky.co.in\/blog\/wp-json\/wp\/v2\/users\/313"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kaspersky.co.in\/blog\/wp-json\/wp\/v2\/comments?post=2623"}],"version-history":[{"count":2,"href":"https:\/\/www.kaspersky.co.in\/blog\/wp-json\/wp\/v2\/posts\/2623\/revisions"}],"predecessor-version":[{"id":18921,"href":"https:\/\/www.kaspersky.co.in\/blog\/wp-json\/wp\/v2\/posts\/2623\/revisions\/18921"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kaspersky.co.in\/blog\/wp-json\/wp\/v2\/media\/2622"}],"wp:attachment":[{"href":"https:\/\/www.kaspersky.co.in\/blog\/wp-json\/wp\/v2\/media?parent=2623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kaspersky.co.in\/blog\/wp-json\/wp\/v2\/categories?post=2623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kaspersky.co.in\/blog\/wp-json\/wp\/v2\/tags?post=2623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}