CryptoByLeo/README.md
Nique_372 f5e497c05c
2026-08-26 13:35:15 -05:00

3.7 KiB

Fast cryptographic library for MQL5: hashes, HMAC, symmetric and asymmetric ciphers, padding and RSP test vector parsing.
Pure MQL5, no DLLs required for the crypto primitives themselves.


Main Features

  • Hashes: SHA-2 (SHA256/384/512), SHA-3 (incl. SHAKE128/256), BLAKE2b
  • HMAC: generic HMAC construction over any supported hash function
  • Symmetric ciphers: AES (128/256) and ChaCha20
  • Asymmetric cipher (RSA): key generation, encryption/decryption and signing — ~90% complete
  • Padding schemes: OAEP, PSS and PKCS#1 v1.5
  • Mask generation function: MGF1
  • RSP parser: fast parser for .rsp NIST test vector files, used to validate hash implementations
  • PRNG: pseudo-random byte generator (CPseudoAleatorio) with Windows bcrypt.dll entropy import

Usage examples

Hashing (SHA-3-256):

#include "Src\\Hash\\SHA3.mqh"

uchar data[] = { /* ... */ };
uchar out[32];

TSN::CCryptoHashSHA3::SHA3_256(data, ArraySize(data), 0, out);

PSS padding encode (for RSA signing):

#include "Src\\Padding\\PSS\\Main.mqh"

uchar msg[], salt[], out[];
// ...
int len = TSN::CPSS::Encode(msg, msg_hash_len, salt, em_bits,
                             TSN::CCryptoHashMeta::TSN_CRYPTO_HASH_TYPE_SHA256, out);

Pseudo-random bytes:

#include "Src\\PseAle\\Main.mqh"

uchar raw[16];
TSN::CPseudoAleatorio::R1(raw, 16, 0);

Repository Structure

CryptoByLeo/
├── Src/
│   ├── Hash/       # SHA-2, SHA-3, BLAKE2b
│   ├── MAC/        # HMAC
│   ├── MGF1/       # Mask generation function
│   ├── Padding/    # OAEP, PKCS1v15, PSS
│   ├── PseAle/     # Pseudo-random byte generator
│   ├── RSA/        # Key generation, sign/enc/dec
│   ├── RSPParser/  # .rsp NIST test vector parser
│   ├── Simetric/   # AES, ChaCha20
│   └── Imports/    # External DLL imports (bcrypt.dll)
└── Wf/             # Workflow / integration test EA

Requirements

See dependencies.json for the full list.


Installation

cd "C:\Users\YOUR_USER\AppData\Roaming\MetaQuotes\Terminal\YOUR_ID\MQL5\Shared Projects"
tsndep install "https://forge.mql5.io/nique_372/CryptoByLeo.git"

Requires the tsndep package, available on PyPI. It automatically downloads and installs all declared dependencies.


Quick Start

1. Include the module you need:

#include "..\\CryptoByLeo\\Src\\Hash\\All.mqh"

2. Use it:

uchar out[32];
TSN::CCryptoHashSHA3::SHA3_256(data, ArraySize(data), 0, out);

License

Read Full License By downloading or using this repository, you accept the license terms.


Contact


Roadmap

  • Hashes (SHA-2, SHA-3, BLAKE2b), HMAC, AES, ChaCha20, Padding (OAEP/PSS/PKCS1v15), MGF1, RSP parser [Complete]
  • RSA (key generation, sign/enc/dec) [~90%, in progress]
  • Test suite coverage [~70%, in progress]

Copyright © 2026 Niquel & Leo — TSN Ecosystem