![]() |
![]()
| ![]() |
![]()
NAME
SYNOPSIS
int
int
int
DESCRIPTIONCryptographic operations often require comparison of secrets or values derived from secrets. Standard comparison functions like memcmp(3) tend to exit when they find the first difference, leaking information through timing differences. As an example, say a message authentication code (MAC) is sent over the network along with a message, but the correct MAC is secret. If the attacker attempts a forgery, one does not want to reveal “your MAC is wrong, and it took 384 microseconds to tell”. If the next attempt takes 462 microseconds instead, it tells the attacker that they just guessed a byte correctly. That way, an attacker can derive the correct MAC byte by byte and successfully forge a message. This has led to practical attacks in the past. To avoid such catastrophic failure,
When in doubt, prefer these functions over memcmp(3). RETURN VALUESThese functions return 0 if the two memory chunks are the same and -1 otherwise. SEE ALSOHISTORYThe CAVEATSMonocypher does not perform any input validation. Any deviation from the specified input and output length ranges results in undefined behaviour. Make sure your inputs are correct.
|