|
Pavona Software APIs
|
Hardened memory operations for constant power buffer manipulation. More...
#include <stddef.h>#include <stdint.h>#include "sw/device/lib/base/hardened.h"#include "sw/device/lib/base/macros.h"Go to the source code of this file.
Functions | |
| uint32_t | hardened_memshred_random_word (void) |
| Expects some external implementation of randomness to be linked. | |
| void | hardened_memcpy (uint32_t *OT_RESTRICT dest, const uint32_t *OT_RESTRICT src, size_t word_len) |
| Copies 32-bit words between non-overlapping regions. | |
| void | hardened_memshred (uint32_t *dest, size_t word_len) |
| Fills a 32-bit aligned region of memory with random data. | |
| hardened_bool_t | hardened_memeq (const uint32_t *lhs, const uint32_t *rhs, size_t word_len) |
| Compare two potentially-overlapping 32-bit aligned regions of memory for equality. | |
| void | hardened_xor (uint32_t *OT_RESTRICT x, const uint32_t *OT_RESTRICT y, size_t word_len) |
| Combines two word buffers with XOR. | |
| void | hardened_mmio_write (uint32_t dest, const uint32_t *src, size_t word_len) |
| Writes 32-bit words into an MMIO location. | |
| void | hardened_mmio_read (uint32_t *dest, uint32_t src, size_t word_len) |
| Reads 32-bit words from an MMIO location. | |
Hardened memory operations for constant power buffer manipulation.
Definition in file hardened_memory.h.
| void hardened_memcpy | ( | uint32_t *OT_RESTRICT | dest, |
| const uint32_t *OT_RESTRICT | src, | ||
| size_t | word_len ) |
Copies 32-bit words between non-overlapping regions.
Unlike memcpy(), this function has important differences:
Input pointers MUST be 32-bit aligned, although they do not need to actually point to memory declared as uint32_t per the C aliasing rules. Internally, this function is careful to not dereference its operands directly, and instead uses dedicated load/store intrinsics.
| dest | The destination of the copy. |
| src | The source of the copy. |
| word_len | The number of words to copy. |
| hardened_bool_t hardened_memeq | ( | const uint32_t * | lhs, |
| const uint32_t * | rhs, | ||
| size_t | word_len ) |
Compare two potentially-overlapping 32-bit aligned regions of memory for equality.
Unlike memcmp(), this function has important differences:
hardened_bool_t.Input pointers MUST be 32-bit aligned, although they do not need to actually point to memory declared as uint32_t per the C aliasing rules. Internally, this function is careful to not dereference its operands directly, and instead uses dedicated load/store intrinsics.
| lhs | The first buffer to compare. |
| rhs | The second buffer to compare. |
| word_len | The number of words to write. |
Definition at line 114 of file hardened_memory.c.
| void hardened_memshred | ( | uint32_t * | dest, |
| size_t | word_len ) |
Fills a 32-bit aligned region of memory with random data.
Unlike memset(), this function has important differences:
Input pointers MUST be 32-bit aligned, although they do not need to actually point to memory declared as uint32_t per the C aliasing rules. Internally, this function is careful to not dereference its operands directly, and instead uses dedicated load/store intrinsics.
| dest | The destination of the set. |
| word_len | The number of words to write. |
Definition at line 83 of file hardened_memory.c.
|
extern |
| void hardened_mmio_read | ( | uint32_t * | dest, |
| uint32_t | src, | ||
| size_t | word_len ) |
Reads 32-bit words from an MMIO location.
Similar to hardened_memcpy, but treats the destination as volatile.
| dest | The destination of the copy. |
| src | The source of the copy (MMIO address). |
| word_len | The number of words to copy. |
Definition at line 269 of file hardened_memory.c.
| void hardened_mmio_write | ( | uint32_t | dest, |
| const uint32_t * | src, | ||
| size_t | word_len ) |
Writes 32-bit words into an MMIO location.
Similar to hardened_memcpy, but treats the destination as volatile.
| dest | The destination of the copy (MMIO address). |
| src | The source of the copy. |
| word_len | The number of words to copy. |
Definition at line 230 of file hardened_memory.c.
| void hardened_xor | ( | uint32_t *OT_RESTRICT | x, |
| const uint32_t *OT_RESTRICT | y, | ||
| size_t | word_len ) |
Combines two word buffers with XOR.
Callers should ensure the entropy complex is up before calling this function. The implementation uses random-order hardening primitives for side-channel defense.
| [in,out] | x | Pointer to the first operand (modified in-place). |
| y | Pointer to the second operand. | |
| word_len | Length in words of each operand. |