gnutls_memcmp(3)

✨ gnutls_memcmp(3) ✨

okay bestie, welcome to the gnutls manual πŸ’– you're literally about to learn about gnutls_memcmp, and it's giving cryptographic main character energy. stay with me, it's short and it slays.


🌸 NAME 🌸

gnutls_memcmp β€” it's an API function, no cap πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnutls/gnutls.h>

int gnutls_memcmp(const void * s1, const void * s2, size_t n);

πŸŽ€ ARGUMENTS πŸŽ€

  • const void * s1 β€” the first address to compare, bestie. that's the first thing we're side-eyeing πŸ‘€
  • const void * s2 β€” the second address to compare. the other one in the ring πŸ’€
  • size_t n β€” the size of memory to compare. how many bytes we're putting under the microscope πŸ”

🌈 DESCRIPTION 🌈

so here's the tea β˜• this function operates similarly to memcmp(), but with one huge glow-up: it operates in time that depends only on the size of the string. that's it. that's the whole flex.

the way that regular memcmp() would just ✨return early✨ the second the strings don't match on the first byte? yeah, gnutls_memcmp does NOT do that. it will not bail early. it stays for the whole ride, every byte, same amount of time, no matter what. constant-time bestie behavior, we love to see it 🫢

ngl this is the kind of thing that matters when you're comparing secrets and don't want to leak info through timing. iconic.

⭐ RETURNS ⭐

  • non zero on difference πŸ‘€
  • zero if the buffers are identical βœ…

periodt.


πŸ’œ SINCE πŸ’œ

3.4.0 β€” she's been here since 3.4.0, a true veteran queen πŸ‘‘


πŸ™ˆ REPORTING BUGS πŸ™ˆ

found a bug? don't be shy, tell the devs fr fr:


Copyright Β© 2001-2023 Free Software Foundation, Inc., and others.

Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. 🫢 (yes you can share it, just keep the receipts bestie)


πŸ“ SEE ALSO πŸ“

The full documentation for gnutls is maintained as a Texinfo manual. If the /usr/share/doc/gnutls/ directory does not contain the HTML form, visit

https://www.gnutls.org/manual/


and that's the whole page, bestie πŸ’– this was gnutls 3.8.13, page gnutls_memcmp(3), brought to you by the gnutls manual. go compare some bytes safely, ily, mwah πŸ’…βœ¨

πŸ“¦ where this page comes from