99 lines
3.4 KiB
MQL4
99 lines
3.4 KiB
MQL4
//+------------------------------------------------------------------+
|
|
//| 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
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
// Includes generales para RSA
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
#include <TSN\\BInt\\Main.mqh>
|
|
|
|
// padders cipher
|
|
#include "..\\Padding\\OAEP\\Main.mqh"
|
|
// normal
|
|
#include "..\\Padding\\PKCS1v15\\Main.mqh"
|
|
#include "..\\Padding\\PSS\\Main.mqh"
|
|
// asn1
|
|
#include "..\\ASN1\\Main.mqh"
|
|
//
|
|
#include "..\\B64\\Decode.mqh"
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
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
|
|
};
|
|
|
|
//---
|
|
#define RSA_PUBKEY_PEMHEADER_CLEAN (26)
|
|
#define RSA_PUBKEY_PEMHEADER_SIZE (28)
|
|
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'
|
|
};
|
|
|
|
//---
|
|
#define RSA_PUBKEY_PEMFOOTER_SIZE (26)
|
|
#define RSA_PUBKEY_PEMFOOTER_CLEAN (24)
|
|
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[];
|
|
};
|
|
|
|
}
|
|
|
|
#endif // CRYPTOBYLEO_SRC_RSA_DEF_MQH
|
|
//+------------------------------------------------------------------+
|