2026-08-23 08:35:14 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| 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_RSA_DEF_MQH
|
| | | #define CRYPTOBYLEO_SRC_RSA_DEF_MQH
|
| | |
|
2026-08-23 19:36:33 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | // Includes generales para RSA
|
| | |
|
2026-08-23 08:35:14 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-09-09 12:01:15 -05:00 | | | #include <TSN\\BInt\\Main.mqh>
|
2026-08-23 08:35:14 -05:00 | | |
|
2026-08-24 09:57:30 -05:00 | | | // padders cipher
|
| | | #include "..\\Padding\\OAEP\\Main.mqh"
|
| | | // normal
|
| | | #include "..\\Padding\\PKCS1v15\\Main.mqh"
|
| | | #include "..\\Padding\\PSS\\Main.mqh"
|
2026-08-31 08:11:57 -05:00 | | | // asn1
|
2026-08-30 13:43:59 -05:00 | | | #include "..\\ASN1\\Main.mqh"
|
2026-08-31 08:11:57 -05:00 | | | //
|
| | | #include "..\\B64\\Decode.mqh"
|
2026-08-24 09:57:30 -05:00 | | |
|
2026-08-29 21:53:22 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | namespace TSN
|
| | | {
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | //-- tipos de padders para firmar
|
| | | enum ENUM_RSA_SING_PADDER
|
| | | {
|
| | | RSA_SING_PADDER_PSS,
|
| | | RSA_SING_PADDER_PKCS1V15
|
| | | };
|
| | |
|
| | | //---
|
| | | #define RSA_PUBKEY_PEM_LINESIZE (64)
|
| | |
|
| | | //---
|
| | | #define RSA_ALG_OID_TSIZE (15)
|
| | | const uint8_t g_rsa_alg_id[RSA_ALG_OID_TSIZE] =
|
| | | {
|
| | | 0x30, 0x0D, // SEQUENCE, len 13
|
| | | 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, // OID rsaEncryption
|
| | | 0x01, 0x01, 0x01,
|
| | | 0x05, 0x00 // NULL
|
| | | };
|
| | |
|
| | | //---
|
2026-08-31 08:11:57 -05:00 | | | #define RSA_PUBKEY_PEMHEADER_CLEAN (26)
|
| | | #define RSA_PUBKEY_PEMHEADER_SIZE (28)
|
2026-08-29 21:53:22 -05:00 | | | const uint8_t g_rsa_pubkey_pem_header[RSA_PUBKEY_PEMHEADER_SIZE] =
|
| | | {
|
| | | '-', '-', '-', '-', '-', 'B', 'E', 'G', 'I', 'N', ' ', 'P', 'U', 'B', 'L', 'I', 'C', ' ',
|
| | | 'K', 'E', 'Y', '-', '-', '-', '-', '-', '\r', '\n'
|
| | | };
|
| | |
|
| | | //---
|
2026-08-31 08:11:57 -05:00 | | | #define RSA_PUBKEY_PEMFOOTER_SIZE (26)
|
| | | #define RSA_PUBKEY_PEMFOOTER_CLEAN (24)
|
2026-08-29 21:53:22 -05:00 | | | const uint8_t g_rsa_pubkey_pem_footer[RSA_PUBKEY_PEMFOOTER_SIZE] =
|
| | | {
|
| | | '-', '-', '-', '-', '-', 'E', 'N', 'D', ' ', 'P', 'U', 'B', 'L', 'I', 'C', ' ', 'K', 'E', 'Y',
|
| | | '-', '-', '-', '-', '-', '\r', '\n'
|
| | | };
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | class PssParams
|
| | | {
|
| | | public:
|
| | | PssParams(uchar& _salt[], const int _salt_len)
|
| | | : salt_len(_salt_len) { ArraySwap(salt, _salt);}
|
| | | PssParams()
|
| | | : salt_len(0) {}
|
| | | ~PssParams(void) {}
|
| | |
|
| | | //---
|
| | | int salt_len;
|
| | | uchar salt[];
|
| | | };
|
2026-08-31 08:11:57 -05:00 | | |
|
2026-08-29 21:53:22 -05:00 | | | }
|
| | |
|
| | | #endif // CRYPTOBYLEO_SRC_RSA_DEF_MQH
|
| | | //+------------------------------------------------------------------+
|