AsymmetricKey
abstract class AsymmetricKey (View source)
Base Class for all asymmetric cipher classes
Properties
static protected BigInteger | $zero | Precomputed Zero | |
static protected BigInteger | $one | Precomputed One | |
protected string | $format | Format of the loaded key | |
protected Hash | $hash | Hash function | |
static protected bool[] | $engines | Available Engines |
Methods
The constructor
Initialize static variables
Load the key
Loads a private key
Loads a public key
Loads parameters
Load the key, assuming a specific format
Loads a private key
Loads a public key
Loads parameters
Validate Plugin
Returns a list of supported formats.
Add a fileformat plugin
Returns the format of the loaded key.
Returns the key's comment
Tests engine validity
Flag to use internal engine only (useful for unit testing)
__toString() magic method
Determines which hashing function should be used
Returns the hash algorithm currently being used
Compute the pseudorandom k for signature generation, using the process specified for deterministic DSA.
Bit String to Integer
Details
protected
__construct()
The constructor
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