|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Secure-comparison primitives implementation. More...
Go to the source code of this file.
Functions | |
| bool | ra8_ct_equal (const void *a, const void *b, size_t len) |
| Constant-time equality of two byte buffers. | |
| void | ra8_secure_memzero (void *ptr, size_t len) |
| Securely zero a buffer such that the write cannot be optimised away. | |
Secure-comparison primitives implementation.
Implements constant-work byte comparison and explicit memory clearing primitives used at security-sensitive ownership boundaries.
Definition in file ra8_secure.c.
|
nodiscard |
Constant-time equality of two byte buffers.
OR-accumulates the per-byte XOR difference across all len bytes with no early-out, then reports equality from the accumulator. The number of byte comparisons – and thus the timing – depends only on len, never on the contents, so a caller comparing a secret (MAC / tag / digest / key) against an attacker-supplied value does not leak how many leading bytes matched.
| [in] | a | First buffer. Must be non-NULL. |
| [in] | b | Second buffer. Must be non-NULL. |
| [in] | len | Number of bytes to compare. |
| true | All len bytes are equal (vacuously true when len == 0). |
| false | The buffers differ, or either pointer is NULL. |
Definition at line 20 of file ra8_secure.c.
Referenced by priv_ra8_sec_cmac_verify(), and ra8_ota_verify_signature().
| void ra8_secure_memzero | ( | void * | ptr, |
| size_t | len ) |
Securely zero a buffer such that the write cannot be optimised away.
Overwrites len bytes at ptr with zero through a volatile pointer. A plain memset immediately before a buffer leaves scope is a dead store the optimiser is free to delete, leaving secret key / MAC / digest material in stack or static memory; the volatile access is an observable side effect the compiler must preserve. Use this to scrub any transient that held a secret.
| [out] | ptr | Buffer to zero. A NULL pointer is a no-op. |
| [in] | len | Number of bytes to zero. Zero length is a no-op. |
Definition at line 37 of file ra8_secure.c.
Referenced by c6_join_phase_associate(), internal_c6_cam_associate(), internal_c6link_op_join(), internal_c6link_sta_set_config(), internal_cmac_subkeys(), internal_cmac_tag(), internal_open_and_join(), internal_run(), internal_verify_cmac(), priv_c6link_rpc_call(), priv_ra8_key_import_build_blob(), priv_ra8_sec_cmac_verify(), ra8_c6link_sta_cfg_set(), ra8_net_provision_clear(), and ra8_net_provision_receive().