class XMLSecurityKey

Constants

TRIPLEDES_CBC

AES128_CBC

AES192_CBC

AES256_CBC

RSA_1_5

RSA_OAEP_MGF1P

DSA_SHA1

RSA_SHA1

RSA_SHA256

RSA_SHA384

RSA_SHA512

HMAC_SHA1

Properties

int|string $type
mixed|null $key
string $passphrase
string|null $iv
string|null $name
mixed|null $keyChain
bool $isEncrypted
XMLSecEnc|null $encryptedCtx
mixed|null $guid

Methods

__construct(string $type, null|array $params = null)

No description

int|null
getSymmetricKeySize()

Retrieve the key size for the symmetric encryption algorithm.

string
generateSessionKey()

Generates a session key using the openssl-extension.

static null|string
getRawThumbprint(string $cert)

Get the raw thumbprint of a certificate

loadKey(string $key, bool $isFile = false, bool $isCert = false)

Loads the given key, or - with isFile set true - the key from the keyfile.

mixed|string
encryptData(string $data)

Encrypts the given data (string) using the regarding php-extension, depending on the library assigned to algorithm in the contructor.

mixed|string
decryptData(string $data)

Decrypts the given data (string) using the regarding php-extension, depending on the library assigned to algorithm in the contructor.

mixed|string
signData(string $data)

Signs the data (string) using the extension assigned to the type in the constructor.

bool|int
verifySignature(string $data, string $signature)

Verifies the data (string) against the given signature using the extension assigned to the type in the constructor.

mixed
getAlgorith() deprecated

No description

mixed
getAlgorithm()

No description

static null|string
makeAsnSegment(int $type, string $string)

No description

static string
convertRSA(string $modulus, string $exponent)

Hint: Modulus and Exponent must already be base64 decoded

string
getX509Certificate()

Retrieve the X509 certificate this key represents.

string
getX509Thumbprint()

Get the thumbprint of this X509 certificate.

static XMLSecurityKey
fromEncryptedKeyElement(DOMElement $element)

Create key from an EncryptedKey-element.

Details

at line 70
__construct(string $type, null|array $params = null)

Parameters

string $type
null|array $params

Exceptions

Exception

at line 193
int|null getSymmetricKeySize()

Retrieve the key size for the symmetric encryption algorithm.

.</p> <p>If the key size is unknown, or this isn't a symmetric encryption algorithm, null is returned.

Return Value

int|null The number of bytes in the key.

at line 207
string generateSessionKey()

Generates a session key using the openssl-extension.

In case of using DES3-CBC the key is checked for a proper parity bits set.

Return Value

string

Exceptions

Exception

at line 241
static null|string getRawThumbprint(string $cert)

Get the raw thumbprint of a certificate

Parameters

string $cert

Return Value

null|string

at line 276
loadKey(string $key, bool $isFile = false, bool $isCert = false)

Loads the given key, or - with isFile set true - the key from the keyfile.

Parameters

string $key
bool $isFile
bool $isCert

Exceptions

Exception

at line 499
mixed|string encryptData(string $data)

Encrypts the given data (string) using the regarding php-extension, depending on the library assigned to algorithm in the contructor.

Parameters

string $data

Return Value

mixed|string

Exceptions

Exception

at line 522
mixed|string decryptData(string $data)

Decrypts the given data (string) using the regarding php-extension, depending on the library assigned to algorithm in the contructor.

Parameters

string $data

Return Value

mixed|string

Exceptions

Exception

at line 545
mixed|string signData(string $data)

Signs the data (string) using the extension assigned to the type in the constructor.

Parameters

string $data

Return Value

mixed|string

Exceptions

Exception

at line 573
bool|int verifySignature(string $data, string $signature)

Verifies the data (string) against the given signature using the extension assigned to the type in the constructor.

Returns in case of openSSL: 1 on succesful signature verification, 0 when signature verification failed, -1 if an error occurred during processing.</p> <p>NOTE: be very careful when checking the return value, because in PHP, -1 will be cast to True when in boolean context. So always check the return value in a strictly typed way, e.g. "$obj->verify(...) === 1".

Parameters

string $data
string $signature

Return Value

bool|int

at line 591
mixed getAlgorith() deprecated

deprecated

Return Value

mixed

See also

at line 599
mixed getAlgorithm()

Return Value

mixed

at line 610
static null|string makeAsnSegment(int $type, string $string)

Parameters

int $type
string $string

Return Value

null|string

at line 643
static string convertRSA(string $modulus, string $exponent)

Hint: Modulus and Exponent must already be base64 decoded

Parameters

string $modulus
string $exponent

Return Value

string

at line 672
string getX509Certificate()

Retrieve the X509 certificate this key represents.

Will return the X509 certificate in PEM-format if this key represents an X509 certificate.

Return Value

string The X509 certificate or null if this key doesn't represent an X509-certificate.

at line 686
string getX509Thumbprint()

Get the thumbprint of this X509 certificate.

Returns: The thumbprint as a lowercase 40-character hexadecimal number, or null if this isn't a X509 certificate.

Return Value

string Lowercase 40-character hexadecimal number of thumbprint

at line 700
static XMLSecurityKey fromEncryptedKeyElement(DOMElement $element)

Create key from an EncryptedKey-element.

Parameters

DOMElement $element The EncryptedKey-element.

Return Value

XMLSecurityKey The new key.

Exceptions

Exception