summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto
diff options
context:
space:
mode:
authorbeck <>2014-04-15 17:46:17 +0000
committerbeck <>2014-04-15 17:46:17 +0000
commitc9414ed70ec89926c1041a64ee4b2f3ef36c90f6 (patch)
treec53c25a15cd89988cef641fa18324c5c6db28fed /src/lib/libcrypto
parent0cfe49dc6db41fd2d4f960b618ed41b11ffffc6a (diff)
downloadopenbsd-c9414ed70ec89926c1041a64ee4b2f3ef36c90f6.tar.gz
openbsd-c9414ed70ec89926c1041a64ee4b2f3ef36c90f6.tar.bz2
openbsd-c9414ed70ec89926c1041a64ee4b2f3ef36c90f6.zip
Send the rotIBM stream cipher (ebcdic) to Valhalla to party for eternity
with the bearded ones... some API's that nobody should be using will dissapear with this commit.
Diffstat (limited to 'src/lib/libcrypto')
-rw-r--r--src/lib/libcrypto/Attic/Makefile6
-rw-r--r--src/lib/libcrypto/asn1/a_gentm.c18
-rw-r--r--src/lib/libcrypto/asn1/a_mbstr.c7
-rw-r--r--src/lib/libcrypto/asn1/a_print.c8
-rw-r--r--src/lib/libcrypto/asn1/a_time.c15
-rw-r--r--src/lib/libcrypto/asn1/a_utctm.c18
-rw-r--r--src/lib/libcrypto/asn1/f_int.c9
-rw-r--r--src/lib/libcrypto/asn1/f_string.c9
-rw-r--r--src/lib/libcrypto/asn1/t_x509.c10
-rw-r--r--src/lib/libcrypto/bf/bftest.c11
-rw-r--r--src/lib/libcrypto/bio/b_dump.c6
-rw-r--r--src/lib/libcrypto/conf/conf_def.h17
-rw-r--r--src/lib/libcrypto/conf/keysets.pl16
-rw-r--r--src/lib/libcrypto/crypto.h4
-rw-r--r--src/lib/libcrypto/crypto/Makefile5
-rw-r--r--src/lib/libcrypto/des/fcrypt.c46
-rw-r--r--src/lib/libcrypto/ebcdic.c221
-rw-r--r--src/lib/libcrypto/ebcdic.h19
-rw-r--r--src/lib/libcrypto/evp/encode.c11
-rw-r--r--src/lib/libcrypto/hmac/hmactest.c11
-rw-r--r--src/lib/libcrypto/md2/md2_one.c16
-rw-r--r--src/lib/libcrypto/md2/md2test.c4
-rw-r--r--src/lib/libcrypto/md4/md4_one.c20
-rw-r--r--src/lib/libcrypto/md5/md5_one.c20
-rw-r--r--src/lib/libcrypto/mdc2/mdc2test.c8
-rw-r--r--src/lib/libcrypto/objects/obj_dat.c16
-rw-r--r--src/lib/libcrypto/pem/pem_lib.c15
-rw-r--r--src/lib/libcrypto/ripemd/rmdtest.c7
-rw-r--r--src/lib/libcrypto/sha/sha1test.c12
-rw-r--r--src/lib/libcrypto/sha/shatest.c12
-rw-r--r--src/lib/libcrypto/x509/x509_obj.c40
-rw-r--r--src/lib/libcrypto/x509v3/v3_ia5.c3
-rw-r--r--src/lib/libcrypto/x509v3/v3_prn.c30
-rw-r--r--src/lib/libcrypto/x509v3/v3_utl.c18
34 files changed, 5 insertions, 683 deletions
diff --git a/src/lib/libcrypto/Attic/Makefile b/src/lib/libcrypto/Attic/Makefile
index aa105e37a2..326915d520 100644
--- a/src/lib/libcrypto/Attic/Makefile
+++ b/src/lib/libcrypto/Attic/Makefile
@@ -35,13 +35,13 @@ GENERAL=Makefile README crypto-lib.com install.com
35LIB= $(TOP)/libcrypto.a 35LIB= $(TOP)/libcrypto.a
36SHARED_LIB= libcrypto$(SHLIB_EXT) 36SHARED_LIB= libcrypto$(SHLIB_EXT)
37LIBSRC= cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c cpt_err.c \ 37LIBSRC= cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c cpt_err.c \
38 ebcdic.c uid.c o_time.c o_str.c o_dir.c o_fips.c o_init.c fips_ers.c 38 uid.c o_time.c o_str.c o_dir.c o_fips.c o_init.c fips_ers.c
39LIBOBJ= cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o cpt_err.o ebcdic.o \ 39LIBOBJ= cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o cpt_err.o \
40 uid.o o_time.o o_str.o o_dir.o o_fips.o o_init.o fips_ers.o $(CPUID_OBJ) 40 uid.o o_time.o o_str.o o_dir.o o_fips.o o_init.o fips_ers.o $(CPUID_OBJ)
41 41
42SRC= $(LIBSRC) 42SRC= $(LIBSRC)
43 43
44EXHEADER= crypto.h opensslv.h opensslconf.h ebcdic.h symhacks.h \ 44EXHEADER= crypto.h opensslv.h opensslconf.h symhacks.h \
45 ossl_typ.h 45 ossl_typ.h
46HEADER= cryptlib.h buildinf.h md32_common.h o_time.h o_str.h o_dir.h $(EXHEADER) 46HEADER= cryptlib.h buildinf.h md32_common.h o_time.h o_str.h o_dir.h $(EXHEADER)
47 47
diff --git a/src/lib/libcrypto/asn1/a_gentm.c b/src/lib/libcrypto/asn1/a_gentm.c
index 04266e790a..4f312ee6c9 100644
--- a/src/lib/libcrypto/asn1/a_gentm.c
+++ b/src/lib/libcrypto/asn1/a_gentm.c
@@ -68,18 +68,6 @@
68 68
69int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a, unsigned char **pp) 69int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a, unsigned char **pp)
70 { 70 {
71#ifdef CHARSET_EBCDIC
72 /* KLUDGE! We convert to ascii before writing DER */
73 int len;
74 char tmp[24];
75 ASN1_STRING tmpstr = *(ASN1_STRING *)a;
76
77 len = tmpstr.length;
78 ebcdic2ascii(tmp, tmpstr.data, (len >= sizeof tmp) ? sizeof tmp : len);
79 tmpstr.data = tmp;
80
81 a = (ASN1_GENERALIZEDTIME *) &tmpstr;
82#endif
83 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp, 71 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
84 V_ASN1_GENERALIZEDTIME,V_ASN1_UNIVERSAL)); 72 V_ASN1_GENERALIZEDTIME,V_ASN1_UNIVERSAL));
85 } 73 }
@@ -97,9 +85,6 @@ ASN1_GENERALIZEDTIME *d2i_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME **a,
97 ASN1err(ASN1_F_D2I_ASN1_GENERALIZEDTIME,ERR_R_NESTED_ASN1_ERROR); 85 ASN1err(ASN1_F_D2I_ASN1_GENERALIZEDTIME,ERR_R_NESTED_ASN1_ERROR);
98 return(NULL); 86 return(NULL);
99 } 87 }
100#ifdef CHARSET_EBCDIC
101 ascii2ebcdic(ret->data, ret->data, ret->length);
102#endif
103 if (!ASN1_GENERALIZEDTIME_check(ret)) 88 if (!ASN1_GENERALIZEDTIME_check(ret))
104 { 89 {
105 ASN1err(ASN1_F_D2I_ASN1_GENERALIZEDTIME,ASN1_R_INVALID_TIME_FORMAT); 90 ASN1err(ASN1_F_D2I_ASN1_GENERALIZEDTIME,ASN1_R_INVALID_TIME_FORMAT);
@@ -256,8 +241,5 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
256 ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec); 241 ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec);
257 s->length=strlen(p); 242 s->length=strlen(p);
258 s->type=V_ASN1_GENERALIZEDTIME; 243 s->type=V_ASN1_GENERALIZEDTIME;
259#ifdef CHARSET_EBCDIC_not
260 ebcdic2ascii(s->data, s->data, s->length);
261#endif
262 return(s); 244 return(s);
263 } 245 }
diff --git a/src/lib/libcrypto/asn1/a_mbstr.c b/src/lib/libcrypto/asn1/a_mbstr.c
index 264d8f677f..dc953c8325 100644
--- a/src/lib/libcrypto/asn1/a_mbstr.c
+++ b/src/lib/libcrypto/asn1/a_mbstr.c
@@ -385,16 +385,9 @@ static int is_printable(unsigned long value)
385 /* Note: we can't use 'isalnum' because certain accented 385 /* Note: we can't use 'isalnum' because certain accented
386 * characters may count as alphanumeric in some environments. 386 * characters may count as alphanumeric in some environments.
387 */ 387 */
388#ifndef CHARSET_EBCDIC
389 if((ch >= 'a') && (ch <= 'z')) return 1; 388 if((ch >= 'a') && (ch <= 'z')) return 1;
390 if((ch >= 'A') && (ch <= 'Z')) return 1; 389 if((ch >= 'A') && (ch <= 'Z')) return 1;
391 if((ch >= '0') && (ch <= '9')) return 1; 390 if((ch >= '0') && (ch <= '9')) return 1;
392 if ((ch == ' ') || strchr("'()+,-./:=?", ch)) return 1; 391 if ((ch == ' ') || strchr("'()+,-./:=?", ch)) return 1;
393#else /*CHARSET_EBCDIC*/
394 if((ch >= os_toascii['a']) && (ch <= os_toascii['z'])) return 1;
395 if((ch >= os_toascii['A']) && (ch <= os_toascii['Z'])) return 1;
396 if((ch >= os_toascii['0']) && (ch <= os_toascii['9'])) return 1;
397 if ((ch == os_toascii[' ']) || strchr("'()+,-./:=?", os_toebcdic[ch])) return 1;
398#endif /*CHARSET_EBCDIC*/
399 return 0; 392 return 0;
400} 393}
diff --git a/src/lib/libcrypto/asn1/a_print.c b/src/lib/libcrypto/asn1/a_print.c
index d18e772320..9eec5034e1 100644
--- a/src/lib/libcrypto/asn1/a_print.c
+++ b/src/lib/libcrypto/asn1/a_print.c
@@ -72,7 +72,6 @@ int ASN1_PRINTABLE_type(const unsigned char *s, int len)
72 while ((*s) && (len-- != 0)) 72 while ((*s) && (len-- != 0))
73 { 73 {
74 c= *(s++); 74 c= *(s++);
75#ifndef CHARSET_EBCDIC
76 if (!( ((c >= 'a') && (c <= 'z')) || 75 if (!( ((c >= 'a') && (c <= 'z')) ||
77 ((c >= 'A') && (c <= 'Z')) || 76 ((c >= 'A') && (c <= 'Z')) ||
78 (c == ' ') || 77 (c == ' ') ||
@@ -86,13 +85,6 @@ int ASN1_PRINTABLE_type(const unsigned char *s, int len)
86 ia5=1; 85 ia5=1;
87 if (c&0x80) 86 if (c&0x80)
88 t61=1; 87 t61=1;
89#else
90 if (!isalnum(c) && (c != ' ') &&
91 strchr("'()+,-./:=?", c) == NULL)
92 ia5=1;
93 if (os_toascii[c] & 0x80)
94 t61=1;
95#endif
96 } 88 }
97 if (t61) return(V_ASN1_T61STRING); 89 if (t61) return(V_ASN1_T61STRING);
98 if (ia5) return(V_ASN1_IA5STRING); 90 if (ia5) return(V_ASN1_IA5STRING);
diff --git a/src/lib/libcrypto/asn1/a_time.c b/src/lib/libcrypto/asn1/a_time.c
index e2eb9b243e..4ade88f065 100644
--- a/src/lib/libcrypto/asn1/a_time.c
+++ b/src/lib/libcrypto/asn1/a_time.c
@@ -74,21 +74,6 @@ IMPLEMENT_ASN1_FUNCTIONS(ASN1_TIME)
74#if 0 74#if 0
75int i2d_ASN1_TIME(ASN1_TIME *a, unsigned char **pp) 75int i2d_ASN1_TIME(ASN1_TIME *a, unsigned char **pp)
76 { 76 {
77#ifdef CHARSET_EBCDIC
78 /* KLUDGE! We convert to ascii before writing DER */
79 char tmp[24];
80 ASN1_STRING tmpstr;
81
82 if(a->type == V_ASN1_UTCTIME || a->type == V_ASN1_GENERALIZEDTIME) {
83 int len;
84
85 tmpstr = *(ASN1_STRING *)a;
86 len = tmpstr.length;
87 ebcdic2ascii(tmp, tmpstr.data, (len >= sizeof tmp) ? sizeof tmp : len);
88 tmpstr.data = tmp;
89 a = (ASN1_GENERALIZEDTIME *) &tmpstr;
90 }
91#endif
92 if(a->type == V_ASN1_UTCTIME || a->type == V_ASN1_GENERALIZEDTIME) 77 if(a->type == V_ASN1_UTCTIME || a->type == V_ASN1_GENERALIZEDTIME)
93 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp, 78 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
94 a->type ,V_ASN1_UNIVERSAL)); 79 a->type ,V_ASN1_UNIVERSAL));
diff --git a/src/lib/libcrypto/asn1/a_utctm.c b/src/lib/libcrypto/asn1/a_utctm.c
index 615395b738..f2e7de16af 100644
--- a/src/lib/libcrypto/asn1/a_utctm.c
+++ b/src/lib/libcrypto/asn1/a_utctm.c
@@ -65,20 +65,8 @@
65#if 0 65#if 0
66int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a, unsigned char **pp) 66int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a, unsigned char **pp)
67 { 67 {
68#ifndef CHARSET_EBCDIC
69 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp, 68 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
70 V_ASN1_UTCTIME,V_ASN1_UNIVERSAL)); 69 V_ASN1_UTCTIME,V_ASN1_UNIVERSAL));
71#else
72 /* KLUDGE! We convert to ascii before writing DER */
73 int len;
74 char tmp[24];
75 ASN1_STRING x = *(ASN1_STRING *)a;
76
77 len = x.length;
78 ebcdic2ascii(tmp, x.data, (len >= sizeof tmp) ? sizeof tmp : len);
79 x.data = tmp;
80 return i2d_ASN1_bytes(&x, pp, V_ASN1_UTCTIME,V_ASN1_UNIVERSAL);
81#endif
82 } 70 }
83 71
84 72
@@ -94,9 +82,6 @@ ASN1_UTCTIME *d2i_ASN1_UTCTIME(ASN1_UTCTIME **a, unsigned char **pp,
94 ASN1err(ASN1_F_D2I_ASN1_UTCTIME,ERR_R_NESTED_ASN1_ERROR); 82 ASN1err(ASN1_F_D2I_ASN1_UTCTIME,ERR_R_NESTED_ASN1_ERROR);
95 return(NULL); 83 return(NULL);
96 } 84 }
97#ifdef CHARSET_EBCDIC
98 ascii2ebcdic(ret->data, ret->data, ret->length);
99#endif
100 if (!ASN1_UTCTIME_check(ret)) 85 if (!ASN1_UTCTIME_check(ret))
101 { 86 {
102 ASN1err(ASN1_F_D2I_ASN1_UTCTIME,ASN1_R_INVALID_TIME_FORMAT); 87 ASN1err(ASN1_F_D2I_ASN1_UTCTIME,ASN1_R_INVALID_TIME_FORMAT);
@@ -233,9 +218,6 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
233 ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec); 218 ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec);
234 s->length=strlen(p); 219 s->length=strlen(p);
235 s->type=V_ASN1_UTCTIME; 220 s->type=V_ASN1_UTCTIME;
236#ifdef CHARSET_EBCDIC_not
237 ebcdic2ascii(s->data, s->data, s->length);
238#endif
239 return(s); 221 return(s);
240 } 222 }
241 223
diff --git a/src/lib/libcrypto/asn1/f_int.c b/src/lib/libcrypto/asn1/f_int.c
index 9494e597ab..8b92fad9df 100644
--- a/src/lib/libcrypto/asn1/f_int.c
+++ b/src/lib/libcrypto/asn1/f_int.c
@@ -123,18 +123,9 @@ int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
123 123
124 for (j=0; j<i; j++) 124 for (j=0; j<i; j++)
125 { 125 {
126#ifndef CHARSET_EBCDIC
127 if (!( ((buf[j] >= '0') && (buf[j] <= '9')) || 126 if (!( ((buf[j] >= '0') && (buf[j] <= '9')) ||
128 ((buf[j] >= 'a') && (buf[j] <= 'f')) || 127 ((buf[j] >= 'a') && (buf[j] <= 'f')) ||
129 ((buf[j] >= 'A') && (buf[j] <= 'F')))) 128 ((buf[j] >= 'A') && (buf[j] <= 'F'))))
130#else
131 /* This #ifdef is not strictly necessary, since
132 * the characters A...F a...f 0...9 are contiguous
133 * (yes, even in EBCDIC - but not the whole alphabet).
134 * Nevertheless, isxdigit() is faster.
135 */
136 if (!isxdigit(buf[j]))
137#endif
138 { 129 {
139 i=j; 130 i=j;
140 break; 131 break;
diff --git a/src/lib/libcrypto/asn1/f_string.c b/src/lib/libcrypto/asn1/f_string.c
index 968698a798..f7d36adac7 100644
--- a/src/lib/libcrypto/asn1/f_string.c
+++ b/src/lib/libcrypto/asn1/f_string.c
@@ -123,18 +123,9 @@ int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
123 123
124 for (j=i-1; j>0; j--) 124 for (j=i-1; j>0; j--)
125 { 125 {
126#ifndef CHARSET_EBCDIC
127 if (!( ((buf[j] >= '0') && (buf[j] <= '9')) || 126 if (!( ((buf[j] >= '0') && (buf[j] <= '9')) ||
128 ((buf[j] >= 'a') && (buf[j] <= 'f')) || 127 ((buf[j] >= 'a') && (buf[j] <= 'f')) ||
129 ((buf[j] >= 'A') && (buf[j] <= 'F')))) 128 ((buf[j] >= 'A') && (buf[j] <= 'F'))))
130#else
131 /* This #ifdef is not strictly necessary, since
132 * the characters A...F a...f 0...9 are contiguous
133 * (yes, even in EBCDIC - but not the whole alphabet).
134 * Nevertheless, isxdigit() is faster.
135 */
136 if (!isxdigit(buf[j]))
137#endif
138 { 129 {
139 i=j; 130 i=j;
140 break; 131 break;
diff --git a/src/lib/libcrypto/asn1/t_x509.c b/src/lib/libcrypto/asn1/t_x509.c
index edbb39a02f..bbf00c7a29 100644
--- a/src/lib/libcrypto/asn1/t_x509.c
+++ b/src/lib/libcrypto/asn1/t_x509.c
@@ -485,7 +485,6 @@ int X509_NAME_print(BIO *bp, X509_NAME *name, int obase)
485 c=s; 485 c=s;
486 for (;;) 486 for (;;)
487 { 487 {
488#ifndef CHARSET_EBCDIC
489 if ( ((*s == '/') && 488 if ( ((*s == '/') &&
490 ((s[1] >= 'A') && (s[1] <= 'Z') && ( 489 ((s[1] >= 'A') && (s[1] <= 'Z') && (
491 (s[2] == '=') || 490 (s[2] == '=') ||
@@ -493,15 +492,6 @@ int X509_NAME_print(BIO *bp, X509_NAME *name, int obase)
493 (s[3] == '=')) 492 (s[3] == '='))
494 ))) || 493 ))) ||
495 (*s == '\0')) 494 (*s == '\0'))
496#else
497 if ( ((*s == '/') &&
498 (isupper(s[1]) && (
499 (s[2] == '=') ||
500 (isupper(s[2]) &&
501 (s[3] == '='))
502 ))) ||
503 (*s == '\0'))
504#endif
505 { 495 {
506 i=s-c; 496 i=s-c;
507 if (BIO_write(bp,c,i) != i) goto err; 497 if (BIO_write(bp,c,i) != i) goto err;
diff --git a/src/lib/libcrypto/bf/bftest.c b/src/lib/libcrypto/bf/bftest.c
index 97e6634d37..20caf0f3f8 100644
--- a/src/lib/libcrypto/bf/bftest.c
+++ b/src/lib/libcrypto/bf/bftest.c
@@ -75,10 +75,6 @@ int main(int argc, char *argv[])
75#else 75#else
76#include <openssl/blowfish.h> 76#include <openssl/blowfish.h>
77 77
78#ifdef CHARSET_EBCDIC
79#include <openssl/ebcdic.h>
80#endif
81
82static char *bf_key[2]={ 78static char *bf_key[2]={
83 "abcdefghijklmnopqrstuvwxyz", 79 "abcdefghijklmnopqrstuvwxyz",
84 "Who is John Galt?" 80 "Who is John Galt?"
@@ -361,16 +357,9 @@ static int test(void)
361 unsigned char out[8]; 357 unsigned char out[8];
362 BF_LONG len; 358 BF_LONG len;
363 359
364#ifdef CHARSET_EBCDIC
365 ebcdic2ascii(cbc_data, cbc_data, strlen(cbc_data));
366#endif
367
368 printf("testing blowfish in raw ecb mode\n"); 360 printf("testing blowfish in raw ecb mode\n");
369 for (n=0; n<2; n++) 361 for (n=0; n<2; n++)
370 { 362 {
371#ifdef CHARSET_EBCDIC
372 ebcdic2ascii(bf_key[n], bf_key[n], strlen(bf_key[n]));
373#endif
374 BF_set_key(&key,strlen(bf_key[n]),(unsigned char *)bf_key[n]); 363 BF_set_key(&key,strlen(bf_key[n]),(unsigned char *)bf_key[n]);
375 364
376 data[0]=bf_plain[n][0]; 365 data[0]=bf_plain[n][0];
diff --git a/src/lib/libcrypto/bio/b_dump.c b/src/lib/libcrypto/bio/b_dump.c
index bea94969a2..32d523563e 100644
--- a/src/lib/libcrypto/bio/b_dump.c
+++ b/src/lib/libcrypto/bio/b_dump.c
@@ -125,14 +125,8 @@ BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u),
125 if (((i*dump_width) + j) >= len) 125 if (((i*dump_width) + j) >= len)
126 break; 126 break;
127 ch = ((unsigned char)*(s + i * dump_width + j)) & 0xff; 127 ch = ((unsigned char)*(s + i * dump_width + j)) & 0xff;
128#ifndef CHARSET_EBCDIC
129 (void) snprintf(tmp, sizeof tmp, "%c", 128 (void) snprintf(tmp, sizeof tmp, "%c",
130 ((ch >= ' ') && (ch <= '~')) ? ch : '.'); 129 ((ch >= ' ') && (ch <= '~')) ? ch : '.');
131#else
132 (void) snprintf(tmp, sizeof tmp, "%c",
133 ((ch >= os_toascii[' ']) && (ch <= os_toascii['~']))
134 ? os_toebcdic[ch] : '.');
135#endif
136 BUF_strlcat(buf, tmp, sizeof buf); 130 BUF_strlcat(buf, tmp, sizeof buf);
137 } 131 }
138 BUF_strlcat(buf, "\n", sizeof buf); 132 BUF_strlcat(buf, "\n", sizeof buf);
diff --git a/src/lib/libcrypto/conf/conf_def.h b/src/lib/libcrypto/conf/conf_def.h
index 92a7d8ad77..b18e6e2728 100644
--- a/src/lib/libcrypto/conf/conf_def.h
+++ b/src/lib/libcrypto/conf/conf_def.h
@@ -78,7 +78,6 @@
78 CONF_PUNCTUATION) 78 CONF_PUNCTUATION)
79 79
80#define KEYTYPES(c) ((unsigned short *)((c)->meth_data)) 80#define KEYTYPES(c) ((unsigned short *)((c)->meth_data))
81#ifndef CHARSET_EBCDIC
82#define IS_COMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_COMMENT) 81#define IS_COMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_COMMENT)
83#define IS_FCOMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_FCOMMENT) 82#define IS_FCOMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_FCOMMENT)
84#define IS_EOF(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_EOF) 83#define IS_EOF(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_EOF)
@@ -92,22 +91,6 @@
92#define IS_DQUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_DQUOTE) 91#define IS_DQUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_DQUOTE)
93#define IS_HIGHBIT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_HIGHBIT) 92#define IS_HIGHBIT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_HIGHBIT)
94 93
95#else /*CHARSET_EBCDIC*/
96
97#define IS_COMMENT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_COMMENT)
98#define IS_FCOMMENT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_FCOMMENT)
99#define IS_EOF(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_EOF)
100#define IS_ESC(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ESC)
101#define IS_NUMBER(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_NUMBER)
102#define IS_WS(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_WS)
103#define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ALPHA_NUMERIC)
104#define IS_ALPHA_NUMERIC_PUNCT(c,a) \
105 (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ALPHA_NUMERIC_PUNCT)
106#define IS_QUOTE(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_QUOTE)
107#define IS_DQUOTE(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_DQUOTE)
108#define IS_HIGHBIT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_HIGHBIT)
109#endif /*CHARSET_EBCDIC*/
110
111static unsigned short CONF_type_default[256]={ 94static unsigned short CONF_type_default[256]={
112 0x0008,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 95 0x0008,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
113 0x0000,0x0010,0x0010,0x0000,0x0000,0x0010,0x0000,0x0000, 96 0x0000,0x0010,0x0010,0x0000,0x0000,0x0010,0x0000,0x0000,
diff --git a/src/lib/libcrypto/conf/keysets.pl b/src/lib/libcrypto/conf/keysets.pl
index 50ed67fa52..fe17be57fe 100644
--- a/src/lib/libcrypto/conf/keysets.pl
+++ b/src/lib/libcrypto/conf/keysets.pl
@@ -132,7 +132,6 @@ print <<"EOF";
132 CONF_PUNCTUATION) 132 CONF_PUNCTUATION)
133 133
134#define KEYTYPES(c) ((unsigned short *)((c)->meth_data)) 134#define KEYTYPES(c) ((unsigned short *)((c)->meth_data))
135#ifndef CHARSET_EBCDIC
136#define IS_COMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_COMMENT) 135#define IS_COMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_COMMENT)
137#define IS_FCOMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_FCOMMENT) 136#define IS_FCOMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_FCOMMENT)
138#define IS_EOF(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_EOF) 137#define IS_EOF(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_EOF)
@@ -146,21 +145,6 @@ print <<"EOF";
146#define IS_DQUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_DQUOTE) 145#define IS_DQUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_DQUOTE)
147#define IS_HIGHBIT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_HIGHBIT) 146#define IS_HIGHBIT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_HIGHBIT)
148 147
149#else /*CHARSET_EBCDIC*/
150
151#define IS_COMMENT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_COMMENT)
152#define IS_FCOMMENT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_FCOMMENT)
153#define IS_EOF(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_EOF)
154#define IS_ESC(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ESC)
155#define IS_NUMBER(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_NUMBER)
156#define IS_WS(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_WS)
157#define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ALPHA_NUMERIC)
158#define IS_ALPHA_NUMERIC_PUNCT(c,a) \\
159 (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ALPHA_NUMERIC_PUNCT)
160#define IS_QUOTE(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_QUOTE)
161#define IS_DQUOTE(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_DQUOTE)
162#define IS_HIGHBIT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_HIGHBIT)
163#endif /*CHARSET_EBCDIC*/
164 148
165EOF 149EOF
166 150
diff --git a/src/lib/libcrypto/crypto.h b/src/lib/libcrypto/crypto.h
index baeba25b99..351ccfd35b 100644
--- a/src/lib/libcrypto/crypto.h
+++ b/src/lib/libcrypto/crypto.h
@@ -130,10 +130,6 @@
130#include <openssl/opensslv.h> 130#include <openssl/opensslv.h>
131#include <openssl/ossl_typ.h> 131#include <openssl/ossl_typ.h>
132 132
133#ifdef CHARSET_EBCDIC
134#include <openssl/ebcdic.h>
135#endif
136
137#ifdef __cplusplus 133#ifdef __cplusplus
138extern "C" { 134extern "C" {
139#endif 135#endif
diff --git a/src/lib/libcrypto/crypto/Makefile b/src/lib/libcrypto/crypto/Makefile
index f07176f829..e3bb0a2b36 100644
--- a/src/lib/libcrypto/crypto/Makefile
+++ b/src/lib/libcrypto/crypto/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.7 2014/04/15 17:20:09 beck Exp $ 1# $OpenBSD: Makefile,v 1.8 2014/04/15 17:46:16 beck Exp $
2 2
3LIB= crypto 3LIB= crypto
4 4
@@ -43,7 +43,7 @@ CFLAGS+= -I${LCRYPTO_SRC}/modes -I${LCRYPTO_SRC}/asn1 -I${LCRYPTO_SRC}/evp
43 43
44# crypto/ 44# crypto/
45SRCS+= cryptlib.c mem.c mem_dbg.c cversion.c ex_data.c cpt_err.c 45SRCS+= cryptlib.c mem.c mem_dbg.c cversion.c ex_data.c cpt_err.c
46SRCS+= ebcdic.c uid.c o_time.c o_str.c o_fips.c o_init.c fips_ers.c 46SRCS+= uid.c o_time.c o_str.c o_fips.c o_init.c fips_ers.c
47 47
48# aes/ 48# aes/
49SRCS+= aes_misc.c aes_ecb.c aes_cfb.c aes_ofb.c 49SRCS+= aes_misc.c aes_ecb.c aes_cfb.c aes_ofb.c
@@ -369,7 +369,6 @@ HDRS=\
369 crypto/dh/dh.h \ 369 crypto/dh/dh.h \
370 crypto/dsa/dsa.h \ 370 crypto/dsa/dsa.h \
371 crypto/dso/dso.h \ 371 crypto/dso/dso.h \
372 crypto/ebcdic.h \
373 crypto/ec/ec.h \ 372 crypto/ec/ec.h \
374 crypto/ecdh/ecdh.h \ 373 crypto/ecdh/ecdh.h \
375 crypto/ecdsa/ecdsa.h \ 374 crypto/ecdsa/ecdsa.h \
diff --git a/src/lib/libcrypto/des/fcrypt.c b/src/lib/libcrypto/des/fcrypt.c
index ccbdff250f..d02189b290 100644
--- a/src/lib/libcrypto/des/fcrypt.c
+++ b/src/lib/libcrypto/des/fcrypt.c
@@ -1,13 +1,5 @@
1/* NOCW */ 1/* NOCW */
2#include <stdio.h> 2#include <stdio.h>
3#ifdef _OSD_POSIX
4#ifndef CHARSET_EBCDIC
5#define CHARSET_EBCDIC 1
6#endif
7#endif
8#ifdef CHARSET_EBCDIC
9#include <openssl/ebcdic.h>
10#endif
11 3
12/* This version of crypt has been developed from my MIT compatible 4/* This version of crypt has been developed from my MIT compatible
13 * DES library. 5 * DES library.
@@ -62,37 +54,7 @@ char *DES_crypt(const char *buf, const char *salt)
62 { 54 {
63 static char buff[14]; 55 static char buff[14];
64 56
65#ifndef CHARSET_EBCDIC
66 return(DES_fcrypt(buf,salt,buff)); 57 return(DES_fcrypt(buf,salt,buff));
67#else
68 char e_salt[2+1];
69 char e_buf[32+1]; /* replace 32 by 8 ? */
70 char *ret;
71
72 /* Copy at most 2 chars of salt */
73 if ((e_salt[0] = salt[0]) != '\0')
74 e_salt[1] = salt[1];
75
76 /* Copy at most 32 chars of password */
77 strncpy (e_buf, buf, sizeof(e_buf));
78
79 /* Make sure we have a delimiter */
80 e_salt[sizeof(e_salt)-1] = e_buf[sizeof(e_buf)-1] = '\0';
81
82 /* Convert the e_salt to ASCII, as that's what DES_fcrypt works on */
83 ebcdic2ascii(e_salt, e_salt, sizeof e_salt);
84
85 /* Convert the cleartext password to ASCII */
86 ebcdic2ascii(e_buf, e_buf, sizeof e_buf);
87
88 /* Encrypt it (from/to ASCII) */
89 ret = DES_fcrypt(e_buf,e_salt,buff);
90
91 /* Convert the result back to EBCDIC */
92 ascii2ebcdic(ret, ret, strlen(ret));
93
94 return ret;
95#endif
96 } 58 }
97 59
98 60
@@ -115,18 +77,10 @@ char *DES_fcrypt(const char *buf, const char *salt, char *ret)
115 * crypt to "*". This was found when replacing the crypt in 77 * crypt to "*". This was found when replacing the crypt in
116 * our shared libraries. People found that the disabled 78 * our shared libraries. People found that the disabled
117 * accounts effectively had no passwd :-(. */ 79 * accounts effectively had no passwd :-(. */
118#ifndef CHARSET_EBCDIC
119 x=ret[0]=((salt[0] == '\0')?'A':salt[0]); 80 x=ret[0]=((salt[0] == '\0')?'A':salt[0]);
120 Eswap0=con_salt[x]<<2; 81 Eswap0=con_salt[x]<<2;
121 x=ret[1]=((salt[1] == '\0')?'A':salt[1]); 82 x=ret[1]=((salt[1] == '\0')?'A':salt[1]);
122 Eswap1=con_salt[x]<<6; 83 Eswap1=con_salt[x]<<6;
123#else
124 x=ret[0]=((salt[0] == '\0')?os_toascii['A']:salt[0]);
125 Eswap0=con_salt[x]<<2;
126 x=ret[1]=((salt[1] == '\0')?os_toascii['A']:salt[1]);
127 Eswap1=con_salt[x]<<6;
128#endif
129
130/* EAY 84/* EAY
131r=strlen(buf); 85r=strlen(buf);
132r=(r+7)/8; 86r=(r+7)/8;
diff --git a/src/lib/libcrypto/ebcdic.c b/src/lib/libcrypto/ebcdic.c
deleted file mode 100644
index 2ac26abc72..0000000000
--- a/src/lib/libcrypto/ebcdic.c
+++ /dev/null
@@ -1,221 +0,0 @@
1/* crypto/ebcdic.c */
2
3#ifndef CHARSET_EBCDIC
4
5#include <openssl/e_os2.h>
6#if defined(PEDANTIC) || defined(__DECC) || defined(OPENSSL_SYS_MACOSX)
7static void *dummy = &dummy;
8#endif
9
10#else /*CHARSET_EBCDIC*/
11
12#include "ebcdic.h"
13/* Initial Port for Apache-1.3 by <Martin.Kraemer@Mch.SNI.De>
14 * Adapted for OpenSSL-0.9.4 by <Martin.Kraemer@Mch.SNI.De>
15 */
16
17#ifdef _OSD_POSIX
18/*
19 "BS2000 OSD" is a POSIX subsystem on a main frame.
20 It is made by Siemens AG, Germany, for their BS2000 mainframe machines.
21 Within the POSIX subsystem, the same character set was chosen as in
22 "native BS2000", namely EBCDIC. (EDF04)
23
24 The name "ASCII" in these routines is misleading: actually, conversion
25 is not between EBCDIC and ASCII, but EBCDIC(EDF04) and ISO-8859.1;
26 that means that (western european) national characters are preserved.
27
28 This table is identical to the one used by rsh/rcp/ftp and other POSIX tools.
29*/
30
31/* Here's the bijective ebcdic-to-ascii table: */
32const unsigned char os_toascii[256] = {
33/*00*/ 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f,
34 0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*................*/
35/*10*/ 0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97,
36 0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /*................*/
37/*20*/ 0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b,
38 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /*................*/
39/*30*/ 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
40 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /*................*/
41/*40*/ 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
42 0xe7, 0xf1, 0x60, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* .........`.<(+|*/
43/*50*/ 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
44 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x9f, /*&.........!$*);.*/
45/*60*/ 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
46 0xc7, 0xd1, 0x5e, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /*-/........^,%_>?*/
47/*70*/ 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
48 0xcc, 0xa8, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /*..........:#@'="*/
49/*80*/ 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
50 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /*.abcdefghi......*/
51/*90*/ 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
52 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /*.jklmnopqr......*/
53/*a0*/ 0xb5, 0xaf, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
54 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae, /*..stuvwxyz......*/
55/*b0*/ 0xa2, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
56 0xbd, 0xbe, 0xac, 0x5b, 0x5c, 0x5d, 0xb4, 0xd7, /*...........[\]..*/
57/*c0*/ 0xf9, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
58 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /*.ABCDEFGHI......*/
59/*d0*/ 0xa6, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
60 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xdb, 0xfa, 0xff, /*.JKLMNOPQR......*/
61/*e0*/ 0xd9, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
62 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /*..STUVWXYZ......*/
63/*f0*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
64 0x38, 0x39, 0xb3, 0x7b, 0xdc, 0x7d, 0xda, 0x7e /*0123456789.{.}.~*/
65};
66
67
68/* The ascii-to-ebcdic table: */
69const unsigned char os_toebcdic[256] = {
70/*00*/ 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f,
71 0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*................*/
72/*10*/ 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26,
73 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, /*................*/
74/*20*/ 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d,
75 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /* !"#$%&'()*+,-./ */
76/*30*/ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
77 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /*0123456789:;<=>?*/
78/*40*/ 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
79 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /*@ABCDEFGHIJKLMNO*/
80/*50*/ 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
81 0xe7, 0xe8, 0xe9, 0xbb, 0xbc, 0xbd, 0x6a, 0x6d, /*PQRSTUVWXYZ[\]^_*/
82/*60*/ 0x4a, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
83 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /*`abcdefghijklmno*/
84/*70*/ 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
85 0xa7, 0xa8, 0xa9, 0xfb, 0x4f, 0xfd, 0xff, 0x07, /*pqrstuvwxyz{|}~.*/
86/*80*/ 0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08,
87 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14, /*................*/
88/*90*/ 0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17,
89 0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0x5f, /*................*/
90/*a0*/ 0x41, 0xaa, 0xb0, 0xb1, 0x9f, 0xb2, 0xd0, 0xb5,
91 0x79, 0xb4, 0x9a, 0x8a, 0xba, 0xca, 0xaf, 0xa1, /*................*/
92/*b0*/ 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3,
93 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, /*................*/
94/*c0*/ 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68,
95 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /*................*/
96/*d0*/ 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf,
97 0x80, 0xe0, 0xfe, 0xdd, 0xfc, 0xad, 0xae, 0x59, /*................*/
98/*e0*/ 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48,
99 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /*................*/
100/*f0*/ 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1,
101 0x70, 0xc0, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf /*................*/
102};
103
104#else /*_OSD_POSIX*/
105
106/*
107This code does basic character mapping for IBM's TPF and OS/390 operating systems.
108It is a modified version of the BS2000 table.
109
110Bijective EBCDIC (character set IBM-1047) to US-ASCII table:
111This table is bijective - there are no ambigous or duplicate characters.
112*/
113const unsigned char os_toascii[256] = {
114 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f, /* 00-0f: */
115 0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
116 0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97, /* 10-1f: */
117 0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
118 0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b, /* 20-2f: */
119 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /* ................ */
120 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30-3f: */
121 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /* ................ */
122 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5, /* 40-4f: */
123 0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* ...........<(+| */
124 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef, /* 50-5f: */
125 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x5e, /* &.........!$*);^ */
126 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5, /* 60-6f: */
127 0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /* -/.........,%_>? */
128 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf, /* 70-7f: */
129 0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /* .........`:#@'=" */
130 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80-8f: */
131 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /* .abcdefghi...... */
132 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* 90-9f: */
133 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /* .jklmnopqr...... */
134 0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* a0-af: */
135 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0x5b, 0xde, 0xae, /* .~stuvwxyz...[.. */
136 0xac, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc, /* b0-bf: */
137 0xbd, 0xbe, 0xdd, 0xa8, 0xaf, 0x5d, 0xb4, 0xd7, /* .............].. */
138 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* c0-cf: */
139 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /* {ABCDEFGHI...... */
140 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* d0-df: */
141 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, /* }JKLMNOPQR...... */
142 0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* e0-ef: */
143 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /* \.STUVWXYZ...... */
144 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* f0-ff: */
145 0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x9f /* 0123456789...... */
146};
147
148
149/*
150The US-ASCII to EBCDIC (character set IBM-1047) table:
151This table is bijective (no ambiguous or duplicate characters)
152*/
153const unsigned char os_toebcdic[256] = {
154 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, /* 00-0f: */
155 0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
156 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, /* 10-1f: */
157 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
158 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, /* 20-2f: */
159 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /* !"#$%&'()*+,-./ */
160 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 30-3f: */
161 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /* 0123456789:;<=>? */
162 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 40-4f: */
163 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /* @ABCDEFGHIJKLMNO */
164 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, /* 50-5f: */
165 0xe7, 0xe8, 0xe9, 0xad, 0xe0, 0xbd, 0x5f, 0x6d, /* PQRSTUVWXYZ[\]^_ */
166 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60-6f: */
167 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* `abcdefghijklmno */
168 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, /* 70-7f: */
169 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07, /* pqrstuvwxyz{|}~. */
170 0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08, /* 80-8f: */
171 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14, /* ................ */
172 0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17, /* 90-9f: */
173 0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0xff, /* ................ */
174 0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5, /* a0-af: */
175 0xbb, 0xb4, 0x9a, 0x8a, 0xb0, 0xca, 0xaf, 0xbc, /* ................ */
176 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3, /* b0-bf: */
177 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, /* ................ */
178 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68, /* c0-cf: */
179 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* ................ */
180 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf, /* d0-df: */
181 0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xba, 0xae, 0x59, /* ................ */
182 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48, /* e0-ef: */
183 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* ................ */
184 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1, /* f0-ff: */
185 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf /* ................ */
186};
187#endif /*_OSD_POSIX*/
188
189/* Translate a memory block from EBCDIC (host charset) to ASCII (net charset)
190 * dest and srce may be identical, or separate memory blocks, but
191 * should not overlap. These functions intentionally have an interface
192 * compatible to memcpy(3).
193 */
194
195void *
196ebcdic2ascii(void *dest, const void *srce, size_t count)
197{
198 unsigned char *udest = dest;
199 const unsigned char *usrce = srce;
200
201 while (count-- != 0) {
202 *udest++ = os_toascii[*usrce++];
203 }
204
205 return dest;
206}
207
208void *
209ascii2ebcdic(void *dest, const void *srce, size_t count)
210{
211 unsigned char *udest = dest;
212 const unsigned char *usrce = srce;
213
214 while (count-- != 0) {
215 *udest++ = os_toebcdic[*usrce++];
216 }
217
218 return dest;
219}
220
221#endif
diff --git a/src/lib/libcrypto/ebcdic.h b/src/lib/libcrypto/ebcdic.h
deleted file mode 100644
index 6d65afcf9e..0000000000
--- a/src/lib/libcrypto/ebcdic.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/* crypto/ebcdic.h */
2
3#ifndef HEADER_EBCDIC_H
4#define HEADER_EBCDIC_H
5
6#include <sys/types.h>
7
8/* Avoid name clashes with other applications */
9#define os_toascii _openssl_os_toascii
10#define os_toebcdic _openssl_os_toebcdic
11#define ebcdic2ascii _openssl_ebcdic2ascii
12#define ascii2ebcdic _openssl_ascii2ebcdic
13
14extern const unsigned char os_toascii[256];
15extern const unsigned char os_toebcdic[256];
16void *ebcdic2ascii(void *dest, const void *srce, size_t count);
17void *ascii2ebcdic(void *dest, const void *srce, size_t count);
18
19#endif
diff --git a/src/lib/libcrypto/evp/encode.c b/src/lib/libcrypto/evp/encode.c
index 28546a84bc..7af9a2780b 100644
--- a/src/lib/libcrypto/evp/encode.c
+++ b/src/lib/libcrypto/evp/encode.c
@@ -60,19 +60,8 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/evp.h> 61#include <openssl/evp.h>
62 62
63#ifndef CHARSET_EBCDIC
64#define conv_bin2ascii(a) (data_bin2ascii[(a)&0x3f]) 63#define conv_bin2ascii(a) (data_bin2ascii[(a)&0x3f])
65#define conv_ascii2bin(a) (data_ascii2bin[(a)&0x7f]) 64#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
76 65
77/* 64 char lines 66/* 64 char lines
78 * pad input with 0 67 * pad input with 0
diff --git a/src/lib/libcrypto/hmac/hmactest.c b/src/lib/libcrypto/hmac/hmactest.c
index 1b906b81af..282e06e53e 100644
--- a/src/lib/libcrypto/hmac/hmactest.c
+++ b/src/lib/libcrypto/hmac/hmactest.c
@@ -74,9 +74,6 @@ int main(int argc, char *argv[])
74#include <openssl/md5.h> 74#include <openssl/md5.h>
75#endif 75#endif
76 76
77#ifdef CHARSET_EBCDIC
78#include <openssl/ebcdic.h>
79#endif
80 77
81#ifndef OPENSSL_NO_MD5 78#ifndef OPENSSL_NO_MD5
82static struct test_st 79static struct test_st
@@ -132,14 +129,6 @@ int main(int argc, char *argv[])
132#ifdef OPENSSL_NO_MD5 129#ifdef OPENSSL_NO_MD5
133 printf("test skipped: MD5 disabled\n"); 130 printf("test skipped: MD5 disabled\n");
134#else 131#else
135
136#ifdef CHARSET_EBCDIC
137 ebcdic2ascii(test[0].data, test[0].data, test[0].data_len);
138 ebcdic2ascii(test[1].data, test[1].data, test[1].data_len);
139 ebcdic2ascii(test[2].key, test[2].key, test[2].key_len);
140 ebcdic2ascii(test[2].data, test[2].data, test[2].data_len);
141#endif
142
143 for (i=0; i<4; i++) 132 for (i=0; i<4; i++)
144 { 133 {
145 p=pt(HMAC(EVP_md5(), 134 p=pt(HMAC(EVP_md5(),
diff --git a/src/lib/libcrypto/md2/md2_one.c b/src/lib/libcrypto/md2/md2_one.c
index f7fef5cc0a..cb8594e085 100644
--- a/src/lib/libcrypto/md2/md2_one.c
+++ b/src/lib/libcrypto/md2/md2_one.c
@@ -71,23 +71,7 @@ unsigned char *MD2(const unsigned char *d, size_t n, unsigned char *md)
71 if (md == NULL) md=m; 71 if (md == NULL) md=m;
72 if (!MD2_Init(&c)) 72 if (!MD2_Init(&c))
73 return NULL; 73 return NULL;
74#ifndef CHARSET_EBCDIC
75 MD2_Update(&c,d,n); 74 MD2_Update(&c,d,n);
76#else
77 {
78 char temp[1024];
79 unsigned long chunk;
80
81 while (n > 0)
82 {
83 chunk = (n > sizeof(temp)) ? sizeof(temp) : n;
84 ebcdic2ascii(temp, d, chunk);
85 MD2_Update(&c,temp,chunk);
86 n -= chunk;
87 d += chunk;
88 }
89 }
90#endif
91 MD2_Final(md,&c); 75 MD2_Final(md,&c);
92 OPENSSL_cleanse(&c,sizeof(c)); /* Security consideration */ 76 OPENSSL_cleanse(&c,sizeof(c)); /* Security consideration */
93 return(md); 77 return(md);
diff --git a/src/lib/libcrypto/md2/md2test.c b/src/lib/libcrypto/md2/md2test.c
index db5f5bc6d2..0195214036 100644
--- a/src/lib/libcrypto/md2/md2test.c
+++ b/src/lib/libcrypto/md2/md2test.c
@@ -72,10 +72,6 @@ int main(int argc, char *argv[])
72#include <openssl/evp.h> 72#include <openssl/evp.h>
73#include <openssl/md2.h> 73#include <openssl/md2.h>
74 74
75#ifdef CHARSET_EBCDIC
76#include <openssl/ebcdic.h>
77#endif
78
79static char *test[]={ 75static char *test[]={
80 "", 76 "",
81 "a", 77 "a",
diff --git a/src/lib/libcrypto/md4/md4_one.c b/src/lib/libcrypto/md4/md4_one.c
index bb64362638..ed6ce33650 100644
--- a/src/lib/libcrypto/md4/md4_one.c
+++ b/src/lib/libcrypto/md4/md4_one.c
@@ -61,10 +61,6 @@
61#include <openssl/md4.h> 61#include <openssl/md4.h>
62#include <openssl/crypto.h> 62#include <openssl/crypto.h>
63 63
64#ifdef CHARSET_EBCDIC
65#include <openssl/ebcdic.h>
66#endif
67
68unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md) 64unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md)
69 { 65 {
70 MD4_CTX c; 66 MD4_CTX c;
@@ -73,23 +69,7 @@ unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md)
73 if (md == NULL) md=m; 69 if (md == NULL) md=m;
74 if (!MD4_Init(&c)) 70 if (!MD4_Init(&c))
75 return NULL; 71 return NULL;
76#ifndef CHARSET_EBCDIC
77 MD4_Update(&c,d,n); 72 MD4_Update(&c,d,n);
78#else
79 {
80 char temp[1024];
81 unsigned long chunk;
82
83 while (n > 0)
84 {
85 chunk = (n > sizeof(temp)) ? sizeof(temp) : n;
86 ebcdic2ascii(temp, d, chunk);
87 MD4_Update(&c,temp,chunk);
88 n -= chunk;
89 d += chunk;
90 }
91 }
92#endif
93 MD4_Final(md,&c); 73 MD4_Final(md,&c);
94 OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */ 74 OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */
95 return(md); 75 return(md);
diff --git a/src/lib/libcrypto/md5/md5_one.c b/src/lib/libcrypto/md5/md5_one.c
index 43fee89379..839e27e972 100644
--- a/src/lib/libcrypto/md5/md5_one.c
+++ b/src/lib/libcrypto/md5/md5_one.c
@@ -61,10 +61,6 @@
61#include <openssl/md5.h> 61#include <openssl/md5.h>
62#include <openssl/crypto.h> 62#include <openssl/crypto.h>
63 63
64#ifdef CHARSET_EBCDIC
65#include <openssl/ebcdic.h>
66#endif
67
68unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md) 64unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md)
69 { 65 {
70 MD5_CTX c; 66 MD5_CTX c;
@@ -73,23 +69,7 @@ unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md)
73 if (md == NULL) md=m; 69 if (md == NULL) md=m;
74 if (!MD5_Init(&c)) 70 if (!MD5_Init(&c))
75 return NULL; 71 return NULL;
76#ifndef CHARSET_EBCDIC
77 MD5_Update(&c,d,n); 72 MD5_Update(&c,d,n);
78#else
79 {
80 char temp[1024];
81 unsigned long chunk;
82
83 while (n > 0)
84 {
85 chunk = (n > sizeof(temp)) ? sizeof(temp) : n;
86 ebcdic2ascii(temp, d, chunk);
87 MD5_Update(&c,temp,chunk);
88 n -= chunk;
89 d += chunk;
90 }
91 }
92#endif
93 MD5_Final(md,&c); 73 MD5_Final(md,&c);
94 OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */ 74 OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */
95 return(md); 75 return(md);
diff --git a/src/lib/libcrypto/mdc2/mdc2test.c b/src/lib/libcrypto/mdc2/mdc2test.c
index 017b31add2..cf8f65cf27 100644
--- a/src/lib/libcrypto/mdc2/mdc2test.c
+++ b/src/lib/libcrypto/mdc2/mdc2test.c
@@ -76,10 +76,6 @@ int main(int argc, char *argv[])
76#include <openssl/evp.h> 76#include <openssl/evp.h>
77#include <openssl/mdc2.h> 77#include <openssl/mdc2.h>
78 78
79#ifdef CHARSET_EBCDIC
80#include <openssl/ebcdic.h>
81#endif
82
83static unsigned char pad1[16]={ 79static unsigned char pad1[16]={
84 0x42,0xE5,0x0C,0xD2,0x24,0xBA,0xCE,0xBA, 80 0x42,0xE5,0x0C,0xD2,0x24,0xBA,0xCE,0xBA,
85 0x76,0x0B,0xDD,0x2B,0xD4,0x09,0x28,0x1A 81 0x76,0x0B,0xDD,0x2B,0xD4,0x09,0x28,0x1A
@@ -98,10 +94,6 @@ int main(int argc, char *argv[])
98 EVP_MD_CTX c; 94 EVP_MD_CTX c;
99 static char *text="Now is the time for all "; 95 static char *text="Now is the time for all ";
100 96
101#ifdef CHARSET_EBCDIC
102 ebcdic2ascii(text,text,strlen(text));
103#endif
104
105 EVP_MD_CTX_init(&c); 97 EVP_MD_CTX_init(&c);
106 EVP_DigestInit_ex(&c,EVP_mdc2(), NULL); 98 EVP_DigestInit_ex(&c,EVP_mdc2(), NULL);
107 EVP_DigestUpdate(&c,(unsigned char *)text,strlen(text)); 99 EVP_DigestUpdate(&c,(unsigned char *)text,strlen(text));
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c
index a597284c80..bced796e62 100644
--- a/src/lib/libcrypto/objects/obj_dat.c
+++ b/src/lib/libcrypto/objects/obj_dat.c
@@ -705,22 +705,6 @@ const void *OBJ_bsearch_ex_(const void *key, const void *base_, int num,
705 else 705 else
706 break; 706 break;
707 } 707 }
708#ifdef CHARSET_EBCDIC
709/* THIS IS A KLUDGE - Because the *_obj is sorted in ASCII order, and
710 * I don't have perl (yet), we revert to a *LINEAR* search
711 * when the object wasn't found in the binary search.
712 */
713 if (c != 0)
714 {
715 for (i=0; i<num; ++i)
716 {
717 p= &(base[i*size]);
718 c = (*cmp)(key,p);
719 if (c == 0 || (c < 0 && (flags & OBJ_BSEARCH_VALUE_ON_NOMATCH)))
720 return p;
721 }
722 }
723#endif
724 if (c != 0 && !(flags & OBJ_BSEARCH_VALUE_ON_NOMATCH)) 708 if (c != 0 && !(flags & OBJ_BSEARCH_VALUE_ON_NOMATCH))
725 p = NULL; 709 p = NULL;
726 else if (c == 0 && (flags & OBJ_BSEARCH_FIRST_VALUE_ON_MATCH)) 710 else if (c == 0 && (flags & OBJ_BSEARCH_FIRST_VALUE_ON_MATCH))
diff --git a/src/lib/libcrypto/pem/pem_lib.c b/src/lib/libcrypto/pem/pem_lib.c
index 5a421fc4b6..74baa2ec1c 100644
--- a/src/lib/libcrypto/pem/pem_lib.c
+++ b/src/lib/libcrypto/pem/pem_lib.c
@@ -382,10 +382,6 @@ int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp,
382 PEMerr(PEM_F_PEM_ASN1_WRITE_BIO,PEM_R_READ_KEY); 382 PEMerr(PEM_F_PEM_ASN1_WRITE_BIO,PEM_R_READ_KEY);
383 goto err; 383 goto err;
384 } 384 }
385#ifdef CHARSET_EBCDIC
386 /* Convert the pass phrase from EBCDIC */
387 ebcdic2ascii(buf, buf, klen);
388#endif
389 kstr=(unsigned char *)buf; 385 kstr=(unsigned char *)buf;
390 } 386 }
391 RAND_add(data,i,0);/* put in the RSA key. */ 387 RAND_add(data,i,0);/* put in the RSA key. */
@@ -458,11 +454,6 @@ int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *plen,
458 PEMerr(PEM_F_PEM_DO_HEADER,PEM_R_BAD_PASSWORD_READ); 454 PEMerr(PEM_F_PEM_DO_HEADER,PEM_R_BAD_PASSWORD_READ);
459 return(0); 455 return(0);
460 } 456 }
461#ifdef CHARSET_EBCDIC
462 /* Convert the pass phrase from EBCDIC */
463 ebcdic2ascii(buf, buf, klen);
464#endif
465
466 if (!EVP_BytesToKey(cipher->cipher,EVP_md5(),&(cipher->iv[0]), 457 if (!EVP_BytesToKey(cipher->cipher,EVP_md5(),&(cipher->iv[0]),
467 (unsigned char *)buf,klen,1,key,NULL)) 458 (unsigned char *)buf,klen,1,key,NULL))
468 return 0; 459 return 0;
@@ -516,15 +507,9 @@ int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher)
516 for (;;) 507 for (;;)
517 { 508 {
518 c= *header; 509 c= *header;
519#ifndef CHARSET_EBCDIC
520 if (!( ((c >= 'A') && (c <= 'Z')) || (c == '-') || 510 if (!( ((c >= 'A') && (c <= 'Z')) || (c == '-') ||
521 ((c >= '0') && (c <= '9')))) 511 ((c >= '0') && (c <= '9'))))
522 break; 512 break;
523#else
524 if (!( isupper(c) || (c == '-') ||
525 isdigit(c)))
526 break;
527#endif
528 header++; 513 header++;
529 } 514 }
530 *header='\0'; 515 *header='\0';
diff --git a/src/lib/libcrypto/ripemd/rmdtest.c b/src/lib/libcrypto/ripemd/rmdtest.c
index fb34e0e836..b32fda96ed 100644
--- a/src/lib/libcrypto/ripemd/rmdtest.c
+++ b/src/lib/libcrypto/ripemd/rmdtest.c
@@ -72,10 +72,6 @@ int main(int argc, char *argv[])
72#include <openssl/ripemd.h> 72#include <openssl/ripemd.h>
73#include <openssl/evp.h> 73#include <openssl/evp.h>
74 74
75#ifdef CHARSET_EBCDIC
76#include <openssl/ebcdic.h>
77#endif
78
79static char *test[]={ 75static char *test[]={
80 "", 76 "",
81 "a", 77 "a",
@@ -112,9 +108,6 @@ int main(int argc, char *argv[])
112 i=1; 108 i=1;
113 while (*P != NULL) 109 while (*P != NULL)
114 { 110 {
115#ifdef CHARSET_EBCDIC
116 ebcdic2ascii((char *)*P, (char *)*P, strlen((char *)*P));
117#endif
118 EVP_Digest(&(P[0][0]),strlen((char *)*P),md,NULL,EVP_ripemd160(), NULL); 111 EVP_Digest(&(P[0][0]),strlen((char *)*P),md,NULL,EVP_ripemd160(), NULL);
119 p=pt(md); 112 p=pt(md);
120 if (strcmp(p,(char *)*R) != 0) 113 if (strcmp(p,(char *)*R) != 0)
diff --git a/src/lib/libcrypto/sha/sha1test.c b/src/lib/libcrypto/sha/sha1test.c
index 6feb3964c7..ad9e3dc407 100644
--- a/src/lib/libcrypto/sha/sha1test.c
+++ b/src/lib/libcrypto/sha/sha1test.c
@@ -72,10 +72,6 @@ int main(int argc, char *argv[])
72#include <openssl/evp.h> 72#include <openssl/evp.h>
73#include <openssl/sha.h> 73#include <openssl/sha.h>
74 74
75#ifdef CHARSET_EBCDIC
76#include <openssl/ebcdic.h>
77#endif
78
79#undef SHA_0 /* FIPS 180 */ 75#undef SHA_0 /* FIPS 180 */
80#define SHA_1 /* FIPS 180-1 */ 76#define SHA_1 /* FIPS 180-1 */
81 77
@@ -112,11 +108,6 @@ int main(int argc, char *argv[])
112 EVP_MD_CTX c; 108 EVP_MD_CTX c;
113 unsigned char md[SHA_DIGEST_LENGTH]; 109 unsigned char md[SHA_DIGEST_LENGTH];
114 110
115#ifdef CHARSET_EBCDIC
116 ebcdic2ascii(test[0], test[0], strlen(test[0]));
117 ebcdic2ascii(test[1], test[1], strlen(test[1]));
118#endif
119
120 EVP_MD_CTX_init(&c); 111 EVP_MD_CTX_init(&c);
121 P=test; 112 P=test;
122 R=ret; 113 R=ret;
@@ -139,9 +130,6 @@ int main(int argc, char *argv[])
139 } 130 }
140 131
141 memset(buf,'a',1000); 132 memset(buf,'a',1000);
142#ifdef CHARSET_EBCDIC
143 ebcdic2ascii(buf, buf, 1000);
144#endif /*CHARSET_EBCDIC*/
145 EVP_DigestInit_ex(&c,EVP_sha1(), NULL); 133 EVP_DigestInit_ex(&c,EVP_sha1(), NULL);
146 for (i=0; i<1000; i++) 134 for (i=0; i<1000; i++)
147 EVP_DigestUpdate(&c,buf,1000); 135 EVP_DigestUpdate(&c,buf,1000);
diff --git a/src/lib/libcrypto/sha/shatest.c b/src/lib/libcrypto/sha/shatest.c
index 27614646d1..6c93c39590 100644
--- a/src/lib/libcrypto/sha/shatest.c
+++ b/src/lib/libcrypto/sha/shatest.c
@@ -72,10 +72,6 @@ int main(int argc, char *argv[])
72#include <openssl/evp.h> 72#include <openssl/evp.h>
73#include <openssl/sha.h> 73#include <openssl/sha.h>
74 74
75#ifdef CHARSET_EBCDIC
76#include <openssl/ebcdic.h>
77#endif
78
79#define SHA_0 /* FIPS 180 */ 75#define SHA_0 /* FIPS 180 */
80#undef SHA_1 /* FIPS 180-1 */ 76#undef SHA_1 /* FIPS 180-1 */
81 77
@@ -112,11 +108,6 @@ int main(int argc, char *argv[])
112 EVP_MD_CTX c; 108 EVP_MD_CTX c;
113 unsigned char md[SHA_DIGEST_LENGTH]; 109 unsigned char md[SHA_DIGEST_LENGTH];
114 110
115#ifdef CHARSET_EBCDIC
116 ebcdic2ascii(test[0], test[0], strlen(test[0]));
117 ebcdic2ascii(test[1], test[1], strlen(test[1]));
118#endif
119
120 EVP_MD_CTX_init(&c); 111 EVP_MD_CTX_init(&c);
121 P=test; 112 P=test;
122 R=ret; 113 R=ret;
@@ -139,9 +130,6 @@ int main(int argc, char *argv[])
139 } 130 }
140 131
141 memset(buf,'a',1000); 132 memset(buf,'a',1000);
142#ifdef CHARSET_EBCDIC
143 ebcdic2ascii(buf, buf, 1000);
144#endif /*CHARSET_EBCDIC*/
145 EVP_DigestInit_ex(&c,EVP_sha(), NULL); 133 EVP_DigestInit_ex(&c,EVP_sha(), NULL);
146 for (i=0; i<1000; i++) 134 for (i=0; i<1000; i++)
147 EVP_DigestUpdate(&c,buf,1000); 135 EVP_DigestUpdate(&c,buf,1000);
diff --git a/src/lib/libcrypto/x509/x509_obj.c b/src/lib/libcrypto/x509/x509_obj.c
index 21fed9f838..bcc1e7429e 100644
--- a/src/lib/libcrypto/x509/x509_obj.c
+++ b/src/lib/libcrypto/x509/x509_obj.c
@@ -75,9 +75,6 @@ int i;
75 static const char hex[17]="0123456789ABCDEF"; 75 static const char hex[17]="0123456789ABCDEF";
76 int gs_doit[4]; 76 int gs_doit[4];
77 char tmp_buf[80]; 77 char tmp_buf[80];
78#ifdef CHARSET_EBCDIC
79 char ebcdic_buf[1024];
80#endif
81 78
82 if (buf == NULL) 79 if (buf == NULL)
83 { 80 {
@@ -114,20 +111,6 @@ int i;
114 type=ne->value->type; 111 type=ne->value->type;
115 num=ne->value->length; 112 num=ne->value->length;
116 q=ne->value->data; 113 q=ne->value->data;
117#ifdef CHARSET_EBCDIC
118 if (type == V_ASN1_GENERALSTRING ||
119 type == V_ASN1_VISIBLESTRING ||
120 type == V_ASN1_PRINTABLESTRING ||
121 type == V_ASN1_TELETEXSTRING ||
122 type == V_ASN1_VISIBLESTRING ||
123 type == V_ASN1_IA5STRING) {
124 ascii2ebcdic(ebcdic_buf, q,
125 (num > sizeof ebcdic_buf)
126 ? sizeof ebcdic_buf : num);
127 q=ebcdic_buf;
128 }
129#endif
130
131 if ((type == V_ASN1_GENERALSTRING) && ((num%4) == 0)) 114 if ((type == V_ASN1_GENERALSTRING) && ((num%4) == 0))
132 { 115 {
133 gs_doit[0]=gs_doit[1]=gs_doit[2]=gs_doit[3]=0; 116 gs_doit[0]=gs_doit[1]=gs_doit[2]=gs_doit[3]=0;
@@ -149,12 +132,7 @@ int i;
149 { 132 {
150 if (!gs_doit[j&3]) continue; 133 if (!gs_doit[j&3]) continue;
151 l2++; 134 l2++;
152#ifndef CHARSET_EBCDIC
153 if ((q[j] < ' ') || (q[j] > '~')) l2+=3; 135 if ((q[j] < ' ') || (q[j] > '~')) l2+=3;
154#else
155 if ((os_toascii[q[j]] < os_toascii[' ']) ||
156 (os_toascii[q[j]] > os_toascii['~'])) l2+=3;
157#endif
158 } 136 }
159 137
160 lold=l; 138 lold=l;
@@ -173,15 +151,10 @@ int i;
173 *(p++)='/'; 151 *(p++)='/';
174 memcpy(p,s,(unsigned int)l1); p+=l1; 152 memcpy(p,s,(unsigned int)l1); p+=l1;
175 *(p++)='='; 153 *(p++)='=';
176
177#ifndef CHARSET_EBCDIC /* q was assigned above already. */
178 q=ne->value->data; 154 q=ne->value->data;
179#endif
180
181 for (j=0; j<num; j++) 155 for (j=0; j<num; j++)
182 { 156 {
183 if (!gs_doit[j&3]) continue; 157 if (!gs_doit[j&3]) continue;
184#ifndef CHARSET_EBCDIC
185 n=q[j]; 158 n=q[j];
186 if ((n < ' ') || (n > '~')) 159 if ((n < ' ') || (n > '~'))
187 { 160 {
@@ -192,19 +165,6 @@ int i;
192 } 165 }
193 else 166 else
194 *(p++)=n; 167 *(p++)=n;
195#else
196 n=os_toascii[q[j]];
197 if ((n < os_toascii[' ']) ||
198 (n > os_toascii['~']))
199 {
200 *(p++)='\\';
201 *(p++)='x';
202 *(p++)=hex[(n>>4)&0x0f];
203 *(p++)=hex[n&0x0f];
204 }
205 else
206 *(p++)=q[j];
207#endif
208 } 168 }
209 *p='\0'; 169 *p='\0';
210 } 170 }
diff --git a/src/lib/libcrypto/x509v3/v3_ia5.c b/src/lib/libcrypto/x509v3/v3_ia5.c
index 4ff12b52b5..ab1c5188b8 100644
--- a/src/lib/libcrypto/x509v3/v3_ia5.c
+++ b/src/lib/libcrypto/x509v3/v3_ia5.c
@@ -105,9 +105,6 @@ static ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method,
105 M_ASN1_IA5STRING_free(ia5); 105 M_ASN1_IA5STRING_free(ia5);
106 goto err; 106 goto err;
107 } 107 }
108#ifdef CHARSET_EBCDIC
109 ebcdic2ascii(ia5->data, ia5->data, ia5->length);
110#endif /*CHARSET_EBCDIC*/
111 return ia5; 108 return ia5;
112 err: 109 err:
113 X509V3err(X509V3_F_S2I_ASN1_IA5STRING,ERR_R_MALLOC_FAILURE); 110 X509V3err(X509V3_F_S2I_ASN1_IA5STRING,ERR_R_MALLOC_FAILURE);
diff --git a/src/lib/libcrypto/x509v3/v3_prn.c b/src/lib/libcrypto/x509v3/v3_prn.c
index 3146218708..2124b447b4 100644
--- a/src/lib/libcrypto/x509v3/v3_prn.c
+++ b/src/lib/libcrypto/x509v3/v3_prn.c
@@ -83,22 +83,7 @@ void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, int ml)
83 nval = sk_CONF_VALUE_value(val, i); 83 nval = sk_CONF_VALUE_value(val, i);
84 if(!nval->name) BIO_puts(out, nval->value); 84 if(!nval->name) BIO_puts(out, nval->value);
85 else if(!nval->value) BIO_puts(out, nval->name); 85 else if(!nval->value) BIO_puts(out, nval->name);
86#ifndef CHARSET_EBCDIC
87 else BIO_printf(out, "%s:%s", nval->name, nval->value); 86 else BIO_printf(out, "%s:%s", nval->name, nval->value);
88#else
89 else {
90 int len;
91 char *tmp;
92 len = strlen(nval->value)+1;
93 tmp = OPENSSL_malloc(len);
94 if (tmp)
95 {
96 ascii2ebcdic(tmp, nval->value, len);
97 BIO_printf(out, "%s:%s", nval->name, tmp);
98 OPENSSL_free(tmp);
99 }
100 }
101#endif
102 if(ml) BIO_puts(out, "\n"); 87 if(ml) BIO_puts(out, "\n");
103 } 88 }
104} 89}
@@ -127,22 +112,7 @@ int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int inde
127 ok = 0; 112 ok = 0;
128 goto err; 113 goto err;
129 } 114 }
130#ifndef CHARSET_EBCDIC
131 BIO_printf(out, "%*s%s", indent, "", value); 115 BIO_printf(out, "%*s%s", indent, "", value);
132#else
133 {
134 int len;
135 char *tmp;
136 len = strlen(value)+1;
137 tmp = OPENSSL_malloc(len);
138 if (tmp)
139 {
140 ascii2ebcdic(tmp, value, len);
141 BIO_printf(out, "%*s%s", indent, "", tmp);
142 OPENSSL_free(tmp);
143 }
144 }
145#endif
146 } else if(method->i2v) { 116 } else if(method->i2v) {
147 if(!(nval = method->i2v(method, ext_str, NULL))) { 117 if(!(nval = method->i2v(method, ext_str, NULL))) {
148 ok = 0; 118 ok = 0;
diff --git a/src/lib/libcrypto/x509v3/v3_utl.c b/src/lib/libcrypto/x509v3/v3_utl.c
index e030234540..c4b6143eff 100644
--- a/src/lib/libcrypto/x509v3/v3_utl.c
+++ b/src/lib/libcrypto/x509v3/v3_utl.c
@@ -378,10 +378,6 @@ char *hex_to_string(const unsigned char *buffer, long len)
378 *q++ = ':'; 378 *q++ = ':';
379 } 379 }
380 q[-1] = 0; 380 q[-1] = 0;
381#ifdef CHARSET_EBCDIC
382 ebcdic2ascii(tmp, tmp, q - tmp - 1);
383#endif
384
385 return tmp; 381 return tmp;
386} 382}
387 383
@@ -400,14 +396,8 @@ unsigned char *string_to_hex(const char *str, long *len)
400 if(!(hexbuf = OPENSSL_malloc(strlen(str) >> 1))) goto err; 396 if(!(hexbuf = OPENSSL_malloc(strlen(str) >> 1))) goto err;
401 for(p = (unsigned char *)str, q = hexbuf; *p;) { 397 for(p = (unsigned char *)str, q = hexbuf; *p;) {
402 ch = *p++; 398 ch = *p++;
403#ifdef CHARSET_EBCDIC
404 ch = os_toebcdic[ch];
405#endif
406 if(ch == ':') continue; 399 if(ch == ':') continue;
407 cl = *p++; 400 cl = *p++;
408#ifdef CHARSET_EBCDIC
409 cl = os_toebcdic[cl];
410#endif
411 if(!cl) { 401 if(!cl) {
412 X509V3err(X509V3_F_STRING_TO_HEX,X509V3_R_ODD_NUMBER_OF_DIGITS); 402 X509V3err(X509V3_F_STRING_TO_HEX,X509V3_R_ODD_NUMBER_OF_DIGITS);
413 OPENSSL_free(hexbuf); 403 OPENSSL_free(hexbuf);
@@ -844,21 +834,13 @@ int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE)*dn_sk,
844 * multiple instances 834 * multiple instances
845 */ 835 */
846 for(p = type; *p ; p++) 836 for(p = type; *p ; p++)
847#ifndef CHARSET_EBCDIC
848 if ((*p == ':') || (*p == ',') || (*p == '.')) 837 if ((*p == ':') || (*p == ',') || (*p == '.'))
849#else
850 if ((*p == os_toascii[':']) || (*p == os_toascii[',']) || (*p == os_toascii['.']))
851#endif
852 { 838 {
853 p++; 839 p++;
854 if(*p) type = p; 840 if(*p) type = p;
855 break; 841 break;
856 } 842 }
857#ifndef CHARSET_EBCDIC
858 if (*type == '+') 843 if (*type == '+')
859#else
860 if (*type == os_toascii['+'])
861#endif
862 { 844 {
863 mval = -1; 845 mval = -1;
864 type++; 846 type++;