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

FreeBSD Manual Pages

  
 
  

home | help
byte_starts(3)		    Library Functions Manual		  byte_starts(3)

NAME
     byte_starts - find out if a buffer starts with a string

SYNTAX
     #include <libowfat/byte.h>

     int byte_starts(const char *buf,size_t buflen,const char *str);

DESCRIPTION
     byte_starts  returns 1 if the buflen>=strlen(str) and the first strlen(str)
     bytes of buf match the contents of str, or 0 otherwise.

     This function is meant to be used in protocol parsing  and  with  a  string
     constant  for str and will use gcc/clang macro trickery to reduce to a call
     to memcmp then.

     byte_starts compares as few bytes as possible. An	attacker  observing  the
     execution timing can thus learn where the first mismatch happened.

     Use  byte_equal_notimingattack  to  compare  keys,  passphrases, cookies or
     hashes instead.

SEE ALSO
     byte_equal(3), byte_equal_notimingattack(3), byte_start(3)

								  byte_starts(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=libowfat_byte_starts&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>

home | help