shishi_encrypt_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_encrypt_iv(3) πŸ’–

okay bestie, so this is a page from the shishi manual β€” section 3, the library-call girlies β€” and we're talking about shishi_encrypt_iv, an API function. yes it's giving cryptography. yes it's iconic. let's go πŸ¦‹


✨ NAME ✨

shishi_encrypt_iv β€” literally just an API function, that's the whole name, no notes πŸ’…


🌸 SYNOPSIS 🌸

#include <shishi.h>

int shishi_encrypt_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. eight arguments. main character energy fr fr πŸ‘‘


πŸŽ€ ARGUMENTS πŸŽ€

  • Shishi * handle β€” the shishi handle, the one you got from shishi_init(). she's the whole vibe, everything runs through her.
  • Shishi_key * key β€” the key you're encrypting with. the actual lock-and-key moment πŸ”
  • int keyusage β€” an integer saying what this key is out here encrypting. like, context bestie, context.
  • const char * iv β€” input array holding the initialization vector.
  • size_t ivlen β€” the size of that input array with the initialization vector. yes, you gotta tell it how big your IV is, it's not psychic πŸ™ˆ
  • const char * in β€” input array with the data you wanna encrypt. the actual tea β˜•
  • size_t inlen β€” size of that input array with the data to encrypt.
  • char ** out β€” output array with the newly allocated encrypted data. she's fresh, she's new, she's yours to free later.
  • size_t * outlen β€” output variable holding the size of that newly allocated output array.

πŸ’œ DESCRIPTION πŸ’œ

So. What does she do? She encrypts data using the specified initialization vector and key. that's it, that's the job ✨

the key that actually gets used is derived using the key usage. and here's the lil detail: if key usage is 0, no key derivation is used at all. zero means raw, bestie.

the OUT buffer must be deallocated by the caller. that's on you, not on her. she handed you a freshly allocated thing and now it's your responsibility, no take-backs 🫢

⚠️ the next IV is lost. like, gone gone. if you actually need it, go see shishi_encrypt_ivupdate instead β€” she's the one holding onto it.

and now the part that lowkey trips everyone up, so pay attention:

😭 DECRYPT(ENCRYPT(data)) does not necessarily yield data exactly.

not a typo, not a glitch, that's just how it is. some encryption types add pad to make the data fit into the block size of the encryption algorithm. and the pad? not guaranteed to look in any special way, though existing implementations often pad with the zero byte. so yeah β€” 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. DER said "I'll just include the length myself" and honestly? slay.


⭐ RETURN VALUE ⭐

Returns SHISHI_OK iff successful. that's the only good outcome, bestie. anything else and it's a vibe check failure πŸ’€


πŸ› REPORTING BUGS πŸ›

Report bugs to <bug-shishi@gnu.org>.

if something's broken, tell the maintainers, don't just suffer in silence 🫢


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. periodt.


🌈 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, the Texinfo girlies stay winning πŸ“š


okay that's the whole page, we ate and left no crumbs πŸ“ this was shishi_encrypt_iv(3) from the shishi manual, version 1.0.3 β€” mwah, take care of your IVs bestie πŸ’–βœ¨