UNPKG

@li0ard/kuznyechik

Version:

Kuznyechik cipher implementation in pure TypeScript

25 lines (24 loc) 748 B
import { BLOCK_SIZE, Kuznyechik } from "../"; import { ofb } from "@li0ard/gost3413"; /** * Encrypts data using the Output Feedback (OFB) mode with Kuznyechik cipher. * * @param key Encryption key * @param data Data to be encrypted * @param iv Initialization vector * @returns {Uint8Array} */ export const encryptOFB = (key, data, iv) => { const cipher = new Kuznyechik(key); const encrypter = (buf) => cipher.encryptBlock(buf); return ofb(encrypter, BLOCK_SIZE, data, iv); }; /** * Decrypts data using the Output Feedback (OFB) mode with Kuznyechik cipher. * * @param key Encryption key * @param data Data to be decrypted * @param iv Initialization vector * @returns {Uint8Array} */ export const decryptOFB = encryptOFB;