Padloc Logo Docs & Resources

Class: StubCryptoProvider

stub-crypto-provider.StubCryptoProvider

StubCryptoProvider is a stub implementation of the CryptoProvider interface mainly used for testing. All methods merely emulate the behavior of an actual implementation in a way that makes it compatible for use with the rest of the @padloc/core package. Needless to say, this class is NOT SECURE AND SHOULD NEVER BE USED IN A PRODUCTION ENVIRONMENT.

Implements

Constructors

constructor

new StubCryptoProvider()

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>

Implementation of

CryptoProvider.decrypt

Defined in

core/src/stub-crypto-provider.ts:82

decrypt(publicKey, data, params): Promise<Uint8Array>

Parameters

Name Type
publicKey Uint8Array
data Uint8Array
params RSAEncryptionParams

Returns

Promise<Uint8Array>

Implementation of

CryptoProvider.decrypt

Defined in

core/src/stub-crypto-provider.ts:83


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>

Implementation of

CryptoProvider.deriveKey

Defined in

core/src/stub-crypto-provider.ts:58


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>

Implementation of

CryptoProvider.encrypt

Defined in

core/src/stub-crypto-provider.ts:64

encrypt(publicKey, data, params): Promise<Uint8Array>

Parameters

Name Type
publicKey Uint8Array
data Uint8Array
params RSAEncryptionParams

Returns

Promise<Uint8Array>

Implementation of

CryptoProvider.encrypt

Defined in

core/src/stub-crypto-provider.ts:65


fingerprint

fingerprint(key): Promise<Uint8Array>

Creates a fingerprint from a given rsa public key

Parameters

Name Type
key Uint8Array

Returns

Promise<Uint8Array>

Implementation of

CryptoProvider.fingerprint

Defined in

core/src/stub-crypto-provider.ts:113


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>

Implementation of

CryptoProvider.generateKey

Defined in

core/src/stub-crypto-provider.ts:41

generateKey(params): Promise<{ privateKey: Uint8Array ; publicKey: Uint8Array }>

Parameters

Name Type
params RSAKeyParams

Returns

Promise<{ privateKey: Uint8Array ; publicKey: Uint8Array }>

Implementation of

CryptoProvider.generateKey

Defined in

core/src/stub-crypto-provider.ts:42

generateKey(params): Promise<Uint8Array>

Parameters

Name Type
params HMACKeyParams

Returns

Promise<Uint8Array>

Implementation of

CryptoProvider.generateKey

Defined in

core/src/stub-crypto-provider.ts:43


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>

Implementation of

CryptoProvider.hash

Defined in

core/src/stub-crypto-provider.ts:37


randomBytes

randomBytes(n): Promise<Uint8Array>

Generates an Array of n random bytes

Parameters

Name Type
n number

Returns

Promise<Uint8Array>

Implementation of

CryptoProvider.randomBytes

Defined in

core/src/stub-crypto-provider.ts:29


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>

Implementation of

CryptoProvider.sign

Defined in

core/src/stub-crypto-provider.ts:117

sign(key, data, params): Promise<Uint8Array>

Parameters

Name Type
key Uint8Array
data Uint8Array
params RSASigningParams

Returns

Promise<Uint8Array>

Implementation of

CryptoProvider.sign

Defined in

core/src/stub-crypto-provider.ts:118


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>

Implementation of

CryptoProvider.timingSafeEqual

Defined in

core/src/stub-crypto-provider.ts:146


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>

Implementation of

CryptoProvider.verify

Defined in

core/src/stub-crypto-provider.ts:127

verify(key, signature, data, params): Promise<boolean>

Parameters

Name Type
key Uint8Array
signature Uint8Array
data Uint8Array
params RSASigningParams

Returns

Promise<boolean>

Implementation of

CryptoProvider.verify

Defined in

core/src/stub-crypto-provider.ts:128