shishi_encrypt_etype(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_encrypt_etype β€” the glow-up encryption function ✨

okay bestie, gather round, because we're looking at a page from shishi, section 3 of the manual (that's the library-functions girlies, not the shell-command ones πŸ’…). This one's called shishi_encrypt_etype, and it's literally just "encrypt my data please, but let me pick the cipher" energy. No cap.


🌸 SYNOPSIS 🌸

#include <shishi.h>

int shishi_encrypt_etype(Shishi * handle, Shishi_key * key, int
keyusage, int32_t etype, const char * in, size_t inlen, char ** out,
size_t * outlen);

like, one function, eight arguments, zero chill πŸŽ€


πŸ¦‹ ARGUMENTS πŸ¦‹

  • Shishi * handle β€” the shishi handle, bestie. You get one from shishi_init(), don't just make one up out of vibes.
  • Shishi_key * key β€” the key you're encrypting with. the moment of truth πŸ”‘
  • int keyusage β€” an integer saying what this key is actually for, like what it's encrypting. context matters, periodt.
  • int32_t etype β€” an integer telling it which cipher to use. this is the whole point of the _etype flavour, so choose wisely ✨
  • const char * in β€” the input array, aka the data you wanna encrypt. the precious cargo πŸ“¦
  • size_t inlen β€” how big that input array is.
  • char ** out β€” output array that gets filled with the newly allocated encrypted data. yes, newly allocated, we'll talk about that in a sec πŸ‘€
  • size_t * outlen β€” output variable that receives the size of that newly allocated output array. so you know how much you got.

πŸ’– DESCRIPTION πŸ’–

So what it do: it encrypts your data according to the encryption method you picked, using a specified initialization vector and key. It's giving "do the crypto thing" πŸ”₯

BUT here's the tea β€” the key that actually gets used is derived using the key usage. And if keyusage is 0, then no key derivation happens at all. Zero. Nada. Just the key you handed it.

The OUT buffer? The caller has to deallocate it. That's you. You are the caller. It's your responsibility now, bestie 🫢

Also, the default IV is used here. If you need to mess with the IV, go see shishi_encrypt_iv_etype instead. And heads up β€” the next IV is lost with this one. If you actually need that next IV, you want shishi_encrypt_ivupdate_etype. Pick your fighter.

Now for the part that lowkey trips everyone up: DECRYPT(ENCRYPT(data)) does not necessarily give you data back exactly. Not a bug, just how it be 😭

Why? Because some encryption types add pad so the data fits into the block size of the encryption algorithm. And that pad is not guaranteed to look in any special way β€” like, existing implementations often pad with the zero byte, but "often" is doing a lot of heavy lifting there. So you can't rely on the pad looking a certain way.

Which means: you may have to "frame" your data so you can infer the original length after decryption. Think of it like telling your bestie "this message is exactly 47 characters long" before you send it, so she knows where it ends. Compare with ASN.1 DER, which contains exactly that kind of information. iconic behaviour, honestly πŸ‘‘


⭐ RETURN VALUE ⭐

Returns SHISHI_OK iff successful. That's it, that's the return value. slay.


πŸ™ˆ REPORTING BUGS πŸ™ˆ

Found a bug? Spill the tea to <bug-shishi@gnu.org>.

they're nice, they wanna help, fr fr.


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. so like, go off, just keep the receipts πŸ’œ


🌈 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. iykyk πŸ“–


and that's the whole page, bestie!! this was shishi_encrypt_etype(3) from shishi 1.0.3, dated 1.0.3 on the footer, section 3 of the manual β€” go encrypt something responsibly and remember to free your output buffer, i'm literally begging you πŸ’–βœ¨πŸ¦‹πŸŒΈπŸŽ€πŸ’