summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/encode.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/evp/encode.c')
-rw-r--r--src/lib/libcrypto/evp/encode.c57
1 files changed, 23 insertions, 34 deletions
diff --git a/src/lib/libcrypto/evp/encode.c b/src/lib/libcrypto/evp/encode.c
index 14d47c1eed..0152624a76 100644
--- a/src/lib/libcrypto/evp/encode.c
+++ b/src/lib/libcrypto/evp/encode.c
@@ -58,10 +58,21 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include "evp.h" 61#include <openssl/evp.h>
62 62
63#ifndef CHARSET_EBCDIC
63#define conv_bin2ascii(a) (data_bin2ascii[(a)&0x3f]) 64#define conv_bin2ascii(a) (data_bin2ascii[(a)&0x3f])
64#define conv_ascii2bin(a) (data_ascii2bin[(a)&0x7f]) 65#define conv_ascii2bin(a) (data_ascii2bin[(a)&0x7f])
66#else
67/* We assume that PEM encoded files are EBCDIC files
68 * (i.e., printable text files). Convert them here while decoding.
69 * When encoding, output is EBCDIC (text) format again.
70 * (No need for conversion in the conv_bin2ascii macro, as the
71 * underlying textstring data_bin2ascii[] is already EBCDIC)
72 */
73#define conv_bin2ascii(a) (data_bin2ascii[(a)&0x3f])
74#define conv_ascii2bin(a) (data_ascii2bin[os_toascii[a]&0x7f])
75#endif
65 76
66/* 64 char lines 77/* 64 char lines
67 * pad input with 0 78 * pad input with 0
@@ -110,20 +121,15 @@ static unsigned char data_ascii2bin[128]={
110 0x31,0x32,0x33,0xFF,0xFF,0xFF,0xFF,0xFF, 121 0x31,0x32,0x33,0xFF,0xFF,0xFF,0xFF,0xFF,
111 }; 122 };
112 123
113void EVP_EncodeInit(ctx) 124void EVP_EncodeInit(EVP_ENCODE_CTX *ctx)
114EVP_ENCODE_CTX *ctx;
115 { 125 {
116 ctx->length=48; 126 ctx->length=48;
117 ctx->num=0; 127 ctx->num=0;
118 ctx->line_num=0; 128 ctx->line_num=0;
119 } 129 }
120 130
121void EVP_EncodeUpdate(ctx,out,outl,in,inl) 131void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
122EVP_ENCODE_CTX *ctx; 132 unsigned char *in, int inl)
123unsigned char *out;
124int *outl;
125unsigned char *in;
126int inl;
127 { 133 {
128 int i,j; 134 int i,j;
129 unsigned int total=0; 135 unsigned int total=0;
@@ -165,10 +171,7 @@ int inl;
165 *outl=total; 171 *outl=total;
166 } 172 }
167 173
168void EVP_EncodeFinal(ctx,out,outl) 174void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl)
169EVP_ENCODE_CTX *ctx;
170unsigned char *out;
171int *outl;
172 { 175 {
173 unsigned int ret=0; 176 unsigned int ret=0;
174 177
@@ -182,9 +185,7 @@ int *outl;
182 *outl=ret; 185 *outl=ret;
183 } 186 }
184 187
185int EVP_EncodeBlock(t,f,dlen) 188int EVP_EncodeBlock(unsigned char *t, unsigned char *f, int dlen)
186unsigned char *t,*f;
187int dlen;
188 { 189 {
189 int i,ret=0; 190 int i,ret=0;
190 unsigned long l; 191 unsigned long l;
@@ -218,8 +219,7 @@ int dlen;
218 return(ret); 219 return(ret);
219 } 220 }
220 221
221void EVP_DecodeInit(ctx) 222void EVP_DecodeInit(EVP_ENCODE_CTX *ctx)
222EVP_ENCODE_CTX *ctx;
223 { 223 {
224 ctx->length=30; 224 ctx->length=30;
225 ctx->num=0; 225 ctx->num=0;
@@ -231,12 +231,8 @@ EVP_ENCODE_CTX *ctx;
231 * 0 for last line 231 * 0 for last line
232 * 1 for full line 232 * 1 for full line
233 */ 233 */
234int EVP_DecodeUpdate(ctx,out,outl,in,inl) 234int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
235EVP_ENCODE_CTX *ctx; 235 unsigned char *in, int inl)
236unsigned char *out;
237int *outl;
238unsigned char *in;
239int inl;
240 { 236 {
241 int seof= -1,eof=0,rv= -1,ret=0,i,v,tmp,n,ln,tmp2,exp_nl; 237 int seof= -1,eof=0,rv= -1,ret=0,i,v,tmp,n,ln,tmp2,exp_nl;
242 unsigned char *d; 238 unsigned char *d;
@@ -341,9 +337,7 @@ end:
341 return(rv); 337 return(rv);
342 } 338 }
343 339
344int EVP_DecodeBlock(t,f,n) 340int EVP_DecodeBlock(unsigned char *t, unsigned char *f, int n)
345unsigned char *t,*f;
346int n;
347 { 341 {
348 int i,ret=0,a,b,c,d; 342 int i,ret=0,a,b,c,d;
349 unsigned long l; 343 unsigned long l;
@@ -383,10 +377,7 @@ int n;
383 return(ret); 377 return(ret);
384 } 378 }
385 379
386int EVP_DecodeFinal(ctx,out,outl) 380int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl)
387EVP_ENCODE_CTX *ctx;
388unsigned char *out;
389int *outl;
390 { 381 {
391 int i; 382 int i;
392 383
@@ -404,9 +395,7 @@ int *outl;
404 } 395 }
405 396
406#ifdef undef 397#ifdef undef
407int EVP_DecodeValid(buf,len) 398int EVP_DecodeValid(unsigned char *buf, int len)
408unsigned char *buf;
409int len;
410 { 399 {
411 int i,num=0,bad=0; 400 int i,num=0,bad=0;
412 401