The appended patch adds EBCDIC support (as well as BS2000/OSD-POSIX support)
to OpenSSL-0.9.2b. Sorry that I didn't update the patch to 0.9.3 yet, but so
many things have changed that I didn't find the time to update yet.
However, the patch works as follows:
@) First of all: this is a WIP version. Though it is a Siemens contribution
to the Open Source, it is an alpha version, not the official version used
by Siemens. Bugs might (and will) be found and be fixed. The main reason
I'm sending this today is that many people have asked for it, and I'd
appreciate any help in forward-porting of this to the current
OpenSSL-0.9.3. Furthermore, I'm on vacation for two weeks now and didn't
want to delay this any longer. Feedback in any form is welcome, of
course. (Send beer barrels to my vacation site near Venice, please ;-)
a) two new files were added: ebcdic.c and ebcdic.h. I copied the ebcdic.c
from the Apache sources (I knew they worked since I made them for apache)
and ebcdich is a thin wrapper which renames the entries to avoid name
clashes in environments where multiple ebcdic2ascii() fnctions might
appear (in various libraries, possibly modified, whatever).
b) the patch tries to keep the internal ASCII representation wherever
possible, converting only at places where the external representation of
objects is required (most notably, the X509_NAME_oneline() function).
Similarly, when objects are checked against valid values (like, numeric
strings in the UTCTM case), comparisons have to be applied where
appropriate.
The crypto algorithms have not been modified; their user interface has,
of course: where the test programs feed ASCII strings into the alorithms,
I had to apply an EBCDIC-to-ASCII conversion beforehand.
SSL uses "meta-string-constants" in the SSL initialization phase. These
were converted to their "binary coded" strings so that the protocol
wouldn't encounter protocol errors early on.
c) The apps and test section was overhauled as well. Without claiming to
have a test 100% coverage (you may assist me in testing: 1000 eyes see
more than 2), most usage scenarios work quite well. The s_server demo and
the s_client utility have been adapted and can be used in the EBCDIC
environment as well. (Not much was done to check the Content-Type and
decide whether conversion has to be applied or not: everything is assumed
to be text).
d) All changes which are specific for all EBCDIC platforms are wrapped in
#ifdef CHARSET_EBCDIC blocks. However, some IBM'er might want to test
whether the #else branch in ebcdic.c actually works for IBM machines.
e) All changes which are BS2000 specific are wrapped into #ifdef _OSD_POSIX
which is a predefined compiler symbol on BS2000.
Have fun, tell me if/how you could use it!
Martin
--
<[EMAIL PROTECTED]> | Siemens Information and
Phone: +49-89-636-46021 | Communication Products
FAX: +49-89-636-47816 | 81730 Munich, Germany
#ifndef _EBCDIC_H_
#define _EBCDIC_H_ "$Id$"
#include <sys/types.h>
/* Avoid name clashes with other applications */
#define os_toascii _eay2000_os_toascii
#define os_toebcdic _eay2000_os_toebcdic
#define ebcdic2ascii _eay2000_ebcdic2ascii
#define ascii2ebcdic _eay2000_ascii2ebcdic
extern const unsigned char os_toascii[256];
extern const unsigned char os_toebcdic[256];
void ebcdic2ascii(unsigned char *dest, const unsigned char *srce, size_t count);
void ascii2ebcdic(unsigned char *dest, const unsigned char *srce, size_t count);
#endif /* _EBCDIC_H_ */
/* ====================================================================
* Copyright (c) 1998 The Apache Group. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the Apache Group
* for use in the Apache HTTP server project (http://www.apache.org/)."
*
* 4. The names "Apache Server" and "Apache Group" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the Apache Group
* for use in the Apache HTTP server project (http://www.apache.org/)."
*
* THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Group and was originally based
* on public domain software written at the National Center for
* Supercomputing Applications, University of Illinois, Urbana-Champaign.
* For more information on the Apache Group and the Apache HTTP server
* project, please see <http://www.apache.org/>.
*
*/
#ifdef CHARSET_EBCDIC
#include "ebcdic.h"
/* Initial Port for Apache-1.3 by <[EMAIL PROTECTED]>
* Adapted for OpenSSL-0.9.2b by <[EMAIL PROTECTED]>
*/
#ifdef _OSD_POSIX
/*
"BS2000 OSD" is a POSIX subsystem on a main frame.
It is made by Siemens AG, Germany, for their BS2000 mainframe machines.
Within the POSIX subsystem, the same character set was chosen as in
"native BS2000", namely EBCDIC. (EDF03)
The name "ASCII" in these routines is misleading: actually, conversion
is not between EBCDIC and ASCII, but EBCDIC(EDF03) and ISO-8859.1;
that means that (western european) national characters are preserved.
*/
/* Here's the bijective ebcdic-to-ascii table: */
const unsigned char os_toascii[256] = {
/*00*/ 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f,
0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*................*/
/*10*/ 0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97,
0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /*................*/
/*20*/ 0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b,
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /*................*/
/*30*/ 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /*................*/
/*40*/ 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
0xe7, 0xf1, 0x60, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* .........`.<(+|*/
/*50*/ 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x9f, /*&.........!$*);.*/
/*60*/ 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
0xc7, 0xd1, 0x5e, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /*-/........^,%_>?*/
/*70*/ 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
0xcc, 0xa8, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /*..........:#@'="*/
/*80*/ 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /*.abcdefghi......*/
/*90*/ 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /*.jklmnopqr......*/
/*a0*/ 0xb5, 0xaf, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae, /*..stuvwxyz......*/
/*b0*/ 0xa2, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
0xbd, 0xbe, 0xac, 0x5b, 0x5c, 0x5d, 0xb4, 0xd7, /*...........[\]..*/
/*c0*/ 0xf9, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /*.ABCDEFGHI......*/
/*d0*/ 0xa6, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xdb, 0xfa, 0xff, /*.JKLMNOPQR......*/
/*e0*/ 0xd9, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /*..STUVWXYZ......*/
/*f0*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0xb3, 0x7b, 0xdc, 0x7d, 0xda, 0x7e /*0123456789.{.}.~*/
};
/* The ascii-to-ebcdic table: */
const unsigned char os_toebcdic[256] = {
/*00*/ 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f,
0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*................*/
/*10*/ 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26,
0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, /*................*/
/*20*/ 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d,
0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /* !"#$%&'()*+,-./ */
/*30*/ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /*0123456789:;<=>?*/
/*40*/ 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /*@ABCDEFGHIJKLMNO*/
/*50*/ 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
0xe7, 0xe8, 0xe9, 0xbb, 0xbc, 0xbd, 0x6a, 0x6d, /*PQRSTUVWXYZ[\]^_*/
/*60*/ 0x4a, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /*`abcdefghijklmno*/
/*70*/ 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
0xa7, 0xa8, 0xa9, 0xfb, 0x4f, 0xfd, 0xff, 0x07, /*pqrstuvwxyz{|}~.*/
/*80*/ 0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08,
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14, /*................*/
/*90*/ 0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17,
0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0x5f, /*................*/
/*a0*/ 0x41, 0xaa, 0xb0, 0xb1, 0x9f, 0xb2, 0xd0, 0xb5,
0x79, 0xb4, 0x9a, 0x8a, 0xba, 0xca, 0xaf, 0xa1, /*................*/
/*b0*/ 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3,
0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, /*................*/
/*c0*/ 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68,
0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /*................*/
/*d0*/ 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf,
0x80, 0xe0, 0xfe, 0xdd, 0xfc, 0xad, 0xae, 0x59, /*................*/
/*e0*/ 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48,
0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /*................*/
/*f0*/ 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1,
0x70, 0xc0, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf /*................*/
};
#else /*_OSD_POSIX*/
/*
This code does basic character mapping for IBM's TPF operating system.
It is a modified version of <[EMAIL PROTECTED]>'s code for
the BS2000 (apache/src/os/bs2000/ebcdic.c).
*/
/*
Bijective EBCDIC (character set IBM-1047) to US-ASCII table:
This table is bijective - there are no ambigous or duplicate characters.
*/
const unsigned char os_toascii[256] = {
0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f, /* 00-0f: */
0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97, /* 10-1f: */
0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b, /* 20-2f: */
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /* ................ */
0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30-3f: */
0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /* ................ */
0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5, /* 40-4f: */
0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* ...........<(+| */
0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef, /* 50-5f: */
0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x5e, /* &.........!$*);^ */
0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5, /* 60-6f: */
0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /* -/.........,%_>? */
0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf, /* 70-7f: */
0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /* .........`:#@'=" */
0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80-8f: */
0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /* .abcdefghi...... */
0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* 90-9f: */
0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /* .jklmnopqr...... */
0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* a0-af: */
0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0x5b, 0xde, 0xae, /* .~stuvwxyz...[.. */
0xac, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc, /* b0-bf: */
0xbd, 0xbe, 0xdd, 0xa8, 0xaf, 0x5d, 0xb4, 0xd7, /* .............].. */
0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* c0-cf: */
0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /* {ABCDEFGHI...... */
0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* d0-df: */
0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, /* }JKLMNOPQR...... */
0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* e0-ef: */
0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /* \.STUVWXYZ...... */
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* f0-ff: */
0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x9f /* 0123456789...... */
};
/*
The US-ASCII to EBCDIC (character set IBM-1047) table:
This table is bijective (no ambiguous or duplicate characters)
*/
const unsigned char os_toebcdic[256] = {
0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, /* 00-0f: */
0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, /* 10-1f: */
0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, /* 20-2f: */
0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /* !"#$%&'()*+,-./ */
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 30-3f: */
0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /* 0123456789:;<=>? */
0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 40-4f: */
0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /* @ABCDEFGHIJKLMNO */
0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, /* 50-5f: */
0xe7, 0xe8, 0xe9, 0xad, 0xe0, 0xbd, 0x5f, 0x6d, /* PQRSTUVWXYZ[\]^_ */
0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60-6f: */
0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* `abcdefghijklmno */
0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, /* 70-7f: */
0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07, /* pqrstuvwxyz{|}~. */
0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08, /* 80-8f: */
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14, /* ................ */
0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17, /* 90-9f: */
0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0xff, /* ................ */
0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5, /* a0-af: */
0xbb, 0xb4, 0x9a, 0x8a, 0xb0, 0xca, 0xaf, 0xbc, /* ................ */
0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3, /* b0-bf: */
0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, /* ................ */
0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68, /* c0-cf: */
0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* ................ */
0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf, /* d0-df: */
0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xba, 0xae, 0x59, /* ................ */
0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48, /* e0-ef: */
0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* ................ */
0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1, /* f0-ff: */
0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf /* ................ */
};
#endif /*_OSD_POSIX*/
/* Translate a memory block from EBCDIC (host charset) to ASCII (net charset)
* dest and srce may be identical, or separate memory blocks, but
* should not overlap.
*/
void
ebcdic2ascii(unsigned char *dest, const unsigned char *srce, size_t count)
{
while (count-- != 0) {
*dest++ = os_toascii[*srce++];
}
}
void
ascii2ebcdic(unsigned char *dest, const unsigned char *srce, size_t count)
{
while (count-- != 0) {
*dest++ = os_toebcdic[*srce++];
}
}
#endif /*CHARSET_EBCDIC*/
Index: Configure
===================================================================
RCS file: /home/cvs/OpenSSL.Org/Configure,v
retrieving revision 1.30
diff -u -r1.30 Configure
--- Configure 1999/03/12 20:31:13 1.30
+++ Configure 1999/05/28 10:16:47
@@ -1,4 +1,4 @@
-:
+#!/usr/local/bin/perl
eval 'exec perl -S $0 ${1+"$@"}'
if $running_under_some_shell;
##
@@ -206,6 +206,9 @@
# Sinix RM400
"SINIX-N","/usr/ucb/cc:-O2 -misaligned:-lucb:RC4_INDEX RC4_CHAR:::",
+
+# SIEMENS BS2000/OSD: an EBCDIC-based mainframe
+"BS2000-OSD","c89:-XLLML -XLLMK -XL -DB_ENDIAN -DTERMIOS -DCHARSET_EBCDIC:-lsocket
+-lnsl:THIRTY_TWO_BIT DES_PTR DES_UNROLL MD2_CHAR RC4_INDEX RC4_CHAR BF_PTR:::",
# Windows NT, Microsoft Visual C++ 4.0
Index: config
===================================================================
RCS file: /home/cvs/OpenSSL.Org/config,v
retrieving revision 1.3
diff -u -r1.3 config
--- config 1999/01/17 14:20:20 1.3
+++ config 1999/05/28 10:16:47
@@ -201,6 +201,10 @@
echo "${MACHINE}-sni-sysv4"; exit 0
;;
+ POSIX-BC*)
+ echo "${MACHINE}-siemens-sysv4"; exit 0 # Here, $MACHINE == "BS2000"
+ ;;
+
machten:*)
echo "${MACHINE}-tenon-${SYSTEM}"; exit 0;
;;
@@ -319,6 +323,7 @@
*-*-openbsd) OUT="OpenBSD" ;;
*-*-osf) OUT="alpha-cc" ;;
*-*-unixware*) OUT="unixware-2.0" ;;
+ BS2000-siemens-sysv4) OUT="BS2000-OSD" ;;
*-sni-sysv4) OUT="SINIX" ;;
*-hpux*) OUT="hpux-$CC" ;;
# these are all covered by the catchall below
Index: apps/req.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/apps/req.c,v
retrieving revision 1.15
diff -u -r1.15 req.c
--- req.c 1999/03/06 19:33:24 1.15
+++ req.c 1999/05/28 10:16:49
@@ -1032,6 +1032,9 @@
j=ASN1_PRINTABLE_type((unsigned char *)buf,-1);
if (req_fix_data(nid,&j,i,min,max) == 0)
goto err;
+#ifdef CHARSET_EBCDIC
+ ebcdic2ascii(buf, buf, i);
+#endif /*CHARSET_EBCDIC*/
if ((ne=X509_NAME_ENTRY_create_by_NID(NULL,nid,j,(unsigned char *)buf,
strlen(buf)))
== NULL) goto err;
Index: apps/s_client.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/apps/s_client.c,v
retrieving revision 1.4
diff -u -r1.4 s_client.c
--- s_client.c 1999/02/15 21:05:17 1.4
+++ s_client.c 1999/05/28 10:16:49
@@ -528,6 +528,9 @@
#ifndef WINDOWS
else if (FD_ISSET(fileno(stdout),&writefds))
{
+#ifdef CHARSET_EBCDIC
+ ascii2ebcdic(&(sbuf[sbuf_off]),&(sbuf[sbuf_off]),sbuf_len);
+#endif
i=write(fileno(stdout),&(sbuf[sbuf_off]),sbuf_len);
if (i <= 0)
@@ -621,6 +624,9 @@
{
cbuf_len=i;
cbuf_off=0;
+#ifdef CHARSET_EBCDIC
+ ebcdic2ascii(cbuf, cbuf, i);
+#endif
}
read_tty=0;
Index: apps/s_server.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/apps/s_server.c,v
retrieving revision 1.8
diff -u -r1.8 s_server.c
--- s_server.c 1999/03/22 12:21:14 1.8
+++ s_server.c 1999/05/28 10:16:49
@@ -226,6 +226,163 @@
static char **local_argv;
static int hack=0;
+#ifdef CHARSET_EBCDIC
+static int ebcdic_new(BIO *bi);
+static int ebcdic_free(BIO *a);
+static int ebcdic_read(BIO *b, char *out, int outl);
+static int ebcdic_write(BIO *b, char *in, int inl);
+static long ebcdic_ctrl(BIO *b, int cmd, long num, char *ptr);
+static int ebcdic_gets(BIO *bp, char *buf, int size);
+static int ebcdic_puts(BIO *bp, char *str);
+
+#define BIO_TYPE_EBCDIC_FILTER (18|0x0200)
+static BIO_METHOD methods_ebcdic=
+ {
+ BIO_TYPE_EBCDIC_FILTER,
+ "EBCDIC/ASCII filter",
+ ebcdic_write,
+ ebcdic_read,
+ ebcdic_puts,
+ ebcdic_gets,
+ ebcdic_ctrl,
+ ebcdic_new,
+ ebcdic_free,
+ };
+
+typedef struct
+{
+ size_t alloced;
+ char buff[1];
+} EBCDIC_OUTBUFF;
+
+BIO_METHOD *BIO_f_ebcdic_filter()
+{
+ return(&methods_ebcdic);
+}
+
+static int
+ebcdic_new(BIO *bi)
+{
+ EBCDIC_OUTBUFF *wbuf;
+
+ wbuf = (EBCDIC_OUTBUFF *)Malloc(sizeof(EBCDIC_OUTBUFF) + 1024);
+ wbuf->alloced = 1024;
+ wbuf->buff[0] = '\0';
+
+ bi->ptr=(char *)wbuf;
+ bi->init=1;
+ bi->flags=0;
+ return(1);
+}
+
+static int
+ebcdic_free(BIO *a)
+{
+ if (a == NULL) return(0);
+ if (a->ptr != NULL)
+ Free(a->ptr);
+ a->ptr=NULL;
+ a->init=0;
+ a->flags=0;
+ return(1);
+}
+
+static int
+ebcdic_read(BIO *b, char *out, int outl)
+{
+ int ret=0;
+
+ if (out == NULL || outl == 0) return(0);
+ if (b->next_bio == NULL) return(0);
+
+ ret=BIO_read(b->next_bio,out,outl);
+ if (ret > 0)
+ ascii2ebcdic(out,out,ret);
+ return(ret);
+}
+
+static int
+ebcdic_write(BIO *b, char *in, int inl)
+{
+ EBCDIC_OUTBUFF *wbuf;
+ int ret=0;
+ int num;
+ unsigned char n;
+
+ if ((in == NULL) || (inl <= 0)) return(0);
+ if (b->next_bio == NULL) return(0);
+
+ wbuf=(EBCDIC_OUTBUFF *)b->ptr;
+
+ if (inl > (num = wbuf->alloced))
+ {
+ num = num + num; /* double the size */
+ if (num < inl)
+ num = inl;
+ Free((char*)wbuf);
+ wbuf=(EBCDIC_OUTBUFF *)Malloc(sizeof(EBCDIC_OUTBUFF) + num);
+
+ wbuf->alloced = num;
+ wbuf->buff[0] = '\0';
+
+ b->ptr=(char *)wbuf;
+ }
+
+ ebcdic2ascii(wbuf->buff, in, inl);
+
+ ret=BIO_write(b->next_bio, wbuf->buff, inl);
+
+ return(ret);
+}
+
+static long
+ebcdic_ctrl(BIO *b, int cmd, long num, char *ptr)
+{
+ long ret;
+
+ if (b->next_bio == NULL) return(0);
+ switch (cmd)
+ {
+ case BIO_CTRL_DUP:
+ ret=0L;
+ break;
+ default:
+ ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
+ break;
+ }
+ return(ret);
+}
+
+static int
+ebcdic_gets(BIO *bp, char *buf, int size)
+{
+ int i, ret;
+ if (bp->next_bio == NULL) return(0);
+/* return(BIO_gets(bp->next_bio,buf,size));*/
+ for (i=0; i<size-1; ++i)
+ {
+ ret = ebcdic_read(bp,&buf[i],1);
+ if (ret <= 0)
+ break;
+ else if (buf[i] == '\n')
+ {
+ ++i;
+ break;
+ }
+ }
+ if (i < size)
+ buf[i] = '\0';
+ return (ret < 0 && i == 0) ? ret : i;
+}
+
+
+static int ebcdic_puts(BIO *bp, char *str)
+{
+ if (bp->next_bio == NULL) return(0);
+ return ebcdic_write(bp, str, strlen(str));
+}
+#endif
+
int MAIN(argc, argv)
int argc;
char *argv[];
@@ -679,6 +836,9 @@
print_stats(bio_s_out,SSL_get_SSL_CTX(con));
}
}
+#ifdef CHARSET_EBCDIC
+ ebcdic2ascii(buf,buf,i);
+#endif /*CHARSET_EBCDIC*/
l=k=0;
for (;;)
{
@@ -737,6 +897,9 @@
switch (SSL_get_error(con,i))
{
case SSL_ERROR_NONE:
+#ifdef CHARSET_EBCDIC
+ ascii2ebcdic(buf,buf,i);
+#endif /*CHARSET_EBCDIC*/
write(fileno(stdout),buf,
(unsigned int)i);
if (SSL_pending(con)) goto again;
@@ -933,6 +1096,9 @@
/* SSL_set_fd(con,s); */
BIO_set_ssl(ssl_bio,con,BIO_CLOSE);
BIO_push(io,ssl_bio);
+#ifdef CHARSET_EBCDIC
+ io = BIO_push(BIO_new(BIO_f_ebcdic_filter()),io);
+#endif /*CHARSET_EBCDIC*/
if (s_debug)
{
@@ -1002,7 +1168,7 @@
static char *space=" ";
BIO_puts(io,"HTTP/1.0 200 ok\r\nContent-type:
text/html\r\n\r\n");
- BIO_puts(io,"<HTML><BODY BGCOLOR=ffffff>\n");
+ BIO_puts(io,"<HTML><BODY BGCOLOR=\"#ffffff\">\n");
BIO_puts(io,"<pre>\n");
/* BIO_puts(io,SSLeay_version(SSLEAY_VERSION));*/
BIO_puts(io,"\n");
@@ -1074,7 +1240,7 @@
BIO_puts(io,"</BODY></HTML>\r\n\r\n");
break;
}
- else if ((www == 2) && (strncmp("GET ",buf,4) == 0))
+ else if ((www == 2) && (strncmp("GET /",buf,5) == 0))
{
BIO *file;
char *p,*e;
Index: crypto/Makefile.ssl
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/Makefile.ssl,v
retrieving revision 1.16
diff -u -r1.16 Makefile.ssl
--- Makefile.ssl 1999/03/22 12:21:17 1.16
+++ Makefile.ssl 1999/05/28 10:16:53
@@ -34,12 +34,12 @@
GENERAL=Makefile README
LIB= $(TOP)/libcrypto.a
-LIBSRC= cryptlib.c mem.c cversion.c ex_data.c tmdiff.c $(ERRC).c
-LIBOBJ= cryptlib.o mem.o cversion.o ex_data.o tmdiff.o $(ERRC).o
+LIBSRC= cryptlib.c mem.c cversion.c ex_data.c tmdiff.c $(ERRC).c ebcdic.c
+LIBOBJ= cryptlib.o mem.o cversion.o ex_data.o tmdiff.o $(ERRC).o ebcdic.o
SRC= $(LIBSRC)
-EXHEADER= crypto.h cryptall.h tmdiff.h opensslv.h
+EXHEADER= crypto.h cryptall.h tmdiff.h opensslv.h ebcdic.h
HEADER= cryptlib.h date.h $(EXHEADER)
ALL= $(GENERAL) $(SRC) $(HEADER)
Index: crypto/crypto.h
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/crypto.h,v
retrieving revision 1.5
diff -u -r1.5 crypto.h
--- crypto.h 1999/03/22 12:21:17 1.5
+++ crypto.h 1999/05/28 10:16:53
@@ -65,6 +65,9 @@
#include "stack.h"
#include "opensslv.h"
+#ifdef CHARSET_EBCDIC
+#include "ebcdic.h"
+#endif /* CHARSET_EBCDIC */
/* Backward compatibility to SSLeay */
/* This is more to be used to check the correct DLL is being used
Index: crypto/asn1/a_gentm.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/asn1/a_gentm.c,v
retrieving revision 1.1
diff -u -r1.1 a_gentm.c
--- a_gentm.c 1999/01/17 00:13:14 1.1
+++ a_gentm.c 1999/05/28 10:16:54
@@ -71,6 +71,18 @@
ASN1_GENERALIZEDTIME *a;
unsigned char **pp;
{
+#ifdef CHARSET_EBCDIC
+ /* KLUDGE! We convert to ascii before writing DER */
+ int len;
+ char tmp[24];
+ ASN1_STRING tmpstr = *(ASN1_STRING *)a;
+
+ len = tmpstr.length;
+ ebcdic2ascii(tmp, tmpstr.data, (len >= sizeof tmp) ? sizeof tmp : len);
+ tmpstr.data = tmp;
+
+ a = (ASN1_GENERALIZEDTIME *) &tmpstr;
+#endif /*CHARSET_EBCDIC*/
return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
V_ASN1_GENERALIZEDTIME,V_ASN1_UNIVERSAL));
}
@@ -90,6 +102,9 @@
ASN1err(ASN1_F_D2I_ASN1_GENERALIZEDTIME,ERR_R_NESTED_ASN1_ERROR);
return(NULL);
}
+#ifdef CHARSET_EBCDIC
+ ascii2ebcdic(ret->data, ret->data, ret->length);
+#endif /*CHARSET_EBCDIC*/
if (!ASN1_GENERALIZEDTIME_check(ret))
{
ASN1err(ASN1_F_D2I_ASN1_GENERALIZEDTIME,ASN1_R_INVALID_TIME_FORMAT);
@@ -213,5 +228,8 @@
ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec);
s->length=strlen(p);
s->type=V_ASN1_GENERALIZEDTIME;
+#ifdef CHARSET_EBCDIC_not
+ ebcdic2ascii(s->data, s->data, s->length);
+#endif /*CHARSET_EBCDIC*/
return(s);
}
Index: crypto/asn1/a_print.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/asn1/a_print.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 a_print.c
--- a_print.c 1998/12/21 10:54:29 1.1.1.2
+++ a_print.c 1999/05/28 10:16:54
@@ -112,6 +112,7 @@
while ((*s) && (len-- != 0))
{
c= *(s++);
+#ifndef CHARSET_EBCDIC
if (!( ((c >= 'a') && (c <= 'z')) ||
((c >= 'A') && (c <= 'Z')) ||
(c == ' ') ||
@@ -125,6 +126,13 @@
ia5=1;
if (c&0x80)
t61=1;
+#else /*CHARSET_EBCDIC*/
+ if (!isalnum(c) && (c != ' ') &&
+ strchr("'()+,-./:=?", c) == NULL)
+ ia5=1;
+ if (os_toascii[c] & 0x80)
+ t61=1;
+#endif /*CHARSET_EBCDIC*/
}
if (t61) return(V_ASN1_T61STRING);
if (ia5) return(V_ASN1_IA5STRING);
Index: crypto/asn1/a_time.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/asn1/a_time.c,v
retrieving revision 1.1
diff -u -r1.1 a_time.c
--- a_time.c 1999/01/17 00:13:14 1.1
+++ a_time.c 1999/05/28 10:16:54
@@ -70,6 +70,21 @@
ASN1_TIME *a;
unsigned char **pp;
{
+#ifdef CHARSET_EBCDIC
+ /* KLUDGE! We convert to ascii before writing DER */
+ char tmp[24];
+ ASN1_STRING tmpstr;
+
+ if(a->type == V_ASN1_UTCTIME || a->type == V_ASN1_GENERALIZEDTIME) {
+ int len;
+
+ tmpstr = *(ASN1_STRING *)a;
+ len = tmpstr.length;
+ ebcdic2ascii(tmp, tmpstr.data, (len >= sizeof tmp) ? sizeof tmp : len);
+ tmpstr.data = tmp;
+ a = (ASN1_GENERALIZEDTIME *) &tmpstr;
+ }
+#endif /*CHARSET_EBCDIC*/
if(a->type == V_ASN1_UTCTIME || a->type == V_ASN1_GENERALIZEDTIME)
return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
a->type ,V_ASN1_UNIVERSAL));
Index: crypto/asn1/a_utctm.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/asn1/a_utctm.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 a_utctm.c
--- a_utctm.c 1998/12/21 10:58:43 1.1.1.3
+++ a_utctm.c 1999/05/28 10:16:54
@@ -69,8 +69,20 @@
ASN1_UTCTIME *a;
unsigned char **pp;
{
+#ifndef CHARSET_EBCDIC
return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
V_ASN1_UTCTIME,V_ASN1_UNIVERSAL));
+#else /*CHARSET_EBCDIC*/
+ /* KLUDGE! We convert to ascii before writing DER */
+ int len;
+ char tmp[24];
+ ASN1_STRING x = *(ASN1_STRING *)a;
+
+ len = x.length;
+ ebcdic2ascii(tmp, x.data, (len >= sizeof tmp) ? sizeof tmp : len);
+ x.data = tmp;
+ return i2d_ASN1_bytes(&x, pp, V_ASN1_UTCTIME,V_ASN1_UNIVERSAL);
+#endif /*CHARSET_EBCDIC*/
}
@@ -88,6 +100,9 @@
ASN1err(ASN1_F_D2I_ASN1_UTCTIME,ERR_R_NESTED_ASN1_ERROR);
return(NULL);
}
+#ifdef CHARSET_EBCDIC
+ ascii2ebcdic(ret->data, ret->data, ret->length);
+#endif /*CHARSET_EBCDIC*/
if (!ASN1_UTCTIME_check(ret))
{
ASN1err(ASN1_F_D2I_ASN1_UTCTIME,ASN1_R_INVALID_TIME_FORMAT);
@@ -208,5 +223,8 @@
ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec);
s->length=strlen(p);
s->type=V_ASN1_UTCTIME;
+#ifdef CHARSET_EBCDIC_not
+ ebcdic2ascii(s->data, s->data, s->length);
+#endif /*CHARSET_EBCDIC*/
return(s);
}
Index: crypto/asn1/f_int.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/asn1/f_int.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 f_int.c
--- f_int.c 1998/12/21 10:54:31 1.1.1.2
+++ f_int.c 1999/05/28 10:16:54
@@ -123,9 +123,18 @@
for (j=0; j<i; j++)
{
+#ifndef CHARSET_EBCDIC
if (!( ((buf[j] >= '0') && (buf[j] <= '9')) ||
((buf[j] >= 'a') && (buf[j] <= 'f')) ||
((buf[j] >= 'A') && (buf[j] <= 'F'))))
+#else /*CHARSET_EBCDIC*/
+ /* This #ifdef is not strictly necessary, since
+ * the characters A...F a...f 0...9 are contiguous
+ * (yes, even in EBCDIC - but not the whole alphabet).
+ * Nevertheless, isxdigit() is faster.
+ */
+ if (!isxdigit(buf[j]))
+#endif /*CHARSET_EBCDIC*/
{
i=j;
break;
Index: crypto/asn1/f_string.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/asn1/f_string.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 f_string.c
--- f_string.c 1998/12/21 10:54:31 1.1.1.2
+++ f_string.c 1999/05/28 10:16:54
@@ -130,9 +130,18 @@
for (j=i-1; j>0; j--)
{
+#ifndef CHARSET_EBCDIC
if (!( ((buf[j] >= '0') && (buf[j] <= '9')) ||
((buf[j] >= 'a') && (buf[j] <= 'f')) ||
((buf[j] >= 'A') && (buf[j] <= 'F'))))
+#else /*CHARSET_EBCDIC*/
+ /* This #ifdef is not strictly necessary, since
+ * the characters A...F a...f 0...9 are contiguous
+ * (yes, even in EBCDIC - but not the whole alphabet).
+ * Nevertheless, isxdigit() is faster.
+ */
+ if (!isxdigit(buf[j]))
+#endif /*CHARSET_EBCDIC*/
{
i=j;
break;
Index: crypto/asn1/t_x509.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/asn1/t_x509.c,v
retrieving revision 1.5
diff -u -r1.5 t_x509.c
--- t_x509.c 1999/01/24 17:50:27 1.5
+++ t_x509.c 1999/05/28 10:16:54
@@ -404,6 +404,7 @@
c=s;
for (;;)
{
+#ifndef CHARSET_EBCDIC
if ( ((*s == '/') &&
((s[1] >= 'A') && (s[1] <= 'Z') && (
(s[2] == '=') ||
@@ -411,6 +412,15 @@
(s[3] == '='))
))) ||
(*s == '\0'))
+#else /*CHARSET_EBCDIC*/
+ if ( ((*s == '/') &&
+ (isupper(s[1]) && (
+ (s[2] == '=') ||
+ (isupper(s[2]) &&
+ (s[3] == '='))
+ ))) ||
+ (*s == '\0'))
+#endif /*CHARSET_EBCDIC*/
{
if ((l <= 0) && !first)
{
Index: crypto/bf/bftest.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/bf/bftest.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 bftest.c
--- bftest.c 1998/12/21 10:54:37 1.1.1.2
+++ bftest.c 1999/05/28 10:16:55
@@ -63,6 +63,9 @@
#include <string.h>
#include <stdlib.h>
#include "blowfish.h"
+#ifdef CHARSET_EBCDIC
+#include "ebcdic.h"
+#endif /*CHARSET_EBCDIC*/
char *bf_key[2]={
"abcdefghijklmnopqrstuvwxyz",
@@ -351,9 +354,16 @@
unsigned char out[8];
BF_LONG len;
+#ifdef CHARSET_EBCDIC
+ ebcdic2ascii(cbc_data, cbc_data, strlen(cbc_data));
+#endif /*CHARSET_EBCDIC*/
+
printf("testing blowfish in raw ecb mode\n");
for (n=0; n<2; n++)
{
+#ifdef CHARSET_EBCDIC
+ ebcdic2ascii(bf_key[n], bf_key[n], strlen(bf_key[n]));
+#endif /*CHARSET_EBCDIC*/
BF_set_key(&key,strlen(bf_key[n]),(unsigned char *)bf_key[n]);
data[0]=bf_plain[n][0];
Index: crypto/bio/b_dump.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/bio/b_dump.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 b_dump.c
--- b_dump.c 1998/12/21 10:54:42 1.1.1.2
+++ b_dump.c 1999/05/28 10:16:56
@@ -105,7 +105,13 @@
if (((i*DUMP_WIDTH)+j)>=len)
break;
ch=((unsigned char)*((char *)(s)+i*DUMP_WIDTH+j)) & 0xff;
+#ifndef CHARSET_EBCDIC
sprintf(tmp,"%c",((ch>=' ')&&(ch<='~'))?ch:'.');
+#else /*CHARSET_EBCDIC*/
+ sprintf(tmp,"%c",((ch>=os_toascii[' '])&&(ch<=os_toascii['~']))
+ ? os_toebcdic[ch]
+ : '.');
+#endif /*CHARSET_EBCDIC*/
strcat(buf,tmp);
}
strcat(buf,"\n");
Index: crypto/conf/conf_lcl.h
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/conf/conf_lcl.h,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 conf_lcl.h
--- conf_lcl.h 1998/12/21 10:54:51 1.1.1.2
+++ conf_lcl.h 1999/05/28 10:17:02
@@ -71,6 +71,7 @@
#define CONF_ALPHA_NUMERIC_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER| \
CONF_PUNCTUATION)
+#ifndef CHARSET_EBCDIC
#define IS_COMMENT(a) (CONF_COMMENT&(CONF_type[(a)&0x7f]))
#define IS_EOF(a) ((a) == '\0')
#define IS_ESC(a) ((a) == '\\')
@@ -80,6 +81,19 @@
#define IS_ALPHA_NUMERIC_PUNCT(a) \
(CONF_type[(a)&0x7f]&CONF_ALPHA_NUMERIC_PUNCT)
#define IS_QUOTE(a) (CONF_type[(a)&0x7f]&CONF_QUOTE)
+
+#else /*CHARSET_EBCDIC*/
+
+#define IS_COMMENT(a) (CONF_COMMENT&(CONF_type[os_toascii[a]&0x7f]))
+#define IS_EOF(a) (os_toascii[a] == '\0')
+#define IS_ESC(a) (os_toascii[a] == '\\')
+#define IS_NUMER(a) (CONF_type[os_toascii[a]&0x7f]&CONF_NUMBER)
+#define IS_WS(a) (CONF_type[os_toascii[a]&0x7f]&CONF_WS)
+#define IS_ALPHA_NUMERIC(a) (CONF_type[os_toascii[a]&0x7f]&CONF_ALPHA_NUMERIC)
+#define IS_ALPHA_NUMERIC_PUNCT(a) \
+
+(CONF_type[os_toascii[a]&0x7f]&CONF_ALPHA_NUMERIC_PUNCT)
+#define IS_QUOTE(a) (CONF_type[os_toascii[a]&0x7f]&CONF_QUOTE)
+#endif/*CHARSET_EBCDIC*/
static unsigned short CONF_type[128]={
0x008,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
Index: crypto/des/ecb3_enc.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/des/ecb3_enc.c,v
retrieving revision 1.2
diff -u -r1.2 ecb3_enc.c
--- ecb3_enc.c 1999/02/13 18:52:20 1.2
+++ ecb3_enc.c 1999/05/28 10:17:02
@@ -58,13 +58,9 @@
#include "des_locl.h"
-void des_ecb3_encrypt(in, out, ks1, ks2, ks3, enc)
-const des_cblock in;
-des_cblock out;
-des_key_schedule ks1;
-des_key_schedule ks2;
-des_key_schedule ks3;
-int enc;
+void des_ecb3_encrypt(const unsigned char *in,unsigned char *out,
+ des_key_schedule ks1,des_key_schedule ks2,
+ des_key_schedule ks3, int enc)
{
register DES_LONG l0,l1;
DES_LONG ll[2];
Index: crypto/des/fcrypt.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/des/fcrypt.c,v
retrieving revision 1.2
diff -u -r1.2 fcrypt.c
--- fcrypt.c 1999/02/13 18:52:20 1.2
+++ fcrypt.c 1999/05/28 10:17:02
@@ -1,5 +1,13 @@
/* NOCW */
#include <stdio.h>
+#ifdef _OSD_POSIX
+#ifndef CHARSET_EBCDIC
+#define CHARSET_EBCDIC 1
+#endif
+#endif
+#ifdef CHARSET_EBCDIC
+#include "ebcdic.h"
+#endif
/* This version of crypt has been developed from my MIT compatable
* DES library.
@@ -79,7 +87,37 @@
{
static char buff[14];
+#ifndef CHARSET_EBCDIC
return(des_fcrypt(buf,salt,buff));
+#else /*CHARSET_EBCDIC*/
+ char e_salt[2+1];
+ char e_buf[32+1]; /* replace 32 by 8 ? */
+ char *ret;
+
+ /* Copy at most 2 chars of salt */
+ if ((e_salt[0] = salt[0]) != '\0')
+ e_salt[1] = salt[1];
+
+ /* Copy at most 32 chars of password */
+ strncpy (e_buf, buf, sizeof(e_buf));
+
+ /* Make sure we have a delimiter */
+ e_salt[sizeof(e_salt)-1] = e_buf[sizeof(e_buf)-1] = '\0';
+
+ /* Convert the e_salt to ASCII, as that's what des_fcrypt works on */
+ ebcdic2ascii(e_salt, e_salt, sizeof e_salt);
+
+ /* Convert the cleartext password to ASCII */
+ ebcdic2ascii(e_buf, e_buf, sizeof e_buf);
+
+ /* Encrypt it (from/to ASCII) */
+ ret = des_fcrypt(e_buf,e_salt,buff);
+
+ /* Convert the result back to EBCDIC */
+ ascii2ebcdic(ret, ret, strlen(ret));
+
+ return ret;
+#endif /*CHARSET_EBCDIC*/
}
@@ -105,10 +143,17 @@
* crypt to "*". This was found when replacing the crypt in
* our shared libraries. People found that the disbled
* accounts effectivly had no passwd :-(. */
+#ifndef CHARSET_EBCDIC
x=ret[0]=((salt[0] == '\0')?'A':salt[0]);
Eswap0=con_salt[x]<<2;
x=ret[1]=((salt[1] == '\0')?'A':salt[1]);
Eswap1=con_salt[x]<<6;
+#else /*CHARSET_EBCDIC*/
+ x=ret[0]=((salt[0] == '\0')?os_toascii['A']:salt[0]);
+ Eswap0=con_salt[x]<<2;
+ x=ret[1]=((salt[1] == '\0')?os_toascii['A']:salt[1]);
+ Eswap1=con_salt[x]<<6;
+#endif /*CHARSET_EBCDIC*/
/* EAY
r=strlen(buf);
Index: crypto/err/err.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/err/err.c,v
retrieving revision 1.3
diff -u -r1.3 err.c
--- err.c 1999/01/24 17:50:30 1.3
+++ err.c 1999/05/28 10:17:04
@@ -259,6 +259,25 @@
{
ERR_STATE *es;
+#ifdef _OSD_POSIX
+ /* In the BS2000-OSD POSIX subsystem, the compiler generates
+ * path names in the form "*POSIX(/etc/passwd)".
+ * This dirty hack strips them to something sensible.
+ * @@@ We shouldn't modify a const string, though.
+ */
+ if (strncmp(file,"*POSIX(", sizeof("*POSIX(")-1) == 0) {
+ char *end;
+
+ /* Skip the "*POSIX(" prefix */
+ file += sizeof("*POSIX(")-1;
+ end = &file[strlen(file)-1];
+ if (*end == ')')
+ *end = '\0';
+ /* Optional: use the basename of the path only. */
+ if ((end = strrchr(file, '/')) != NULL)
+ file = &end[1];
+ }
+#endif
es=ERR_get_state();
es->top=(es->top+1)%ERR_NUM_ERRORS;
Index: crypto/err/err_code.pl
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/err/Attic/err_code.pl,v
retrieving revision 1.2
diff -u -r1.2 err_code.pl
--- err_code.pl 1999/01/18 22:18:31 1.2
+++ err_code.pl 1999/05/28 10:17:04
@@ -1,4 +1,4 @@
-#!/usr/local/bin/perl -w
+#!/usr/local/bin/perl
# Modified by Steve Henson. It should now read in the .err
# file and only add new error codes, retaining the old
Index: crypto/evp/encode.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/evp/encode.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 encode.c
--- encode.c 1998/12/21 10:55:13 1.1.1.2
+++ encode.c 1999/05/28 10:17:05
@@ -60,8 +60,19 @@
#include "cryptlib.h"
#include "evp.h"
+#ifndef CHARSET_EBCDIC
#define conv_bin2ascii(a) (data_bin2ascii[(a)&0x3f])
#define conv_ascii2bin(a) (data_ascii2bin[(a)&0x7f])
+#else /*CHARSET_EBCDIC*/
+/* 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 /*CHARSET_EBCDIC*/
/* 64 char lines
* pad input with 0
Index: crypto/hmac/hmactest.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/hmac/hmactest.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 hmactest.c
--- hmactest.c 1998/12/21 10:55:20 1.1.1.1
+++ hmactest.c 1999/05/28 10:17:06
@@ -60,6 +60,9 @@
#include <string.h>
#include <stdlib.h>
#include "hmac.h"
+#ifdef CHARSET_EBCDIC
+#include "ebcdic.h"
+#endif /*CHARSET_EBCDIC*/
struct test_st
{
@@ -114,6 +117,13 @@
{
int i,err=0;
char *p;
+
+#ifdef CHARSET_EBCDIC
+ ebcdic2ascii(test[0].data, test[0].data, test[0].data_len);
+ ebcdic2ascii(test[1].data, test[1].data, test[1].data_len);
+ ebcdic2ascii(test[2].key, test[2].key, test[2].key_len);
+ ebcdic2ascii(test[2].data, test[2].data, test[2].data_len);
+#endif /*CHARSET_EBCDIC*/
for (i=0; i<4; i++)
{
Index: crypto/md2/md2_one.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/md2/md2_one.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 md2_one.c
--- md2_one.c 1998/12/21 10:55:26 1.1.1.1
+++ md2_one.c 1999/05/28 10:17:07
@@ -59,6 +59,9 @@
#include <stdio.h>
#include "cryptlib.h"
#include "md2.h"
+#ifdef CHARSET_EBCDIC
+#include "ebcdic.h"
+#endif
/* This is a separate file so that #defines in cryptlib.h can
* map my MD functions to different names */
@@ -73,7 +76,23 @@
if (md == NULL) md=m;
MD2_Init(&c);
+#ifndef CHARSET_EBCDIC
MD2_Update(&c,d,n);
+#else
+ {
+ char temp[1024];
+ unsigned long chunk;
+
+ while (n > 0)
+ {
+ chunk = (n > sizeof(temp)) ? sizeof(temp) : n;
+ ebcdic2ascii(temp, d, chunk);
+ MD2_Update(&c,temp,chunk);
+ n -= chunk;
+ d += chunk;
+ }
+ }
+#endif
MD2_Final(md,&c);
memset(&c,0,sizeof(c)); /* Security consideration */
return(md);
Index: crypto/md5/md5.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/md5/md5.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 md5.c
--- md5.c 1998/12/21 10:55:26 1.1.1.1
+++ md5.c 1999/05/28 10:17:07
@@ -65,7 +65,9 @@
#ifndef NOPROTO
void do_fp(FILE *f);
void pt(unsigned char *md);
+#ifndef _OSD_POSIX
int read(int, void *, unsigned int);
+#endif
#else
void do_fp();
void pt();
Index: crypto/md5/md5_one.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/md5/md5_one.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 md5_one.c
--- md5_one.c 1998/12/21 10:55:26 1.1.1.1
+++ md5_one.c 1999/05/28 10:17:07
@@ -58,6 +58,9 @@
#include <stdio.h>
#include "md5_locl.h"
+#ifdef CHARSET_EBCDIC
+#include "ebcdic.h"
+#endif
unsigned char *MD5(d, n, md)
unsigned char *d;
@@ -69,7 +72,23 @@
if (md == NULL) md=m;
MD5_Init(&c);
+#ifndef CHARSET_EBCDIC
MD5_Update(&c,d,n);
+#else
+ {
+ char temp[1024];
+ unsigned long chunk;
+
+ while (n > 0)
+ {
+ chunk = (n > sizeof(temp)) ? sizeof(temp) : n;
+ ebcdic2ascii(temp, d, chunk);
+ MD5_Update(&c,temp,chunk);
+ n -= chunk;
+ d += chunk;
+ }
+ }
+#endif
MD5_Final(md,&c);
memset(&c,0,sizeof(c)); /* security consideration */
return(md);
Index: crypto/mdc2/mdc2test.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/mdc2/mdc2test.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 mdc2test.c
--- mdc2test.c 1998/12/21 10:55:26 1.1.1.2
+++ mdc2test.c 1999/05/28 10:17:07
@@ -60,6 +60,9 @@
#include <stdlib.h>
#include <string.h>
#include "mdc2.h"
+#ifdef CHARSET_EBCDIC
+#include "ebcdic.h"
+#endif /*CHARSET_EBCDIC*/
static unsigned char pad1[16]={
0x42,0xE5,0x0C,0xD2,0x24,0xBA,0xCE,0xBA,
@@ -80,6 +83,10 @@
int i;
MDC2_CTX c;
static char *text="Now is the time for all ";
+
+#ifdef CHARSET_EBCDIC
+ ebcdic2ascii(text,text,strlen(text));
+#endif /*CHARSET_EBCDIC*/
MDC2_Init(&c);
MDC2_Update(&c,(unsigned char *)text,strlen(text));
Index: crypto/objects/obj_dat.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/objects/obj_dat.c,v
retrieving revision 1.3
diff -u -r1.3 obj_dat.c
--- obj_dat.c 1999/02/14 16:48:21 1.3
+++ obj_dat.c 1999/05/28 10:17:08
@@ -531,6 +531,17 @@
else
return(p);
}
+#ifdef CHARSET_EBCDIC
+/* THIS IS A KLUDGE - Because the *_obj is sorted in ASCII order, and
+ * I don't have perl (yet), we revert to a *LINEAR* search
+ * when the object wasn't found in the binary search.
+ */
+ for (i=0; i<num; ++i) {
+ p= &(base[i*size]);
+ if ((*cmp)(key,p) == 0)
+ return p;
+ }
+#endif
return(NULL);
}
Index: crypto/pem/pem_lib.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/pem/pem_lib.c,v
retrieving revision 1.6
diff -u -r1.6 pem_lib.c
--- pem_lib.c 1999/03/22 12:21:43 1.6
+++ pem_lib.c 1999/05/28 10:17:08
@@ -325,6 +325,10 @@
PEMerr(PEM_F_PEM_ASN1_WRITE_BIO,PEM_R_READ_KEY);
goto err;
}
+#ifdef CHARSET_EBCDIC
+ /* Convert the pass phrase from EBCDIC */
+ ebcdic2ascii(buf, buf, klen);
+#endif /*CHARSET_EBCDIC*/
kstr=(unsigned char *)buf;
}
RAND_seed(data,i);/* put in the RSA key. */
@@ -387,6 +391,11 @@
PEMerr(PEM_F_PEM_DO_HEADER,PEM_R_BAD_PASSWORD_READ);
return(0);
}
+#ifdef CHARSET_EBCDIC
+ /* Convert the pass phrase from EBCDIC */
+ ebcdic2ascii(buf, buf, klen);
+#endif /*CHARSET_EBCDIC*/
+
EVP_BytesToKey(cipher->cipher,EVP_md5(),&(cipher->iv[0]),
(unsigned char *)buf,klen,1,key,NULL);
@@ -438,9 +447,15 @@
for (;;)
{
c= *header;
+#ifndef CHARSET_EBCDIC
if (!( ((c >= 'A') && (c <= 'Z')) || (c == '-') ||
((c >= '0') && (c <= '9'))))
break;
+#else /*CHARSET_EBCDIC*/
+ if (!( isupper(c) || (c == '-') ||
+ isdigit(c)))
+ break;
+#endif /*CHARSET_EBCDIC*/
header++;
}
*header='\0';
Index: crypto/rc4/rc4_locl.org
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/rc4/Attic/rc4_locl.org,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 rc4_locl.org
--- rc4_locl.org 1998/12/21 10:55:35 1.1.1.1
+++ rc4_locl.org 1999/05/28 10:17:12
@@ -66,5 +66,5 @@
/* if this is defined data[i] is used instead of *data, this is a %20
* speedup on x86 */
-#undef RC4_INDEX
+#define RC4_INDEX
Index: crypto/ripemd/rmd160.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/ripemd/rmd160.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 rmd160.c
--- rmd160.c 1998/12/21 10:55:45 1.1.1.1
+++ rmd160.c 1999/05/28 10:17:13
@@ -65,7 +65,9 @@
#ifndef NOPROTO
void do_fp(FILE *f);
void pt(unsigned char *md);
+#ifndef _OSD_POSIX
int read(int, void *, unsigned int);
+#endif
#else
void do_fp();
void pt();
Index: crypto/ripemd/rmdtest.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/ripemd/rmdtest.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 rmdtest.c
--- rmdtest.c 1998/12/21 10:55:45 1.1.1.1
+++ rmdtest.c 1999/05/28 10:17:13
@@ -60,6 +60,9 @@
#include <string.h>
#include <stdlib.h>
#include "ripemd.h"
+#ifdef CHARSET_EBCDIC
+#include "ebcdic.h"
+#endif /*CHARSET_EBCDIC*/
char *test[]={
"",
@@ -103,6 +106,9 @@
i=1;
while (*P != NULL)
{
+#ifdef CHARSET_EBCDIC
+ ebcdic2ascii((char *)*P, (char *)*P, strlen((char *)*P));
+#endif /*CHARSET_EBCDIC*/
p=pt(RIPEMD160(&(P[0][0]),(unsigned long)strlen((char *)*P),NULL));
if (strcmp(p,(char *)*R) != 0)
{
Index: crypto/sha/sha1.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/sha/sha1.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 sha1.c
--- sha1.c 1998/12/21 10:55:38 1.1.1.1
+++ sha1.c 1999/05/28 10:17:14
@@ -65,7 +65,9 @@
#ifndef NOPROTO
void do_fp(FILE *f);
void pt(unsigned char *md);
+#ifndef _OSD_POSIX
int read(int, void *, unsigned int);
+#endif
#else
void do_fp();
void pt();
Index: crypto/sha/sha1test.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/sha/sha1test.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 sha1test.c
--- sha1test.c 1998/12/21 10:55:38 1.1.1.2
+++ sha1test.c 1999/05/28 10:17:15
@@ -60,6 +60,9 @@
#include <string.h>
#include <stdlib.h>
#include "sha.h"
+#ifdef CHARSET_EBCDIC
+#include "ebcdic.h"
+#endif /*CHARSET_EBCDIC*/
#undef SHA_0 /* FIPS 180 */
#define SHA_1 /* FIPS 180-1 */
@@ -104,6 +107,11 @@
SHA_CTX c;
unsigned char md[SHA_DIGEST_LENGTH];
+#ifdef CHARSET_EBCDIC
+ ebcdic2ascii(test[0], test[0], strlen(test[0]));
+ ebcdic2ascii(test[1], test[1], strlen(test[1]));
+#endif /*CHARSET_EBCDIC*/
+
P=(unsigned char **)test;
R=(unsigned char **)ret;
i=1;
@@ -124,6 +132,9 @@
}
memset(buf,'a',1000);
+#ifdef CHARSET_EBCDIC
+ ebcdic2ascii(buf, buf, 1000);
+#endif /*CHARSET_EBCDIC*/
SHA1_Init(&c);
for (i=0; i<1000; i++)
SHA1_Update(&c,buf,1000);
Index: crypto/sha/shatest.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/sha/shatest.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 shatest.c
--- shatest.c 1998/12/21 10:55:38 1.1.1.2
+++ shatest.c 1999/05/28 10:17:14
@@ -60,6 +60,9 @@
#include <string.h>
#include <stdlib.h>
#include "sha.h"
+#ifdef CHARSET_EBCDIC
+#include "ebcdic.h"
+#endif /*CHARSET_EBCDIC*/
#define SHA_0 /* FIPS 180 */
#undef SHA_1 /* FIPS 180-1 */
@@ -104,6 +107,11 @@
SHA_CTX c;
unsigned char md[SHA_DIGEST_LENGTH];
+#ifdef CHARSET_EBCDIC
+ ebcdic2ascii(test[0], test[0], strlen(test[0]));
+ ebcdic2ascii(test[1], test[1], strlen(test[1]));
+#endif /*CHARSET_EBCDIC*/
+
P=(unsigned char **)test;
R=(unsigned char **)ret;
i=1;
@@ -124,6 +132,9 @@
}
memset(buf,'a',1000);
+#ifdef CHARSET_EBCDIC
+ ebcdic2ascii(buf, buf, 1000);
+#endif /*CHARSET_EBCDIC*/
SHA_Init(&c);
for (i=0; i<1000; i++)
SHA_Update(&c,buf,1000);
Index: crypto/x509/x509_obj.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/crypto/x509/x509_obj.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 x509_obj.c
--- x509_obj.c 1998/12/21 10:55:43 1.1.1.2
+++ x509_obj.c 1999/05/28 10:17:16
@@ -77,6 +77,9 @@
static char hex[17]="0123456789ABCDEF";
int gs_doit[4];
char tmp_buf[80];
+#ifdef CHARSET_EBCDIC
+ char ebcdic_buf[1024];
+#endif /*CHARSET_EBCDIC*/
if (a == NULL) return("NO X509_NAME");
if (buf == NULL)
@@ -103,6 +106,19 @@
type=ne->value->type;
num=ne->value->length;
q=ne->value->data;
+#ifdef CHARSET_EBCDIC
+ if (type == V_ASN1_GENERALSTRING ||
+ type == V_ASN1_VISIBLESTRING ||
+ type == V_ASN1_PRINTABLESTRING ||
+ type == V_ASN1_TELETEXSTRING ||
+ type == V_ASN1_VISIBLESTRING ||
+ type == V_ASN1_IA5STRING) {
+ ascii2ebcdic(ebcdic_buf, q,
+ (num > sizeof ebcdic_buf)
+ ? sizeof ebcdic_buf : num);
+ q=ebcdic_buf;
+ }
+#endif /*CHARSET_EBCDIC*/
if ((type == V_ASN1_GENERALSTRING) && ((num%4) == 0))
{
@@ -125,7 +141,12 @@
{
if (!gs_doit[j&3]) continue;
l2++;
+#ifndef CHARSET_EBCDIC
if ((q[j] < ' ') || (q[j] > '~')) l2+=3;
+#else /*CHARSET_EBCDIC*/
+ if ((os_toascii[q[j]] < os_toascii[' ']) ||
+ (os_toascii[q[j]] > os_toascii['~'])) l2+=3;
+#endif /*CHARSET_EBCDIC*/
}
lold=l;
@@ -145,11 +166,14 @@
memcpy(p,s,(unsigned int)l1); p+=l1;
*(p++)='=';
+#ifndef CHARSET_EBCDIC /* q was assigned above already. */
q=ne->value->data;
+#endif /*CHARSET_EBCDIC*/
for (j=0; j<num; j++)
{
if (!gs_doit[j&3]) continue;
+#ifndef CHARSET_EBCDIC
n=q[j];
if ((n < ' ') || (n > '~'))
{
@@ -160,6 +184,19 @@
}
else
*(p++)=n;
+#else /*CHARSET_EBCDIC*/
+ n=os_toascii[q[j]];
+ if ((n < os_toascii[' ']) ||
+ (n > os_toascii['~']))
+ {
+ *(p++)='\\';
+ *(p++)='x';
+ *(p++)=hex[(n>>4)&0x0f];
+ *(p++)=hex[n&0x0f];
+ }
+ else
+ *(p++)=q[j];
+#endif /*CHARSET_EBCDIC*/
}
*p='\0';
}
Index: ssl/s2_lib.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/ssl/s2_lib.c,v
retrieving revision 1.10
diff -u -r1.10 s2_lib.c
--- s2_lib.c 1999/03/22 12:22:03 1.10
+++ s2_lib.c 1999/05/28 10:17:22
@@ -378,6 +378,10 @@
unsigned char *km;
unsigned char c='0';
+#ifdef CHARSET_EBCDIC
+ c = os_toascii['0']; /* Must be an ASCII '0', not EBCDIC '0', see SSLv2 docu */
+#endif
+
km=s->s2->key_material;
for (i=0; i<s->s2->key_material_length; i+=MD5_DIGEST_LENGTH)
{
Index: ssl/s3_enc.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/ssl/s3_enc.c,v
retrieving revision 1.6
diff -u -r1.6 s3_enc.c
--- s3_enc.c 1999/02/21 20:03:22 1.6
+++ s3_enc.c 1999/05/28 10:17:22
@@ -94,6 +94,9 @@
unsigned char c='A';
int i,j,k;
+#ifdef CHARSET_EBCDIC
+ c = os_toascii[c]; /*'A' in ASCII */
+#endif
k=0;
for (i=0; i<num; i+=MD5_DIGEST_LENGTH)
{
@@ -542,9 +545,15 @@
int len;
{
static unsigned char *salt[3]={
+#ifndef CHARSET_EBCDIC
(unsigned char *)"A",
(unsigned char *)"BB",
(unsigned char *)"CCC",
+#else
+ (unsigned char *)"\x41",
+ (unsigned char *)"\x42\x42",
+ (unsigned char *)"\x43\x43\x43",
+#endif
};
unsigned char buf[EVP_MAX_MD_SIZE];
EVP_MD_CTX ctx;
Index: ssl/ssl_ciph.c
===================================================================
RCS file: /home/cvs/OpenSSL.Org/ssl/ssl_ciph.c,v
retrieving revision 1.7
diff -u -r1.7 ssl_ciph.c
--- ssl_ciph.c 1999/03/12 01:43:28 1.7
+++ ssl_ciph.c 1999/05/28 10:17:22
@@ -462,10 +462,14 @@
{
ch= *l;
i=0;
+#ifndef CHARSET_EBCDIC
while ( ((ch >= 'A') && (ch <= 'Z')) ||
((ch >= '0') && (ch <= '9')) ||
((ch >= 'a') && (ch <= 'z')) ||
(ch == '-'))
+#else /*CHARSET_EBCDIC*/
+ while ( isalnum(ch) || (ch == '-'))
+#endif /*CHARSET_EBCDIC*/
{
buf[i]=ch;
ch= *(++l);
Index: ssl/tls1.h
===================================================================
RCS file: /home/cvs/OpenSSL.Org/ssl/tls1.h,v
retrieving revision 1.3
diff -u -r1.3 tls1.h
--- tls1.h 1999/03/06 15:21:02 1.3
+++ tls1.h 1999/05/28 10:17:23
@@ -118,6 +118,25 @@
#define TLS_MD_MASTER_SECRET_CONST "master secret"
#define TLS_MD_MASTER_SECRET_CONST_SIZE 13
+#ifdef CHARSET_EBCDIC
+#undef TLS_MD_CLIENT_FINISH_CONST
+#define TLS_MD_CLIENT_FINISH_CONST
+"\x63\x6c\x69\x65\x6e\x74\x20\x66\x69\x6e\x69\x73\x68\x65\x64" /*client finished*/
+#undef TLS_MD_SERVER_FINISH_CONST
+#define TLS_MD_SERVER_FINISH_CONST
+"\x73\x65\x72\x76\x65\x72\x20\x66\x69\x6e\x69\x73\x68\x65\x64" /*server finished*/
+#undef TLS_MD_SERVER_WRITE_KEY_CONST
+#define TLS_MD_SERVER_WRITE_KEY_CONST
+"\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*server write
+key*/
+#undef TLS_MD_KEY_EXPANSION_CONST
+#define TLS_MD_KEY_EXPANSION_CONST
+"\x6b\x65\x79\x20\x65\x78\x70\x61\x6e\x73\x69\x6f\x6e" /*key expansion*/
+#undef TLS_MD_CLIENT_WRITE_KEY_CONST
+#define TLS_MD_CLIENT_WRITE_KEY_CONST
+"\x63\x6c\x69\x65\x6e\x74\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*client write
+key*/
+#undef TLS_MD_SERVER_WRITE_KEY_CONST
+#define TLS_MD_SERVER_WRITE_KEY_CONST
+"\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*server write
+key*/
+#undef TLS_MD_IV_BLOCK_CONST
+#define TLS_MD_IV_BLOCK_CONST "\x49\x56\x20\x62\x6c\x6f\x63\x6b" /*IV block*/
+#undef TLS_MD_MASTER_SECRET_CONST
+#define TLS_MD_MASTER_SECRET_CONST
+"\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" /*master secret*/
+#endif
+
#ifdef __cplusplus
}
#endif
Index: tools/c_rehash
===================================================================
RCS file: /home/cvs/OpenSSL.Org/tools/Attic/c_rehash,v
retrieving revision 1.4
diff -u -r1.4 c_rehash
--- c_rehash 1999/03/09 10:08:17 1.4
+++ c_rehash 1999/05/28 10:17:26
@@ -4,7 +4,7 @@
# on the command line.
#
-if [ "$OPENSSL"x = "x" -o ! -x "$OPENSSL" ]; then
+if [ "$OPENSSL"x = "x" ] || [ ! -x "$OPENSSL" ]; then
OPENSSL='openssl'
export OPENSSL
fi