PHP Class RobRichards\XMLSecLibs\XMLSecurityKey

Copyright (c) 2007-2015, Robert Richards . All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Robert Richards nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Author: Robert Richards ([email protected])
Afficher le fichier Open project: robrichards/xmlseclibs Class Usage Examples

Méthodes publiques

Свойство Type Description
$encryptedCtx RobRichards\XMLSecLibs\XMLSecEnc | null
$guid mixed | null
$isEncrypted boolean
$iv string | null
$key mixed | null
$keyChain mixed | null
$name string | null
$passphrase string
$type integer | string

Méthodes publiques

Méthode Description
__construct ( string $type, null | array $params = null )
convertRSA ( string $modulus, string $exponent ) : string Hint: Modulus and Exponent must already be base64 decoded
decryptData ( string $data ) : mixed | string Decrypts the given data (string) using the regarding php-extension, depending on the library assigned to algorithm in the contructor.
encryptData ( string $data ) : mixed | string Encrypts the given data (string) using the regarding php-extension, depending on the library assigned to algorithm in the contructor.
fromEncryptedKeyElement ( DOMElemen\DOMElement $element ) : XMLSecurityKey Create key from an EncryptedKey-element.
generateSessionKey ( ) : string Generates a session key using the openssl-extension or using the mcrypt-extension as a fallback.
getAlgorith ( ) : mixed
getAlgorithm ( ) : mixed
getRawThumbprint ( string $cert ) : null | string Get the raw thumbprint of a certificate
getSymmetricKeySize ( ) : integer | null Retrieve the key size for the symmetric encryption algorithm.
getX509Certificate ( ) : string Retrieve the X509 certificate this key represents.
getX509Thumbprint ( ) : string Get the thumbprint of this X509 certificate.
loadKey ( string $key, boolean $isFile = false, boolean $isCert = false ) Loads the given key, or - with isFile set true - the key from the keyfile.
makeAsnSegment ( integer $type, string $string ) : null | string
serializeKey ( mixed $parent )
signData ( string $data ) : mixed | string Signs the data (string) using the extension assigned to the type in the constructor.
verifySignature ( string $data, string $signature ) : boolean | integer Verifies the data (string) against the given signature using the extension assigned to the type in the constructor.

Private Methods

Méthode Description
decryptMcrypt ( string $data ) : string Decrypts the given data (string) using the mcrypt-extension
decryptOpenSSL ( string $data ) : string Decrypts the given data (string) using the openssl-extension
encryptMcrypt ( string $data ) : string Encrypts the given data (string) using the mcrypt-extension
encryptOpenSSL ( string $data ) : string Encrypts the given data (string) using the openssl-extension
signOpenSSL ( string $data ) : string Signs the given data (string) using the openssl-extension
verifyOpenSSL ( string $data, string $signature ) : integer Verifies the given data (string) belonging to the given signature using the openssl-extension

Method Details

__construct() public méthode

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

convertRSA() public static méthode

Hint: Modulus and Exponent must already be base64 decoded
public static convertRSA ( string $modulus, string $exponent ) : string
$modulus string
$exponent string
Résultat string

decryptData() public méthode

Decrypts the given data (string) using the regarding php-extension, depending on the library assigned to algorithm in the contructor.
public decryptData ( string $data ) : mixed | string
$data string
Résultat mixed | string

encryptData() public méthode

Encrypts the given data (string) using the regarding php-extension, depending on the library assigned to algorithm in the contructor.
public encryptData ( string $data ) : mixed | string
$data string
Résultat mixed | string

fromEncryptedKeyElement() public static méthode

Create key from an EncryptedKey-element.
public static fromEncryptedKeyElement ( DOMElemen\DOMElement $element ) : XMLSecurityKey
$element DOMElemen\DOMElement The EncryptedKey-element.
Résultat XMLSecurityKey The new key.

generateSessionKey() public méthode

In case of using DES3-CBC the key is checked for a proper parity bits set - Mcrypt doesn't care about the parity bits, but others may care.
public generateSessionKey ( ) : string
Résultat string

getAlgorith() public méthode

See also: getAlgorithm()
Deprecation:
public getAlgorith ( ) : mixed
Résultat mixed

getAlgorithm() public méthode

public getAlgorithm ( ) : mixed
Résultat mixed

getRawThumbprint() public static méthode

Get the raw thumbprint of a certificate
public static getRawThumbprint ( string $cert ) : null | string
$cert string
Résultat null | string

getSymmetricKeySize() public méthode

. If the key size is unknown, or this isn't a symmetric encryption algorithm, null is returned.
public getSymmetricKeySize ( ) : integer | null
Résultat integer | null The number of bytes in the key.

getX509Certificate() public méthode

Will return the X509 certificate in PEM-format if this key represents an X509 certificate.
public getX509Certificate ( ) : string
Résultat string The X509 certificate or null if this key doesn't represent an X509-certificate.

getX509Thumbprint() public méthode

Returns: The thumbprint as a lowercase 40-character hexadecimal number, or null if this isn't a X509 certificate.
public getX509Thumbprint ( ) : string
Résultat string Lowercase 40-character hexadecimal number of thumbprint

loadKey() public méthode

Loads the given key, or - with isFile set true - the key from the keyfile.
public loadKey ( string $key, boolean $isFile = false, boolean $isCert = false )
$key string
$isFile boolean
$isCert boolean

makeAsnSegment() public static méthode

public static makeAsnSegment ( integer $type, string $string ) : null | string
$type integer
$string string
Résultat null | string

serializeKey() public méthode

public serializeKey ( mixed $parent )
$parent mixed

signData() public méthode

Signs the data (string) using the extension assigned to the type in the constructor.
public signData ( string $data ) : mixed | string
$data string
Résultat mixed | string

verifySignature() public méthode

Verifies the data (string) against the given signature using the extension assigned to the type in the constructor.
public verifySignature ( string $data, string $signature ) : boolean | integer
$data string
$signature string
Résultat boolean | integer

Property Details

$encryptedCtx public_oe property

public XMLSecEnc,RobRichards\XMLSecLibs|null $encryptedCtx
Résultat RobRichards\XMLSecLibs\XMLSecEnc | null

$guid public_oe property

public mixed|null $guid
Résultat mixed | null

$isEncrypted public_oe property

public bool $isEncrypted
Résultat boolean

$iv public_oe property

public string|null $iv
Résultat string | null

$key public_oe property

public mixed|null $key
Résultat mixed | null

$keyChain public_oe property

public mixed|null $keyChain
Résultat mixed | null

$name public_oe property

public string|null $name
Résultat string | null

$passphrase public_oe property

public string $passphrase
Résultat string

$type public_oe property

public int|string $type
Résultat integer | string