Skip to content

Latest commit

 

History

History
19 lines (13 loc) · 714 Bytes

constant-time.md

File metadata and controls

19 lines (13 loc) · 714 Bytes

Constant Time Cryptography

Back{: .button}

function checkApiKey(inputKey, correctKey) {
  if (inputKey !== correctKey) {
      throw new Error("wrong key");
  }
}

Since string comparison is done byte by byte, even if an exception is thrown the number of correct bits can be guessed.

This has to be considered when choosing what to use for implementing cryptography algorithm, as an example BigInt is vulnerable to this

References