Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
CONSTTIME_MEMEQUAL(3)	 BSD Library Functions Manual	 CONSTTIME_MEMEQUAL(3)

NAME
     consttime_memequal	-- compare byte	strings	for equality without timing
     leaks

LIBRARY
     Standard C	Library	(libc, -lc)

SYNOPSIS
     #include <string.h>

     int
     consttime_memequal(void *b1, void *b2, size_t len);

DESCRIPTION
     The consttime_memequal() function compares	len bytes of memory at b1 and
     b2	for equality, returning	0 if they are distinct and 1 if	they are iden-
     tical.

     The time taken by consttime_memequal() depends on len, but	not on the
     data at b1	or b2.	Thus, consttime_memequal() is appropriate for compar-
     ing cryptographic secrets,	hashes,	message	authentication codes, etc.,
     without leaking information about them through a timing side channel.  In
     crypto literature,	consttime_memequal() is	said to	take `constant time',
     meaning time that does not	vary depending on the data it processes.

     Note that unlike memcmp(3), consttime_memequal() does not return a	lexi-
     cographic ordering	on the data at b1 and b2; it tells only	whether	they
     are equal.

SEE ALSO
     explicit_memset(3), memcmp(3)

HISTORY
     The consttime_memequal() function appeared	in NetBSD 7.0.

BSD			       November	14, 2013			   BSD

NAME | LIBRARY | SYNOPSIS | DESCRIPTION | SEE ALSO | HISTORY

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=consttime_memequal&manpath=NetBSD+7.0>

home | help