//+------------------------------------------------------------------+ //| DER.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_ASN1_MAIN_MQH #define CRYPTOBYLEO_SRC_ASN1_MAIN_MQH //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #include "Def.mqh" //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ namespace TSN { //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class CASN1Utils { public: CASN1Utils(void) {} ~CASN1Utils(void) {} //--- static int ContentTotalBytes(int content_len, uchar& lenw); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // retonra el tamaƱo total // lenw=byte luego del tag a escribir.. static int CASN1Utils::ContentTotalBytes(int content_len, uchar& lenw) { uchar count = 1; if(content_len > 127) { // en cuantos bytes reqeurrimos (extra) do { content_len >>= 8; count++; } while(content_len > 0); lenw = CBL_ASN1_MASK_BYTEALTO | count; } else { lenw = uchar(content_len); } // tag + byteslen + contentlen return 1 + count + content_len; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // en caso este acitvo el alto long form (saltaomos el numero de bytes que menciona) // de lo contraio solo saltmaos.. 1 #define CBL_ASN1_U_SALTAR_LEN(buf, r) \ { \ if((buf[r] & CBL_ASN1_MASK_BYTEALTO) != 0) \ r += (buf[r] & CBL_ASN1_MASK_CLEAN_BYTEALTO); \ else \ r++; \ } //+------------------------------------------------------------------+ #define CBL_ASN1_U_WRITELEN(buf, w, lenw, total) \ { \ buf[w++] = lenw; \ if((lenw & CBL_ASN1_MASK_BYTEALTO) != 0) \ { \ lenw &= CBL_ASN1_MASK_CLEAN_BYTEALTO; \ total -= 1 + lenw; \ do \ { \ buf[w++] = uchar(total); \ total >>= 8; \ } \ while(total > 0); \ } \ } } #endif // CRYPTOBYLEO_SRC_ASN1_MAIN_MQH //+------------------------------------------------------------------+