Guomi.SM4 (guomi v0.5.1)

Copy Markdown View Source

Pure Elixir SM4 block cipher (GM/T 0002-2012).

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()}

decrypt_ctr(ciphertext, key, counter, opts \\ [])

@spec decrypt_ctr(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()}

encrypt_ctr(plaintext, key, counter, opts \\ [])

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

supported?()

@spec supported?() :: boolean()