EC

Extends\phpseclib3\Crypt\Common\AsymmetricKey

Pure-PHP implementation of EC.

author

Jim Wigginton terrafrost@php.net

package

Default

Methods

The constructor

__construct()
inherited

__toString() magic method

__toString(): string
inherited

Response

string

Add a fileformat plugin

addFileFormat(string $fullname): boolean
inheritedstatic

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()

Arguments

$fullname

string

Response

boolean

Bit String to Integer

bits2int(string $in): \phpseclib3\Math\BigInteger
inherited

Arguments

$in

string

Response

\phpseclib3\Math\BigInteger

Bit String to Octet String

bits2octets(string $in): string
inherited

Arguments

$in

string

Response

string

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

computek(string $h1): string
inherited

Arguments

$h1

string

Response

string

Create public / private key pair.

createKey(string $curve): \phpseclib3\Crypt\EC\PrivateKey
static

Arguments

$curve

string

Response

\phpseclib3\Crypt\EC\PrivateKey

Returns the key's comment

getComment(): null|string
inherited

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

Response

null|string

Returns the signature format currently being used

getContext()

Returns the curve

getCurve(): string|array

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

Response

string|array

Returns the public key coordinates as a string

getEncodedCoordinates(): string

Used by ECDH

Response

string

Returns the current engine being used

getEngine(): string
see self::useInternalEngine()self::useBestEngine()

Response

string

Returns the hash algorithm currently being used

getHash()
inherited

Returns the key size

getLength(): integer

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"

Response

integer

Returns the format of the loaded key.

getLoadedFormat(): mixed
inherited

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()

Response

mixed

Returns the parameters

getParameters(string $type = 'PKCS1'): mixed
see self::getPublicKey()

Arguments

$type

string

optional

Response

mixed

Returns the signature format currently being used

getSignatureFormat()

Returns a list of supported formats.

getSupportedKeyFormats(): array
inheritedstatic

Response

array

Initialize static variables

initialize_static_variables()
inheritedstatic

Integer to Octet String

int2octets(\phpseclib3\Math\BigInteger $v): string
inherited

Arguments

Response

string

Load the key

load(string $key,string $password = false): \phpseclib3\Crypt\Common\AsymmetricKey
inheritedstatic

Arguments

$key

string

$password

string

optional

Response

\phpseclib3\Crypt\Common\AsymmetricKey

Load the key, assuming a specific format

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

Arguments

$type

string

$key

string

$password

string

optional

Response

static

Loads parameters

loadParameters(string|array $key): \phpseclib3\Crypt\Common\AsymmetricKey
inheritedstatic

Arguments

$key

string|array

Response

\phpseclib3\Crypt\Common\AsymmetricKey

Loads parameters

loadParametersFormat(string $type,string|array $key): \phpseclib3\Crypt\Common\AsymmetricKey
inheritedstatic

Arguments

$type

string

$key

string|array

Response

\phpseclib3\Crypt\Common\AsymmetricKey

Load Plugins

loadPlugins(string $format)
inheritedstatic

Arguments

$format

string

Loads a private key

loadPrivateKey(string|array $key,string $password = ''): \phpseclib3\Crypt\Common\PrivateKey
inheritedstatic

Arguments

$key

string|array

$password

string

optional

Response

\phpseclib3\Crypt\Common\PrivateKey

Loads a private key

loadPrivateKeyFormat(string $type,string $key,string $password = false): \phpseclib3\Crypt\Common\PrivateKey
inheritedstatic

Arguments

$type

string

$key

string

$password

string

optional

Response

\phpseclib3\Crypt\Common\PrivateKey

Loads a public key

loadPublicKey(string|array $key): \phpseclib3\Crypt\Common\PublicKey
inheritedstatic

Arguments

$key

string|array

Response

\phpseclib3\Crypt\Common\PublicKey

Loads a public key

loadPublicKeyFormat(string $type,string $key): \phpseclib3\Crypt\Common\PublicKey
inheritedstatic

Arguments

$type

string

$key

string

Response

\phpseclib3\Crypt\Common\PublicKey

OnLoad Handler

onLoad(array $components): boolean
static

Arguments

$components

array

Response

boolean

toString

toString(string $type,array $options = array()): string
inheritedabstract

Arguments

$type

string

$options

array

Response

string

Tests engine validity

useBestEngine()
inheritedstatic

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

useInternalEngine()
inheritedstatic

Validate Plugin

validatePlugin(string $format,string $type,string $method = null): mixed
inheritedstatic

Arguments

$format

string

$type

string

$method

string

optional

Response

mixed

Sets the context

withContext(string $context = null)

Used by Ed25519 / Ed448.

see self::sign()self::verify()

Arguments

$context

string

optional

Determines which hashing function should be used

withHash(string $hash)
inherited

Arguments

$hash

string

Determines the signature padding mode

withSignatureFormat(string $format)

Valid values are: ASN1, SSH2, Raw

Arguments

$format

string

Constants

Algorithm Name

ALGORITHM
var

Properties

Public Key QA

QA :array<mixed,object>
var

Type(s)

array<mixed,object>

Curve

curve :\phpseclib3\Crypt\EC\BaseCurves\Base

Format of the loaded key

format :string
inherited
var

Type(s)

string

Signature Format (Short)

shortFormat :string
var

Type(s)

string

Curve Name

curveName :string
var

Type(s)

string

Curve Order

q :\phpseclib3\Math\BigInteger

Used for deterministic ECDSA

var

Type(s)

\phpseclib3\Math\BigInteger

Alias for the private key

x :\phpseclib3\Math\BigInteger

Used for deterministic ECDSA. AsymmetricKey expects $x. I don't like x because with x you have x the base point yielding an (x, y)-coordinate that is the public key. But the x is different depending on which side of the equal sign you're on. It's less ambiguous if you do dA base point = (x, y)-coordinate.

var

Type(s)

\phpseclib3\Math\BigInteger

Context

context :string
var

Type(s)

string

Signature Format

sigFormat :string
var

Type(s)

string

Precomputed Zero

zero :\phpseclib3\Math\BigInteger
inheritedstatic

Precomputed One

one :\phpseclib3\Math\BigInteger
inheritedstatic

Hash function

hash :\phpseclib3\Crypt\Hash
inherited

HMAC function

hmac :\phpseclib3\Crypt\Hash
inherited

Supported plugins (lower case)

plugins :array
inheritedstatic
see
var

Type(s)

array

Invisible plugins

invisiblePlugins :array
inheritedstatic
see
var

Type(s)

array

Available Engines

engines :array<mixed,boolean>
inheritedstatic
var

Type(s)

array<mixed,boolean>

Key Comment

comment :null|string
inherited
var

Type(s)

null|string