@return: {ARRAY} [ err, pubKey, version ]
@param: {STRING} $eccPrivKeyOrCertificate: The PEM Private Key or PEM Certificate
@param: {STRING} $privKeyPassword: *OPTIONAL* The password for the PEM Private Key if requires
Extract the PEM Public Key from a PEM Private Key or a PEM Certificate
public staticfunctiondecryptPrivateKeyPem (
string$encryptedPrivKeyPem,
string$privKeyPassword
) {} :: ARRAY
@return: {ARRAY} [ err, privKey ]
@param: {STRING} $encryptedPrivKeyPem: The encrypted PEM Private Key
@param: {STRING} $privKeyPassword: The password used to decrypt the PEM Private Key
Decrypt an encrypted PEM Private Key using a password
public staticfunctionencryptPrivateKeyPem (
string$plainPrivKeyPem,
string$privKeyPassword
) {} :: ARRAY
@return: {ARRAY} [ err, privKey ]
@param: {STRING} $plainPrivKeyPem: The plain PEM Private Key
@param: {STRING} $privKeyPassword: The password used to encrypt the PEM Private Key
@return: {ARRAY} [ err, algo, mode, signatureB64 ]
@param: {STRING} $eccPrivKey: The PEM Private Key (plain or encrypted)
@param: {STRING} $eccPubKey: The PEM Public Key, required for verification
@param: {STRING} $data: Data to be Signed
@param: {STRING} $algo: Algorithm to be used for the Signature, must be compliant with the algorithm used by the used keys and certificate ; by example cannot sign using sha256 or sha3-256 with a sha512 or sha3-512 certificate private/public key because the hash size differs
@param: {STRING} $privKeyPassword: *OPTIONAL* The password for the PEM Private Key if requires
@param: {BOOL} $useASN1: *OPTIONAL* by default is TRUE, will create an ASN1 compliant signature ; if set to FALSE will create a Raw (Non-ASN1) signature
Create an EcDSA Digital Signature
Supported Algorithms: sha3-512, sha512, sha3-384, sha384, sha3-256, sha256
@return: {ARRAY} [ err, algo, mode, verifyResult ] ; the verifyResult must be TRUE if verified, otherwise may return NULL or INTEGER
@param: {STRING} $eccPubKey: The PEM Public Key or the Certificate PEM
@param: {STRING} $data: Data to be Verified
@param: {STRING} $signatureB64: The Base64 Signature
@param: {STRING} $algo: Algorithm to be used for the Signature, must be compliant with the algorithm used by the used keys and certificate ; by example cannot sign using sha256 or sha3-256 with a sha512 or sha3-512 certificate private/public key because the hash size differs
@param: {BOOL} $useASN1: *OPTIONAL* by default is TRUE, will create an ASN1 compliant signature ; if set to FALSE will create a Raw (Non-ASN1) signature
Verify an EcDSA Digital Signature
Supported Algorithms: sha3-512, sha512, sha3-384, sha384, sha3-256, sha256
@return: {ARRAY} [ err, mode, algo, curve, scheme, years, dNames, certificate, privKey, pubKey, serial, dateTime ]
@param: {ARRAY} $dNames: The MetaInfo Certificate Names, minimum required is: [ commonName ] ; example: ['commonName' => 'My Sample Name', 'emailAddress' => 'my@email.local', 'organizationName' => 'my.local', 'organizationalUnitName' => 'My Sample Test - ECDSA Digital Signature']
@param: {INT} $years: The number of years for the certificate to be valid, 1..100
@param: {STRING} $curve: The EcDSA curve ; can use only: secp521r1 with sha3-256 or sha256 ; secp384r1 with sha3-384 or sha384 ; secp256k1 with sha3-256 or sha256 ; any other combinations are invalid due to the hash size required by the curve
@param: {STRING} $algo: Algorithm to be used for the Signature, must be compliant with the algorithm used by the curve
@param: {STRING} $privKeyPassword: *OPTIONAL* The password for the PEM Private Key ; if provided the returned Private Key PEM will be encrypted
Create a New EcDSA Certificate and the key Pair as Private and Public Key, all in PEM format
Supported Algorithms: sha3-512, sha512, sha3-384, sha384, sha3-256, sha256
Supported Curves: secp521r1, secp384r1, secp256k1
public staticfunctionisValidPrivateKeyPEM (
string$eccPrivKey
) {} :: BOOL
@return: {BOOL} TRUE if Valid, FALSE if not valid or not supported
@param: {STRING} $eccPrivKey: The plain or encrypted Private Key PEM
Validates a Private Key PEM format
It does not validate the type, by example if it is EcDSA or RSA
Supports: Plain or Encrypted Private Key PEM
Plain Private Key PEM, in base 64 format must be enclosed within: -----BEGIN PRIVATE KEY----- ... -----END PRIVATE KEY-----
Encrypted Private Key PEM, in base 64 format must be enclosed within: -----BEGIN PRIVATE KEY----- ... -----END PRIVATE KEY----- and having Proc-Type: 4,ENCRYPTED in header
or, alternate encrypted key as
Encrypted Private Key PEM, in base 64 format must be enclosed within: -----BEGIN ENCRYPTED PRIVATE KEY----- ... -----END ENCRYPTED PRIVATE KEY-----
public staticfunctionisValidPublicKeyPEM (
string$eccPubKey
) {} :: BOOL
@return: {BOOL} TRUE if Valid, FALSE if not valid or not supported
@param: {STRING} $eccPubKey: The Public Key PEM
Validates a Public Key PEM format
It does not validate the type, by example if it is EcDSA or RSA
Public Key PEM, in base 64 format must be enclosed within: -----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----
public staticfunctionisValidCertificatePEM (
string$eccCertPem
) {} :: BOOL
@return: {BOOL} TRUE if Valid, FALSE if not valid or not supported
@param: {STRING} $eccCertPem: The Certificate PEM
Validates a Certificate PEM format
It does not validate the type, by example if it is EcDSA or RSA
Certificate PEM, in base 64 format must be enclosed within: -----BEGIN CERTIFICATE----- ... -----END CERTIFICATE-----
Supports (standard): secp521r1/sha512 ; secp384r1/sha384 ; secp256k1/sha256
Supports (non-standard): secp521r1/sha3-512 ; secp384r1/sha3-384 ; secp256k1/sha3-256