- Extract all decode/decrypt into a dependency-free C99 core
(include/victronble.h, src/victronble_core.c): victronble_decode(),
is_product_adv/key_matches pre-filters, NAN sentinels, LE accessors.
- AES-128-CTR behind a hook: weak-symbol bundled tiny-AES default,
runtime override (victronble_set_aes_ctr) for PSA/mbedTLS/hardware.
- Arduino VictronBLE class becomes a thin wrapper over the core
(registry + nonce dedup + rate limit); public C++ API unchanged,
NAN converted back to the legacy 0 convention.
- Host test vectors (tests/vectors): openssl-generated ciphertext,
independent of the bundled AES; all five payload shapes + negatives.
- Zephyr module: zephyr/module.yml + Kconfig (CONFIG_VICTRONBLE) +
observer backend (victronble_zephyr.{h,c}) — scan cb pre-filters and
queues, dedicated decode thread, listener callbacks, slow passive
scan defaults, stats counters. docs/ZEPHYR_PORT.md records the plan.
- library.properties: fix URL (gitea, not the nonexistent GitHub).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
39 lines
946 B
C
39 lines
946 B
C
/**
|
|
* victronble — bundled software AES-128-CTR backend.
|
|
*
|
|
* Weak symbol: an alternative backend (PSA Crypto, mbedTLS, hardware) defines
|
|
* victronble_aes_ctr_default strong and the linker drops this file's code —
|
|
* and with it the bundled AES tables — from the final image.
|
|
*
|
|
* Copyright (c) 2025-2026 Scott Penrose
|
|
* License: MIT
|
|
*/
|
|
|
|
#include "victronble.h"
|
|
#include "crypto/vble_aes.h"
|
|
|
|
#include <string.h>
|
|
|
|
#if defined(_MSC_VER)
|
|
#define VICTRONBLE_WEAK
|
|
#else
|
|
#define VICTRONBLE_WEAK __attribute__((weak))
|
|
#endif
|
|
|
|
VICTRONBLE_WEAK
|
|
int victronble_aes_ctr_default(const uint8_t key[16], const uint8_t iv[16],
|
|
const uint8_t *in, uint8_t *out,
|
|
size_t len, void *user)
|
|
{
|
|
(void)user;
|
|
|
|
struct vble_aes_ctx ctx;
|
|
|
|
vble_aes_init_ctx_iv(&ctx, key, iv);
|
|
if (out != in) {
|
|
memcpy(out, in, len);
|
|
}
|
|
vble_aes_ctr_xcrypt(&ctx, out, len);
|
|
return 0;
|
|
}
|