@li0ard/kuznyechik
Version:
Kuznyechik cipher implementation in pure TypeScript
22 lines (21 loc) • 656 B
JavaScript
import { BLOCK_SIZE, Kuznyechik } from "../index.js";
import { ctr } from "@li0ard/gost3413";
/**
* Encrypts data using the Counter (CTR) mode with Kuznyechik cipher.
*
* @param key Encryption key
* @param data Data to be encrypted
* @param iv Initialization vector
*/
export const encryptCTR = (key, data, iv) => {
const cipher = new Kuznyechik(key);
return ctr(cipher.encryptBlock.bind(cipher), BLOCK_SIZE, data, iv);
};
/**
* Decrypts data using the Counter (CTR) mode with Kuznyechik cipher.
*
* @param key Encryption key
* @param data Data to be decrypted
* @param iv Initialization vector
*/
export const decryptCTR = encryptCTR;