PublicKey
class PublicKey extends DSA implements PublicKey (View source)
DSA Public Key
Traits
Constants
ALGORITHM |
Algorithm Name |
Properties
static protected BigInteger | $zero | Precomputed Zero | from AsymmetricKey |
static protected BigInteger | $one | Precomputed One | from AsymmetricKey |
protected string | $format | Format of the loaded key | from AsymmetricKey |
protected Hash | $hash | Hash function | from AsymmetricKey |
static protected bool[] | $engines | Available Engines | from AsymmetricKey |
protected BigInteger | $p | DSA Prime P | from DSA |
protected BigInteger | $q | DSA Group Order q | from DSA |
protected BigInteger | $g | DSA Group Generator G | from DSA |
protected BigInteger | $y | DSA public key value y | from DSA |
protected string | $sigFormat | Signature Format | from DSA |
protected string | $shortFormat | Signature Format (Short) | from DSA |
Methods
Loads a private key
Load the key, assuming a specific format
Loads a private key
Loads parameters
Validate Plugin
Flag to use internal engine only (useful for unit testing)
Compute the pseudorandom k for signature generation, using the process specified for deterministic DSA.
Returns the public key's fingerprint
Verify a signature
Returns the public key
Details
in
DSA at line 264
protected
__construct()
Constructor
PublicKey and PrivateKey objects can only be created from abstract RSA class
static protected
initialize_static_variables()
Initialize static variables
static AsymmetricKey
load(string $key, string $password = false)
Load the key
PrivateKey
loadPrivateKey(string|array $key, string $password = '')
Loads a private key
PublicKey
loadPublicKey(string|array $key)
Loads a public key
AsymmetricKey
loadParameters(string|array $key)
Loads parameters
static AsymmetricKey
loadFormat(string $type, string $key, string $password = false)
Load the key, assuming a specific format
PrivateKey
loadPrivateKeyFormat(string $type, string $key, string $password = false)
Loads a private key
PublicKey
loadPublicKeyFormat(string $type, string $key)
Loads a public key
AsymmetricKey
loadParametersFormat(string $type, string|array $key)
Loads parameters
static protected mixed
validatePlugin(string $format, string $type, string $method = NULL)
Validate Plugin
static array
getSupportedKeyFormats()
Returns a list of supported formats.
static bool
addFileFormat(string $fullname)
Add a fileformat plugin
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.
mixed
getLoadedFormat()
Returns the format of the loaded key.
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.
null|string
getComment()
Returns the key's comment
Not all key formats support comments. If you want to set a comment use toString()
static
useBestEngine()
Tests engine validity
static
useInternalEngine()
Flag to use internal engine only (useful for unit testing)
string
__toString()
__toString() magic method
withHash(string $hash)
Determines which hashing function should be used
getHash()
Returns the hash algorithm currently being used
protected string
computek(string $h1)
Compute the pseudorandom k for signature generation, using the process specified for deterministic DSA.
protected BigInteger
bits2int(string $in)
Bit String to Integer
in
DSA at line 116
static DSA|bool
createParameters(int $L = 2048, int $N = 224)
Create DSA parameters
in
DSA at line 192
static PrivateKey
createKey(int[] ...$args)
Create public / private key pair.
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
in
DSA at line 233
static protected bool
onLoad(array $components)
OnLoad Handler
in
DSA at line 280
array
getLength()
Returns the key size
More specifically, this L (the length of DSA Prime P) and N (the length of DSA Group Order q)
in
DSA at line 293
string
getEngine()
Returns the current engine being used
in
DSA at line 309
mixed
getParameters()
Returns the parameters
A public / private key is only returned if the currently loaded "key" contains an x or y value.
in
DSA at line 327
withSignatureFormat(string $format)
Determines the signature padding mode
Valid values are: ASN1, SSH2, Raw
in
DSA at line 340
getSignatureFormat()
Returns the signature format currently being used
mixed
getFingerprint(string $algorithm = 'md5')
Returns the public key's fingerprint
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)
verify($message, $signature)
Verify a signature
toString($type, array $options = [])
Returns the public key