File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3333#ifndef XMEMCMP
3434#define XMEMCMP memcmp
3535#endif
36+ /* A memory compare function that has to run in constant time,
37+ * c.f. mem_neq() API summary.
38+ */
3639#ifndef XMEM_NEQ
3740#define XMEM_NEQ mem_neq
3841#endif
Original file line number Diff line number Diff line change 1010
1111/**
1212 @file mem_neq.c
13- Compare two blocks of memory for inequality.
13+ Compare two blocks of memory for inequality in constant time .
1414 Steffen Jaeckel
1515*/
1616
1717/**
18- Compare two blocks of memory for inequality.
18+ Compare two blocks of memory for inequality in constant time .
1919
2020 The usage is similar to that of standard memcmp, but you can only test
2121 if the memory is equal or not - you can not determine by how much the
2222 first different byte differs.
2323
24+ This function shall be used to compare results of cryptographic
25+ operations where inequality means most likely usage of a wrong key.
26+ The execution time has therefore to be constant as otherwise
27+ timing attacks could be possible.
28+
2429 @param a The first memory region
2530 @param b The second memory region
2631 @param len The length of the area to compare (octets)
2732
28- @return 0 when a and b are equal for len bytes, else they are not equal.
33+ @return 0 when a and b are equal for len bytes, 1 they are not equal.
2934*/
3035int mem_neq (const void * a , const void * b , size_t len )
3136{
You can’t perform that action at this time.
0 commit comments