Documentation

PublicKey extends DSA
in package
implements PublicKey uses Fingerprint

DSA Public Key

Tags
author

Jim Wigginton terrafrost@php.net

access

public

Table of Contents

Interfaces

PublicKey
PublicKey interface

Constants

ALGORITHM  = 'DSA'
Algorithm Name

Properties

$engines  : array<string|int, bool>
Available Engines
$format  : string
Format of the loaded key
$g  : BigInteger
DSA Group Generator G
$hash  : Hash
Hash function
$one  : BigInteger
Precomputed One
$p  : BigInteger
DSA Prime P
$q  : BigInteger
DSA Group Order q
$shortFormat  : string
Signature Format (Short)
$sigFormat  : string
Signature Format
$y  : BigInteger
DSA public key value y
$zero  : BigInteger
Precomputed Zero
$comment  : null|string
Key Comment
$hmac  : Hash
HMAC function
$invisiblePlugins  : array<string|int, mixed>
Invisible plugins
$plugins  : array<string|int, mixed>
Supported plugins (lower case)
$signatureFileFormats  : array<string|int, mixed>
Supported signature formats (original case)
$signatureFormats  : array<string|int, mixed>
Supported signature formats (lower case)

Methods

__toString()  : string
__toString() magic method
addFileFormat()  : bool
Add a fileformat plugin
createKey()  : PrivateKey
Create public / private key pair.
createParameters()  : DSA|bool
Create DSA parameters
getComment()  : null|string
Returns the key's comment
getEngine()  : string
Returns the current engine being used
getFingerprint()  : mixed
Returns the public key's fingerprint
getHash()  : mixed
Returns the hash algorithm currently being used
getLength()  : array<string|int, mixed>
Returns the key size
getLoadedFormat()  : mixed
Returns the format of the loaded key.
getParameters()  : mixed
Returns the parameters
getSignatureFormat()  : mixed
Returns the signature format currently being used
getSupportedKeyFormats()  : array<string|int, mixed>
Returns a list of supported formats.
load()  : AsymmetricKey
Load the key
loadFormat()  : AsymmetricKey
Load the key, assuming a specific format
loadParameters()  : AsymmetricKey
Loads parameters
loadParametersFormat()  : AsymmetricKey
Loads parameters
loadPrivateKey()  : PrivateKey
Loads a private key
loadPrivateKeyFormat()  : PrivateKey
Loads a private key
loadPublicKey()  : PublicKey
Loads a public key
loadPublicKeyFormat()  : PublicKey
Loads a public key
toString()  : string
Returns the public key
useBestEngine()  : mixed
Tests engine validity
useInternalEngine()  : mixed
Flag to use internal engine only (useful for unit testing)
verify()  : mixed
Verify a signature
withHash()  : mixed
Determines which hashing function should be used
withSignatureFormat()  : mixed
Determines the signature padding mode
__construct()  : mixed
Constructor
bits2int()  : BigInteger
Bit String to Integer
computek()  : string
Compute the pseudorandom k for signature generation, using the process specified for deterministic DSA.
initialize_static_variables()  : mixed
Initialize static variables
onLoad()  : bool
OnLoad Handler
validatePlugin()  : mixed
Validate Plugin
bits2octets()  : string
Bit String to Octet String
int2octets()  : string
Integer to Octet String
loadPlugins()  : mixed
Load Plugins

Constants

ALGORITHM

Algorithm Name

public string ALGORITHM = 'DSA'
Tags
access

private

Properties

$engines

Available Engines

protected static array<string|int, bool> $engines = []
Tags
access

private

$format

Format of the loaded key

protected string $format
Tags
access

private

$q

DSA Group Order q

protected BigInteger $q

Prime divisor of p-1

Tags
access

private

$shortFormat

Signature Format (Short)

protected string $shortFormat
Tags
access

private

$sigFormat

Signature Format

protected string $sigFormat
Tags
access

private

$comment

Key Comment

private null|string $comment
Tags
access

private

$invisiblePlugins

Invisible plugins

private static array<string|int, mixed> $invisiblePlugins = []
Tags
see
self::initialize_static_variables()
access

private

$plugins

Supported plugins (lower case)

private static array<string|int, mixed> $plugins = []
Tags
see
self::initialize_static_variables()
access

private

$signatureFileFormats

Supported signature formats (original case)

private static array<string|int, mixed> $signatureFileFormats = []
Tags
see
self::initialize_static_variables()
access

private

$signatureFormats

Supported signature formats (lower case)

private static array<string|int, mixed> $signatureFormats = []
Tags
see
self::initialize_static_variables()
access

private

Methods

__toString()

__toString() magic method

public __toString() : string
Return values
string

addFileFormat()

Add a fileformat plugin

public static addFileFormat(string $fullname) : bool

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.

Parameters
$fullname : string
Tags
see
self::load()
access

public

Return values
bool

createKey()

Create public / private key pair.

public static createKey(array<string|int, int> ...$args) : PrivateKey

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

Parameters
$args : array<string|int, int>
Tags
access

public

Return values
PrivateKey

createParameters()

Create DSA parameters

public static createParameters([int $L = 2048 ][, int $N = 224 ]) : DSA|bool
Parameters
$L : int = 2048
$N : int = 224
Tags
access

public

Return values
DSA|bool

getComment()

Returns the key's comment

public getComment() : null|string

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

Tags
access

public

Return values
null|string

getEngine()

Returns the current engine being used

public getEngine() : string
Tags
see
self::useInternalEngine()
see
self::useBestEngine()
access

public

Return values
string

getFingerprint()

Returns the public key's fingerprint

public getFingerprint([string $algorithm = 'md5' ]) : mixed

The public key's fingerprint is returned, which is equivalent to running ssh-keygen -lf rsa.pub. If there is no public key currently loaded, false is returned. Example output (md5): "c1:b1:30:29:d7:b8:de:6c:97:77:10:d7:46:41:63:87" (as specified by RFC 4716)

Parameters
$algorithm : string = 'md5'

The hashing algorithm to be used. Valid options are 'md5' and 'sha256'. False is returned for invalid values.

Tags
access

public

getHash()

Returns the hash algorithm currently being used

public getHash() : mixed
Tags
access

public

getLength()

Returns the key size

public getLength() : array<string|int, mixed>

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

Tags
access

public

Return values
array<string|int, mixed>

getLoadedFormat()

Returns the format of the loaded key.

public getLoadedFormat() : mixed

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.

Tags
see
self::load()
access

public

getParameters()

Returns the parameters

public getParameters() : mixed

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

Tags
see
self::getPublicKey()
access

public

getSignatureFormat()

Returns the signature format currently being used

public getSignatureFormat() : mixed
Tags
access

public

getSupportedKeyFormats()

Returns a list of supported formats.

public static getSupportedKeyFormats() : array<string|int, mixed>
Tags
access

public

Return values
array<string|int, mixed>

loadFormat()

Load the key, assuming a specific format

public static loadFormat(string $type, string $key[, string $password = false ]) : AsymmetricKey
Parameters
$type : string
$key : string
$password : string = false

optional

Return values
AsymmetricKey

loadParameters()

Loads parameters

public loadParameters(string|array<string|int, mixed> $key) : AsymmetricKey
Parameters
$key : string|array<string|int, mixed>
Tags
access

public

Return values
AsymmetricKey

loadParametersFormat()

Loads parameters

public loadParametersFormat(string $type, string|array<string|int, mixed> $key) : AsymmetricKey
Parameters
$type : string
$key : string|array<string|int, mixed>
Tags
access

public

Return values
AsymmetricKey

loadPrivateKey()

Loads a private key

public loadPrivateKey(string|array<string|int, mixed> $key[, string $password = '' ]) : PrivateKey
Parameters
$key : string|array<string|int, mixed>
$password : string = ''

optional

Tags
access

public

Return values
PrivateKey

loadPrivateKeyFormat()

Loads a private key

public loadPrivateKeyFormat(string $type, string $key[, string $password = false ]) : PrivateKey
Parameters
$type : string
$key : string
$password : string = false

optional

Tags
access

public

Return values
PrivateKey

loadPublicKey()

Loads a public key

public loadPublicKey(string|array<string|int, mixed> $key) : PublicKey
Parameters
$key : string|array<string|int, mixed>
Tags
access

public

Return values
PublicKey

loadPublicKeyFormat()

Loads a public key

public loadPublicKeyFormat(string $type, string $key) : PublicKey
Parameters
$type : string
$key : string
Tags
access

public

Return values
PublicKey

toString()

Returns the public key

public toString(string $type[, array<string|int, mixed> $options = [] ]) : string
Parameters
$type : string
$options : array<string|int, mixed> = []

optional

Return values
string

useBestEngine()

Tests engine validity

public static useBestEngine() : mixed
Tags
access

public

useInternalEngine()

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

public static useInternalEngine() : mixed
Tags
access

public

verify()

Verify a signature

public verify(string $message, string $signature) : mixed
Parameters
$message : string
$signature : string
Tags
see
self::verify()
access

public

withHash()

Determines which hashing function should be used

public withHash(string $hash) : mixed
Parameters
$hash : string
Tags
access

public

withSignatureFormat()

Determines the signature padding mode

public withSignatureFormat(string $format) : mixed

Valid values are: ASN1, SSH2, Raw

Parameters
$format : string
Tags
access

public

__construct()

Constructor

protected __construct() : mixed

PublicKey and PrivateKey objects can only be created from abstract RSA class

computek()

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

protected computek(string $h1) : string
Parameters
$h1 : string
Tags
access

public

Return values
string

initialize_static_variables()

Initialize static variables

protected static initialize_static_variables() : mixed

onLoad()

OnLoad Handler

protected static onLoad(array<string|int, mixed> $components) : bool
Parameters
$components : array<string|int, mixed>
Tags
access

protected

Return values
bool

validatePlugin()

Validate Plugin

protected static validatePlugin(string $format, string $type[, string $method = NULL ]) : mixed
Parameters
$format : string
$type : string
$method : string = NULL

optional

Tags
access

private

bits2octets()

Bit String to Octet String

private bits2octets(string $in) : string
Parameters
$in : string
Tags
access

private

Return values
string

loadPlugins()

Load Plugins

private static loadPlugins(string $format) : mixed
Parameters
$format : string
Tags
access

private


        
On this page

Search results