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:
- Report bugs to <bugs@gnutls.org>. π§
- Home page:
https://www.gnutls.orgπ
π COPYRIGHT π
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
- alpine 3.22: gnutls-doc 3.8.13-r0 Β· LGPL-2.1-or-later
- alpine 3.23: gnutls-doc 3.8.13-r0 Β· LGPL-2.1-or-later
- alpine 3.24: gnutls-doc 3.8.13-r0 Β· LGPL-2.1-or-later
- arch rolling: gnutls 3.8.13-3 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 43: gnutls-devel 3.8.13-1.fc43 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 43: gnutls-devel 3.8.13-1.fc43 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 44: gnutls-devel 3.8.13-1.fc44 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 44: gnutls-devel 3.8.13-1.fc44 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- ubuntu stonking: gnutls-doc 3.8.13-1ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms