13 void hardened_memcpy(uint32_t *restrict dest,
const uint32_t *restrict src,
24 uintptr_t src_addr = (uintptr_t)src;
25 uintptr_t dest_addr = (uintptr_t)dest;
35 uintptr_t decoy_addr = (uintptr_t)&decoys;
39 size_t byte_len = word_len *
sizeof(uint32_t);
56 uintptr_t srcp = src_addr + byte_idx;
57 uintptr_t destp = dest_addr + byte_idx;
58 uintptr_t decoy1 = decoy_addr + (byte_idx %
sizeof(decoys));
60 decoy_addr + ((byte_idx +
sizeof(decoys) / 2) %
sizeof(decoys));
83 uint32_t hardened_memshred_random_word(
void) {
return 0xcaffe17e; }
92 uintptr_t data_addr = (uintptr_t)dest;
95 uintptr_t decoy_addr = (uintptr_t)&decoys;
97 size_t byte_len = word_len *
sizeof(uint32_t);
98 for (; count < expected_count; count =
launderw(count) + 1) {
102 uintptr_t datap = data_addr + byte_idx;
103 uintptr_t decoy = decoy_addr + (byte_idx %
sizeof(decoys));
109 write_32(hardened_memshred_random_word(), data);
123 uintptr_t lhs_addr = (uintptr_t)lhs;
124 uintptr_t rhs_addr = (uintptr_t)rhs;
129 uint32_t decoys[8] = {
130 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa,
131 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa,
133 uintptr_t decoy_addr = (uintptr_t)&decoys;
136 uint32_t ones = UINT32_MAX;
140 size_t byte_len = word_len *
sizeof(uint32_t);
141 for (; count < expected_count; count =
launderw(count) + 1) {
145 uintptr_t ap = lhs_addr + byte_idx;
146 uintptr_t bp = rhs_addr + byte_idx;
147 uintptr_t decoy1 = decoy_addr + (byte_idx %
sizeof(decoys));
149 decoy_addr + ((byte_idx +
sizeof(decoys) / 2) %
sizeof(decoys));
164 zeros = launder32(zeros) | (launder32(a) ^ b);
168 ones = launder32(ones) & (launder32(a) ^ ~b);
172 if (launder32(zeros) == 0) {
177 HARDENED_CHECK_NE(ones, UINT32_MAX);