PrivateKey

Extends\phpseclib3\Crypt\DSA Implements\phpseclib3\Crypt\Common\PrivateKey

DSA Private Key

author

Jim Wigginton terrafrost@php.net

package

Default

Methods

The constructor

__construct()
inherited

__toString() magic method

__toString(): string
inherited

Response

string

Add a fileformat plugin

addFileFormat(string $fullname): boolean
inheritedstatic

The plugin needs to either already be loaded or be auto-loadable. Loading a plugin whose shortname overwrite an existing shortname will overwrite the old plugin.

see \phpseclib3\Crypt\Common\AsymmetricKey::load()

Arguments

$fullname

string

Response

boolean

Bit String to Integer

bits2int(string $in): \phpseclib3\Math\BigInteger
inherited

Arguments

$in

string

Response

\phpseclib3\Math\BigInteger

Bit String to Octet String

bits2octets(string $in): string
inherited

Arguments

$in

string

Response

string

Compute the pseudorandom k for signature generation, using the process specified for deterministic DSA.

computek(string $h1): string
inherited

Arguments

$h1

string

Response

string

Create public / private key pair.

createKey(array<mixed,integer> $args): \phpseclib3\Crypt\DSA\PrivateKey
inheritedstatic

This method is a bit polymorphic. It can take a DSA/Parameters object, L / N as two distinct parameters or no parameters (at which point L and N will be generated with this method)

Returns the private key, from which the publickey can be extracted

Arguments

$args

array<mixed,integer>

Response

\phpseclib3\Crypt\DSA\PrivateKey

Create DSA parameters

createParameters(integer $L = 2048,integer $N = 224): \phpseclib3\Crypt\DSA|boolean
inheritedstatic

Arguments

$L

integer

$N

integer

Response

\phpseclib3\Crypt\DSA|boolean

Returns the key's comment

getComment(): null|string
inherited

Not all key formats support comments. If you want to set a comment use toString()

Response

null|string

Returns the current engine being used

getEngine(): string
inherited
see self::useInternalEngine()self::useBestEngine()

Response

string

Returns the hash algorithm currently being used

getHash()
inherited

Returns the key size

getLength(): array
inherited

More specifically, this L (the length of DSA Prime P) and N (the length of DSA Group Order q)

Response

array

Returns the format of the loaded key.

getLoadedFormat(): mixed
inherited

If the key that was loaded wasn't in a valid or if the key was auto-generated with RSA::createKey() then this will throw an exception.

see \phpseclib3\Crypt\Common\AsymmetricKey::load()

Response

mixed

Returns the parameters

getParameters(): mixed
inherited

A public / private key is only returned if the currently loaded "key" contains an x or y value.

see self::getPublicKey()

Response

mixed

Returns the public key

getPublicKey(): mixed

If you do "openssl rsa -in private.rsa -pubout -outform PEM" you get a PKCS8 formatted key that contains a publicKeyAlgorithm AlgorithmIdentifier and a publicKey BIT STRING. An AlgorithmIdentifier contains an OID and a parameters field. With RSA public keys this parameters field is NULL. With DSA PKCS8 public keys it is not - it contains the p, q and g variables. The publicKey BIT STRING contains, simply, the y variable. This can be verified by getting a DSA PKCS8 public key:

"openssl dsa -in private.dsa -pubout -outform PEM"

ie. just swap out rsa with dsa in the rsa command above.

A PKCS1 public key corresponds to the publicKey portion of the PKCS8 key. In the case of RSA the publicKey portion /is/ the key. In the case of DSA it is not. You cannot verify a signature without the parameters and the PKCS1 DSA public key format does not include the parameters.

see self::getPrivateKey()

Response

mixed

Returns the signature format currently being used

getSignatureFormat()
inherited

Returns a list of supported formats.

getSupportedKeyFormats(): array
inheritedstatic

Response

array

Initialize static variables

initialize_static_variables()
inheritedstatic

Integer to Octet String

int2octets(\phpseclib3\Math\BigInteger $v): string
inherited

Arguments

Response

string

Load the key

load(string $key,string $password = false): \phpseclib3\Crypt\Common\AsymmetricKey
inheritedstatic

Arguments

$key

string

$password

string

optional

Response

\phpseclib3\Crypt\Common\AsymmetricKey

Load the key, assuming a specific format

loadFormat(string $type,string $key,string $password = false): static
inheritedstatic

Arguments

$type

string

$key

string

$password

string

optional

Response

static

Loads parameters

loadParameters(string|array $key): \phpseclib3\Crypt\Common\AsymmetricKey
inheritedstatic

Arguments

$key

string|array

Response

\phpseclib3\Crypt\Common\AsymmetricKey

Loads parameters

loadParametersFormat(string $type,string|array $key): \phpseclib3\Crypt\Common\AsymmetricKey
inheritedstatic

Arguments

$type

string

$key

string|array

Response

\phpseclib3\Crypt\Common\AsymmetricKey

Load Plugins

loadPlugins(string $format)
inheritedstatic

Arguments

$format

string

Loads a private key

loadPrivateKey(string|array $key,string $password = ''): \phpseclib3\Crypt\Common\PrivateKey
inheritedstatic

Arguments

$key

string|array

$password

string

optional

Response

\phpseclib3\Crypt\Common\PrivateKey

Loads a private key

loadPrivateKeyFormat(string $type,string $key,string $password = false): \phpseclib3\Crypt\Common\PrivateKey
inheritedstatic

Arguments

$type

string

$key

string

$password

string

optional

Response

\phpseclib3\Crypt\Common\PrivateKey

Loads a public key

loadPublicKey(string|array $key): \phpseclib3\Crypt\Common\PublicKey
inheritedstatic

Arguments

$key

string|array

Response

\phpseclib3\Crypt\Common\PublicKey

Loads a public key

loadPublicKeyFormat(string $type,string $key): \phpseclib3\Crypt\Common\PublicKey
inheritedstatic

Arguments

$type

string

$key

string

Response

\phpseclib3\Crypt\Common\PublicKey

OnLoad Handler

onLoad(array $components): boolean
inheritedstatic

Arguments

$components

array

Response

boolean

Create a signature

sign(string $message): mixed
see self::verify()

Arguments

$message

string

Response

mixed

toString

toString(string $type,array $options = array()): string
inheritedabstract

Arguments

$type

string

$options

array

Response

string

Tests engine validity

useBestEngine()
inheritedstatic

Flag to use internal engine only (useful for unit testing)

useInternalEngine()
inheritedstatic

Validate Plugin

validatePlugin(string $format,string $type,string $method = null): mixed
inheritedstatic

Arguments

$format

string

$type

string

$method

string

optional

Response

mixed

Determines which hashing function should be used

withHash(string $hash)
inherited

Arguments

$hash

string

Sets the password

withPassword(string|boolean $password = false)
inherited

Private keys can be encrypted with a password. To unset the password, pass in the empty string or false. Or rather, pass in $password such that empty($password) && !is_string($password) is true.

see self::createKey()self::load()

Arguments

$password

string|boolean

Determines the signature padding mode

withSignatureFormat(string $format)
inherited

Valid values are: ASN1, SSH2, Raw

Arguments

$format

string

Constants

Algorithm Name

ALGORITHM
inherited
var

Properties

DSA secret exponent x

x :\phpseclib3\Math\BigInteger

Password

password :string|boolean
inherited
var

Type(s)

string|boolean

DSA Prime P

p :\phpseclib3\Math\BigInteger
inherited

DSA Group Order q

q :\phpseclib3\Math\BigInteger
inherited

Prime divisor of p-1

var

Type(s)

\phpseclib3\Math\BigInteger

DSA Group Generator G

g :\phpseclib3\Math\BigInteger
inherited

DSA public key value y

y :\phpseclib3\Math\BigInteger
inherited

Signature Format

sigFormat :string
inherited
var

Type(s)

string

Signature Format (Short)

shortFormat :string
inherited
var

Type(s)

string

Precomputed Zero

zero :\phpseclib3\Math\BigInteger
inheritedstatic

Precomputed One

one :\phpseclib3\Math\BigInteger
inheritedstatic

Format of the loaded key

format :string
inherited
var

Type(s)

string

Hash function

hash :\phpseclib3\Crypt\Hash
inherited

HMAC function

hmac :\phpseclib3\Crypt\Hash
inherited

Supported plugins (lower case)

plugins :array
inheritedstatic
see
var

Type(s)

array

Invisible plugins

invisiblePlugins :array
inheritedstatic
see
var

Type(s)

array

Available Engines

engines :array<mixed,boolean>
inheritedstatic
var

Type(s)

array<mixed,boolean>

Key Comment

comment :null|string
inherited
var

Type(s)

null|string