Constants

ALGORITHM_NAME

ALGORITHM_NAME

The internal name of the algorithm.

KEY_SIZE

KEY_SIZE

The internal key size measured in raw bits length for the algorithm

Properties

$digestion

$digestion : integer

The signature's internal digestion algorithm property.

Type

integer — The digestion algorithm integer code value.

$signatureFormat

$signatureFormat : integer

The output signature format property storage.

Type

integer — The output signature format integer code value.

$privateKey

$privateKey : string

The private key string property storage.

Type

string — The private key string value.

$publicKey

$publicKey : string

The public key string property storage.

Type

string — The public key string value.

Methods

__construct()

__construct() 

Asymmetrical algorithm constructor.

__debugInfo()

__debugInfo() : array

Get debug information for the class instance.

Returns

array —

Debug information.

signData()

signData(string  $plainData) : string

Generates a signature of the given plain data.

Parameters

string $plainData

The plain input string.

Throws

\Exception

Validation errors.

Returns

string —

The signature data.

verifyDataSignature()

verifyDataSignature(string  $signatureData, string  $plainData) : boolean

Verifies that the signature is correct for the given plain data.

Parameters

string $signatureData

The signature input string.

string $plainData

The plain input string.

Throws

\Exception

Validation errors.

Returns

boolean —

The verification result.

setSignatureDigestion()

setSignatureDigestion(integer  $signingAlgorithm) : $this

Setter for the signature's internal digestion algorithm property.

Parameters

integer $signingAlgorithm

The digestion algorithm integer code value.

Throws

\Exception

Validation errors.

Returns

$this —

The signature algorithm object.

getSignatureDigestion()

getSignatureDigestion() : integer

Setter for the signature's internal digestion algorithm property.

Returns

integer —

The digestion algorithm integer code value.

signObject()

signObject(object|\stdClass  $object) : string

Generates a signature of the given object.

Parameters

object|\stdClass $object

The object for signing.

Throws

\Exception

Validation errors.

Returns

string —

The signature data.

verifyObjectSignature()

verifyObjectSignature(string  $signatureData, object|\stdClass  $object) : boolean

Verifies that the signature is correct for the given object.

Parameters

string $signatureData

The signature input string.

object|\stdClass $object

The object used for signing.

Throws

\Exception

Validation errors.

Returns

boolean —

The verification result.

signFile()

signFile(string  $filename) : string

Generates a signature of a given plain file.

Parameters

string $filename

The full path and name of the file for signing.

Throws

\Exception

Validation errors.

Returns

string —

The signature data.

verifyFileSignature()

verifyFileSignature(string  $signatureData, string  $filename) : boolean

Verifies that the signature is correct for a given plain file.

Parameters

string $signatureData

The signature input string.

string $filename

The full path and name of the file for signing.

Throws

\Exception

Validation errors.

Returns

boolean —

The verification result.

setSignatureFormat()

setSignatureFormat(integer  $signatureFormat) : $this

Setter for the output signature format code property.

Parameters

integer $signatureFormat

The output signature format code.

Throws

\Exception

Validation errors.

Returns

$this —

The signature algorithm object.

getSignatureFormat()

getSignatureFormat() : integer

Getter for the output signature format code property.

Returns

integer —

The output signature format code.

setKeyPair()

setKeyPair(\CryptoManana\DataStructures\KeyPair  $keyPair) : $this

Setter for the whole key pair as an array.

Parameters

\CryptoManana\DataStructures\KeyPair $keyPair

The private and public key pair as an object.

Throws

\Exception

Validation errors.

Returns

$this —

The encryption/signature algorithm object.

getKeyPair()

getKeyPair() : \CryptoManana\DataStructures\KeyPair

Getter for the whole key pair as an array.

Throws

\Exception

Validation errors.

Returns

\CryptoManana\DataStructures\KeyPair

The private and public key pair as an object.

setPrivateKey()

setPrivateKey(string  $privateKey) : $this

Setter for the private key string property.

Parameters

string $privateKey

The private key string.

Throws

\Exception

Validation errors.

Returns

$this —

The encryption/signature algorithm object.

getPrivateKey()

getPrivateKey() : string

Getter for the private key string property.

Returns

string —

The private key string.

setPublicKey()

setPublicKey(string  $publicKey) : $this

Setter for the public key string property.

Parameters

string $publicKey

The public key string.

Throws

\Exception

Validation errors.

Returns

$this —

The encryption/signature algorithm object.

getPublicKey()

getPublicKey() : string

Getter for the public key string property.

Returns

string —

The public key string.

checkIfThePrivateKeyIsSet()

checkIfThePrivateKeyIsSet() 

Checks if the private key is present.

Throws

\Exception

If there is no private key set.

checkIfThePublicKeyIsSet()

checkIfThePublicKeyIsSet() 

Checks if the public key is present.

Throws

\Exception

If there is no public key set.

validatePlainData()

validatePlainData(string  $plainData) 

Internal method for the validation of plain data used at encryption/signing operations.

Parameters

string $plainData

The plain input string.

Throws

\Exception

Validation errors.

validateCipherOrSignatureData()

validateCipherOrSignatureData(string  $cipherOrSignatureData) 

Internal method for the validation of cipher/signature data used at decryption/verifying operations.

Parameters

string $cipherOrSignatureData

The encrypted input string or a signature string.

Throws

\Exception

Validation errors.

signingFormat()

signingFormat(string  $bytes) 

Internal method for converting format after signing operations.

Parameters

string $bytes

The bytes for conversion.

verificationFormatHex()

verificationFormatHex(string  $bytes) 

Internal method for converting from HEX formatted string after verification operations.

Parameters

string $bytes

The bytes for conversion.

verificationFormatBase64()

verificationFormatBase64(string  $bytes) 

Internal method for converting from Base64 formatted string after verification operations.

Parameters

string $bytes

The bytes for conversion.

verificationFormat()

verificationFormat(string  $bytes) 

Internal method for converting format after verification operations.

Parameters

string $bytes

The bytes for conversion.

changeOutputFormat()

changeOutputFormat(string  $bytes, boolean|integer|null  $direction = true) : string

Internal method for converting the output format representation via the chosen format.

Parameters

string $bytes

The bytes for conversion.

boolean|integer|null $direction

Flag for signing direction (sign => true or verify => false).

Returns

string —

The formatted bytes.

validatePrivateKeyResource()

validatePrivateKeyResource(string  $privateKey) : string

Internal method for the validation of the private key resource.

Parameters

string $privateKey

The private key input string.

Throws

\Exception

Validation errors.

Returns

string —

The extracted public key string from the private key resource.

validatePublicKeyResource()

validatePublicKeyResource(string  $publicKey) 

Internal method for the validation of the public key resource.

Parameters

string $publicKey

The public key input string.

Throws

\Exception

Validation errors.

validateKeyPair()

validateKeyPair(string  $privateKey, string  $publicKey) 

Internal method for the validation of the private and public key pair string representations.

Parameters

string $privateKey

The private key input string.

string $publicKey

The public key input string.

Throws

\Exception

Validation errors.