4#ifndef PROTOCORE_ECDSA_H
5#define PROTOCORE_ECDSA_H
65#define PROTOCORE_ECDSA_P256_PRIV_LEN 32
68#define PROTOCORE_ECDSA_P256_COORD_LEN 32
71#define PROTOCORE_ECDSA_P256_PUB_LEN 65
74#define PROTOCORE_ECDSA_P256_SIG_LEN 64
79 embed_bool (*
pubkey)(uint8_t *,
const uint8_t *, uint8_t *);
80 embed_bool (*
sign)(uint8_t *,
const uint8_t *, size_t,
const uint8_t *, uint8_t *);
81 embed_bool (*
verify)(uint8_t *,
const uint8_t *,
const uint8_t *, size_t,
const uint8_t *);
82 embed_bool (*
ecdh)(uint8_t *,
const uint8_t *,
const uint8_t *, uint8_t *);
103embed_bool
protocore_ecdsa_sign(uint8_t *work,
const uint8_t *msg,
size_t mlen,
const uint8_t *priv, uint8_t *sig);
123embed_bool
protocore_ecdsa_ecdh(uint8_t *work,
const uint8_t *peer_pub,
const uint8_t *priv, uint8_t *shared_x);
embed_bool protocore_ecdsa_ecdh(uint8_t *work, const uint8_t *peer_pub, const uint8_t *priv, uint8_t *shared_x)
Write the X coordinate of d * Q_peer.
embed_bool protocore_ecdsa_sign(uint8_t *work, const uint8_t *msg, size_t mlen, const uint8_t *priv, uint8_t *sig)
Hash the message with SHA-256 and write the raw r || s.
embed_bool protocore_ecdsa_verify(uint8_t *work, const uint8_t *pub, const uint8_t *msg, size_t mlen, const uint8_t *sig)
Hash the message with SHA-256 and check r || s against the point.
embed_bool protocore_ecdsa_pubkey(uint8_t *work, const uint8_t *priv, uint8_t *pub)
Derive Q = d*G and write it uncompressed.
#define PROTOCORE_UNUSED
Suppress the unused warning. Every module ends in a namespace most callers only partly use.
#define PROTOCORE_NS_LAYOUT(T,...)
Pin every dispatch slot of a table that is nothing but function pointers.
#define PROTOCORE_NS
Storage for a dispatch table. The const is load bearing.
Dispatch table. Addressed by offset, so the layout is asserted below.
embed_bool(* pubkey)(uint8_t *, const uint8_t *, uint8_t *)
embed_bool(* ecdh)(uint8_t *, const uint8_t *, const uint8_t *, uint8_t *)
embed_bool(* sign)(uint8_t *, const uint8_t *, size_t, const uint8_t *, uint8_t *)
embed_bool(* verify)(uint8_t *, const uint8_t *, const uint8_t *, size_t, const uint8_t *)