@ars9/kalyna
v0.1.4
Published
CommonJS build of @li0ard/kalyna - Kalyna (DSTU 7624:2014) cipher implementation in pure TypeScript
Readme
[!CAUTION] Disclaimer: This package is merely a repackage of the original
@li0ard/kalynamodule. All intellectual property, development, and maintenance credit belongs to the original author, li0ard. This version is provided as a CommonJS build for specific compatibility needs and does not introduce any new features or modifications beyond the build configuration.
Installation
# from NPM
npm i @ars9/kalyna
# from JSR
bunx jsr i @ars9/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 "@ars9/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 "@ars9/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));