libcanlock(3)

🌸 libcanlock(3) β€” the cl_get_key era 🌸

okay bestie, gather round, because we're diving into libcanlock β€” yes the manual name is literally libcanlock, iconic β€” and today's main character is a little function called cl_get_key. it's giving crypto girlboss and we're obsessed πŸ’…


✨ NAME ✨

cl_get_key β€” Create Cancel-Key with libcanlock πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

ok so first you gotta invite the header in:

#include <libcanlock-3/canlock.h>

then the function itself, in all its glory:

char *cl_get_key(cl_hash_version hash,
                 const unsigned char *sec, size_t sec_len,
                 const unsigned char *msg, size_t msg_len);

and the supported values for hash (as of version 3.0.0 of libcanlock, no cap):

CL_SHA1 CL_SHA224 CL_SHA256 CL_SHA384 CL_SHA512

like, pick your fighter πŸ’–


πŸ’œ DESCRIPTION πŸ’œ

so cl_get_key() creates a <c-key> element following the algorithm recommended by RFC 8315 in Section 4 β€” yes, the algorithm, and yes, we're being that precise. the hash algorithm you selected for <scheme> is used for the HMAC operation too, bestie, they're a package deal 🫢

you pick the hash algorithm for <scheme> with the hash argument. slay.

the local secret goes in sec β€” and sec_len must be set to the length of sec. also, the length of the local secret should be at least the length of the hash you selected for <scheme> (that's 32 octets for SHA256, for the people in the back). highkey important, don't skip that πŸ™ˆ

the Message-ID of the target article β€” y'know, the one that should be cancelled or superseded β€” goes in msg. and yep, msg_len must be set to the length of msg. no guessing bestie, give it the real length πŸ’€

here's a cute extra: the Message-ID msg can be prepended with an optional User-ID. the length of the User-ID must be added to msg_len. and the User-ID must not contain angle brackets β€” that's the vibe check, it has to pass ⭐


🌈 RETURN VALUE 🌈

if everything goes off without a hitch, you get back a pointer to the result string. chef's kiss. ✨

otherwise? NULL. that's it. that's the whole story 😭

on success, it's on you (the caller, the main character) to call free() for the pointer you got back as your result. don't ghost your malloc'd memory, that's rude πŸ’€


πŸ‘‘ AUTHORS πŸ‘‘

  • Dennis Preiser β€” (based in part on the implementation from G. J. Andruk for Version 2) 🫢
  • the base64 implementation is written by Kungliga Tekniska Hogskolan (Royal Institute of Technology, Stockholm, Sweden) πŸ‡ΈπŸ‡ͺ
  • the hash algorithms are implemented with code from RFC 6234 πŸ”₯

πŸŽ€ REPORTING BUGS πŸŽ€

found something cursed? report bugs to <mailto:michael.baeuerle@gmx.net>. be nice about it, it's giving constructive πŸ’–


⭐ STANDARDS ⭐

libcanlock tries to comply with the following standards (overachiever behavior, we love it):

RFC 5537, RFC 6234, RFC 8315


πŸ’… SEE ALSO πŸ’…

go read these next, bestie, iykyk:


and that's the whole page, bestie πŸ¦‹ this was libcanlock 3.3.3, dated 2026-07-06, straight from the Unix corner of the internet. periodt. πŸ’œβœ¨

πŸ“¦ where this page comes from