# `ExCEP.Crypto.Signer`

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:
- `ExCEP.Crypto.SM2` — Pure Elixir GB/T 32918.2 SM2 signer/verifier.
- `ExCEP.Crypto.NoopSigner` — Development/test stub that produces/accepts 64-byte zero signatures.

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

# `opts`

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

# `signature`

```elixir
@type signature() :: &lt;&lt;_::512&gt;&gt;
```

# `sign`

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

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

# `verify`

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

Verifies a 64-byte `signature` over `payload`.

# `sign`

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

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

# `verify`

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

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
