diff options
author | beck <> | 1999-09-29 04:37:45 +0000 |
---|---|---|
committer | beck <> | 1999-09-29 04:37:45 +0000 |
commit | de8f24ea083384bb66b32ec105dc4743c5663cdf (patch) | |
tree | 1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libcrypto/evp/encode.c | |
parent | cb929d29896bcb87c2a97417fbd03e50078fc178 (diff) | |
download | openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.gz openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.bz2 openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.zip |
OpenSSL 0.9.4 merge
Diffstat (limited to 'src/lib/libcrypto/evp/encode.c')
-rw-r--r-- | src/lib/libcrypto/evp/encode.c | 57 |
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 | ||
113 | void EVP_EncodeInit(ctx) | 124 | void EVP_EncodeInit(EVP_ENCODE_CTX *ctx) |
114 | EVP_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 | ||
121 | void EVP_EncodeUpdate(ctx,out,outl,in,inl) | 131 | void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, |
122 | EVP_ENCODE_CTX *ctx; | 132 | unsigned char *in, int inl) |
123 | unsigned char *out; | ||
124 | int *outl; | ||
125 | unsigned char *in; | ||
126 | int 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 | ||
168 | void EVP_EncodeFinal(ctx,out,outl) | 174 | void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl) |
169 | EVP_ENCODE_CTX *ctx; | ||
170 | unsigned char *out; | ||
171 | int *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 | ||
185 | int EVP_EncodeBlock(t,f,dlen) | 188 | int EVP_EncodeBlock(unsigned char *t, unsigned char *f, int dlen) |
186 | unsigned char *t,*f; | ||
187 | int 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 | ||
221 | void EVP_DecodeInit(ctx) | 222 | void EVP_DecodeInit(EVP_ENCODE_CTX *ctx) |
222 | EVP_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 | */ |
234 | int EVP_DecodeUpdate(ctx,out,outl,in,inl) | 234 | int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, |
235 | EVP_ENCODE_CTX *ctx; | 235 | unsigned char *in, int inl) |
236 | unsigned char *out; | ||
237 | int *outl; | ||
238 | unsigned char *in; | ||
239 | int 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 | ||
344 | int EVP_DecodeBlock(t,f,n) | 340 | int EVP_DecodeBlock(unsigned char *t, unsigned char *f, int n) |
345 | unsigned char *t,*f; | ||
346 | int 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 | ||
386 | int EVP_DecodeFinal(ctx,out,outl) | 380 | int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl) |
387 | EVP_ENCODE_CTX *ctx; | ||
388 | unsigned char *out; | ||
389 | int *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 |
407 | int EVP_DecodeValid(buf,len) | 398 | int EVP_DecodeValid(unsigned char *buf, int len) |
408 | unsigned char *buf; | ||
409 | int len; | ||
410 | { | 399 | { |
411 | int i,num=0,bad=0; | 400 | int i,num=0,bad=0; |
412 | 401 | ||