@li0ard/kalyna
v0.1.5
Published
Kalyna (DSTU 7624:2014) cipher implementation in pure TypeScript
Readme
Installation
# from NPM
npm i @li0ard/kalyna
# from JSR
bunx jsr i @li0ard/kalynaSupported modes
- [x] Electronic Codebook (ECB)
- [x] Cipher Block Chaining (CBC)
- [x] Output Feedback (OFB)
- [x] Counter (CTR)
- [x] Cipher Feedback (CFB)
- [x] Cipher-based Message Authentication Code (CMAC/OMAC)
- [x] Cipher Block Chaining-Message Authentication Code (CCM)
- [x] Galois Message Authentication Code (GMAC)
- [x] Galois/Counter Mode (GCM)
- [x] Key wrapping (KW)
- [x] XEX Tweakable Block Ciphertext Stealing (XTS)
Features
- Provides simple and modern API
- Most of the APIs are strictly typed
- Fully complies with DSTU 7624:2014 standard
- Supports Bun, Node.js, Deno, Browsers
Examples
ECB mode
import { Kalyna128, encryptECB, decryptECB } from "@li0ard/kalyna";
const cipher = new Kalyna128(hexToBytes("000102030405060708090A0B0C0D0E0F"));
const ct = hexToBytes("81BF1C7D779BAC20E1C9EA39B4D2AD06");
const pt = hexToBytes("101112131415161718191A1B1C1D1E1F");
console.log(encryptECB(cipher, pt));
console.log(decryptECB(cipher, ct));CBC mode
import { Kalyna128, encryptCBC, decryptCBC } from "@li0ard/kalyna";
const cipher = new Kalyna128(hexToBytes("000102030405060708090A0B0C0D0E0F"));
const iv = hexToBytes("101112131415161718191A1B1C1D1E1F");
const ct = hexToBytes("a73625d7be994e85469a9faabcedaab6dbc5f65dd77bb35e06bd7d1d8eafc8624d6cb31ce189c82b8979f2936de9bf14");
const pt = hexToBytes("202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F");
console.log(encryptCBC(cipher, pt, iv));
console.log(decryptCBC(cipher, ct, iv));