Gpg4win 8192 Bit Key Generation

Posted By admin On 11.12.20
Gpg4win 8192 bit key generation 2

Jun 13, 2011  gpg4win Generate Keys Benjamin Hare. Unsubscribe from Benjamin Hare? How To Create Private and Public Keys Using GPG4win - Duration: 6:43. Interpayroll 41,762 views. Creating a 8192 bit GPG key to replace my 1024 bit one As some of you will have heard, there's been some new research into the security of the SHA-1 hash, which has found a faster way to locate collisions.

A readme and a script to generate PGP keys using GnuPG, using the current best practices.

If your YubiKey can only hold 2048 bits RSA keys, you will need to generate smaller subkeys in the appropriate step (the master key should still be kept at 4096 bits). Step 1: Install and set up GPG If you are using Windows, you will need gpg4win. The encryption power comes from key bit size or length. In this tutorial we will look how to create 4096 bit keys. Generate 4098 Bit Key. In this example we will generate very secure key. This key size will be 4096 bit. 4096 bit keys are a lot more secure than 2048 or 1024 bit keys. Enable creation of 8192 bit GPG keys. Although it is technicaly possible to work with 8192 bit GPG keys the creators of Gnupgp ship the sources with a hard coded limit of 4096 bit. If you want a larger GPG key than 4096 bit your are supposed to change the given limit yourself. How to Generate and Use a Public Key. Keys are usually used with a system like OpenPGP that provides a selection of encryption algorithms and lets you do key generation, compression, signing, symmetric encryption, and lots of other things. GPG is a free OpenPGP client that implements a lot of different algorithms but the parts we care about.

Its goal is to provide a concise and up-to-date description of best practices regarding the usage of GnuPG. A basic understanding of public key cryptography, and GnuPG in particular is assumed.

If something is not clear or you're new to PGP, then make sure to start with the Glossary below.

Some quick insights

  • Public key cryptography happens between two encryption keys, which is not necessarily only two humans, unless enough care has been taken when exchanging public keys and to keep the secret keys indeed secret.
  • In a digital networked world it's not possible to delete any published information, it must be assumed to be just there forever. This also applies to PGP keys.
  • Properly authenticated revocation requests can be published, though. If such requests are digitally signed (authenticated), then they will be honored by programs handling e.g. PGP keys (key servers, client programs), and the revoked data will be ignored/hidden from the user accordingly.
  • Having a separately stored revocation certificate in your backup comes very handy if your key gets compromised or lost. By publishing it you can tell your peers that your key should not be used anymore.
  • The most precious part of a PGP key block is its master signing key.
  • The master signing key of a PGP key block is rarely needed (mostly when editing/extending the PGP key block itself and when signing other people's keys).
  • You can only trust you generated PGP key to the extent you trust the software environment and/or the computer generating it. Opensource is a minimum in security, so use a Linux live cd or something similar from a trusted source to generate and/or use your master signing key, preferably while being offline (see live CD's in the Glossary)!
  • Specialized hardware solutions offer much better protection for secret keys. See below.
  • If you forget the passphrase for your already published key, and you don't have a revocation certificate either, then your key will be lingering on the keyservers confusing your peers, who will annoy you by sending you messages you cannot read.
  • Passphrases: three to five word long sentences that you make up yourself (based on a non-trivial vocabulary, personal experiences, dreams, preferably with s0me typ0s) are easier to remember than a bunch of random characters, and are better passphrases. You can even build a little story around them to have separate but semantically interconnected passphrases (for the keys, for the revocation certificate, etc.). A vivid dream or delightful fantasies can be a good basis for something you won't forget... :)
  • ...but at the end of the day it'll always be a tradeoff between security and convenience. Assess your risks and act accordingly.

The PGP algorithm needs an extra parameter, a key, to sign or encrypt data. That parameter is a cryptographic keypair, usually one of the subkeys from a PGP key block. New subkeys can be freely generated and published, so forward secrecy can be achieved by publishing new subkeys, as long as the secret part of the master signing keypair has not been compromised. Therefore the most precious part of a PGP key block is its master signing key, because whenever new information is attached to the key block (e.g. a new subkey is generated), this new data must be signed by the secret part of the master signing keypair, otherwise conforming programs will reject the new unsigned or improperly signed part of the PGP key block. In this scheme publishing valid additions to the key block is only possible by people who know the secret part of the master signing key. This is ideally you, and you only.

So, to conclude: keep the secret part of your master signing key safe!

Generating a key

The aim is to generate a digital identity that can serve to identify you and to facilitate secret communication with you in the future.

Things to consider:

  • If a valid signing subkey exists, then the master signing key is rarely used (only to sign internal parts of the key block itself, when explicitly selected, or when signing other people's keys), so the size of the signatures it generates is not a major concern.
  • Having a strong master signing key (and taking good care of it) can provide a long time span for your digital identity (possibly 10+ years) and for forward secrecy.
  • The security of RSA keys does not scale well beyond 2048 bits, use ECC (Elliptic curve cryptography) instead as recommended. Unfortunately it requires GnuPG 2.1+ (2014 Nov).
  • Longer signing keys generate longer signatures.
  • Signature length: RSA > DSA = ECDSA (Elliptic Curve DSA) (but there's more to this story).
  • Some GnuPG configuration parameters affect newly generated keys (although not in a permanent way); e.g. see setpref to set the preferred hash algorithms for identities here.

Even more thoughts here.

Using GnuPG

GnuPG properly operates with a PGP key block that is missing the secret part of its master signing key, as long as it's not needed for an operation. Therefore it's a good idea not to store the secret part of the master signing key in the regularly used gpg home directory, but rather generate and handle it in a safer environment; e.g. generate and handle it using a live CD without Internet connection, and store it on a pendrive dedicated to this purpose. Then only attach it when needed (e.g. when signing other people's keys or when your own keyblock needs to be modified).

This script generates (with defaults in parens):

  • a master signing key (RSA 4096 bit, no expiration date marked)
  • a subkey for signing (RSA 4096 bit, 3 years)
  • a subkey for encryption (RSA 2048 bit, 3 years)
  • export the secret part of the master signing key into the file secret-master-key.gpg
  • export the secret parts of the two generated subkeys into the file secret-subkeys.gpg
  • export the public parts of all the three generated keys into the file public-keys.gpg
  • generate and symmetrically encrypt a revocation certificate into the file revocation-certificate-for-[keyid]-passphrase-protected.gpg
  • (planned: support for ssss-split to generate secret sharing to backup the master key and the revocation certificate in a distributed manner)

Once the exported files have been generated, you can import them into the gpg homedir's on your devices (by default ~/.gnupg). Where you should import and what depends on the level of security you want to achieve, but keeping the master key offline is advised as described above.

(the '#' character in the output shows that the secret part of the master signing key is missing)

SmartCards and other hardware keys

SmartCards and USB cryptographic tokens are specialized simple computers that perform cryptographic operations. They are designed to keep the secret keys secret even against physical attacks. They are much more secure than storing a key on a personal computer, but they are not flawless ⁽¹⁾⁽²⁾. Usually they can store three separate keys for signing, encryption, and authentication. The secret keys can be either uploaded or generated on the cards themselves, so that they never get exposed to less secure environments.

Gpg4win 8192 Bit Key Generation Free

  • The OpenPGP Card version 2.0 - a SmartCard with extensive documentation and thus stable Linux support. You can also get one by joining the FSFE Fellowship. Supports three 4096 bit keys and on-card key generation⁽¹⁾.
  • Crypto Stick - a tiny OpenSource USB computer and firmware with an integrated proprietary smart card chip. Supports OATH TOTP as described here.
  • gnuk - a portable OpenSource implementation of the OpenPGP Card specification that can run on e.g. this tiny ARM based OpenSource USB computer.

Some laptops have internal smart card readers, and higher security external readers have their own PIN entry keyboard.

Further information on using smart cards on Linux: Debian wiki, Using an OpenPGP SmartCard, OpenSC – tools and libraries for smart cards, GnuPG wiki.

Glossary

  • PGP key - It's usually a shorthand for PGP key block, which will be the case in this document, too. Not to be confused with asymmetric cryptographic keypairs, which are merely parts of PGP key blocks.
  • PGP key block - a complex structure of information (normally stored in ~/.gnupg/). Examples of the information it can contain: multiple cryptographic (sub)keys; multiple identities (email addresses, photgraphs, etc); digital signatures on various parts of the key block (potentially made by other people's keys, e.g. to communicate the belief to the rest of the world that the same real world person owns the listed digital identities, and also the secret part of the key).
  • subkey - PGP key blocks can have, among other things, multiple asymmetric cryptographic keypairs. One such asymmetric cryptographic keypair is mandatory for normal operation. It's called the master signing key, and it's used to sign various information inside the key block, e.g. identities and/or other cryptographic keys, which are called subkeys.
  • asymmetric cryptographic keypair - they are basically pairs of very big interconnected random numbers, one of them should be made public, while the other one should be kept secret. Asymmetric encryption algorithms use the public part to encrypt data and to verify signature blocks, while use the secret part to decrypt data and to generate signature blocks.
  • OATH is short for Initiative for Open Authentication. Among other things it defines a Time-based One-time Password (TOTP) authentication standard, supported by more and more websites.
  • Live CD is a bootable read-only operating system, like these security focused Linux Live CDs (bootable from USB pendrives also):
    • Liberté Linux.

Alternatives and/or further reading

Bit

Credits

Written by Attila Lendvai attila.lendvai@gmail.com (Key fingerprint: 2FA1 A9DC 9C1E BA25 A59C 963F 5D5F 45C7 DFCD 0A39).

If you've found this useful, then tips are welcome:

  • Bitcoin (BTC): 1Ej8SeMNTkwjSwhKLu7H1XLVRPZ3HUjM4J (0 BTC as of 2014-01-18)
  • Ripple (XRP): r33NEgyd7HqvrUeB98rQ4VoBxP438gC74Q (0 XRP as of 2014-01-18)
  • Paypal: (0 USD as of 2015-11-10)

Next: Signing Keys, Previous: Manipulating Keys, Up: Key Management [Contents][Index]

7.5.5 Generating Keys

GPGME provides a set of functions to create public key pairs. Most ofthese functions require the use of GnuPG 2.1 and later; for olderGnuPG versions the gpgme_op_genkey function can be used.Existing code which wants to update to the new functions or new codewhich shall supports older GnuPG versions may try the new functionsfirst and provide a fallback to the old function if the error codeGPG_ERR_NOT_SUPPORTED is received.

Function: gpgme_error_tgpgme_op_createkey(gpgme_ctx_tctx, const char *userid, const char *algo, unsigned long reserved, unsigned long expires, gpgme_key_textrakey, unsigned int flags);

SINCE: 1.7.0

The function gpgme_op_createkey generates a new key for theprocotol active in the context ctx. As of now this functiondoes only work for OpenPGP and requires at least version 2.1.13 ofGnuPG.

userid is commonly the mail address associated with the key.GPGME does not require a specific syntax but if more than a mailaddress is given, RFC-822 style format is suggested. The value isexpected to be in UTF-8 encoding (i.e. no IDN encoding for mailaddresses). This is a required parameter.

algo specifies the algorithm for the new key (actually a keypairof public and private key). For a list of supported algorithms, seethe GnuPG manual. If algo is NULL or the string'default', the key is generated using the default algorithm of theengine. If the string 'future-default' is used the engine may use analgorithm which is planned to be the default in a future release ofthe engine; however existing implementation of the protocol may not beable to already handle such future algorithms. For the OpenPGPprotocol, the specification of a default algorithm, without requestinga non-default usage via flags, triggers the creation of aprimary key plus a secondary key (subkey).

reserved must be set to zero.

expires specifies the expiration time in seconds. If you supply0, a reasonable expiration time is chosen. Use the flagGPGME_CREATE_NOEXPIRE to create keys that do not expire. Notethat this parameter takes an unsigned long value and not atime_t to avoid problems on systems which use a signed 32 bittime_t. Note further that the OpenPGP protocol uses 32 bitvalues for timestamps and thus can only encode dates up to the year2106.

extrakey is currently not used and must be set to NULL.A future version of GPGME may use this parameter to create X.509 keys.

flags can be set to the bit-wise OR of the following flags:

GPGME_CREATE_SIGN
GPGME_CREATE_ENCR
GPGME_CREATE_CERT
GPGME_CREATE_AUTH

SINCE: 1.7.0

Do not create the key with the default capabilities (key usage) of therequested algorithm but use those explicitly given by these flags:“signing”, “encryption”, “certification”, or “authentication”.The allowed combinations depend on the algorithm.

If any of these flags are set and a default algorithm has beenselected only one key is created in the case of the OpenPGPprotocol.

GPGME_CREATE_NOPASSWD

SINCE: 1.7.0

Request generation of the key without password protection.

GPGME_CREATE_SELFSIGNED

SINCE: 1.7.0

For an X.509 key do not create a CSR but a self-signed certificate.This has not yet been implemented.

GPGME_CREATE_NOSTORE

SINCE: 1.7.0

Do not store the created key in the local key database.This has not yet been implemented.

GPGME_CREATE_WANTPUB
GPGME_CREATE_WANTSEC

SINCE: 1.7.0

Return the public or secret key as part of the result structure.This has not yet been implemented.

GPGME_CREATE_FORCE

SINCE: 1.7.0

The engine does not allow the creation of a key with a user IDalready existing in the local key database. This flag can be used tooverride this check.

GPGME_CREATE_NOEXPIRE

SINCE: 1.8.0

Request generation of keys that do not expire.

After the operation completed successfully, information about thecreated key can be retrieved with gpgme_op_genkey_result.

The function returns zero on success, GPG_ERR_NOT_SUPPORTED ifthe engine does not support the command, or a bunch of other errorcodes.

Function: gpgme_error_tgpgme_op_createkey_start(gpgme_ctx_tctx, const char *userid, const char *algo, unsigned long reserved, unsigned long expires, gpgme_key_textrakey, unsigned int flags);

SINCE: 1.7.0

The function gpgme_op_createkey_start initiates agpgme_op_createkey operation; see there for details. It mustbe completed by calling gpgme_wait on the context.See Waiting For Completion.

Function: gpgme_error_tgpgme_op_createsubkey(gpgme_ctx_tctx, gpgme_key_tkey, const char *algo, unsigned long reserved, unsigned long expires, unsigned int flags);

SINCE: 1.7.0

The function gpgme_op_createsubkey creates and adds a newsubkey to the primary OpenPGP key given by KEY. The onlyallowed protocol in ctx is GPGME_PROTOCOL_OPENPGP.Subkeys (aka secondary keys) are a concept in the OpenPGP protocol tobind several keys to a primary key. As of now this function requiresat least version 2.1.13 of GnuPG.

key specifies the key to operate on.

algo specifies the algorithm for the new subkey. For a list ofsupported algorithms, see the GnuPG manual. If algo isNULL or the string 'default', the subkey is generated using thedefault algorithm for an encryption subkey of the engine. If thestring 'future-default' is used the engine may use an encryptionalgorithm which is planned to be the default in a future release ofthe engine; however existing implementation of the protocol may not beable to already handle such future algorithms.

reserved must be set to zero.

expires specifies the expiration time in seconds. If you supply0, a reasonable expiration time is chosen. Use the flagGPGME_CREATE_NOEXPIRE to create keys that do not expire. Notethat this parameter takes an unsigned long value and not atime_t to avoid problems on systems which use a signed 32 bittime_t. Note further that the OpenPGP protocol uses 32 bitvalues for timestamps and thus can only encode dates up to the year2106.

flags takes the same values as described above forgpgme_op_createkey.

After the operation completed successfully, information about thecreated key can be retrieved with gpgme_op_genkey_result.

The function returns zero on success, GPG_ERR_NOT_SUPPORTED ifthe engine does not support the command, or a bunch of other errorcodes.

Function: gpgme_error_tgpgme_op_createsubkey_start(gpgme_ctx_tctx, gpgme_key_tkey, const char *algo, unsigned long reserved, unsigned long expires, unsigned int flags);

SINCE: 1.7.0

The function gpgme_op_createsubkey_start initiates agpgme_op_createsubkey operation; see there for details. It mustbe completed by calling gpgme_wait on the context.See Waiting For Completion.

Function: gpgme_error_tgpgme_op_adduid(gpgme_ctx_tctx, gpgme_key_tkey, const char *userid, unsigned int flags);

SINCE: 1.7.0

The function gpgme_op_adduid adds a new user ID to the OpenPGPkey given by KEY. Adding additional user IDs after key creationis a feature of the OpenPGP protocol and thus the protocol for thecontext ctx must be set to OpenPGP. As of now this functionrequires at least version 2.1.13 of GnuPG.

key specifies the key to operate on.

userid is the user ID to add to the key. A user ID is commonlythe mail address to be associated with the key. GPGME does notrequire a specific syntax but if more than a mail address is given,RFC-822 style format is suggested. The value is expected to be inUTF-8 encoding (i.e. no IDN encoding for mail addresses). This is arequired parameter.

flags are currently not used and must be set to zero.

The function returns zero on success, GPG_ERR_NOT_SUPPORTED ifthe engine does not support the command, or a bunch of other errorcodes.

Function: gpgme_error_tgpgme_op_adduid_start(gpgme_ctx_tctx, gpgme_key_tkey, const char *userid, unsigned int flags);

SINCE: 1.7.0

The function gpgme_op_adduid_start initiates agpgme_op_adduid operation; see there for details. It mustbe completed by calling gpgme_wait on the context.See Waiting For Completion.

Function: gpgme_error_tgpgme_op_revuid(gpgme_ctx_tctx, gpgme_key_tkey, const char *userid, unsigned int flags);

SINCE: 1.7.0

The function gpgme_op_revuid revokes a user ID from the OpenPGPkey given by KEY. Revoking user IDs after key creation is afeature of the OpenPGP protocol and thus the protocol for the contextctx must be set to OpenPGP. As of now this function requires atleast version 2.1.13 of GnuPG.

key specifies the key to operate on.

userid is the user ID to be revoked from the key. The user IDmust be given verbatim because the engine does an exact and casesensitive match. Thus the uid field from the user ID object(gpgme_user_id_t) is to be used. This is a required parameter.

flags are currently not used and must be set to zero.

Note that the engine won’t allow to revoke the last valid user ID. Tochange a user ID is better to first add the new user ID, then revokethe old one, and finally publish the key.

The function returns zero on success, GPG_ERR_NOT_SUPPORTED ifthe engine does not support the command, or a bunch of other errorcodes.

Function: gpgme_error_tgpgme_op_revuid_start(gpgme_ctx_tctx, gpgme_key_tkey, const char *userid, unsigned int flags);

SINCE: 1.7.0

The function gpgme_op_revuid_start initiates agpgme_op_revuid operation; see there for details. It mustbe completed by calling gpgme_wait on the context.See Waiting For Completion.

Function: gpgme_error_tgpgme_op_set_ui_flag(gpgme_ctx_tctx, gpgme_key_tkey, const char *userid, cons char * name, cons char * value);

SINCE: 1.8.0

The function gpgme_op_set_uid_flag is used to set flags on auser ID from the OpenPGP key given by KEY. Setting flags onuser IDs after key creation is a feature of the OpenPGP protocol andthus the protocol for the context ctx must be set to OpenPGP.

key specifies the key to operate on. This parameters is required.

userid is the user ID of the key to be manipulated. This user IDmust be given verbatim because the engine does an exact and casesensitive match. Thus the uid field from the user ID object(gpgme_user_id_t) is to be used. This is a required parameter.

name names the flag which is to be changed. The only currentlysupported flag is:

primary

This sets the primary key flag on the given user ID. All otherprimary key flag on other user IDs are removed. value must begiven as NULL. For technical reasons this functions bumps thecreation timestamp of all affected self-signatures up by one second.At least GnuPG version 2.1.20 is required.

The function returns zero on success, GPG_ERR_NOT_SUPPORTED ifthe engine does not support the command, or a bunch of other errorcodes.

Function: gpgme_error_tgpgme_op_set_uid_flag_start(gpgme_ctx_tctx, gpgme_key_tkey, const char *userid, cons char * name, cons char * value);

SINCE: 1.8.0

The function gpgme_op_set_uid_flag_start initiates agpgme_op_set_uid_flag operation; see there for details. It mustbe completed by calling gpgme_wait on the context.See Waiting For Completion.

Function: gpgme_error_tgpgme_op_genkey(gpgme_ctx_tctx, const char *parms, gpgme_data_tpublic, gpgme_data_tsecret)

The function gpgme_op_genkey generates a new key pair in thecontext ctx. The meaning of public and secretdepends on the crypto backend.

GPG does not support public and secret, they should beNULL. GnuPG will generate a key pair and add it to thestandard key ring. The fingerprint of the generated key is availablewith gpgme_op_genkey_result.

GpgSM requires public to be a writable data object. GpgSM willgenerate a secret key (which will be stored by gpg-agent,and return a certificate request in public, which then needs tobe signed by the certification authority and imported before it can beused. GpgSM does not make the fingerprint available.

The argument parms specifies parameters for the key in an stringthat looks something like XML. The details about the format ofparms are specific to the crypto engine used by ctx. Thefirst line of the parameters must be <GnupgKeyParamsformat='internal'> and the last line must be</GnupgKeyParams>. Every line in between the first and lastlines is treated as a Header: Value pair. In particular, no XMLescaping is necessary if you need to include the characters <,>, or &.

Here is an example for GnuPG as the crypto engine (all parameters ofOpenPGP key generation are documented in the GPG manual):

Here is an example for GpgSM as the crypto engine (all parameters ofOpenPGP key generation are documented in the GPGSM manual):

Strings should be given in UTF-8 encoding. The only format supportedfor now is “internal”. The content of the GnupgKeyParmscontainer is passed verbatim to the crypto backend. Controlstatements are not allowed.

Gpg4win 8192 Bit Key Generation 10

After the operation completed successfully, the result can beretrieved with gpgme_op_genkey_result.

The function returns the error code GPG_ERR_NO_ERROR if theoperation could be started successfully, GPG_ERR_INV_VALUE ifparms is not a well-formed string (e.g. does not have theexpected tag-like headers and footers), GPG_ERR_NOT_SUPPORTEDif public or secret is not valid, andGPG_ERR_GENERAL if no key was created by the backend.

Function: gpgme_error_tgpgme_op_genkey_start(gpgme_ctx_tctx, const char *parms, gpgme_data_tpublic, gpgme_data_tsecret)

The function gpgme_op_genkey_start initiates agpgme_op_genkey operation. It can be completed by callinggpgme_wait on the context. See Waiting For Completion.

The function returns the error code GPG_ERR_NO_ERROR if theoperation could be started successfully, GPG_ERR_INV_VALUE ifparms is not a valid XML string, andGPG_ERR_NOT_SUPPORTED if public or secret is notNULL.

Data type: gpgme_genkey_result_t

This is a pointer to a structure used to store the result of agpgme_op_genkey operation. After successfully generating akey, you can retrieve the pointer to the result withgpgme_op_genkey_result. The structure contains the followingmembers:

unsigned int primary : 1

This flag is set to 1 if a primary key was created and to 0if not.

unsigned int sub : 1

This flag is set to 1 if a subkey was created and to 0 if not.

unsigned int uid : 1

Gpg4win 8192 Bit Key Generation Download

This flag is set to 1 if a user ID was created and to 0 if not.

char *fpr

This is the fingerprint of the key that was created. If both aprimary and a subkey were generated, the fingerprint of the primarykey will be returned. If the crypto engine does not provide thefingerprint, fpr will be a null pointer.

gpgme_data_t pubkey

SINCE: 1.7.0

This will eventually be used to return the public key. It iscurrently not used.

gpgme_data_t seckey

SINCE: 1.7.0

Gpg4win 8192 Bit Key Generation 7

This will eventually be used to return the secret key. It iscurrently not used.

Function: gpgme_genkey_result_tgpgme_op_genkey_result(gpgme_ctx_tctx)

The function gpgme_op_genkey_result returns agpgme_genkey_result_t pointer to a structure holding the result ofa gpgme_op_genkey operation. The pointer is only valid if thelast operation on the context was a gpgme_op_genkey orgpgme_op_genkey_start operation, and if this operation finishedsuccessfully. The returned pointer is only valid until the nextoperation is started on the context.

Gpg4win 8192 Bit Key Generation 3

Next: Signing Keys, Previous: Manipulating Keys, Up: Key Management [Contents][Index]