@li0ard/kuznyechik
v0.1.4
Published
Kuznyechik cipher implementation in pure TypeScript
Readme
[!WARNING] This library is currently in alpha stage: the lib is not very stable yet, and there may be a lot of bugs feel free to try it out, though, any feedback is appreciated!
Installation
# from NPM
npm i @li0ard/kuznyechik
# from JSR
bunx jsr i @li0ard/kuznyechikSupported modes
- [x] Electronic Codebook (ECB)
- [x] Cipher Block Chaining (CBC)
- [x] Cipher Feedback (CFB)
- [x] Counter (CTR)
- [x] Output Feedback (OFB)
- [x] MAC (CMAC/OMAC)
- [x] Counter with Advance Cryptographic Prolongation of Key Material (CTR-ACPKM)
- [x] MAC with Advance Cryptographic Prolongation of Key Material (OMAC-ACPKM)
- [x] Multilinear Galois Mode (MGM)
Features
- Provides simple and modern API
- Most of the APIs are strictly typed
- Fully complies with GOST R 34.12-2015 (RFC 7801) and GOST R 34.13-2015 (in Russian) standarts
- Supports Bun, Node.js, Deno, Browsers
Examples
ECB mode
import { decryptECB, encryptECB } from "@li0ard/kuznyechik";
const key = Buffer.from("8899AABBCCDDEEFF0011223344556677FEDCBA98765432100123456789ABCDEF", "hex")
const plaintext = Buffer.from("1122334455667700ffeeddccbbaa9988", "hex")
const encrypted = encryptECB(key, plaintext)
console.log(encrypted) // Uint8Array [ ... ]
const decrypted = decryptECB(key, encrypted)
console.log(decrypted) // Uint8Array [ ... ]CTR-ACPKM mode
import { decryptCTR_ACPKM, encryptCTR_ACPKM } from "@li0ard/kuznyechik"
const key = Buffer.from("8899AABBCCDDEEFF0011223344556677FEDCBA98765432100123456789ABCDEF", "hex")
const iv = Buffer.from("1234567890ABCEF0", "hex")
const plaintext = Buffer.from("1122334455667700FFEEDDCCBBAA998800112233445566778899AABBCCEEFF0A112233445566778899AABBCCEEFF0A002233445566778899AABBCCEEFF0A001133445566778899AABBCCEEFF0A001122445566778899AABBCCEEFF0A001122335566778899AABBCCEEFF0A0011223344", "hex")
const encrypted = encryptCTR_ACPKM(key, plaintext, iv)
console.log(encrypted) // Uint8Array [...]
const decrypted = decryptCTR_ACPKM(key, encrypted, iv)
console.log(decrypted) // Uint8Array [...]