npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gost89

v0.1.11

Published

Gost89 in JS

Downloads

2,779

Readme

Gost89

Gost89 cipher and hash function implementation in JS

Build Status npm module dependencies

Algos

  • DSTU Gost 34311-95 hash function
  • DSTU Gost 28147-2009 CFB mode block cipher
  • DSTU Gost 28147-2009 ECB mode block cipher
  • DSTU Gost 28147 key wrapper as specified by DSTSZI [0]
  • PBKDF (Gost-34311 based)
  • Dumb KDF (N-iterations of hash)

[0] http://dstszi.kmu.gov.ua/dstszi/control/uk/publish/article?showHidden=1&art_id=90096&cat_id=38837

GOST-DSTU Notice

This package implements GOST functions, however S-BOX used by default comes from Ukrainian counterpart standard DSTU as original GOST does not specify explicitly what table to use.

Examples

All function except Hash.update() accept buffer objects, string or byte arrays.

Hash messages:

var gost89 = require("gost89");
var hash = gost89.gosthash("LA LA LA SHTIRLITZ KURWA VODKA MATRIOSKA");
// <Buffer 0a 32 7f 3b ce e1 f3 de 0f 40 61 2e c3 ce d0 a3 29 51 b8 b2 16 8e 9a 01 0f 5b 15 46 c0 a9 1d 93>

var hash_ctx = gost89.Hash.init();
hash_ctx.update("ARBITARY SIZED VODKA");
hash_ctx.update("VODKA VODKA MORE VODKA");
var hash = hash_ctx.finish(Buffer.alloc(32));
// <Buffer 2c 1e d1 f1 2c 05 13 38 b2 7f 42 5d ea df e0 62 17 e6 9b 2c 19 d4 4a cd 24 ac 8d 5b b7 53 34 3f>

hash_ctx.reset();
hash.update32(buffer_of_32_bytes);
var hash = hash_ctx.finish(Buffer.alloc(32));

Encrypt message:

var gost = gost89.init();
var clear = Buffer.from('lol', 'binary');
gost.key(Buffer.alloc(32));
var out = gost.crypt(clear, out);

Encrypt messages in CFB mode:

var gost = gost89.init();
var out = gost.crypt_cfb(iv, clear);
// out contains encrypted text

Properly encrypt message:

var gost = gost89.init();
var key = crypto.randomBytes(32);
gost.key(key);
var enc = gost.crypt(text, enc);

var iv = crypto.randomBytes(8);
var shared_key = some_diffie_hellman_here(me, you); // see jkurwa
var wrapped_key = gost89.wrap_key(key, shared_key, iv);
// send enc and wrapped_key to other party