Returns the default Crypt_KeyStore type.
static
string
getDefaultType
()
Returns a Crypt_KeyStore object of the specified type. If an instance of the specified type is not already initialized, a new instance is created.
-
string
$type: the type of key store instance
Lists all the alias names of this Crypt_KeyStore.
array
aliases
()
Checks if the given alias exists in this Crypt_KeyStore.
boolean
containsAlias
(string $alias)
-
string
$alias: the alias of the entry to query
Creates a new private key and certificate signing request (CSR) for the private key. The CSR is returned for signing.
string
createCSR
(string $alias, [string $password = false], [array $dn = array()], [array $options = array()])
-
string
$alias: alias to store new key/certificate under
-
string
$password: password used to protect the private key
-
array
$dn: distinguished name used to create CSR
-
array
$options: array of key pair/certificate creation options
Creates a symmetric secret key from a randomly generated
pass phrase and stores the new key in the key store, protecting it with the password if specified. The pass phrase is a sequence of random hex numbers which is then used to generate the key using a SHA-256 hash and 8-bytes of salt.
void
createSecretKey
(string $alias, [array $password = false], [array $options = array()])
-
string
$alias: the alias the new key will be stored as
-
array
$password: password used to protected the key
-
array
$options: array of key creation options
Decrypts the data with the key stored with the alias, optionally using the password to decrypt the key.
string
decrypt
(string $encData, string $alias, [string $password = false], [array $options = array()])
-
string
$encData: the encrypted data to decrypt
-
string
$alias: the alias of the key to use to decrypt
-
string
$password: the password to use to decrypt the key
-
array
$options: array of decryption options
Deletes the entry identified by the given alias from this Crypt_KeyStore.
void
deleteEntry
(string $alias)
-
string
$alias: the alias of the entry to delete
Encrypts the data with the key stored with the alias, optionally using the password to decrypt the key.
string
encrypt
(string $data, string $alias, [string $password = false], [array $options = array()])
-
string
$data: the plain text data to encrypt
-
string
$alias: the alias of the key to use to encrypt
-
string
$password: the password to use to decrypt the key
-
array
$options: array of encryption options
Determines if the Crypt_KeyStore Entry for the specified alias is an instance or subclass of the specified entryClass.
boolean
entryInstanceOf
(string $alias, class $entryClazzName)
-
string
$alias: the alias of the entry to test
-
class
$entryClazzName: the key store entry class name to test
Returns the (alias) name of the first Crypt_KeyStore entry whose certificate matches the given certificate.
string
getCertificateAlias
(string $cert)
-
string
$cert: the certificate text
Returns the certificate chain associated with the given alias.
array
getCertificateChain
(string $alias)
-
string
$alias: the alias of the certificate chain
Returns the creation date of the entry identified by the given alias.
DateTime
getCreationDate
(string $alias)
-
string
$alias: the alias of the entry to retrieve
Gets a Crypt_KeyStore Entry for the specified alias with the specified protection parameter.
-
string
$alias: the alias of the entry to retrieve
-
array
$options: the password used to decrypt the key
Returns the type of this Crypt_KeyStore.
string
getType
()
Imports a signed-certificate into the key store assigning the alias to
the new entry. If the alias is a pre-existing private key, the certificate must be valid and correspond to the private key. Otherwise, an exception is thrown. If no entry exists for the alias, a new trusted certificate entry is created for the certificate.
void
importCertificate
(string $cert, string $alias, [string $password = false])
-
string
$cert: the certificate to import
-
string
$alias: the alias of the entry to import certificate into
-
string
$password: private key password
Helper function to return an associative array initialized with default values for a distinguished name (DN) worthy of creating a CSR.
TODO - populate with values from a configuration file
array
initializeDn
()
Returns true if the entry identified by the given alias was created by a call to _setCertificateEntry, or created by a call to _setEntry with a Crypt_KeyStore_TrustedCertificateEntry.
boolean
isCertificateEntry
(string $alias)
-
string
$alias: the alias of the entry to test
Returns true if the entry identified by the given alias was created by a call to _setKeyEntry, or created by a call to _setEntry with a Crypt_KeyStore_PrivateKeyEntry or a Crypt_KeyStore_SecretKeyEntry.
boolean
isKeyEntry
(string $alias)
-
string
$alias: the alias of the entry to test
Loads this Crypt_KeyStore from the given input stream.
void
load
(string $filename, string $password, [array $options = array()])
-
string
$filename: path and file name of key store file
-
string
$password: password used encrypt key store
-
array
$options: load options
Signs the data with the private key stored by the specified alias.
string
sign
(string $data, string $alias, [string $password = false], [array $options = array()])
-
string
$data: the data to be signed
-
string
$alias: the alias of the private key to use for signing
-
string
$password: the password to unlock the private key
-
array
$options: array of signing options
Retrieves the number of entries in this Crypt_KeyStore.
int
size
()
Stores this Crypt_KeyStore to the given output stream, and protects its integrity with the given password.
void
store
(string $filename, string $password, [array $options = array()])
-
string
$filename: path and file name of key store file
-
string
$password: password used encrypt key store
-
array
$options: store options
Verifies the signature was signed by the private key stored by the specified alias.
boolean
verify
(string $data, string $signature, string $alias, [array $options = array()])
-
string
$data: the original data to verify signature against
-
string
$signature: the signature to verify
-
string
$alias: the alias of the private key
-
array
$options: array of verification options