class Parameters extends EC (View source)

EC Parameters

Constants

ALGORITHM

Algorithm Name

Properties

static protected BigInteger $zero Precomputed Zero from  AsymmetricKey
static protected BigInteger $one Precomputed One from  AsymmetricKey
protected string $format Signature Format from  EC
protected Hash $hash Hash function from  AsymmetricKey
static protected bool[] $engines Available Engines from  AsymmetricKey
protected object[] $QA Public Key QA from  EC
protected Base $curve Curve from  EC
protected string $shortFormat Signature Format (Short) from  EC
protected BigInteger $q Curve Order from  EC
protected BigInteger $x Alias for the private key from  EC
protected string $context Context from  EC

Methods

__construct()

Constructor

from  EC
static 
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 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

mixed
getLoadedFormat()

Returns the format of the loaded key.

null|string
getComment()

Returns the key's comment

static 
useBestEngine()

Tests engine validity

static 
useInternalEngine()

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

string
__toString()

__toString() magic method

from  EC
withHash(string $hash)

Determines which hashing function should be used

from  EC
getHash()

Returns the hash algorithm currently being used

string
computek(string $h1)

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

bits2int(string $in)

Bit String to Integer

static PrivateKey
createKey(string $curve)

Create public / private key pair.

from  EC
static bool
onLoad(array $components)

OnLoad Handler

from  EC
string|array
getCurve()

Returns the curve

from  EC
int
getLength()

Returns the key size

from  EC
string
getEngine()

Returns the current engine being used

from  EC
string
getEncodedCoordinates()

Returns the public key coordinates as a string

from  EC
mixed
getParameters(string $type = 'PKCS1')

Returns the parameters

from  EC
withSignatureFormat(string $format)

Determines the signature padding mode

from  EC
getSignatureFormat()

Returns the signature format currently being used

from  EC
withContext(string $context = null)

Sets the context

from  EC
getContext()

Returns the signature format currently being used

from  EC
string
toString(string $type = 'PKCS1', array $options = [])

Returns the parameters

Details

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

Parameters

string $key
string $password optional

Return Value

AsymmetricKey

PrivateKey loadPrivateKey(string|array $key, string $password = '')

Loads a private key

Parameters

string|array $key
string $password optional

Return Value

PrivateKey

PublicKey loadPublicKey(string|array $key)

Loads a public key

Parameters

string|array $key

Return Value

PublicKey

AsymmetricKey loadParameters(string|array $key)

Loads parameters

Parameters

string|array $key

Return Value

AsymmetricKey

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

Load the key, assuming a specific format

Parameters

string $type
string $key
string $password optional

Return Value

AsymmetricKey

PrivateKey loadPrivateKeyFormat(string $type, string $key, string $password = false)

Loads a private key

Parameters

string $type
string $key
string $password optional

Return Value

PrivateKey

PublicKey loadPublicKeyFormat(string $type, string $key)

Loads a public key

Parameters

string $type
string $key

Return Value

PublicKey

AsymmetricKey loadParametersFormat(string $type, string|array $key)

Loads parameters

Parameters

string $type
string|array $key

Return Value

AsymmetricKey

static protected mixed validatePlugin(string $format, string $type, string $method = NULL)

Validate Plugin

Parameters

string $format
string $type
string $method optional

Return Value

mixed

static array getSupportedKeyFormats()

Returns a list of supported formats.

Return Value

array

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.

Parameters

string $fullname

Return Value

bool

See also

\self::load()

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.

Return Value

mixed

See also

\self::load()

null|string getComment()

Returns the key's comment

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

Return Value

null|string

static useBestEngine()

Tests engine validity

static useInternalEngine()

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

string __toString()

__toString() magic method

Return Value

string

withHash(string $hash)

Determines which hashing function should be used

Parameters

string $hash

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.

Parameters

string $h1

Return Value

string

protected BigInteger bits2int(string $in)

Bit String to Integer

Parameters

string $in

Return Value

BigInteger

static PrivateKey createKey(string $curve)

Create public / private key pair.

Parameters

string $curve

Return Value

PrivateKey

static protected bool onLoad(array $components)

OnLoad Handler

Parameters

array $components

Return Value

bool

string|array getCurve()

Returns the curve

Returns a string if it's a named curve, an array if not

Return Value

string|array

int getLength()

Returns the key size

Quoting https://tools.ietf.org/html/rfc5656#section-2,

"The size of a set of elliptic curve domain parameters on a prime curve is defined as the number of bits in the binary representation of the field order, commonly denoted by p. Size on a characteristic-2 curve is defined as the number of bits in the binary representation of the field, commonly denoted by m. A set of elliptic curve domain parameters defines a group of order n generated by a base point P"

Return Value

int

string getEngine()

Returns the current engine being used

Return Value

string

See also

\self::useInternalEngine()
\self::useBestEngine()

string getEncodedCoordinates()

Returns the public key coordinates as a string

Used by ECDH

Return Value

string

mixed getParameters(string $type = 'PKCS1')

Returns the parameters

Parameters

string $type optional

Return Value

mixed

See also

\self::getPublicKey()

withSignatureFormat(string $format)

Determines the signature padding mode

Valid values are: ASN1, SSH2, Raw

Parameters

string $format

getSignatureFormat()

Returns the signature format currently being used

withContext(string $context = null)

Sets the context

Used by Ed25519 / Ed448.

Parameters

string $context optional

See also

\self::sign()
\self::verify()

getContext()

Returns the signature format currently being used

string toString(string $type = 'PKCS1', array $options = [])

Returns the parameters

Parameters

string $type
array $options optional

Return Value

string