Class: FilePrivateKeyStorage

FilePrivateKeyStorage

new FilePrivateKeyStorage(nonDefaultTpmPath)

FilePrivateKeyStorage works with NFD's default private key storage, the files stored in .ndn/ndnsec-tpm-file. This library will not be available from the browser
Parameters:
Name Type Description
nonDefaultTpmPath string if desired, override the default TPM path (i.e. .ndn/ndnsec-tpm-file)
Source:

Methods

(static) getUserHomePath() → {string}

Retrieve the user's current home directory
Source:
Returns:
path to the user's home directory
Type
string

deleteKey(keyName)

Delete all keys with this name. If the key doesn't exist, do nothing.
Parameters:
Name Type Description
keyName Name The name of the key pair.
Source:

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.
Source:
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.
Source:
Returns:
A promise which returns true if the key exists.
Type
SyncPromise

generateKeyPairPromise(keyName, params) → {SyncPromise}

Generate a pair of asymmetric keys; only currently supports RSA
Parameters:
Name Type Description
keyName Name The name of the key pair.
params KeyParams The parameters of the key.
Source:
Returns:
A promise that fulfills when the pair is generated.
Type
SyncPromise

getPrivateKey(keyName, keyType) → {string}

A private method to get the private key.
Parameters:
Name Type Description
keyName Name The name of private key.
keyType Array.<KeyType> Set keyType[0] to the KeyType.
Source:
Returns:
The PEM-encoded private key for use by the crypto module.
Type
string

getPublicKeyPromise(keyName) → {SyncPromise}

Get the public key
Parameters:
Name Type Description
keyName Name The name of public key.
Source:
Returns:
A promise that returns the PublicKey.
Type
SyncPromise

read(keyName, keyClass) → {Buffer}

Read from a key file
Parameters:
Name Type Description
keyName Name
keyClass number An int from KeyClass.
Source:
Throws:
Error if the file cannot be read from
Returns:
key bytes
Type
Buffer

signPromise(data, keyName, digestAlgorithm) → {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.
Source:
Returns:
A promise that returns the signature Blob.
Type
SyncPromise

transformName(keyName, keyClass)

Transform the key name into a file name
Parameters:
Name Type Description
keyName Name
keyClass number An int from KeyClass.
Source:

write(keyName, keyClass, bytes)

Write to a key file
Parameters:
Name Type Description
keyName Name
keyClass KeyClass [PUBLIC, PRIVATE, SYMMETRIC]
bytes Buffer
Source:
Throws:
Error if the file cannot be written to