+
Skip to content

li0ard/kuznyechik

Repository files navigation

@li0ard/kuznyechik
Kuznyechik cipher implementation in pure TypeScript
docs




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/kuznyechik

Supported modes

  • Electronic Codebook (ECB)
  • Cipher Block Chaining (CBC)
  • Cipher Feedback (CFB)
  • Counter (CTR)
  • Output Feedback (OFB)
  • MAC (CMAC/OMAC/OMAC1)
  • Counter with Advance Cryptographic Prolongation of Key Material (CTR-ACPKM)
  • MAC with Advance Cryptographic Prolongation of Key Material (OMAC-ACPKM)
  • Multilinear Galois Mode (MGM)

Features

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 [...]

About

Kuznyechik cipher implementation in pure TypeScript

Resources

License

Stars

Watchers

Forks

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载