shishi_encrypt_iv_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_iv_etype ✨

okay bestie, so this is a page from the shishi manual β€” section 3, the library functions zone πŸ’… β€” and it's all about one very specific little function: shishi_encrypt_iv_etype. it's an API function, no cap. let's get into it 🫢


🌸 SYNOPSIS 🌸

#include <shishi.h>

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

that's a LOT of parameters, i know. breathe. we're going through every single one πŸ’–


πŸŽ€ ARGUMENTS πŸŽ€

  • Shishi * handle β€” the shishi handle, and you get it from shishi_init(). it's like, your whole session's main character πŸ‘‘
  • Shishi_key * key β€” the key you're encrypting with. the vibe. the secret. πŸ”‘
  • int keyusage β€” an integer saying what this key is being used to encrypt. yes, context matters ✨
  • int32_t etype β€” an integer saying which cipher to use. pick your fighter 🌈
  • const char * iv β€” the input array holding the initialization vector.
  • size_t ivlen β€” how big that initialization vector input array is.
  • const char * in β€” the input array with the data you wanna encrypt πŸ“
  • size_t inlen β€” how big that data input array is.
  • char ** out β€” the output array, and it's newly allocated encrypted data. so like, it's yours now, you have to deal with it.
  • size_t * outlen β€” the output variable holding the size of that newly allocated output array.

πŸ’œ DESCRIPTION πŸ’œ

so what does it DO. it encrypts data according to the encryption method you specified, using the initialization vector and the key you handed it. easy.

the key actually used is derived using the key usage. important!! and listen β€” if key usage is 0, then no key derivation is used. periodt.

the OUT buffer must be deallocated by the caller. yes, that's on you, bestie 😭

and the next IV is lost β€” so if you need it, go look at shishi_encrypt_ivupdate_etype instead. iykyk.

🚨 okay this next bit is the real tea, so pay attention: note that DECRYPT(ENCRYPT(data)) does not necessarily give you back data exactly. some encryption types add pad to make the data fit into the block size of the encryption algorithm. and the pad isn't guaranteed to look any special way either β€” although existing implementations often pad with the zero byte. which means: you may have to "frame" your data, so it's actually possible to infer the original length after decryption. compare ASN.1 DER, which contains that kind of information. so yeah, no round-trip illusions here πŸ’€

⭐ RETURN VALUE ⭐

returns SHISHI_OK iff successful. that's it. that's the whole condition. iconic.


πŸ› REPORTING BUGS πŸ›

found a bug? 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.


🌈 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, this command:

info shishi

should give you access to the complete manual. go read it, it's giving βœ¨πŸ“š


and that's the whole page, bestie πŸ’– this was shishi version 1.0.3, page shishi_encrypt_iv_etype(3) β€” slay, go encrypt something responsibly, and remember to free() your output πŸŽ€πŸ¦‹