new MemoryPrivateKeyStorage()
MemoryPrivateKeyStorage class extends PrivateKeyStorage to implement private
key storage in memory.
Methods
(static) encodePkcs8PrivateKey(privateKeyDer, oid, parameters) → {Blob}
Encode the private key to a PKCS #8 private key. We do this explicitly here
to avoid linking to extra OpenSSL libraries.
Parameters:
| Name | Type | Description |
|---|---|---|
privateKeyDer |
Buffer | The input private key DER. |
oid |
OID | The OID of the privateKey. |
parameters |
DerNode | The DerNode of the parameters for the OID. |
Returns:
The PKCS #8 private key DER.
- Type
- Blob
deleteKeyPair(keyName)
Delete a pair of asymmetric keys. If the key doesn't exist, do nothing.
Parameters:
| Name | Type | Description |
|---|---|---|
keyName |
Name | The name of the key pair. |
doesKeyExist(keyName, keyClass) → {boolean}
Check if a particular key exists.
Parameters:
| Name | Type | Description |
|---|---|---|
keyName |
Name | The name of the key. |
keyClass |
number | The class of the key, e.g. KeyClass.PUBLIC, KeyClass.PRIVATE, or KeyClass.SYMMETRIC. |
Returns:
True if the key exists, otherwise false.
- Type
- boolean
getPublicKey(keyName) → {PublicKey}
Get the public key
Parameters:
| Name | Type | Description |
|---|---|---|
keyName |
Name | The name of public key. |
Returns:
The public key.
- Type
- PublicKey
setKeyPairForKeyName(keyName, keyType, publicKeyDer, privateKeyDer)
Set the public and private key for the keyName.
Parameters:
| Name | Type | Description |
|---|---|---|
keyName |
Name | The key name. |
keyType |
number | The KeyType, such as KeyType.RSA. |
publicKeyDer |
Buffer | The public key DER byte array. |
privateKeyDer |
Buffer | The private key DER byte array. |
setPrivateKeyForKeyName(keyName, keyType, privateKeyDer)
Set the private key for the keyName.
Parameters:
| Name | Type | Description |
|---|---|---|
keyName |
Name | The key name. |
keyType |
number | The KeyType, such as KeyType.RSA. |
privateKeyDer |
Buffer | The private key DER byte array. |
setPublicKeyForKeyName(keyName, keyType, publicKeyDer)
Set the public key for the keyName.
Parameters:
| Name | Type | Description |
|---|---|---|
keyName |
Name | The key name. |
keyType |
number | The KeyType, such as KeyType.RSA. |
publicKeyDer |
Buffer | The public key DER byte array. |
sign(data, keyName, digestAlgorithm, onComplete) → {Blob}
Fetch the private key for keyName and sign the data to produce a signature Blob.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Buffer | Pointer to the input byte array. |
keyName |
Name | The name of the signing key. |
digestAlgorithm |
number | (optional) The digest algorithm from DigestAlgorithm, such as DigestAlgorithm.SHA256. If omitted, use DigestAlgorithm.SHA256. |
onComplete |
function | (optional) This calls onComplete(signature) with the signature Blob. If omitted, the return value is the signature Blob. (Some crypto libraries only use a callback, so onComplete is required to use these.) |
Returns:
If onComplete is omitted, return the signature Blob. Otherwise,
return null and use onComplete as described above.
- Type
- Blob