Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions sw/device/lib/base/hardened_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ status_t hardened_memcpy(uint32_t *restrict dest, const uint32_t *restrict src,
RANDOM_ORDER_HARDENED_CHECK_DONE(order);
HARDENED_CHECK_EQ(count, word_len);

return OTCRYPTO_OK;
return (status_t){.value = (int32_t)launder32((uint32_t)OTCRYPTO_OK.value)};
}

status_t hardened_memshred(uint32_t *dest, size_t word_len) {
Expand All @@ -72,7 +72,7 @@ status_t hardened_memshred(uint32_t *dest, size_t word_len) {

HARDENED_CHECK_EQ(count, word_len);

return OTCRYPTO_OK;
return (status_t){.value = (int32_t)launder32((uint32_t)OTCRYPTO_OK.value)};
}

hardened_bool_t hardened_memeq(const uint32_t *lhs, const uint32_t *rhs,
Expand Down Expand Up @@ -207,7 +207,7 @@ status_t hardened_xor(const uint32_t *restrict x, const uint32_t *restrict y,
RANDOM_ORDER_HARDENED_CHECK_DONE(order);
HARDENED_CHECK_EQ(count, word_len);

return OTCRYPTO_OK;
return (status_t){.value = (int32_t)launder32((uint32_t)OTCRYPTO_OK.value)};
}

status_t hardened_xor_in_place(uint32_t *restrict x, const uint32_t *restrict y,
Expand Down Expand Up @@ -239,7 +239,7 @@ status_t hardened_xor_in_place(uint32_t *restrict x, const uint32_t *restrict y,
RANDOM_ORDER_HARDENED_CHECK_DONE(order);
HARDENED_CHECK_EQ(count, word_len);

return OTCRYPTO_OK;
return (status_t){.value = (int32_t)launder32((uint32_t)OTCRYPTO_OK.value)};
}

status_t randomized_bytecopy(void *restrict dest, const void *restrict src,
Expand All @@ -265,7 +265,7 @@ status_t randomized_bytecopy(void *restrict dest, const void *restrict src,
RANDOM_ORDER_HARDENED_CHECK_DONE(order);
HARDENED_CHECK_EQ(count, byte_len);

return OTCRYPTO_OK;
return (status_t){.value = (int32_t)launder32((uint32_t)OTCRYPTO_OK.value)};
}

status_t randomized_bytexor_in_place(void *restrict x, const void *restrict y,
Expand All @@ -291,5 +291,5 @@ status_t randomized_bytexor_in_place(void *restrict x, const void *restrict y,
RANDOM_ORDER_HARDENED_CHECK_DONE(order);
HARDENED_CHECK_EQ(count, byte_len);

return OTCRYPTO_OK;
return (status_t){.value = (int32_t)launder32((uint32_t)OTCRYPTO_OK.value)};
}
4 changes: 2 additions & 2 deletions sw/device/lib/base/hardened_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern uint32_t hardened_memshred_random_word(void);
* Unlike `memcpy()`, this function has important differences:
* - It is significantly slower, since it mitigates power-analysis attacks.
* - It performs operations on 32-bit words, rather than bytes.
* - It returns void.
* - It returns a status.
*
* 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.
Expand All @@ -56,7 +56,7 @@ status_t hardened_memcpy(uint32_t *OT_RESTRICT dest,
* - It is significantly slower, since it mitigates power-analysis attacks.
* - It performs operations on 32-bit words, rather than bytes.
* - A fill value cannot be specified.
* - It returns void.
* - It returns a status.
*
* 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.
Expand Down
2 changes: 1 addition & 1 deletion sw/device/lib/crypto/impl/rsa/rsa_padding.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ static status_t reverse_bytes(size_t input_len, uint32_t *input) {
RANDOM_ORDER_HARDENED_CHECK_DONE(order);
HARDENED_CHECK_EQ(i, num_idx);

return OTCRYPTO_OK;
return (status_t){.value = (int32_t)launder32((uint32_t)OTCRYPTO_OK.value)};
}

/**
Expand Down
Loading