//+------------------------------------------------------------------+ //| Def.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_SIMETRIC_CHACHA20_DEF_MQH #define CRYPTOBYLEO_SRC_SIMETRIC_CHACHA20_DEF_MQH //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ namespace TSN { //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // s = state // b = bytes #define CHACHA20_KEYSIZEB (32) #define CHACHA20_STATE_S (16) #define CHACHA20_KEYSTREAM_SIZEB (64) // tamaño para uint32_t (para bytes compeltos el tamaño de key strema de es de 64) para u32 es de16 #define CHACHA20_KEYSTREAM_SIZE_U32 (16) #define CHACHA20_IVNONE_B (12) #define CHACHA20_STATE_IDX_CNT (12) //---- Macro de utildiades // rotacion a la izuqirda 32 #define CHACHA20_ROT32L(x, n) ((x << n) | (x >> (32 - n))) //--- Macro base del algoritmo la funcion QR #define CHACHA20_QR(a, b, c, d) \ a += b; d ^= a; d = CHACHA20_ROT32L(d, 16); \ c += d; b ^= c; b = CHACHA20_ROT32L(b, 12); \ a += b; d ^= a; d = CHACHA20_ROT32L(d, 8); \ c += d; b ^= c; b = CHACHA20_ROT32L(b, 7); //---- Macro que eqvuila a una ronda completa.. // ¿Aplicamos en columnas luego en diagnoleas.. #define CHACHA20_DOUBLE_ROUND \ CHACHA20_QR(x0, x4, x8, x12) \ CHACHA20_QR(x1, x5, x9, x13) \ CHACHA20_QR(x2, x6, x10, x14) \ CHACHA20_QR(x3, x7, x11, x15) \ CHACHA20_QR(x0, x5, x10, x15) \ CHACHA20_QR(x1, x6, x11, x12) \ CHACHA20_QR(x2, x7, x8, x13) \ CHACHA20_QR(x3, x4, x9, x14) } //+------------------------------------------------------------------+ #endif // CRYPTOBYLEO_SRC_SIMETRIC_CHACHA20_DEF_MQH