ExCEP.Crypto.Signer behaviour (ex_cep v0.1.1)

Copy Markdown

Pluggable signing and verification behaviour for CEP APDU 64-byte SM2 signatures.

CEP TS2.2 Section 4.8 specifies 64-byte SM2 signatures over header <> asdu. Built-in implementations:

Custom hardware/HSM/NIF implementations can implement this behaviour and be passed via signer: {MySigner, opts} in connection/server parameters.

Summary

Callbacks

Signs payload (header <> asdu) and returns a 64-byte signature.

Verifies a 64-byte signature over payload.

Functions

Helper that invokes a {module, opts} signer tuple or nil.

Helper that invokes a {module, opts} verifier tuple or nil.

Types

opts()

@type opts() :: keyword() | map() | term()

signature()

@type signature() :: <<_::512>>

Callbacks

sign(payload, opts)

@callback sign(payload :: binary(), opts :: opts()) ::
  {:ok, signature()} | {:error, term()}

Signs payload (header <> asdu) and returns a 64-byte signature.

verify(payload, signature, opts)

@callback verify(payload :: binary(), signature :: binary(), opts :: opts()) ::
  :ok | {:error, term()}

Verifies a 64-byte signature over payload.

Functions

sign(arg1, payload)

@spec sign({module(), opts()} | nil, binary()) ::
  {:ok, signature()} | {:error, term()}

Helper that invokes a {module, opts} signer tuple or nil.

verify(arg1, payload, sig)

@spec verify({module(), opts()} | nil, binary(), binary()) :: :ok | {:error, term()}

Helper that invokes a {module, opts} verifier tuple or nil.