PHP Класс 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.
Автор: Robert Richards ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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

Открытые методы

Метод Описание
__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.

Приватные методы

Метод Описание
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

Описание методов

__construct() публичный Метод

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

convertRSA() публичный статический Метод

Hint: Modulus and Exponent must already be base64 decoded
public static convertRSA ( string $modulus, string $exponent ) : string
$modulus string
$exponent string
Результат string

decryptData() публичный Метод

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
Результат mixed | string

encryptData() публичный Метод

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
Результат mixed | string

fromEncryptedKeyElement() публичный статический Метод

Create key from an EncryptedKey-element.
public static fromEncryptedKeyElement ( DOMElemen\DOMElement $element ) : XMLSecurityKey
$element DOMElemen\DOMElement The EncryptedKey-element.
Результат XMLSecurityKey The new key.

generateSessionKey() публичный Метод

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
Результат string

getAlgorith() публичный Метод

См. также: getAlgorithm()
Устаревший:
public getAlgorith ( ) : mixed
Результат mixed

getAlgorithm() публичный Метод

public getAlgorithm ( ) : mixed
Результат mixed

getRawThumbprint() публичный статический Метод

Get the raw thumbprint of a certificate
public static getRawThumbprint ( string $cert ) : null | string
$cert string
Результат null | string

getSymmetricKeySize() публичный Метод

. If the key size is unknown, or this isn't a symmetric encryption algorithm, null is returned.
public getSymmetricKeySize ( ) : integer | null
Результат integer | null The number of bytes in the key.

getX509Certificate() публичный Метод

Will return the X509 certificate in PEM-format if this key represents an X509 certificate.
public getX509Certificate ( ) : string
Результат string The X509 certificate or null if this key doesn't represent an X509-certificate.

getX509Thumbprint() публичный Метод

Returns: The thumbprint as a lowercase 40-character hexadecimal number, or null if this isn't a X509 certificate.
public getX509Thumbprint ( ) : string
Результат string Lowercase 40-character hexadecimal number of thumbprint

loadKey() публичный Метод

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 makeAsnSegment ( integer $type, string $string ) : null | string
$type integer
$string string
Результат null | string

serializeKey() публичный Метод

public serializeKey ( mixed $parent )
$parent mixed

signData() публичный Метод

Signs the data (string) using the extension assigned to the type in the constructor.
public signData ( string $data ) : mixed | string
$data string
Результат mixed | string

verifySignature() публичный Метод

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
Результат boolean | integer

Описание свойств

$encryptedCtx публичное свойство

public XMLSecEnc,RobRichards\XMLSecLibs|null $encryptedCtx
Результат RobRichards\XMLSecLibs\XMLSecEnc | null

$guid публичное свойство

public mixed|null $guid
Результат mixed | null

$isEncrypted публичное свойство

public bool $isEncrypted
Результат boolean

$iv публичное свойство

public string|null $iv
Результат string | null

$key публичное свойство

public mixed|null $key
Результат mixed | null

$keyChain публичное свойство

public mixed|null $keyChain
Результат mixed | null

$name публичное свойство

public string|null $name
Результат string | null

$passphrase публичное свойство

public string $passphrase
Результат string

$type публичное свойство

public int|string $type
Результат integer | string