CryptoByLeo/README.md

134 lines
3.7 KiB
Markdown
Raw Permalink Normal View History

2026-08-25 09:46:02 -05:00
<p align="center">
<img src="https://img.shields.io/badge/Language-MQL5-1B6CA8?style=flat-square"/>
<img src="https://img.shields.io/badge/Platform-MetaTrader%205-0D1B2A?style=flat-square"/>
<img src="https://img.shields.io/badge/Author-nique__372-C9D6DF?style=flat-square&logoColor=white"/>
<img src="https://img.shields.io/badge/MQL5.com-nique__372-1B6CA8?style=flat-square"/>
</p>
2026-08-10 20:56:10 +00:00
2026-08-25 09:46:02 -05:00
<p align="center">
Fast cryptographic library for MQL5: hashes, HMAC, symmetric and asymmetric ciphers, padding and RSP test vector parsing.<br/> Pure MQL5, no DLLs required for the crypto primitives themselves.
</p>
---
## 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):**
```mql5
#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):**
```mql5
#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:**
```mql5
#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](./dependencies.json) for the full list.
---
## Installation
```bash
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](https://pypi.org/project/tsndep). It automatically downloads and installs all declared dependencies.
---
## Quick Start
**1. Include the module you need:**
```mql5
#include "..\\CryptoByLeo\\Src\\Hash\\All.mqh"
```
**2. Use it:**
```mql5
uchar out[32];
TSN::CCryptoHashSHA3::SHA3_256(data, ArraySize(data), 0, out);
```
---
## License
**[Read Full License](./LICENSE)**
By downloading or using this repository, you accept the license terms.
---
## Contact
- **Platform:** [MQL5 Community](https://www.mql5.com/es/users/nique_372)
- **Profile:** https://www.mql5.com/es/users/nique_372
- **Articles:** https://www.mql5.com/es/users/nique_372/publications
---
## 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]
2026-08-26 13:35:15 -05:00
- Test suite coverage [~70%, in progress]
2026-08-25 09:46:02 -05:00
<p align="center"><sub>Copyright © 2026 Niquel & Leo — TSN Ecosystem</sub></p>