aes(3tcl)

πŸ“¦
version 2.0 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ aes(3tcl) ✨

okay bestie, you're looking at the man page for aes(3tcl) β€” aka Advanced Encryption Standard (AES), living in the tcllib collection. pull up a chair, we're gonna learn about block ciphers together πŸ’–


🌸 NAME 🌸

aes β€” the implementation of the AES block cipher. that's it, that's the name, short and iconic πŸ‘‘


✨ SYNOPSIS ✨

package require Tcl 8.5 9

package require aes ?1.2.2?

::aes::aes  ?-mode [ecb|cbc]? ?-dir [encrypt|decrypt]? -key keydata ?-iv
vector? ?-hex? ?-out channel? ?-chunksize size? [  -in  channel  |  ?--?
data ]

::aes::Init mode keydata iv

::aes::Encrypt Key data

::aes::Decrypt Key data

::aes::Reset Key iv

::aes::Final Key

πŸ’œ DESCRIPTION πŸ’œ

so this is a Tcl implementation of the Advanced Encryption Standard (AES) as published by the U.S. National Institute of Standards and Technology [1]. it's giving official. it's giving certified. πŸŽ€

here's the tea: AES is a 128-bit block cipher with a variable key size of 128, 192 or 256 bits. and this particular implementation supports ECB and CBC modes. no cap. 🌈


πŸ‘‘ COMMANDS πŸ‘‘

::aes::aes ?-mode [ecb|cbc]? ?-dir [encrypt|decrypt]? -key keydata ?-iv vector? ?-hex? ?-out channel? ?-chunksize size? [ -in channel | ?--? data ]

this one runs the aes algorithm on either the data you handed it as an argument, or on the data it reads from the -in channel. and if you give it an -out channel, the result gets written straight to that channel. main character energy fr. πŸ’…

  • the -key option is mandatory, no skipping it bestie. it takes a binary string of either 16, 24 or 32 bytes in length, and that's what gets used to generate the key schedule.
  • -mode and -dir are optional and they default to cbc mode and encrypt respectively. the initialization vector -iv takes a 16 byte binary argument and defaults to all zeros. go read MODES OF OPERATION if you wanna know more about the modes and what they're for πŸ‘€
heads up: AES is a 128-bit block cipher, which literally means the data has to be provided in units that are a multiple of 16 bytes. don't come at it with 15 bytes and expect slay, it will not slay. 😭

πŸ¦‹ PROGRAMMING INTERFACE πŸ¦‹

internal state is kept in an opaque structure that gets returned from the Init function. in ECB mode the state isn't affected by the input, but for CBC mode some input-dependent state is maintained, and you can reset it by calling the Reset function with a new initialization vector value. cute, right? 🫢

::aes::Init mode keydata iv

constructs a brand new AES key schedule using the specified key data and the given initialization vector. the initialization vector isn't used with ECB mode, but it is important for CBC mode. check MODES OF OPERATION for the details about cipher modes. ✨

::aes::Encrypt Key data

uses a prepared key you got by calling Init to encrypt the provided data. the data argument should be a binary array that's a multiple of the AES block size of 16 bytes. the result is a binary array the same size as the input, full of encrypted data. glow up complete. πŸ”₯

::aes::Decrypt Key data

deciphers data using the key. ngl the cute part is that the same key can be used to encrypt and decrypt data β€” provided the initialization vector is reset appropriately for CBC mode. πŸŽ€

::aes::Reset Key iv

resets the initialization vector. this lets the programmer re-use a key and dodge the cost of re-generating the key schedule when the same key data is being used multiple times. efficiency icon. ⭐

::aes::Final Key

this is the one you call to clean up resources associated with Key. and bestie, listen β€” once this function has been called the key may not be used again. it's over, it's done, do not text it back. πŸ’€


🌈 MODES OF OPERATION 🌈

Electronic Code Book (ECB)

ECB is the basic mode of all block ciphers. each block is encrypted independently, which means identical plain text will produce identical output when encrypted with the same key. 😬 any encryption errors will only affect a single block β€” but this is vulnerable to known plaintext attacks. so like, it's simple but it's not the moment.

Cipher Block Chaining (CBC)

CBC mode uses the output of the last block encryption to affect the current block. an initialization vector of the same size as the cipher block size is used to handle the first block. that initialization vector should be chosen randomly and transmitted as the first block of the output. errors in encryption affect the current block and the next block, after which the cipher will correct itself. CBC is the most commonly used mode in software encryption, and it's the default mode of operation for this module. periodt. πŸ‘‘


πŸ“ EXAMPLES πŸ“

% set nil_block [string repeat \\0 16]
% aes::aes -hex -mode cbc -dir encrypt -key $nil_block $nil_block
66e94bd4ef8a2c3b884cfa59ca342b2e

set Key [aes::Init cbc $sixteen_bytes_key_data $sixteen_byte_iv]
append ciphertext [aes::Encrypt $Key $plaintext]
append ciphertext [aes::Encrypt $Key $additional_plaintext]
aes::Final $Key

πŸ“š REFERENCES πŸ“š


🧚 AUTHORS 🧚

Thorsten Schloermann, Pat Thoyts β€” legends, honestly. πŸ’–


πŸ™ˆ BUGS, IDEAS, FEEDBACK πŸ™ˆ

this document, and the package it describes, will undoubtedly contain bugs and other problems. (their words, not mine, but ok go off.) please report such in the category aes of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. please also report any ideas for enhancements you may have for either the package and/or documentation. we want the feedback, we love the feedback. 🫢

when proposing code changes, please provide unified diffs, i.e the output of diff -u.

note further that attachments are strongly preferred over inlined patches. attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. iykyk. ✨


🌟 SEE ALSO 🌟

blowfish(3tcl), des(3tcl), md5(3tcl), sha1(3tcl)


πŸ’… KEYWORDS πŸ’…

aes, block cipher, data integrity, encryption, security


πŸŽ€ CATEGORY πŸŽ€

Hashes, checksums, and encryption


Copyright (c) 2005, Pat Thoyts <patthoyts@users.sourceforge.net>
Copyright (c) 2012-2014, Andreas Kupries <andreas_kupries@users.sourceforge.net>

okay that's the whole page bestie, you're officially AES-literate πŸ’– this was tcllib version 1.2.2, page aes(3tcl) β€” go encrypt something responsibly, stay safe, and remember: random IVs only. mwah πŸŽ€βœ¨

πŸ“¦ where this page comes from