byte_start(3)

πŸ’– byte_start(3) πŸ’–

okay bestie, welcome to the Library Functions Manual, section 3, where we talk about byte_start β€” the little function that checks whether one string is a prefix of another. yes that's the whole job. she's focused. she's iconic. πŸŽ€


✨ NAME ✨

byte_start β€” find out if string b is prefix of string a


🌸 SYNTAX 🌸

#include <libowfat/byte.h>

int byte_start(const char *a,size_t alen,const char *b,size_t blen);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea. byte_start returns 1 if alen >= blen and the first blen bytes from a and b are equal. that's it. that's the whole vibe check. βœ…

now the important part, and I need you to actually listen, bestie, because this is the plot twist: when blen is too large, or when the strings are different, byte_start does not read bytes past the first difference. sounds efficient, right? it is! but it also means an attacker who's watching your execution timing can figure out where the first mismatch happened. 😭 like, she's leaking information through how fast she runs. not her fault, but still.

🚨 so if you're comparing keys, passphrases, cookies or hashes, do NOT use this one. use byte_equal_notimingattack instead. fr fr. protect your secrets, queen. πŸ‘‘

πŸ’… SEE ALSO πŸ’…


and that's the page!! 🫢 big love to libowfat, section 3 of the Library Functions Manual, and to byte_start(3) herself for keeping it short and sweet. mwah. πŸ’‹βœ¨