All files / src/crypto-extras/crypto-aes index.ts

100% Statements 13/13
100% Branches 0/0
100% Functions 4/4
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 4042x       42x         41x 41x     42x         12x 12x     42x         3x 3x     42x         3x 3x    
import { createCipher } from './create-cipher';
 
export * from './get-crypto';
 
export async function aes256CbcEncrypt(
  iv: Uint8Array,
  key: Uint8Array,
  plaintext: Uint8Array
): Promise<Uint8Array> {
  const cipher = await createCipher();
  return cipher.encrypt('aes-256-cbc', key, iv, plaintext);
}
 
export async function aes256CbcDecrypt(
  iv: Uint8Array,
  key: Uint8Array,
  ciphertext: Uint8Array
): Promise<Uint8Array> {
  const cipher = await createCipher();
  return cipher.decrypt('aes-256-cbc', key, iv, ciphertext);
}
 
export async function aes128CbcEncrypt(
  iv: Uint8Array,
  key: Uint8Array,
  plaintext: Uint8Array
): Promise<Uint8Array> {
  const cipher = await createCipher();
  return cipher.encrypt('aes-128-cbc', key, iv, plaintext);
}
 
export async function aes128CbcDecrypt(
  iv: Uint8Array,
  key: Uint8Array,
  ciphertext: Uint8Array
): Promise<Uint8Array> {
  const cipher = await createCipher();
  return cipher.decrypt('aes-128-cbc', key, iv, ciphertext);
}