Class: PrivateKeyStorage

PrivateKeyStorage

new PrivateKeyStorage()

PrivateKeyStorage is an abstract class which declares methods for working with a private key storage. You should use a subclass.
Source:

Methods

decrypt(keyName, data, isSymmetric) → {Blob}

Decrypt data.
Parameters:
Name Type Description
keyName Name The name of the decrypting key.
data Buffer The byte to be decrypted.
isSymmetric boolean (optional) If true symmetric encryption is used, otherwise asymmetric encryption is used. If omitted, use asymmetric encryption.
Source:
Returns:
The decrypted data.
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.
Source:

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.
Source:
Returns:
True if the key exists, otherwise false.
Type
boolean

encrypt(keyName, data, isSymmetric) → {Blob}

Encrypt data.
Parameters:
Name Type Description
keyName Name The name of the encrypting key.
data Buffer The byte to be encrypted.
isSymmetric boolean (optional) If true symmetric encryption is used, otherwise asymmetric encryption is used. If omitted, use asymmetric encryption.
Source:
Returns:
The encrypted data.
Type
Blob

generateKey(keyName, params)

Parameters:
Name Type Description
keyName Name The name of the key.
params KeyParams The parameters of the key.
Source:

generateKeyPair(keyName, params)

Generate a pair of asymmetric keys.
Parameters:
Name Type Description
keyName Name The name of the key pair.
params KeyParams (optional) The parameters of the key.
Source:

getPublicKey(keyName) → {PublicKey}

Get the public key
Parameters:
Name Type Description
keyName Name The name of public key.
Source:
Returns:
The public key.
Type
PublicKey

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.)
Source:
Returns:
If onComplete is omitted, return the signature Blob. Otherwise, return null and use onComplete as described above.
Type
Blob