Crate crypto_wasi

source ·
Expand description

crypto-wasi is subset of apis of nodejs’s crypto module for wasm32-wasi, implemented in rust, powered by WASI Cryptography APIs. This library is developed and tested over WasmEdge runtime

Note: The api of this library is not completely consistent with the api of nodejs.

§Currently Subset Implemented

§Working In Process

  • create_public_key & create_private_key
  • ECDH (you can use generate_key_pair and diffie_hellman as alternatives)

§Not Implemented

  • createCipher & createDecipher: This function is semantically insecure for all supported ciphers and fatally flawed for ciphers in counter mode (such as CTR, GCM, or CCM).
  • generateKey & createSecretKey: In nodejs, SecretKey is just store the raw key data. In wasi-crypto, SymmetricKey is equivalent to SecretKey, which is also just store the raw key data in WasmEdge’s implementation. But in wasi-crypto, each key is required to be bound to a kind of algorithms, which cause some complications when managing keys and reusing keys. So we’re not going to implement SecretKey.

§Known Issues:

  • ECDSA_P384_SHA384 key export as Jwk: elliptic curve routines:ec_GFp_simple_point2oct:buffer too small
  • ECDSA_P384_SHA384 in sign & verify use sha256 as digest actually

Modules§

  • Low-level binding to wasi-crypto
  • Some helpful tools and simpified api

Structs§

  • Equivalent to crypto.Cipheriv
  • Equivalent to crypto.Decipheriv
  • Equivalent to crypto.Hash
  • Equivalent to crypto.Hmac
  • crypto.KeyObject for private (asymmetric) keys
  • crypto.KeyObject for public (asymmetric) keys

Enums§

Functions§

  • Creates and returns a Hash object that can be used to generate hash digests using the given algorithm.
  • Creates and returns an Hmac object that uses the given algorithm and key.
  • Generates a new asymmetric key pair of the given algorithm
  • HKDF is a simple key derivation function defined in RFC 5869.
  • As same as hkdf, but use hmac to manual expand
  • Password-Based Key Derivation Function 2 (PBKDF2) implementation.
  • Provides a synchronous scrypt implementation.

Type Aliases§