openaliro
Aliro reader: UWB/CCC core and ESP32-S3/C5/C6 port
Loading...
Searching...
No Matches
aliro_assert_ec.h
1/*
2 * Copyright (c) 2026 asxeem
3 * SPDX-License-Identifier: ISC
4 *
5 * aliro_assert_ec — binds the aliro_assert P-256 seam to aliro_prim.
6 *
7 * aliro_assert.c stays free of any crypto backend so it can remain portable
8 * C11, model-checked and fuzzed. This is the other half: the two-function shim
9 * that hands the seam whatever P-256 the platform already provides, so nothing
10 * else has to know the seam exists.
11 *
12 * Split into its own translation unit rather than #ifdef'd into aliro_assert.c
13 * because it is the only part with a dependency: a build that has no PSA (the
14 * main host suite) simply does not compile this file, and the codec keeps its
15 * harnesses either way.
16 */
17#pragma once
18
19#include <stdint.h>
20
21#include "aliro_assert.h"
22#include "aliro_prim.h"
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/* Key material the two binders expect as their ctx. Pass a pointer to one of
29 * these as the void *ctx argument of aliro_assert_build_p256 / _verify_p256. */
30struct aliro_assert_ec_priv {
31 uint8_t d[ALIRO_P256_SCALAR]; /* P-256 private scalar */
32};
33
38 uint8_t q[ALIRO_ASSERT_PUB_LEN]; /* uncompressed point, 0x04 || X || Y */
39};
40
41/* aliro_assert_sign_fn over aliro_ecdsa_p256_sign. ctx is a
42 * struct aliro_assert_ec_priv *. Returns 0 on success. */
43int aliro_assert_ec_sign(void *ctx, const uint8_t *msg, size_t msg_len,
44 uint8_t sig[ALIRO_ASSERT_SIG_LEN]);
45
46/* aliro_assert_verify_fn over aliro_ecdsa_p256_verify. ctx is a
47 * struct aliro_assert_ec_pub *. Returns 0 when the signature is valid. */
48int aliro_assert_ec_verify(void *ctx, const uint8_t *msg, size_t msg_len,
49 const uint8_t sig[ALIRO_ASSERT_SIG_LEN]);
50
51#ifdef __cplusplus
52}
53#endif
Uncompressed ECDSA-P256 public key point: 0x04 || X || Y (65 bytes).
Definition aliro_assert_ec.h:37