63 #ifndef CHARSET_EBCDIC
64 #define conv_bin2ascii(a) (data_bin2ascii[(a)&0x3f])
65 #define conv_ascii2bin(a) (data_ascii2bin[(a)&0x7f])
73 #define conv_bin2ascii(a) (data_bin2ascii[(a)&0x3f])
74 #define conv_ascii2bin(a) (data_ascii2bin[os_toascii[a]&0x7f])
84 #define BIN_PER_LINE (64/4*3)
85 #define CHUNKS_PER_LINE (64/4)
86 #define CHAR_PER_LINE (64+1)
88 static const unsigned char data_bin2ascii[65]=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ\
89 abcdefghijklmnopqrstuvwxyz0123456789+/";
102 #define B64_ERROR 0xFF
103 #define B64_NOT_BASE64(a) (((a)|0x13) == 0xF3)
105 static const unsigned char data_ascii2bin[128]={
106 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
107 0xFF,0xE0,0xF0,0xFF,0xFF,0xF1,0xFF,0xFF,
108 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
109 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
110 0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
111 0xFF,0xFF,0xFF,0x3E,0xFF,0xF2,0xFF,0x3F,
112 0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,
113 0x3C,0x3D,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,
114 0xFF,0x00,0x01,0x02,0x03,0x04,0x05,0x06,
115 0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,
116 0x0F,0x10,0x11,0x12,0x13,0x14,0x15,0x16,
117 0x17,0x18,0x19,0xFF,0xFF,0xFF,0xFF,0xFF,
118 0xFF,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20,
119 0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,
120 0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30,
121 0x31,0x32,0x33,0xFF,0xFF,0xFF,0xFF,0xFF,
132 const unsigned char *in,
int inl)
135 unsigned int total=0;
138 if (inl == 0)
return;
159 while (inl >= ctx->
length)
194 for (i=dlen; i > 0; i-=3)
198 l= (((
unsigned long)f[0])<<16L)|
199 (((
unsigned long)f[1])<< 8L)|f[2];
207 l=((
unsigned long)f[0])<<16L;
208 if (i == 2) l|=((
unsigned long)f[1]<<8L);
236 const unsigned char *in,
int inl)
238 int seof= -1,eof=0,rv= -1,ret=0,i,v,tmp,n,ln,exp_nl;
251 for (i=0; i<inl; i++)
254 if (ln >= 80) { rv= -1;
goto end; }
278 if (seof == -1) seof=n;
303 if (((i+1) == inl) && (((n&3) == 0) || eof))
311 if (d[n-1] ==
'=') eof++;
312 if (d[n-2] ==
'=') eof++;
316 if ((v ==
B64_EOF && (n&3) == 0) || (n >= 64))
321 if ((v !=
B64_EOF) && (n >= 64)) exp_nl=1;
326 if (v < 0) { rv=0;
goto end; }
337 if ((v < ctx->
length) && eof)
345 if (seof >= 0) { rv=0;
goto end; }
375 if (n%4 != 0)
return(-1);
383 if ( (
a & 0x80) || (b & 0x80) ||
384 (c & 0x80) || (d & 0x80))
386 l=( (((
unsigned long)
a)<<18L)|
387 (((
unsigned long)
b)<<12L)|
388 (((
unsigned long)c)<< 6L)|
389 (((
unsigned long)d) ));
390 *(t++)=(
unsigned char)(l>>16L)&0xff;
391 *(t++)=(
unsigned char)(l>> 8L)&0xff;
392 *(t++)=(
unsigned char)(l )&0xff;
406 if (i < 0)
return(-1);
416 int EVP_DecodeValid(
unsigned char *buf,
int len)
420 if (len == 0)
return(-1);
425 if (len == 0)
return(-1);
428 for (i=len; i >= 4; i-=4)
436 num+=1+(buf[2] !=
'=')+(buf[3] !=
'=');