CryptoByLeo/Src/Hash/All.mqh
2026-08-13 18:48:30 -05:00

105 lines
3.7 KiB
MQL5

//+------------------------------------------------------------------+
//| All.mqh |
//| Copyright 2026, Niquel Mendoza |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, Niquel Mendoza"
#property link "https://www.mql5.com"
#property strict
#ifndef CRYPTOBYLEO_SRC_MAC_HMAC_ALL_MQH
#define CRYPTOBYLEO_SRC_MAC_HMAC_ALL_MQH
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#include "Blake2b.mqh"
#include "SHA256.mqh"
#include "SHA3.mqh"
#include "SHA512.mqh"
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
namespace TSN
{
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
// banderas disponibles
#define CRYPTOBYLEO_HASHFUNC_F_XOF (1)
// totales
#define CRYPTOBYLEO_HASHFUNC_TOTAL (8)
#define CRYPTOBYLEO_HASHFUNC_TOTAL_FIXED (5)
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CCryptoHashMeta
{
public:
CCryptoHashMeta(void) {}
~CCryptoHashMeta(void) {}
//--- Puntero a funcion general para cualquier funcion hash compatbile (in,ins, out)
// Solo soporta hash func con:
// - Entrada X varialbe
// - Tamaño de X varaible
// - Salida con un tamaño FIJO no dinamico o parametrizable
typedef void (*TsnCryptoByLeoHashFuncFixed)(const uchar &in[], int ins, uchar &out[]);
//----
// Enum de todos los hashes que soporta esta lib
enum ENUM_TSN_CRYPTO_HASH
{
TSN_CRYPTO_HASH_TYPE_SHA256,
TSN_CRYPTO_HASH_TYPE_SHA384,
TSN_CRYPTO_HASH_TYPE_SHA512,
TSN_CRYPTO_HASH_TYPE_SHA3_256,
TSN_CRYPTO_HASH_TYPE_SHA3_512,
TSN_CRYPTO_HASH_TYPE_SHAKE_128,
TSN_CRYPTO_HASH_TYPE_SHAKE_256,
TSN_CRYPTO_HASH_TYPE_BLAKE2B,
};
//---
struct CryptoHashMeta
{
string name; // nombre del hash
int outl; // tamaño de la salida (0) si no aplica
int blocksize; // numero de bytes que procesa en cada "iteracion"
uchar flags; // banderas
};
//---
static const CryptoHashMeta g_crytpo_hash_meta[CRYPTOBYLEO_HASHFUNC_TOTAL];
static const TsnCryptoByLeoHashFuncFixed g_crypto_fhash_fixed[CRYPTOBYLEO_HASHFUNC_TOTAL_FIXED];
};
//--- tabla final
const CCryptoHashMeta::CryptoHashMeta CCryptoHashMeta::g_crytpo_hash_meta[CRYPTOBYLEO_HASHFUNC_TOTAL] =
{
{"SHA2-256", 32, 64, 0},
{"SHA2-384", 48, 128, 0},
{"SHA2-512", 64, 128, 0},
{"SHA3-256", 32, 136, 0},
{"SHA3-512", 64, 72, 0},
{"SHAKE-128", 0, 168, CRYPTOBYLEO_HASHFUNC_F_XOF},
{"SHAKE-256", 0, 136, CRYPTOBYLEO_HASHFUNC_F_XOF},
{"BLAKE-2B", 64, 128, 0}, // por defecto saldia MAXIMA
};
//--- tabla act
const CCryptoHashMeta::TsnCryptoByLeoHashFuncFixed CCryptoHashMeta::g_crypto_fhash_fixed[CRYPTOBYLEO_HASHFUNC_TOTAL_FIXED] =
{
CCryptoHash::SHA256,
CCryptoHash::SHA384,
CCryptoHash::SHA512,
CCryptoHash::SHA3_256,
CCryptoHash::SHA3_512
};
}
#endif // CRYPTOBYLEO_SRC_MAC_HMAC_ALL_MQH