DSA Private Key
author | Jim Wigginton terrafrost@php.net |
---|---|
package | Default |
__construct()
__toString(): string
string
addFileFormat(string $fullname): boolean
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() |
---|
string
boolean
bits2int(string $in): \phpseclib3\Math\BigInteger
bits2octets(string $in): string
string
string
computek(string $h1): string
string
string
createKey(array<mixed,integer> $args): \phpseclib3\Crypt\DSA\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
array<mixed,integer>
\phpseclib3\Crypt\DSA\PrivateKey
createParameters(integer $L = 2048,integer $N = 224): \phpseclib3\Crypt\DSA|boolean
getComment(): null|string
Not all key formats support comments. If you want to set a comment use toString()
null|string
getEngine(): string
see | self::useInternalEngine()self::useBestEngine() |
---|---|
string
getHash()
getLength(): array
More specifically, this L (the length of DSA Prime P) and N (the length of DSA Group Order q)
array
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.
see | \phpseclib3\Crypt\Common\AsymmetricKey::load() |
---|---|
mixed
getParameters(): mixed
A public / private key is only returned if the currently loaded "key" contains an x or y value.
see | self::getPublicKey() |
---|---|
mixed
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() |
---|---|
mixed
getSignatureFormat()
getSupportedKeyFormats(): array
array
initialize_static_variables()
int2octets(\phpseclib3\Math\BigInteger $v): string
load(string $key,string $password = false): \phpseclib3\Crypt\Common\AsymmetricKey
loadFormat(string $type,string $key,string $password = false): static
string
string
string
optional
static
loadParameters(string|array $key): \phpseclib3\Crypt\Common\AsymmetricKey
loadParametersFormat(string $type,string|array $key): \phpseclib3\Crypt\Common\AsymmetricKey
loadPlugins(string $format)
string
loadPrivateKey(string|array $key,string $password = ''): \phpseclib3\Crypt\Common\PrivateKey
loadPrivateKeyFormat(string $type,string $key,string $password = false): \phpseclib3\Crypt\Common\PrivateKey
string
string
string
optional
\phpseclib3\Crypt\Common\PrivateKey
loadPublicKey(string|array $key): \phpseclib3\Crypt\Common\PublicKey
loadPublicKeyFormat(string $type,string $key): \phpseclib3\Crypt\Common\PublicKey
onLoad(array $components): boolean
array
boolean
sign(string $message): mixed
see | self::verify() |
---|
string
mixed
toString(string $type,array $options = array()): string
string
array
string
useBestEngine()
useInternalEngine()
validatePlugin(string $format,string $type,string $method = null): mixed
string
string
string
optional
mixed
withHash(string $hash)
string
withPassword(string|boolean $password = false)
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() |
---|---|
string|boolean
withSignatureFormat(string $format)
Valid values are: ASN1, SSH2, Raw
string
ALGORITHM
var |
---|
password :string|boolean
var |
---|
string|boolean
q :\phpseclib3\Math\BigInteger
g :\phpseclib3\Math\BigInteger
y :\phpseclib3\Math\BigInteger
sigFormat :string
var |
---|
string
shortFormat :string
var |
---|
string
zero :\phpseclib3\Math\BigInteger
one :\phpseclib3\Math\BigInteger
format :string
var |
---|
string
plugins :array
see | |
---|---|
var |
array
invisiblePlugins :array
see | |
---|---|
var |
array
engines :array<mixed,boolean>
var |
---|
array<mixed,boolean>
Key Comment
Type(s)
null|string