bash.h(3)

📦
version 2.2.0 · 2 versions
, in fedora 44

💖 bash.h 💖

okay so bestie 🫶 pull up a chair, this is the manual for bash.h, living its best life in the Library Functions Manual (section 3, where all the C library girlies hang out). It's giving cryptography, it's giving sponge functions, it's giving a whole family of algorithms — and we are gonna get through every single crumb of it together. No skipping, no skimming, periodt. 💅


✨ NAME ✨

bash.h — the СТБ 34.101.77 algorithms (aka bash). 💖


✨ SYNOPSIS ✨

#include 'bee2/defs.h'

🦋 Functions 🦋

  • size_t bashF_deep() — the depth of the sponge-function stack
  • void bashF (octet block[192], void *stack) — the sponge function
  • size_t bashHash_keep() — the length of the hashing-function state
  • void bashHashStart (void *state, size_t l) — kick off the hashing
  • void bashHashStepH (const void *buf, size_t count, void *state) — hash one chunk of data
  • void bashHashStepG (octet hash[], size_t hash_len, void *state) — figure out the hash value
  • bool_t bashHashStepV (const octet hash[], size_t hash_len, void *state) — check a hash value
  • err_t bashHash (octet hash[], size_t l, const void *src, size_t count) — hash it up
  • size_t bashPrg_keep() — the length of the automaton state
  • void bashPrgStart (void *state, size_t l, size_t d, const octet ann[], size_t ann_len, const octet key[], size_t key_len) — set the automaton up
  • void bashPrgRestart (const octet ann[], size_t ann_len, const octet key[], size_t key_len, void *state) — re-initialize the automaton
  • void bashPrgAbsorbStart (void *state) — start loading data in
  • void bashPrgAbsorbStep (const void *buf, size_t count, void *state) — one step of loading data
  • void bashPrgAbsorb (const void *buf, size_t count, void *state) — load the data
  • void bashPrgSqueezeStart (void *state) — start unloading data
  • void bashPrgSqueezeStep (void *buf, size_t count, void *state) — one step of unloading data
  • void bashPrgSqueeze (void *buf, size_t count, void *state) — unload the data
  • void bashPrgEncrStart (void *state) — start encrypting
  • void bashPrgEncrStep (void *buf, size_t count, void *state) — one step of encryption
  • void bashPrgEncr (void *buf, size_t count, void *state) — encrypt
  • void bashPrgDecrStart (void *state) — start decrypting
  • void bashPrgDecrStep (void *buf, size_t count, void *state) — one step of decryption
  • void bashPrgDecr (void *buf, size_t count, void *state) — decrypt
  • void bashPrgRatchet (void *state) — irreversibly change the automaton

✨ DESCRIPTION ✨ (Подробное описание)

СТБ 34.101.77. That's the vibe. It defines a whole family of hashing algorithms built on top of the sponge function bash-f, which is implemented in bashF(). And here's the tea: the sponge function is lowkey a standalone icon — it has its own independent meaning and can absolutely be used outside the bash module. 🌈 The stack depth of bashF() is determined with the bashF_keep() function.

When you build the library with the BASH_PLATFORM option, you can request a version of bashF() that's optimized for one of 5 hardware platforms:

  • 64-bit (BASH_64),
  • 32-bit (BASH_32),
  • Intel SSE2 (BASH_SSE2),
  • Intel AVX2 (BASH_AVX2),
  • Intel AVX512 (BASH_AVX512),
  • ARM NEON (BASH_NEON). By default, the implementation for the BASH_64 platform is used, or, if 64-bit registers aren't supported, BASH_32.

The stack depth of bashF() is determined with the bashF_deep() function. ✨

The specific hashing algorithm bashHashNNN returns NNN-bit hash values, where NNN is a multiple of 32 and doesn't exceed 512. The NNN parameter is controlled by the security level l = NNN / 2.

Hashing goes down like this:

  • determine the length of the hash state with the bashHash_keep() function;
  • set up a memory buffer for the state;
  • initialize the state with bashHashStart(). Pass the required security level into this function;
  • process the chunks of data you wanna hash with bashHashStepH();
  • determine the hash value with bashHashStepG(), or verify it with bashHashStepV().

The functions bashHashStart(), bashHashStepH(), bashHashStepG(), and bashHashStepV() all share one common hash state and form a bundle. These bundle functions are lowkey low-level — they do not check their input data. The bundle gets covered by the high-level bashHash() function. 🫶

The standard levels l = 128, 192, 256 are supported by the bashNNNXXX macros.

Besides the hashing algorithms, СТБ 34.101.77 also defines a cryptographic automaton built on the sponge function, plus programmable algorithms — which are literally just sequences of automaton commands. The length of the automaton state is determined with the bashPrg_keep() function.

The command lineup:

  • start (initialize);
  • restart (re-initialize);
  • absorb (load data);
  • squeeze (unload data);
  • encrypt (encrypt — shortened to encr);
  • decrypt (decrypt — shortened to decr);
  • ratchet (irreversibly change the automaton).

There's one more command, commit, but she's internal — she gets called from the other commands. 🙈

The commands start, restart, and ratchet are implemented in the bashPrgStart(), bashPrgRestart(), and bashPrgRatchet() functions.

The absorb, squeeze, encrypt, and decrypt commands process data of potentially arbitrary volume. That's why the standard chained Start/Step processing exists. This scheme is supported by the bashPrgCmdStart() and bashPrgCmdStep() functions, where Cmd is the command name. And quick heads up: there's no Stop step. It's not needed, because the automaton's commands run in a deferred manner — a command finishes when the next one starts. 👑

In the functions that implement the commands, the programmable-algorithm automaton is identified with its own state. There's some acceptable jargon going on here (and honestly it captures the whole point): "load into the automaton", "unload from the automaton".

The specific programmable algorithms — including the ones defined in СТБ 34.101.77 — are not implemented. But they're easy to build by calling the command functions in a particular sequence. Slay, DIY. 💅

Ожидается (Expects)

  • The common state of the function bundle is not changed outside of these functions.

Предусловие (Precondition)

  • All input pointers of the low-level functions are valid.
  • Unless stated otherwise, the input buffers of the bundle functions do not overlap.

Регулярность (Regularity)

  • The implementations for the BASH_SSE2, BASH_AVX2, and BASH_AVX512 platforms may leave data on the stack that doesn't fit into the extended registers of the corresponding architectures.

✨ FUNCTIONS ✨ (Функции)

🎀 void bashF (octet block[192], void *stack)

The block buffer gets transformed with the sponge function bash-f.

Предусловие (Precondition)

  • The block buffer is correct.
  • If BASH_PLATFORM == BASH_32, then memIsAligned(block, 4) == TRUE.
  • If BASH_PLATFORM == BASH_64, then memIsAligned(block, 8) == TRUE.

Аргументы (Arguments)

  • block — preimage/image (прообраз/образ)
  • stack — stack

🎀 size_t bashF_deep ()

Returns the depth of the sponge function's stack (in octets).

Возвращает (Returns)

  • The stack depth.

🎀 err_t bashHash (octet hash[], size_t l, const void *src, size_t count)

Using the bash algorithm at security level l, the hash value [l / 4]hash of the buffer [count]src is determined.

Ожидается [ERR_BAD_PARAM] (Expects)

  • l > 0 && l % 16 == 0 && l <= 256.

Ожидается [ERR_BAD_INPUT] (Expects)

  • The hash and src buffers are correct.

Возвращает (Returns)

  • ERR_OK if the hashing completed successfully, or an error code otherwise.

Прим. (Note)

  • The buffers may overlap.

Аргументы (Arguments)

  • hash — the hash value
  • l — security level
  • src — the data
  • count — number of data octets

🎀 size_t bashHash_keep ()

Returns the length of the state (in octets) of the bash hashing algorithms.

Возвращает (Returns)

  • The state length.

🎀 void bashHashStart (void *state, size_t l)

The data structures needed for hashing with the bash algorithms at level l get formed in state.

Предусловие (Precondition)

  • l > 0 && l % 16 == 0 && l <= 256.
  • bashHash_keep() octets are reserved at the address state.

Аргументы (это ещё от функции сверху, мы просто продолжаем — не переключайся 💖)

  • state — состояние
  • l — уровень стойкости

🌸 void bashHashStepG (octet hash[], size_t hash_len, void * state)

okay so this one takes the first hash_len octets of the final hash value of every single thing you've already fed through bashHashStepH() and drops them into hash. It's the grand reveal moment, bestie. ✨

Предусловие — read it before you vibe:

  • hash_len <= l / 4, где l — уровень стойкости, ранее переданный в bashHashStart().

Ожидается — the call-order law, don't fight it:

(bashHashStepH()* < bashHashStepG())*

Прим. Если продолжение хэширования не предполагается, то буферы hash и state могут пересекаться. Lowkey convenient. 💅

Аргументы:

  • hash — сюда приезжает хэш-значение
  • hash_len — длина hash
  • state — состояние

🦋 void bashHashStepH (const void * buf, size_t count, void * state)

Текущее хэш-значение, которое живёт в state, пересчитывается по алгоритму bash с учётом нового кусочка данных [count]buf. New data, who dis. 👑

Ожидается:

bashHashStart() < bashHashStepH()*

Аргументы:

  • buf — данные
  • count — число октетов данных
  • state — состояние

💜 bool_t bashHashStepV (const octet hash[], size_t hash_len, void * state)

This one literally vibe-checks: it confirms that the first octets of the final hash value of everything processed so far by bashHashStepH() match [hash_len]hash. 🫶

Предусловие:

  • hash_len <= l / 4, где l — уровень стойкости, ранее переданный в bashHashStart().

Ожидается:

(bashHashStepH()* < bashHashStepV())*

Возвращает: признак успеха.

Аргументы:

  • hash — контрольное хэш-значение
  • hash_len — длина hash
  • state — состояние

🎀 size_t bashPrg_keep ()

Возвращается длина состояния (в октетах) автомата программируемых алгоритмов — i.e. how much room you gotta reserve. Budgeting era. 💾

Возвращает: длина состояния.


🌟 void bashPrgAbsorb (const void * buf, size_t count, void * state)

В автомат state загружаются данные [count]buf. Nom nom nom. 🍓

Ожидается:

bashPrgStart() < bashPrgAbsorb()*

Аргументы:

  • buf — данные
  • count — число октетов данных
  • state — автомат

🌈 void bashPrgAbsorbStart (void * state)

Инициализируется загрузка данных в автомат state. Setting the stage, main character energy. 👑

Ожидается:

bashPrgStart() < bashPrgAbsorbStart()

Прим. В начале загрузки завершается предыдущая команда.

Аргументы:

  • state — автомат

✨ void bashPrgAbsorbStep (const void * buf, size_t count, void * state)

Выполняется загрузка в автомат state фрагмента [count]buf. Piece by piece, no rush. 🧚

Ожидается:

bashPrgAbsorbStart() < bashPrgAbsorbStep()*

Аргументы:

  • buf — данные
  • count — число октетов данных
  • state — автомат

🔓 void bashPrgDecr (void * buf, size_t count, void * state)

С помощью автомата state расшифровываются данные [count]buf. Unscrambling the tea. ☕

Предусловие: автомат находится в ключевом режиме.

Ожидается:

bashPrgStart() < bashPrgDecr()*

Аргументы:

  • buf — данные
  • count — число октетов данных
  • state — автомат

🗝️ void bashPrgDecrStart (void * state)

Инициализируется расшифрование данных с помощью автомата state.

Предусловие: автомат находится в ключевом режиме.

Ожидается:

bashPrgStart() < bashPrgDecrStart()

Прим. В начале расшифрования завершается предыдущая команда.

Аргументы:

  • state — автомат

💫 void bashPrgDecrStep (void * buf, size_t count, void * state)

Выполняется расшифрование с помощью автомата state фрагмента [count]buf.

Ожидается:

bashPrgDecrStart() < bashPrgDecrStep()*

Аргументы:

  • buf — данные
  • count — число октетов данных
  • state — автомат

🔐 void bashPrgEncr (void * buf, size_t count, void * state)

С помощью автомата state зашифровываются данные [count]buf. Locking it down, periodt. 🔒

Предусловие: автомат находится в ключевом режиме.

Ожидается:

bashPrgStart() < bashPrgEncr()*

Аргументы:

  • buf — данные
  • count — число октетов данных
  • state — автомат

🧚 void bashPrgEncrStart (void * state)

Инициализируется зашифрование с помощью автомата state.

Ожидается:

bashPrgStart() < bashPrgEncrStart()

Предусловие: автомат находится в ключевом режиме.

Прим. В начале зашифрования завершается предыдущая команда.

Аргументы:

  • state — автомат

⭐ void bashPrgEncrStep (void * buf, size_t count, void * state)

Выполняется зашифрование с помощью автомата state фрагмента [count]buf.

Ожидается:

bashPrgEncrStart() < bashPrgEncrStep()*

Аргументы:

  • buf — данные
  • count — число октетов данных
  • state — автомат

🌀 void bashPrgRatchet (void * state)

Автомат state меняется так, что по новому состоянию трудно определить предыдущее. Glow-up so hard nobody recognizes the before pic. 📸

Ожидается:

bashPrgStart() < bashPrgRatchet()

Аргументы:

  • state — автомат

🎡 bashPrgRestart

void bashPrgRestart (const octet ann[], size_t ann_len, const octet key[],
    size_t key_len, void * state)

По анонсу [ann_len]ann и ключу [key_len]key выполняется повторная инициализация автомата state. Remix, restart, reinvention. 💫

Предусловие:

  • ann_len % 4 == 0 && ann_len <= 60.
  • key_len % 4 == 0 && key_len <= 60.
  • key_len == 0 || key_len >= l / 8,

Ожидается:

bashPrgStart() < bashPrgRestart()*

Прим. Если key_len != 0, то автомат переводится в ключевой режим.

Аргументы:

  • ann — анонс
  • ann_len — длина анонса в октетах
  • key — ключ
  • key_len — длина ключа в октетах
  • state — автомат

🍓 void bashPrgSqueeze (void * buf, size_t count, void * state)

Из автомата state выгружаются данные [count]buf. Squeezing out every last drop. 🧃

Ожидается:

bashPrgStart() < bashPrgSqueeze()*

Аргументы:

  • buf — данные
  • count — число октетов данных
  • state — автомат

🫶 void bashPrgSqueezeStart (void * state)

Инициализируется выгрузка данных из автомата state.

Ожидается:

bashPrgStart() < bashPrgSqueezeStart()

Прим. В начале выгрузки завершается предыдущая команда.

Аргументы:

  • state — автомат

💜 void bashPrgSqueezeStep (void * buf, size_t count, void * state)

Выполняется выгрузка из автомата state фрагмента [count]buf.

Ожидается:

bashPrgSqueezeStart() < bashPrgSqueezeStep()*

Аргументы:

  • buf — данные
  • count — число октетов данных
  • state — автомат

👑 bashPrgStart

void bashPrgStart (void * state, size_t l, size_t d, const octet ann[],
    size_t ann_len, const octet key[], size_t key_len)

По уровню стойкости l, емкости d, анонсу [ann_len]ann и ключу [key_len]ley инициализуется автомат state. The origin story. 🌱

Предусловие:

  • l == 128 || l == 192 || l == 256.
  • d == 1 || d == 2.
  • ann_len % 4 == 0 && ann_len <= 60.
  • key_len % 4 == 0 && key_len <= 60.
  • key_len == 0 || key_len >= l / 8, где l --- уровень, заданный в bashPrgStart().
  • По адресу state зарезервировано bashPrg_keep() октетов.

Прим. Если key_len != 0, то автомат переводится в ключевой режим.

Аргументы:

  • state — автомат
  • l — уровень стойкости
  • d — емкость
  • ann — анонс
  • ann_len — длина анонса в октетах
  • key — ключ
  • key_len — длина ключа в октетах

🎀 Автор

Автоматически создано Doxygen для Библиотека Bee2 из исходного текста.


and that's the whole page, bestie!! 💖 this lil masterpiece comes to you from Библиотека Bee2, stamped Вс 25 Янв 2026 00:00:00, filed under bash.h(3) — read it, love it, cite it. no cap. ✨👑💅
📦 where this page comes from