Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ARMv8 #384

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
29 changes: 29 additions & 0 deletions src/util_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,35 @@ uint32_t rust_crypto_util_fixed_time_eq_asm(uint8_t* lhsp, uint8_t* rhsp, size_t
}
#endif

#ifdef __aarch64__
uint32_t rust_crypto_util_fixed_time_eq_asm(uint8_t* lhsp, uint8_t* rhsp, size_t count) {
if (count == 0) {
return 1;
}
uint8_t result = 0;
asm(
" \
1: \
\
ldrb w4, [%1]; \
ldrb w5, [%2]; \
eor w4, w4, w5; \
orr %0, %0, w4; \
\
add %1, %1, #1; \
add %2, %2, #1; \
subs %3, %3, #1; \
bne 1b; \
"
: "+&r" (result), "+&r" (lhsp), "+&r" (rhsp), "+&r" (count) // all input and output
: // input
: "w4", "w5", "cc" // clobbers
);

return result;
}
#endif

void rust_crypto_util_secure_memset(uint8_t* dst, uint8_t val, size_t count) {
memset(dst, val, count);
asm volatile("" : : "g" (dst) : "memory");
Expand Down