Interface: CryptoProvider
crypto.CryptoProvider
CryptoProvider provides a unified interface for cryptographic primitives accross all platforms. This is usually a thin wrapper around the native crypto module provided by the platform.
Implemented by
Methods
decrypt
▸ decrypt(key, data, params): Promise<Uint8Array>
Decrypts data with key using the cipher and parameters specified in params
Parameters
| Name | Type |
|---|---|
key |
Uint8Array |
data |
Uint8Array |
params |
AESEncryptionParams |
Returns
Promise<Uint8Array>
Defined in
▸ decrypt(privateKey, data, params): Promise<Uint8Array>
Parameters
| Name | Type |
|---|---|
privateKey |
Uint8Array |
data |
Uint8Array |
params |
RSAEncryptionParams |
Returns
Promise<Uint8Array>
Defined in
deriveKey
▸ deriveKey(password, params): Promise<Uint8Array>
Derives a key from a given password using the provided key derivation
params password should be the byte array representation of a UTF-8 encoded
password.
Parameters
| Name | Type |
|---|---|
password |
Uint8Array |
params |
PBKDF2Params |
Returns
Promise<Uint8Array>
Defined in
encrypt
▸ encrypt(key, data, params): Promise<Uint8Array>
Encrypts data with key using the cipher and parameters specified in params
Parameters
| Name | Type |
|---|---|
key |
Uint8Array |
data |
Uint8Array |
params |
AESEncryptionParams |
Returns
Promise<Uint8Array>
Defined in
▸ encrypt(publicKey, data, params): Promise<Uint8Array>
Parameters
| Name | Type |
|---|---|
publicKey |
Uint8Array |
data |
Uint8Array |
params |
RSAEncryptionParams |
Returns
Promise<Uint8Array>
Defined in
fingerprint
▸ fingerprint(key): Promise<Uint8Array>
Creates a fingerprint from a given rsa public key
Parameters
| Name | Type |
|---|---|
key |
Uint8Array |
Returns
Promise<Uint8Array>
Defined in
generateKey
▸ generateKey(params): Promise<Uint8Array>
Generates a random key or key pair for the algorithm specified in params
Parameters
| Name | Type |
|---|---|
params |
AESKeyParams |
Returns
Promise<Uint8Array>
Defined in
▸ generateKey(params): Promise<Uint8Array>
Parameters
| Name | Type |
|---|---|
params |
HMACKeyParams |
Returns
Promise<Uint8Array>
Defined in
▸ generateKey(params): Promise<{ privateKey: Uint8Array ;
publicKey: Uint8Array }>
Parameters
| Name | Type |
|---|---|
params |
RSAKeyParams |
Returns
Promise<{ privateKey: Uint8Array ; publicKey: Uint8Array }>
Defined in
hash
▸ hash(input, params): Promise<Uint8Array>
Creates a digest of the provided input using the algorithm specified in params For algorithms that should be supported, see HashParams.
Parameters
| Name | Type |
|---|---|
input |
Uint8Array |
params |
HashParams |
Returns
Promise<Uint8Array>
Defined in
randomBytes
▸ randomBytes(n): Promise<Uint8Array>
Generates an Array of n random bytes
Parameters
| Name | Type |
|---|---|
n |
number |
Returns
Promise<Uint8Array>
Defined in
sign
▸ sign(key, data, params): Promise<Uint8Array>
Creates a signature from data with key using the algorithm and parameters
specified in params
Parameters
| Name | Type |
|---|---|
key |
Uint8Array |
data |
Uint8Array |
params |
HMACParams |
Returns
Promise<Uint8Array>
Defined in
▸ sign(key, data, params): Promise<Uint8Array>
Parameters
| Name | Type |
|---|---|
key |
Uint8Array |
data |
Uint8Array |
params |
RSASigningParams |
Returns
Promise<Uint8Array>
Defined in
timingSafeEqual
▸ timingSafeEqual(a, b): Promise<boolean>
Compares two values without leaking timing information that would allow an attacker to guess one of the values
Parameters
| Name | Type |
|---|---|
a |
Uint8Array |
b |
Uint8Array |
Returns
Promise<boolean>
Defined in
verify
▸ verify(key, signature, data, params): Promise<boolean>
Verifies signature with data and key using the algorithm and parameters
specified in params
Parameters
| Name | Type |
|---|---|
key |
Uint8Array |
signature |
Uint8Array |
data |
Uint8Array |
params |
HMACParams |
Returns
Promise<boolean>
Defined in
▸ verify(key, signature, data, params): Promise<boolean>
Parameters
| Name | Type |
|---|---|
key |
Uint8Array |
signature |
Uint8Array |
data |
Uint8Array |
params |
RSASigningParams |
Returns
Promise<boolean>