# FreeBSD Manual Pages

Crypt::OpenPGP::Key(3)User Contributed Perl DocumentatioCrypt::OpenPGP::Key(3)NAMECrypt::OpenPGP::Key - OpenPGP key factorySYNOPSISuse Crypt::OpenPGP::Key; my($pub, $sec) = Crypt::OpenPGP::Key->keygen('DSA', Size => 1024); use Crypt::OpenPGP::Key::Public; my $pubkey = Crypt::OpenPGP::Key::Public->new('DSA'); use Crypt::OpenPGP::Key::Secret; my $seckey = Crypt::OpenPGP::Key::Secret->new('RSA');DESCRIPTIONCrypt::OpenPGP::Keyprovides base class functionality for allCrypt::OpenPGPpublic and secret keys. It functions as a factory class for key generation and key instantiation. The only time you will ever useCrypt::OpenPGP::Keydirectly is to generate a key-pair; in all other scenarios--for example, when instantiating a new key object--you should use eitherCrypt::OpenPGP::Key::PublicorCrypt::OpenPGP::Key::Secret, depending on whether the key is public or secret, respectively.KEY GENERATIONCrypt::OpenPGP::Key->keygen($type,%arg)Generates a new key-pair of public key algorithm$type. Returns a public and a secret key, each blessed into the appropriate implementation class. Returns an empty list on failure, in which case you should call the class methoderrstrto determine the error. Valid values for type are "DSA", "RSA", and "ElGamal".%argcan contain:oSize Bitsize of the key to be generated. This should be an even integer; there is no low end currently set, but for the sake of securitySizeshould be at least 1024 bits. This is a required argument.oVerbosity Set to a true value to enable a status display during key generation; since key generation is a relatively length process, it is helpful to have an indication that some action is occurring.Verbosityis 0 by default.METHODSCrypt::OpenPGP::Keyis not meant to be used directly (unless you are generating keys; seeKEYGENERATION, above); instead you should use the subclasses of this module. There are, however, useful interface methods that are shared by all subclasses.KeyDataAccessEach public-key algorithm has different key data associated with it. For example, a public DSA key has 4 attributes:p,q,g, andy. A secret DSA key has the same attributes as a public key, and in addition it has an attributex. All of the key data attributes can be accessed by calling methods of the same name on theKeyobject. For example: my $q = $dsa_key->q; The attributes for each public-key algorithm are:oRSA Public key:n,eSecret key:n,e,d,p,q,uoDSA Public key:p,q,g,ySecret key:p,q,g,y,xoElGamal Public key:p,g,ySecret key:p,g,y,x$key->checkCheck the key data to determine if it is valid. For example, an RSA secret key would multiply the values ofpandqand verify that the product is equal to the value ofn. Returns true if the key is valid, false otherwise. Not all public key algorithm implementations implement acheckmethod; for those that don't,checkwill always return true.$key->sizeReturns the "size" of the key. The definition of "size" depends on the public key algorithm; for example, DSA defines the size of a key as the bitsize of the value ofp.$key->bytesizeWhereassizewill return a bitsize of the key,bytesizereturns the size in bytes. This value is defined as "int((bitsize(key)+7)/8)".$key->is_secretReturns true if the key$keyis a secret key, false otherwise.$key->public_keyReturns the public part of the key$key. If$keyis already a public key,$keyis returned; otherwise a new public key object (Crypt::OpenPGP::Key::Public) is constructed, and the public values from the secret key are copied into the public key. The new public key is returned.$key->can_encryptReturns true if the key algorithm has encryption/decryption capabilities, false otherwise.$key->can_signReturns true if the key algorithm has signing/verification capabilities, false otherwise.$key->algReturns the name of the public key algorithm.$key->alg_idReturns the number ID of the public key algorithm.AUTHOR & COPYRIGHTSPlease see the Crypt::OpenPGP manpage for author, copyright, and license information. perl v5.24.1 2009-12-10 Crypt::OpenPGP::Key(3)

NAME | SYNOPSIS | DESCRIPTION | KEY GENERATION | METHODS | AUTHOR & COPYRIGHTS

Want to link to this manual page? Use this URL:

<https://www.freebsd.org/cgi/man.cgi?query=Crypt::OpenPGP::Key&sektion=3&manpath=FreeBSD+12.1-RELEASE+and+Ports>