new TpmBackEndFile(locationPath)
TpmBackEndFile extends TpmBackEnd to implement a TPM back-end using on-disk
file storage. In this TPM, each private key is stored in a separate file with
permission 0400, i.e., owner read-only. The key is stored in PKCS #1 format
in base64 encoding.
Create a TpmBackEndFile to use the given path to store files (of provided) or
to the default location.
Parameters:
Name | Type | Description |
---|---|---|
locationPath |
string | (optional) The full path of the directory to store private keys. If omitted or null or "", use the default location ~/.ndn/ndnsec-key-file. |
- Source:
Classes
Methods
doCreateKeyPromise_(identityName, params, useSync) → {Promise|SyncPromise}
A protected method to create a key for identityName according to params. The
created key is named as: //[keyId]/KEY . The key name is set in
the returned TpmKeyHandle.
Parameters:
Name | Type | Description |
---|---|---|
identityName |
Name | The name if the identity. |
params |
KeyParams | The KeyParams for creating the key. |
useSync |
boolean | (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise. |
Returns:
A promise which returns the TpmKeyHandle of
the created key, or a promise rejected with TpmBackEnd.Error if the key
cannot be created.
- Type
- Promise | SyncPromise
doDeleteKeyPromise_(keyName, useSync) → {Promise|SyncPromise}
A protected method to delete the key with name keyName. If the key doesn't
exist, do nothing.
Parameters:
Name | Type | Description |
---|---|---|
keyName |
Name | The name of the key to delete. |
useSync |
boolean | (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise. |
Returns:
A promise which fulfills when finished, or a
promise rejected with TpmBackEnd.Error if the deletion fails.
- Type
- Promise | SyncPromise
doGetKeyHandlePromise_(keyName, useSync) → {Promise|SyncPromise}
A protected method to get the handle of the key with name keyName.
Parameters:
Name | Type | Description |
---|---|---|
keyName |
Name | The name of the key. |
useSync |
boolean | (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise. |
Returns:
A promise which returns a TpmKeyHandle of the
key, or returns null if the key does not exist.
- Type
- Promise | SyncPromise
doHasKeyPromise_(keyName, useSync) → {Promise|SyncPromise}
A protected method to check if the key with name keyName exists in the TPM.
Parameters:
Name | Type | Description |
---|---|---|
keyName |
Name | The name of the key. |
useSync |
boolean | (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise. |
- Source:
Returns:
A promise which returns true if the key exists.
- Type
- Promise | SyncPromise
hasKey_(keyName) → {boolean}
Do the work of doHasKeyPromise_
Parameters:
Name | Type | Description |
---|---|---|
keyName |
Name | The name of the key. |
- Source:
Returns:
True if the key exists.
- Type
- boolean
loadKey_(keyName) → {TpmPrivateKey}
Load the private key with name keyName from the key file directory.
Parameters:
Name | Type | Description |
---|---|---|
keyName |
Name | The name of the key. |
Returns:
The key loaded into a TpmPrivateKey.
- Type
- TpmPrivateKey
saveKey_(keyName, key)
Save the private key using keyName into the key file directory.
Parameters:
Name | Type | Description |
---|---|---|
keyName |
Name | The name of the key. |
key |
TpmPrivateKey | The private key to save. |
toFilePath_(keyName) → {string}
Get the file path for the keyName, which is keyStorePath_ + "/" +
hex(sha256(keyName-wire-encoding)) + ".privkey" .
Parameters:
Name | Type | Description |
---|---|---|
keyName |
Name | The name of the key. |
Returns:
The file path for the key.
- Type
- string