SASL_DECODE(3)

πŸ’– SASL_DECODE(3) πŸ’–

okay bestie so this is sasl_decode from the Cyrus SASL docs, section 3 of the manual, and it's genuinely one of the most useful little functions in the whole library. come sit with me, we're gonna get you fluent in this πŸ’…


✨ NAME ✨

sasl_decode β€” Cyrus SASL documentation, babes πŸ“–


🌸 SYNOPSIS 🌸

#include <sasl/sasl.h>

int sasl_decode(sasl_conn_t *conn,
               const char * input,
                unsigned inputlen,
               const char ** output,
               unsigned * outputlen);

yes the indentation is a little chaotic in the original, we don't talk about it, it's iconic πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

int sasl_decode(sasl_conn_t *conn,

const char * input,

unsigned inputlen,

const char ** output,

unsigned * outputlen);

so like. sasl_decode decodes data received. that's the whole vibe. after a successful authentication you should be calling this function on all data you receive, no skipping, no "I'll do it later" πŸ™ˆ. it takes data that's in encrypted or signed form and turns it back into plain data. and here's the cute part β€” if there was no security layer negotiated, the output is identical to the input. literally a mirror. no notes. ✨

🧚 Parameters 🧚

  • conn – is the SASL connection context πŸ’«
  • output – contains the decoded data and is allocated/freed by the library. so like, don't you dare touch that memory management, it's the library's job bestie, hands off 🫢
  • outputlen – length of output πŸ“
⚠️ one should not give sasl_decode more data than the negotiated maxbufsize (see sasl_getprop(3)). respect the buffer limit, it's giving boundaries and we love that for it 🚧

and a lil plot twist that trips people up every single time: note that sasl_decode can succeed and outputlen can be zero 😭 that's not a bug, that's not an error, that's just the vibe. if that happens, simply wait for more data and call sasl_decode again. periodt πŸ’…


πŸ”₯ RETURN VALUE πŸ”₯

SASL callback functions should return SASL return codes. see sasl.h for a complete list, it's all in there iykyk πŸ“œ

SASL_OK indicates success πŸŽ‰πŸ‘‘

Other return codes indicate errors and should be handled. like actually handled, not ignored, we're not doing that today 🚨


πŸ‘‘ SEE ALSO πŸ‘‘

(the sasl_encode one is literally just this but backwards, they're a matched set, soulmates fr fr πŸ’ž)


πŸ’œ AUTHOR πŸ’œ

The Cyrus Team 🫑


1993-2016, The Cyrus Team


and that's the whole page bestie!! this dropped as version 2.1.28 back on February 18, 2022, and yes it's still SASL_DECODE(3) energy around here πŸ’–βœ¨πŸŽ€ go forth and decode responsibly, mwah 🫢πŸ’