RIJNDAEL(9)

✨ RIJNDAEL(9) β€” AES encryption, but make it a vibe ✨

okay bestie, welcome to the kernel developer's manual page for rijndael πŸ’… this is section 9 of the Kernel Developer's Manual, and it's literally all about AES encryption. sit down, grab a strawberry πŸ“, we're doing crypto.


🌸 NAME 🌸

rijndael_makeKey, rijndael_cipherInit, rijndael_blockEncrypt, rijndael_padEncrypt, rijndael_blockDecrypt, rijndael_padDecrypt β€” AES encryption

no cap, that's the whole roster. six little functions, one iconic cipher πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

first things first, you gotta include the headers or nothing works, obviously:

#include <sys/types.h>
#include <crypto/rijndael.h>

and here's the full cast, character for character, don't @ me:

int
rijndael_makeKey(keyInstance *key, uint8_t direction, int keyLen,
    char *keyMaterial);

int
rijndael_cipherInit(cipherInstance *cipher, uint8_t mode, char *IV);

int
rijndael_blockEncrypt(cipherInstance *cipher, keyInstance *key,
    uint8_t *input, int inputLen, uint8_t *outBuffer);

int
rijndael_padEncrypt(cipherInstance *cipher, keyInstance *key,
    uint8_t *input, int inputOctets, uint8_t *outBuffer);

int
rijndael_blockDecrypt(cipherInstance *cipher, keyInstance *key,
    uint8_t *input, int inputLen, uint8_t *outBuffer);

int
rijndael_padDecrypt(cipherInstance *cipher, keyInstance *key,
    uint8_t *input, int inputOctets, uint8_t *outBuffer);

like, look at them. main character energy, every single one πŸ’–


πŸ’œ DESCRIPTION πŸ’œ

so here's the tea. the rijndael_makeKey() function is the one that sets up the key schedule inside key. that's its whole job, and it does it flawlessly.

the direction tells it what the key is for, and it has to be either DIR_ENCRYPT or DIR_DECRYPT β€” like, are we locking it in or unlocking it, bestie? pick one 🫢

the length of the key, in bits, goes in keyLen, and it must be 128, 192 or 256. those are the only three options, periodt. don't try anything else.

and then the actual key itself lives in the buffer that keyMaterial points to. now, here's the little plot twist πŸŒ€: that material can be either

  • raw binary data, or
  • an ASCII string holding a hexadecimal rendition of the raw binary data

which one you get depends on a compile-time option in the rijndael_makeKey sources called BINARY_KEY_MATERIAL. so it's giving ✨build-dependent behaviour✨, iykyk.


πŸ”₯ RETURN VALUES πŸ”₯

rijndael_makeKey() is gonna hand you back one of these, so pay attention:

  • BAD_KEY_INSTANCE β€” if you passed a NULL key. not me forgetting to allocate πŸ’€
  • BAD_KEY_DIR β€” if direction isn't DIR_ENCRYPT or DIR_DECRYPT
  • BAD_KEY_MAT β€” if the key materials aren't a hexadecimal string (and binary keys are not set)
  • TRUE β€” otherwise! slay, it worked πŸŽ‰

🌈 AUTHORS 🌈

Mark R V Murray

the icon, the legend, the moment πŸ‘‘


okay that's the whole page bestie, go forth and encrypt responsibly πŸ¦‹

Debian Β· February 6, 2002 β€” that's the source/version and date this lil page came from, mwah πŸ’‹

πŸ“¦ where this page comes from