Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Bastia

Futuristic Gadgets Laboratory, Lead Researcher: Serexp

A C++20 cryptography library designed for the Pandragon framework.

Features

  • Compile-time string obfuscation, LCG-based XOR cipher with per-translation-unit seeds. Ciphertext lives in .rodata; plaintext is never materialized at rest. Zero runtime overhead after first access with a decrypt-once caching layer.
  • XChaCha20 stream cipher, 20-round ChaCha20 with 24-byte nonce (DJB, IETF, and XChaCha20 variants).
  • XChaCha20-Poly1305 AEAD, Authenticated encryption with associated data. Constant-time MAC verification.
  • Poly1305 MAC, Incremental one-time message authentication.
  • AES-128 (AES-NI accelerated), ECB and CTR modes using hardware aesenc/aesdec instructions.
  • Secure memory wiping, crypto_wipe with volatile pointers and compiler barriers.
  • Standalone CLI, Build with -DBASTIA_STANDALONE for a command-line encrypt/decrypt tool.

Hardware Abstraction Layer (HAL)

Bastia delegates all platform-specific operations to a HAL, no OS-specific code or inline assembly lives in the library core.

Call bastia_init() once before using any Bastia function:

#include "bastia_hal.h"

int main(void) {
    bastia_init(malloc, free, calloc,
                my_csprng_seeder,
                my_aes_ni_check,
                "expand 32-byte k");

    // Use Bastia crypto functions...
}
Parameter Purpose Required
malloc_func / free_func / calloc_func Dynamic memory allocation Yes
seed_csprng_func Feed entropy into your CSPRNG Yes (if nonces are needed)
aes_ni_available_func Query AES-NI hardware support Pass NULL to assume no AES-NI
chacha20_constant 16-byte ChaCha20 constant string Yes (typically "expand 32-byte k")

Returns 0 on success, -1 if already initialized. Check with bastia_is_initialized().

Requirements

  • C++20 compiler (Clang or GCC)
  • CPU with AES-NI support (-maes)
  • Windows x86-64 target (cross-compiled or native)
  • BUILD_TIME_RANDOM_SEED defined per translation unit

Constant-time operations are not implemented for this library.

something broke?

contact Serexp

About

freestanding crypto library

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages