Crypt_GPG
[ class tree: Crypt_GPG ] [ index: Crypt_GPG ] [ all elements ]

Class: Crypt_GPG_KeyGenerator

Source Location: /Crypt_GPG-1.6.4/Crypt/GPG/KeyGenerator.php

Class Overview

Crypt_GPGAbstract
   |
   --Crypt_GPG_KeyGenerator

GnuPG key generator


Author(s):

Copyright:

  • 2005-2013 silverorange

Variables

Methods


Inherited Variables

Inherited Methods

Class: Crypt_GPGAbstract

Crypt_GPGAbstract::__construct()
Creates a new GPG object
Crypt_GPGAbstract::getVersion()
Returns version of the engine (GnuPG) used for operation.
Crypt_GPGAbstract::setEngine()
Sets the I/O engine to use for GnuPG operations
Crypt_GPGAbstract::setEngineOptions()
Sets per-command additional arguments
Crypt_GPGAbstract::_getKeys()
Gets the available keys in the keyring

Class Details

[line 72]
GnuPG key generator

This class provides an object oriented interface for generating keys with the GNU Privacy Guard (GPG).

Secure key generation requires true random numbers, and as such can be slow. If the operating system runs out of entropy, key generation will block until more entropy is available.

If quick key generation is important, a hardware entropy generator, or an entropy gathering daemon may be installed. For example, administrators of Debian systems may want to install the 'randomsound' package.

This class uses the experimental automated key generation support available in GnuPG. See doc/DETAILS in the GPG distribution for detailed information on the key generation format.



[ Top ]


Class Variables

$expirationDate =  0

[line 83]

The expiration date of generated keys

Type:   integer


[ Top ]

$keyAlgorithm =  Crypt_GPG_SubKey::ALGORITHM_DSA

[line 101]

The algorithm for generated primary keys

Type:   integer


[ Top ]

$keySize =  1024

[line 110]

The size of generated primary keys

Type:   integer


[ Top ]

$keyUsage =  6

[line 122]

The usages of generated primary keys

This is a bitwise combination of the usage constants in Crypt_GPG_SubKey.


Type:   integer


[ Top ]

$passphrase =  ''

[line 92]

The passphrase of generated keys

Type:   string


[ Top ]

$subKeyAlgorithm =  Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC

[line 131]

The algorithm for generated sub-keys

Type:   integer


[ Top ]

$subKeySize =  2048

[line 140]

The size of generated sub-keys

Type:   integer


[ Top ]

$subKeyUsage =  Crypt_GPG_SubKey::USAGE_ENCRYPT

[line 152]

The usages of generated sub-keys

This is a bitwise combination of the usage constants in Crypt_GPG_SubKey.


Type:   integer


[ Top ]



Method Detail

__construct (Constructor)   [line 183]

Crypt_GPG_KeyGenerator __construct( [array $options = array()])

Creates a new GnuPG key generator
  • Throws: Crypt_GPG_FileException if the homedir does not exist and cannot be created. This can happen if homedir is not specified, Crypt_GPG is run as the web user, and the web user has no home directory. This exception is also thrown if any of the options publicKeyring, privateKeyring or trustDb options are specified but the files do not exist or are are not readable. This can happen if the user running the Crypt_GPG process (for example, the Apache user) does not have permission to read the files.
  • Throws: PEAR_Exception if the provided binary is invalid, or if no binary is provided and no suitable binary could be found.
  • Throws: PEAR_Exception if the provided agent is invalid, or if no agent is provided and no suitable gpg-agent could be found.
  • Access: public

Overrides Crypt_GPGAbstract::__construct() (Creates a new GPG object)

Parameters:

array   $options   —  An array of options used to create the object. All options are optional and are represented as key-value pairs. See Crypt_GPGAbstract::__construct() for more info.

[ Top ]

generateKey   [line 455]

Crypt_GPG_Key generateKey( string|Crypt_GPG_UserId $name, [string $email = ''], [string $comment = ''])

Generates a new key-pair in the current keyring

Secure key generation requires true random numbers, and as such can be solw. If the operating system runs out of entropy, key generation will block until more entropy is available.

If quick key generation is important, a hardware entropy generator, or an entropy gathering daemon may be installed. For example, administrators of Debian systems may want to install the 'randomsound' package.

  • Return: the newly generated key.
  • Throws: Crypt_GPG_Exception if an unknown or unexpected error occurs. Use the debug option and file a bug report if these exceptions occur.
  • Throws: Crypt_GPG_KeyNotCreatedException if the key parameters are incorrect, if an unknown error occurs during key generation, or if the newly generated key is not found in the keyring.
  • Access: public

Parameters:

string|Crypt_GPG_UserId   $name   —  either a Crypt_GPG_UserId object, or a string containing the name of the user id.
string   $email   —  optional. If $name is specified as a string, this is the email address of the user id.
string   $comment   —  optional. If $name is specified as a string, this is the comment of the user id.

[ Top ]

getUsage   [line 564]

string getUsage( integer $usage)

Builds a GnuPG key usage string suitable for key generation

See doc/DETAILS in the GPG distribution for detailed information on the key usage format.

  • Return: the key usage string.
  • Access: protected

Parameters:

integer   $usage   —  a bitwise combination of the key usages. This is a combination of the Crypt_GPG_SubKey::USAGE_* constants.

[ Top ]

getUserId   [line 606]

Crypt_GPG_UserId getUserId( string|Crypt_GPG_UserId $name, [string $email = ''], [string $comment = ''])

Gets a user id object from parameters
  • Return: a user id object for the specified parameters.
  • Access: protected

Parameters:

string|Crypt_GPG_UserId   $name   —  either a Crypt_GPG_UserId object, or a string containing the name of the user id.
string   $email   —  optional. If $name is specified as a string, this is the email address of the user id.
string   $comment   —  optional. If $name is specified as a string, this is the comment of the user id.

[ Top ]

setExpirationDate   [line 210]

Crypt_GPG_KeyGenerator setExpirationDate( string|integer $date)

Sets the expiration date of generated keys
  • Return: the current object, for fluent interface.
  • Throws: InvalidArgumentException if the date is not a valid format, or if the date is not at least one day in the future, or if the date is greater than 2038-01-19T03:14:07.
  • Access: public

Parameters:

string|integer   $date   —  either a string that may be parsed by PHP's strtotime() function, or an integer timestamp representing the number of seconds since the UNIX epoch. This date must be at least one date in the future. Keys that expire in the past may not be generated. Use an expiration date of 0 for keys that do not expire.

[ Top ]

setKeyParams   [line 288]

Crypt_GPG_KeyGenerator setKeyParams( integer $algorithm, [integer $size = 0], [integer $usage = 0])

Sets the parameters for the primary key of generated key-pairs
  • Return: the current object, for fluent interface.
  • Access: public

Parameters:

integer   $algorithm   —  the algorithm used by the key. This should be one of the Crypt_GPG_SubKey::ALGORITHM_* constants.
integer   $size   —  optional. The size of the key. Different algorithms have different size requirements. If not specified, the default size for the specified algorithm will be used. If an invalid key size is used, GnuPG will do its best to round it to a valid size.
integer   $usage   —  optional. A bitwise combination of key usages. If not specified, the primary key will be used only to sign and certify. This is the default behavior of GnuPG in interactive mode. Use the Crypt_GPG_SubKey::USAGE_* constants here. The primary key may be used to certify even if the certify usage is not specified.

[ Top ]

setPassphrase   [line 257]

Crypt_GPG_KeyGenerator setPassphrase( string $passphrase)

Sets the passphrase of generated keys
  • Return: the current object, for fluent interface.
  • Access: public

Parameters:

string   $passphrase   —  the passphrase to use for generated keys. Use null or an empty string for no passphrase.

[ Top ]

setSubKeyParams   [line 363]

Crypt_GPG_KeyGenerator setSubKeyParams( integer $algorithm, [integer $size = ''], [integer $usage = 0])

Sets the parameters for the sub-key of generated key-pairs
  • Return: the current object, for fluent interface.
  • Access: public

Parameters:

integer   $algorithm   —  the algorithm used by the key. This should be one of the Crypt_GPG_SubKey::ALGORITHM_* constants.
integer   $size   —  optional. The size of the key. Different algorithms have different size requirements. If not specified, the default size for the specified algorithm will be used. If an invalid key size is used, GnuPG will do its best to round it to a valid size.
integer   $usage   —  optional. A bitwise combination of key usages. If not specified, the sub-key will be used only to encrypt. This is the default behavior of GnuPG in interactive mode. Use the Crypt_GPG_SubKey::USAGE_* constants here.

[ Top ]


Documentation generated on Sun, 22 Mar 2020 08:01:07 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.