shishi_decrypt_iv(3)

πŸ“¦
version 1.0.3 Β· 2 versions
  • 1.0.3 Β· debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 1.0.2 Β· ubuntu jammy
, in debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– shishi_decrypt_iv β€” the vibe

okay bestie, welcome to shishi_decrypt_iv(3), one of the lil gems from the shishi manual. this is the API function that takes your scrambled lil bytes and ✨un-scrambles✨ them, as long as you brought the right key and the right initialization vector. no cap.


🌸 NAME 🌸

shishi_decrypt_iv β€” API function. that's it. that's the name. she does one thing and she does it well πŸ’…


✨ SYNOPSIS ✨

#include <shishi.h>

int shishi_decrypt_iv(Shishi * handle, Shishi_key * key, int keyusage,
const char * iv, size_t ivlen, const char * in, size_t inlen, char **
out, size_t * outlen);

look at her. nine arguments. she's high maintenance but she's worth it πŸŽ€


🫢 ARGUMENTS 🫢

here's the full roster, every single one, no skipping (i would never):

  • Shishi * handle β€” your shishi handle, the one you got from shishi_init(). she's the main character of the whole operation tbh.
  • Shishi_key * key β€” the key you're decrypting with. the actual key used gets derived later, so don't get too attached to this exact one πŸ‘€
  • int keyusage β€” an integer saying what this key is decrypting. it's the whole reason the key derivation knows what to do.
  • const char * iv β€” input array holding the initialization vector.
  • size_t ivlen β€” size of that input array with the initialization vector. yes you have to tell her. she's not a mind reader.
  • const char * in β€” input array with the data to decrypt. the locked box πŸ“¦
  • size_t inlen β€” size of the input array with the data to decrypt.
  • char ** out β€” output array with the newly allocated decrypted data. newly allocated, bestie, remember that.
  • size_t * outlen β€” output variable that gets the size of that newly allocated output array.

πŸ’œ DESCRIPTION πŸ’œ

so what does she actually do? she decrypts your data using the specified initialization vector and key. simple. iconic.

but here's the tea 🍡 β€” the key that actually gets used is derived using the key usage. so if keyusage is 0, then no key derivation is used at all. zero. none. just vibes and the raw key.

🚨 the OUT buffer must be deallocated by the caller. that's on you, bestie. she allocated it, you free it. that's the deal.
😭 also: the next IV is lost. gone. if you need it, go check out shishi_decrypt_ivupdate_etype instead. iykyk.

and now the part that lowkey ruins everyone's day: note that DECRYPT(ENCRYPT(data)) does not necessarily yield data exactly. not a perfect round trip, fr fr. some encryption types add pad to make the data fit into the block size of the encryption algorithm. and worse β€” the pad is not guaranteed to look in any special way, even though existing implementations often pad with the zero byte. so yeah. this means you may have to "frame" your data, so it's possible to infer the original length after decryption. compare ASN.1 DER, which contains such information. (ASN.1 DER said "i'll just tell you the length" and honestly? queen behavior πŸ‘‘)


⭐ RETURN VALUE ⭐

returns SHISHI_OK iff successful. that's the whole story. if you got SHISHI_OK, you ate. πŸ”₯


πŸ™ˆ REPORTING BUGS πŸ™ˆ

found a bug? don't be shy, report it to <bug-shishi@gnu.org>.


Copyright Β© 2002-2022 Simon Josefsson.

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.

(very generous, very slay, we love a permissive license 🫢)


🌈 SEE ALSO 🌈

the full documentation for shishi is maintained as a Texinfo manual. if the info and shishi programs are properly installed at your site, the command

info shishi

should give you access to the complete manual. go read it, it's giving ✨knowledge✨


and that's the whole page, bestie!! this was shishi_decrypt_iv(3) from the shishi manual, version 1.0.3 πŸ’– go forth and decrypt responsibly, and don't forget to free that out buffer or i will find out πŸ¦‹πŸŒΈπŸ§š