Guomi.SM4 (guomi v0.4.2)

Copy Markdown View Source

SM4 block cipher helpers using Erlang :crypto.

Summary

Types

error_reason()

@type error_reason() ::
  :invalid_key_size
  | :invalid_iv_size
  | :invalid_block_size
  | :invalid_padding
  | :unsupported

Functions

decrypt(ciphertext, key, opts \\ [])

@spec decrypt(binary(), binary(), keyword()) ::
  {:ok, binary()} | {:error, error_reason()}

decrypt_cbc(ciphertext, key, iv, opts \\ [])

@spec decrypt_cbc(binary(), binary(), binary(), keyword()) ::
  {:ok, binary()} | {:error, error_reason()}

encrypt(plaintext, key, opts \\ [])

@spec encrypt(binary(), binary(), keyword()) ::
  {:ok, binary()} | {:error, error_reason()}

encrypt_cbc(plaintext, key, iv, opts \\ [])

@spec encrypt_cbc(binary(), binary(), binary(), keyword()) ::
  {:ok, binary()} | {:error, error_reason()}

supported?()

@spec supported?() :: boolean()