Skip to content

0xNullll/CryptoForge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

229 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CryptoForge

CryptoForge is a modular, lightweight C cryptographic library implementing SHA variants, HMAC, KMAC, Keccak, AES, ChaCha, AEAD constructions, KDFs, MACs, and encoding utilities.

It is designed with layered APIs, separating low-level primitives (ll_*) from user-facing functions (CF_*), while remaining lightweight and portable.

CryptoForge is intended for educational, experimental. It has not undergone formal audits.


Directory Structure

/CryptoForge
├─ /src
│   ├─ /crypto
│   │   ├─ /aead
│   │   │   ├─ /aes           <-- AES-GCM implementation file
│   │   │   └─ /chacha        <-- ChaCha20-Poly1305 and XChaCha20-Poly1305 AEAD
│   │   ├─ /cf_api            <-- Public API implementations for all crypto primitives
│   │   ├─ /enc               <-- Encoder implementations (Base16/32/58/64/85)
│   │   ├─ /hash
│   │   │   ├─ /md            <-- Legacy hash algorithms (MD5)
│   │   │   └─ /sha
│   │   │       └─ /keccak    <-- SHA3 / Keccak / SHAKE implementations
│   │   ├─ /kdf               <-- Key derivation functions (PBKDF2, HKDF)
│   │   ├─ /mac               <-- Message authentication codes (HMAC, CMAC, GMAC, KMAC, Poly1305)
│   │   └─ /cipher
│   │       ├─ /aes           <-- AES core + standard modes (ECB, CBC, CFB, OFB, CTR)
│   │       └─ /chacha        <-- ChaCha/XChaCha core and stream implementations
│   ├─ /include
│   │   ├─ /cf_api            <-- Public API headers (cf_*)
│   │   ├─ /crypto            <-- Internal crypto headers
│   │   ├─ /config            <-- Build/runtime configuration headers
│   │   └─ /utils             <-- Utility headers (memory, helpers)
│   ├─ /utils                 <-- Utility implementations
├─ /tests                     <-- Test programs and demos
│   ├─ /smoke                 <-- Lightweight, fast internal smoke tests
│   └─ /thirdparty            <-- Tests using third-party vectors (Wycheproof, NIST KATs)
├─ /vectors                   <-- Auto-generated test vector headers
│   ├─ /NIST
│   │   └─ /KAT               <-- NIST Known Answer Tests for AES, SHA, etc.
│   └─ /wycheproof            <-- Wycheproof JSON vectors converted to headers for edge case testing
└─ LICENSE, README.md

Layered API Design

  1. Low-Level / Context Layer (ll_*)

    • Implements atomic primitives: AES, ChaCha, SHA family, SHAKE, HMAC, KMAC, PBKDF2, etc.
    • Maintains deterministic state and supports streaming operations.
    • Minimal internal helpers; some ll_* call other ll_* primitives.
    • No user-facing checks or policy enforcement.
  2. Facade / User-Facing Layer (cf_*)

    • Dispatcher layer by enum/macro for algorithm selection.
    • Supports streaming, pipelining, and memory-safe APIs.
    • Enforces key sizes and nonce rules for AEAD.
    • Handles zeroization, error codes, and resource management.

Main Features

Symmetric Ciphers

  • AES: ECB, CBC, CFB8, CFB128, OFB, CTR modes
  • ChaCha / XChaCha: ChaCha8, ChaCha12, ChaCha20, XChaCha8 XChaCha12, XChaCha20
  • AEAD Constructions: AES-GCM, ChaCha20-Poly1305, XChaCha20-Poly1305

Hash Functions

  • SHA family: SHA-1, SHA-224, SHA-256, SHA-384, SHA-512
  • SHA3 / Keccak: SHA3-224/256/384/512, rawSHAKE128/256, SHAKE128/256
  • cSHAKE cSHAKE128/256
  • Legacy: MD5

Message Authentication Codes (MACs)

  • HMAC, CMAC, GMAC, KMAC, KMAC-XOF, Poly1305

Key Derivation Functions (KDFs)

  • PBKDF2, HKDF, KMAC-XOF

Encoding / Decoding Utilities

  • Base16, Base32, Base58, Base64, Base85

Miscellaneous

  • Modular, layered API for flexibility
  • Portable and lightweight, suitable for embedded targets
  • Configurable memory footprint via compile-time options

Security Disclaimer

CryptoForge prioritizes clarity, correctness, and simplicity of implementation over performance tuning or platform‑specific optimizations.

  • The library is purely software-based and does not include hardware acceleration (e.g., AES-NI, NEON, AVX, or other CPU-specific optimizations).
  • Implementations aim to be as close as possible to their reference specifications, favoring readability and auditability over aggressive micro-optimizations.
  • Memory handling is designed to be explicit and defensive, using OS-provided memory helpers where appropriate, secure zeroization, and constant-time comparisons for sensitive operations.
  • The API is intentionally designed to be easy to use correctly, with layered abstractions to reduce common misuse patterns.

However, CryptoForge is not production-ready at this stage:

  • The library is intended for educational and experimental use.
  • It has not undergone formal security audits, third-party reviews, or certification by recognized cryptographic authorities.
  • Correctness and edge cases are currently verified using a combination of:
    • Wycheproof test vectors
    • NIST KATs (Known Answer Tests)
    • Other internal or synthetic test suites
      These cover different usage patterns, boundary conditions, and input scenarios.
  • Side-channel resistance beyond basic constant-time logic (e.g., cache, power, or microarchitectural attacks) has not been formally evaluated.
  • The API surface and internal behavior may change as the project evolves.

Do not use CryptoForge to protect sensitive, high-value, or real-world secrets without independent review and additional hardening.

CryptoForge is best suited for:

  • Learning cryptographic internals
  • Studying algorithm behavior and design tradeoffs
  • Experimentation, prototyping, and embedded research
  • Security education and reverse-engineering practice

Performance Notes

CryptoForge prioritizes clarity, correctness, and safety over raw speed.

Benchmarks against highly-optimized libraries like Crypto++ suggest CryptoForge is roughly 4× slower on average, though performance depends on the algorithm—sometimes it can be comparable or even faster. Note that your CPU may outperform the hardware used in standard benchmarks.

This is expected because:

  • CryptoForge uses pure C implementations without CPU-specific assembly optimizations (AES-NI, AVX, NEON, etc.).
  • High-level API calls enforce memory safety and zeroization, which adds overhead.
  • The library is primarily intended for education, experimentation, and research, rather than production-grade performance.

Performance may improve with compiler optimizations or targeted algorithmic tweaks, but speed is not the main design goal at this stage.


Sources / References

RFCs

NIST

RSA Laboratories

Other / Misc


Build and Install

Clone the Repository

git clone https://github.com/0xNullll/CryptoForge
cd CryptoForge

Installation Instructions

After obtaining the source code:


License

This project is released under the Apache-2.0 license. See LICENSE for full text.

About

Lightweight C crypto library with layered API: AES, ChaCha, SHA, KDFs, MACs, AEAD.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages