75#define CW_AESKEY_SIZE (32U)
76#define CW_MACKEY_SIZE (32U)
77#define CW_IV_SIZE (16U)
82#define CW_INVALID_SESSION (0x02U)
85#define CW_SIGN_CURR_K1 (0x00U)
86#define CW_SIGN_CURR_R1 (0x10U)
87#define CW_SIGN_DERIVE_K1 (0x01U)
88#define CW_SIGN_DERIVE_R1 (0x11U)
89#define CW_SIGN_PINLESS_K1 (0x03U)
92#define CW_SIGN_WITH_PIN (false)
93#define CW_SIGN_PINLESS (true)
96#define CW_SIGN_SIG_ECDSA_LOW_S (0x00U)
97#define CW_SIGN_SIG_ECDSA_EOSIO (0x01U)
98#define CW_SIGN_SIG_SCHNORR_BIP340 (0x02U)
101#define CW_SIGN_KEY_TOO_SHORT (0x80U)
102#define CW_SIGN_NO_KEY_LOADED (0x81U)
103#define CW_SIGN_PIN_INCORRECT (0x82U)
104#define CW_SIGN_KEY_TOO_SHORT_WITH_PINLESS_MODE (0x83U)
107#define CW_RAW_SIGNATURE_SIZE (64U)
108#define CW_HASH_SIZE (32U)
109#define CW_MAX_DERIVE_PATH_LENGTH (20U)
110#define CW_MIN_PIN_LENGTH (4U)
111#define CW_MAX_PIN_LENGTH (9U)
112#define CW_USER_DATA_PAGE_SIZE (208U)
113#define CW_CONNECT_MAX_ATTEMPTS (5U)
116#define CW_SIG_R_OFFSET (0U)
117#define CW_SIG_S_OFFSET (32U)
120#define CW_DER_TAG_SEQUENCE (0x30U)
121#define CW_DER_TAG_INTEGER (0x02U)
124#define CW_CERT_NONCE_SIZE (8U)
127#define CW_CERT_OK (0x00U)
128#define CW_CERT_FORMAT_ERROR (0x10U)
129#define CW_CERT_NONCE_MISMATCH (0x11U)
130#define CW_CERT_CARD_SIG_INVALID (0x12U)
131#define CW_CERT_MANUF_SIG_INVALID (0x13U)
132#define CW_CERT_KEY_NOT_FOUND (0x14U)
136#define CW_MANUF_CERT_MAX_BYTES (420U)
177 memset(
iv, 0U,
sizeof(
iv));
195#ifndef CW_VERIFY_CERT
196#define CW_VERIFY_CERT 1
198#if CW_VERIFY_CERT == 0
199# error "CW_VERIFY_CERT=0 disables certificate chain verification (CRIT-02/H-07). " \
200 "Remove -DCW_VERIFY_CERT=0 from your build flags — this gate must never be disabled."
214#ifndef CW_DEBUG_LOGGING
215# define CW_DEBUG_LOGGING 0
218#if CW_DEBUG_LOGGING && defined(NDEBUG)
219# error "CW_DEBUG_LOGGING=1 is set but NDEBUG is defined (release/optimised build). " \
220 "Debug logging must not ship in production firmware — it leaks session state " \
221 "over UART. Remove -DCW_DEBUG_LOGGING=1 from your release build flags (SEC-012)."
Platform-independent security and memory utilities.
static void secure_wipe(uint8_t *buf, size_t len)
Securely zero a buffer, guaranteed not to be optimised away.
CW_Curve
Portable curve identifier used throughout the SDK.
uint8_t macKey[CW_MACKEY_SIZE]
void clear()
Securely clear all session keys and IV.
CW_SecureSession()
Zero-initialise all session keys and IV.
uint8_t aesKey[CW_AESKEY_SIZE]