All Projects → fission-suite → keystore-idb

fission-suite / keystore-idb

Licence: Apache-2.0 license
In-browser key management with IndexedDB and the Web Crypto API

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to keystore-idb

hazmat-math
Hazmat ECC arithmetic for Cryptography.io
Stars: ✭ 28 (-24.32%)
Mutual labels:  ecc, elliptic-curves
enigma
A fast, native, cryptographic engine for the web
Stars: ✭ 101 (+172.97%)
Mutual labels:  ecc, rsa
elliptic-curve
A polymorphic interface for elliptic curve operations
Stars: ✭ 37 (+0%)
Mutual labels:  ecc, elliptic-curves
galois
A performant NumPy extension for Galois fields and their applications
Stars: ✭ 106 (+186.49%)
Mutual labels:  rsa, elliptic-curves
optiga-trust-m
OPTIGA™ Trust M Software Framework
Stars: ✭ 86 (+132.43%)
Mutual labels:  ecc, rsa
libgoldilocks
An implementation of Mike Hamburg's Ed448 (Goldilocks) curve - derived from libdecaf. This is a mirror of https://bugs.otr.im/otrv4/libgoldilocks
Stars: ✭ 17 (-54.05%)
Mutual labels:  ecc, elliptic-curves
Practical Cryptography For Developers Book
Practical Cryptography for Developers: Hashes, MAC, Key Derivation, DHKE, Symmetric and Asymmetric Ciphers, Public Key Cryptosystems, RSA, Elliptic Curves, ECC, secp256k1, ECDH, ECIES, Digital Signatures, ECDSA, EdDSA
Stars: ✭ 2,400 (+6386.49%)
Mutual labels:  ecc, elliptic-curves
Illustrated Tls
The Illustrated TLS Connection: Every byte explained
Stars: ✭ 2,751 (+7335.14%)
Mutual labels:  rsa, elliptic-curves
interesting-keys
Interesting collected (leaked) encryption/decryption keys
Stars: ✭ 33 (-10.81%)
Mutual labels:  ecc, rsa
pairing
Optimised bilinear pairings over elliptic curves
Stars: ✭ 44 (+18.92%)
Mutual labels:  ecc, elliptic-curves
noble-ed25519
Fastest JS implementation of ed25519, x25519 & ristretto255. Independently audited, high-security, 0-dependency EDDSA signatures and ECDH key agreement
Stars: ✭ 220 (+494.59%)
Mutual labels:  ecc, elliptic-curves
cryptotools
No description or website provided.
Stars: ✭ 182 (+391.89%)
Mutual labels:  rsa, elliptic-curves
littleca
littleca是一个基于BC的小型ca库,支持ecc,rsa,dsa,sm2的证书签发,加密解密,签名验签操作,支持国密加解密,证书签发
Stars: ✭ 44 (+18.92%)
Mutual labels:  ecc, rsa
EllipticCurve
An elliptic curve library written in Swift 4
Stars: ✭ 18 (-51.35%)
Mutual labels:  ecc, elliptic-curves
oseid
Microchip AVR based smartcard/token with ECC and RSA cryptography
Stars: ✭ 17 (-54.05%)
Mutual labels:  ecc, rsa
crypto.js
base on crypto module
Stars: ✭ 13 (-64.86%)
Mutual labels:  rsa
crypto-in-action
algebra arithmetic, finite fields, elliptic curves, zero-knowledge
Stars: ✭ 65 (+75.68%)
Mutual labels:  elliptic-curves
btclib
btclib: a Python3 library for 'bitcoin cryptography'
Stars: ✭ 16 (-56.76%)
Mutual labels:  elliptic-curves
sodalite
tweetnacl in rust
Stars: ✭ 26 (-29.73%)
Mutual labels:  ecc
rsa-encrypt-body-spring-boot
Spring Boot 接口请求参数自动加解密
Stars: ✭ 108 (+191.89%)
Mutual labels:  rsa

IndexedDB KeyStore

NPM License Maintainability Built by FISSION Discord Discourse

In-browser key management with IndexedDB and the Web Crypto API.

Securely store and use keys for encryption, decryption, and signatures. IndexedDB and Web Crypto keep keys safe from malicious javascript.

Supports both RSA (RSASSA-PKCS1-v1_5 & RSA-OAEP) and Elliptic Curves (P-256, P-381 & P-521).

ECC (Elliptic Curve Cryptography) is only available on Chrome. Firefox and Safari do not support ECC and must use RSA. Specifically, this is an issue with storing ECC keys in IndexedDB

Config

Below is the default config and all possible values Note: these are given as primitives, but in Typescript you can use the included enums

const defaultConfig = {
  type: 'ecc', // 'ecc' | 'rsa'
  curve: 'P-256', // 'P-256' | 'P-384' | 'P-521'
  rsaSize: 2048, // 1024 | 2048 | 4096
  symmAlg: 'AES-CTR', // 'AES-CTR' | 'AES-GCM' | 'AES-CBC'
  symmLen: 128, // 128 | 192 | 256
  hashAlg: 'SHA-256', // 'SHA-1' | 'SHA-256' | 'SHA-384' | 'SHA-512'
  charSize: 16, // 8 | 16
  storeName: 'keystore', // any string
  exchangeKeyName: 'exchange-key', // any string
  writeKeyName: 'write-key', // any string
}

Note: if you don't include a crypto "type" ('ecc' | 'rsa'), the library will check if your browser supports ECC. If so (Chrome), it will use ECC, if not (Firefox, Safari) it will fall back to RSA.

Example Usage

import keystore from 'keystore-idb'

async function run() {
  await keystore.clear()

  const ks1 = await keystore.init({ storeName: 'keystore' })
  const ks2 = await keystore.init({ storeName: 'keystore2' })

  const msg = "Incididunt id ullamco et do."

  // exchange keys and write keys are separate because of the Web Crypto API
  const exchangeKey1 = await ks1.publicExchangeKey()
  const writeKey1 = await ks1.publicWriteKey()
  const exchangeKey2 = await ks2.publicExchangeKey()

  // these keys get exported as strings
  console.log('exchangeKey1: ', exchangeKey1)
  console.log('writeKey1: ', writeKey1)
  console.log('exchangeKey2: ', exchangeKey2)

  const sig = await ks1.sign(msg)
  const valid = await ks2.verify(msg, sig, writeKey1)
  console.log('sig: ', sig)
  console.log('valid: ', valid)

  const cipher = await ks1.encrypt(msg, exchangeKey2)
  const decipher = await ks2.decrypt(cipher, exchangeKey1)
  console.log('cipher: ', cipher)
  console.log('decipher: ', decipher)
}

run()

Development

# install dependencies
yarn

# run development server
yarn start

# build
yarn build

# test
yarn test

# test w/ reloading
yarn test:watch

# publish (run this script instead of npm publish!)
./publish.sh
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].