summaryrefslogtreecommitdiff
path: root/lib/libcrypto/evp/encode.c
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>1999-09-29 04:37:45 +0000
committerBob Beck <beck@cvs.openbsd.org>1999-09-29 04:37:45 +0000
commitca679cff5e2a72ad205119c981e695c8cc640970 (patch)
tree691368331190f762b9f484d059ec119620396521 /lib/libcrypto/evp/encode.c
parent30902ef04e4a800063b5f4afdbf1732ad34aa6b3 (diff)
OpenSSL 0.9.4 merge
Diffstat (limited to 'lib/libcrypto/evp/encode.c')
-rw-r--r--lib/libcrypto/evp/encode.c57
1 files changed, 23 insertions, 34 deletions
diff --git a/lib/libcrypto/evp/encode.c b/lib/libcrypto/evp/encode.c
index 14d47c1eed5..0152624a769 100644
--- a/lib/libcrypto/evp/encode.c
+++ b/lib/libcrypto/evp/encode.c
@@ -58,10 +58,21 @@
#include <stdio.h>
#include "cryptlib.h"
-#include "evp.h"
+#include <openssl/evp.h>
+#ifndef CHARSET_EBCDIC
#define conv_bin2ascii(a) (data_bin2ascii[(a)&0x3f])
#define conv_ascii2bin(a) (data_ascii2bin[(a)&0x7f])
+#else
+/* We assume that PEM encoded files are EBCDIC files
+ * (i.e., printable text files). Convert them here while decoding.
+ * When encoding, output is EBCDIC (text) format again.
+ * (No need for conversion in the conv_bin2ascii macro, as the
+ * underlying textstring data_bin2ascii[] is already EBCDIC)
+ */
+#define conv_bin2ascii(a) (data_bin2ascii[(a)&0x3f])
+#define conv_ascii2bin(a) (data_ascii2bin[os_toascii[a]&0x7f])
+#endif
/* 64 char lines
* pad input with 0
@@ -110,20 +121,15 @@ static unsigned char data_ascii2bin[128]={
0x31,0x32,0x33,0xFF,0xFF,0xFF,0xFF,0xFF,
};
-void EVP_EncodeInit(ctx)
-EVP_ENCODE_CTX *ctx;
+void EVP_EncodeInit(EVP_ENCODE_CTX *ctx)
{
ctx->length=48;
ctx->num=0;
ctx->line_num=0;
}
-void EVP_EncodeUpdate(ctx,out,outl,in,inl)
-EVP_ENCODE_CTX *ctx;
-unsigned char *out;
-int *outl;
-unsigned char *in;
-int inl;
+void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
+ unsigned char *in, int inl)
{
int i,j;
unsigned int total=0;
@@ -165,10 +171,7 @@ int inl;
*outl=total;
}
-void EVP_EncodeFinal(ctx,out,outl)
-EVP_ENCODE_CTX *ctx;
-unsigned char *out;
-int *outl;
+void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl)
{
unsigned int ret=0;
@@ -182,9 +185,7 @@ int *outl;
*outl=ret;
}
-int EVP_EncodeBlock(t,f,dlen)
-unsigned char *t,*f;
-int dlen;
+int EVP_EncodeBlock(unsigned char *t, unsigned char *f, int dlen)
{
int i,ret=0;
unsigned long l;
@@ -218,8 +219,7 @@ int dlen;
return(ret);
}
-void EVP_DecodeInit(ctx)
-EVP_ENCODE_CTX *ctx;
+void EVP_DecodeInit(EVP_ENCODE_CTX *ctx)
{
ctx->length=30;
ctx->num=0;
@@ -231,12 +231,8 @@ EVP_ENCODE_CTX *ctx;
* 0 for last line
* 1 for full line
*/
-int EVP_DecodeUpdate(ctx,out,outl,in,inl)
-EVP_ENCODE_CTX *ctx;
-unsigned char *out;
-int *outl;
-unsigned char *in;
-int inl;
+int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
+ unsigned char *in, int inl)
{
int seof= -1,eof=0,rv= -1,ret=0,i,v,tmp,n,ln,tmp2,exp_nl;
unsigned char *d;
@@ -341,9 +337,7 @@ end:
return(rv);
}
-int EVP_DecodeBlock(t,f,n)
-unsigned char *t,*f;
-int n;
+int EVP_DecodeBlock(unsigned char *t, unsigned char *f, int n)
{
int i,ret=0,a,b,c,d;
unsigned long l;
@@ -383,10 +377,7 @@ int n;
return(ret);
}
-int EVP_DecodeFinal(ctx,out,outl)
-EVP_ENCODE_CTX *ctx;
-unsigned char *out;
-int *outl;
+int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl)
{
int i;
@@ -404,9 +395,7 @@ int *outl;
}
#ifdef undef
-int EVP_DecodeValid(buf,len)
-unsigned char *buf;
-int len;
+int EVP_DecodeValid(unsigned char *buf, int len)
{
int i,num=0,bad=0;