new MemoryPrivateKeyStorage()
MemoryPrivateKeyStorage class extends PrivateKeyStorage to implement private
key storage in memory.
Methods
deleteKeyPairPromise(keyName) → {SyncPromise}
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. |
Returns:
A promise that fulfills when the key pair is deleted.
- Type
- SyncPromise
doesKeyExistPromise(keyName, keyClass) → {SyncPromise}
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:
A promise which returns true if the key exists.
- Type
- SyncPromise
generateKeyPairPromise(keyName, params, useSync) → {Promise|SyncPromise}
Generate a pair of asymmetric keys.
Parameters:
Name | Type | Description |
---|---|---|
keyName |
Name | The name of the key pair. |
params |
KeyParams | The parameters of the key. |
useSync |
boolean | (optional) If true then use blocking crypto and return a SyncPromise which is already fulfilled. If omitted or false, if possible use crypto.subtle and return an async Promise, otherwise use blocking crypto and return a SyncPromise. |
Returns:
A promise that fulfills when the pair is
generated.
- Type
- Promise | SyncPromise
getPublicKeyPromise(keyName) → {SyncPromise}
Get the public key
Parameters:
Name | Type | Description |
---|---|---|
keyName |
Name | The name of public key. |
Returns:
A promise that returns the PublicKey.
- Type
- SyncPromise
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. |
signPromise(data, keyName, digestAlgorithm, useSync) → {Promise|SyncPromise}
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. |
useSync |
boolean | (optional) If true then use blocking crypto and return a SyncPromise which is already fulfilled. If omitted or false, if possible use crypto.subtle and return an async Promise, otherwise use blocking crypto and return a SyncPromise. |
Returns:
A promise that returns the signature Blob.
- Type
- Promise | SyncPromise