Browse Source

core/crypto: Disable optimization for the ct byte compare

Hedge against the possibility of a compiler getting clever enough to
optimize this pattern as well.
Yawning Angel 2 years ago
parent
commit
b8c2b0105b
1 changed files with 1 additions and 0 deletions
  1. 1 0
      core/crypto/crypto.odin

+ 1 - 0
core/crypto/crypto.odin

@@ -26,6 +26,7 @@ compare_constant_time :: proc "contextless" (a, b: []byte) -> int {
 //
 //
 // The execution time of this routine is constant regardless of the
 // The execution time of this routine is constant regardless of the
 // contents of the memory being compared.
 // contents of the memory being compared.
+@(optimization_mode="none")
 compare_byte_ptrs_constant_time :: proc "contextless" (a, b: ^byte, n: int) -> int {
 compare_byte_ptrs_constant_time :: proc "contextless" (a, b: ^byte, n: int) -> int {
 	x := mem.slice_ptr(a, n)
 	x := mem.slice_ptr(a, n)
 	y := mem.slice_ptr(b, n)
 	y := mem.slice_ptr(b, n)