(Answer) (Category) OpenLDAP Faq-O-Matic : (Category) OpenLDAP Developer's FAQ : (Category) Porting OpenLDAP : (Category) Porting to IBM OS/390 : (Answer) Building OpenSSL
OpenSSL has been ported to EBCDIC platforms but as of 0.9.6g the support is missing a couple details. Here are the patches and steps that are needed to build a working OpenSSL package on IBM's OS/390.

After obtaining the source and applying the patches, run Configure to set up the Makefiles:

    ./Configure OS390-Unix
There are several quirks to this build though, so it's not as simple as just typing "make; make install" and letting it go.

On my system the "make install" procedure hangs while running pod2man to create the manpages, so I just installed the headers and library files manually. The IBM Redbook on OpenSSL lists some patches for the pod2man.pl script but they didn't seem to help in my case.

I built OpenSSL using the 2.9 C compiler. This compiler appears to have a few bugs; the OpenSSL library will fail its self-test if certain files are compiled with optimization enabled. Most of the library works when compiled with "-O", but these files must not be compiled with "-O":

  • crypto/des/des_enc.c - just omit "-O"
  • crypto/rand/rand_lib.c - must be compiled with "-g"
  • crypto/x509v3/v3_lib.c - must be compiled with "-g"
The simplest thing for me was just to build the entire crypto directory with the "-O" flag enabled, and then manually remove the objects for the above three files and recompile them. It helps to edit the top-level Makefile and replace "-O" with "$(OPT)" so you can then say:
  cd crypto
  make OPT=-O
  (cd des; rm des_enc.o; make OPT=)
  rm rand/rand_lib.o x509v3/v3_lib.o
  make OPT=-g
  cd ..
  make OPT=-O
That should build the entire package without any problems. You can verify by running the test suite; it should run to completion with no fatal messages.
hyc@openldap.org
--- apps/ca.c   2002/08/31 03:38:01     1.1
+++ apps/ca.c   2002/08/31 03:39:35
@@ -1596,13 +1596,22 @@
                p=(char *)str->data;
                for (j=str->length; j>0; j--)
                        {
+#ifdef CHARSET_EBCDIC
+                       if ((*p >= 0x20) && (*p <= 0x7e))
+                               BIO_printf(bio_err,"%c", os_toebcdic[*p]);
+#else
                        if ((*p >= ' ') && (*p <= '~'))
                                BIO_printf(bio_err,"%c",*p);
+#endif
                        else if (*p & 0x80)
                                BIO_printf(bio_err,"\\0x%02X",*p);
                        else if ((unsigned char)*p == 0xf7)
                                BIO_printf(bio_err,"^?");
+#ifdef CHARSET_EBCDIC
+                       else    BIO_printf(bio_err,"^%c",os_toebcdic[*p+0x40]);
+#else
                        else    BIO_printf(bio_err,"^%c",*p+'@');
+#endif
                        p++;
                        }
                BIO_printf(bio_err,"'\n");
--- crypto/asn1/a_print.c       2002/08/28 23:52:53     1.1
+++ crypto/asn1/a_print.c       2002/08/29 00:05:50
@@ -116,27 +116,18 @@
        while ((*s) && (len-- != 0))
                {
                c= *(s++);
-#ifndef CHARSET_EBCDIC
-               if (!(  ((c >= 'a') && (c <= 'z')) ||
-                       ((c >= 'A') && (c <= 'Z')) ||
-                       (c == ' ') ||
-                       ((c >= '0') && (c <= '9')) ||
-                       (c == ' ') || (c == '\'') ||
-                       (c == '(') || (c == ')') ||
-                       (c == '+') || (c == ',') ||
-                       (c == '-') || (c == '.') ||
-                       (c == '/') || (c == ':') ||
-                       (c == '=') || (c == '?')))
-                       ia5=1;
                if (c&0x80)
+                       {
                        t61=1;
-#else
-               if (!isalnum(c) && (c != ' ') &&
-                   strchr("'()+,-./:=?", c) == NULL)
+                       break;
+                       }
+               if (!(  ((c > 0x40) && (c < 0x5b)) ||   /* AZ */
+                       ((c > 0x60) && (c < 0x7b)) ||   /* az */
+                       ((c > 0x2a) && (c < 0x3b)) ||   /* +,-./09: */
+                       (c == 0x20) || (c == 0x27) ||   /* SPC, ' */
+                       (c == 0x28) || (c == 0x29) ||   /* () */
+                       (c == 0x3d) || (c == 0x3f)))    /* =? */
                        ia5=1;
-               if (os_toascii[c] & 0x80)
-                       t61=1;
-#endif
                }
        if (t61) return(V_ASN1_T61STRING);
        if (ia5) return(V_ASN1_IA5STRING);
--- crypto/x509v3/v3_alt.c      2002/08/31 03:27:11     1.1
+++ crypto/x509v3/v3_alt.c      2002/08/31 03:31:54
@@ -99,6 +99,15 @@
        return ret;
 }
 
+#ifdef CHARSET_EBCDIC
+static const char _unsup[] = {0x3c,0x75,0x6e,0x73,0x75,0x70,0x70,0x6f,
+       0x72,0x74,0x65,0x64,0x3e,0 };
+static const char _inval[] = {0x3c,0x69,0x6e,0x76,0x61,0x6c,0x69,0x64,0x3e,0};
+#else
+static const char _unsup[] = "<unsupported>";
+static const char _inval[] = "<invalid>";
+#endif
+
 STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method,
                                GENERAL_NAME *gen, STACK_OF(CONF_VALUE) *ret)
 {
@@ -107,15 +116,15 @@
        switch (gen->type)
        {
                case GEN_OTHERNAME:
-               X509V3_add_value("othername","<unsupported>", &ret);
+               X509V3_add_value("othername",_unsup, &ret);
                break;
 
                case GEN_X400:
-               X509V3_add_value("X400Name","<unsupported>", &ret);
+               X509V3_add_value("X400Name",_unsup, &ret);
                break;
 
                case GEN_EDIPARTY:
-               X509V3_add_value("EdiPartyName","<unsupported>", &ret);
+               X509V3_add_value("EdiPartyName",_unsup, &ret);
                break;
 
                case GEN_EMAIL:
@@ -132,6 +141,9 @@
 
                case GEN_DIRNAME:
                X509_NAME_oneline(gen->d.dirn, oline, 256);
+#ifdef CHARSET_EBCDIC
+               ebcdic2ascii(oline, oline, strlen(oline));
+#endif
                X509V3_add_value("DirName",oline, &ret);
                break;
 
@@ -139,15 +151,21 @@
                p = gen->d.ip->data;
                /* BUG: doesn't support IPV6 */
                if(gen->d.ip->length != 4) {
-                       X509V3_add_value("IP Address","<invalid>", &ret);
+                       X509V3_add_value("IP Address",_inval, &ret);
                        break;
                }
                sprintf(oline, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
+#ifdef CHARSET_EBCDIC
+               ebcdic2ascii(oline, oline, strlen(oline));
+#endif
                X509V3_add_value("IP Address",oline, &ret);
                break;
 
                case GEN_RID:
                i2t_ASN1_OBJECT(oline, 256, gen->d.rid);
+#ifdef CHARSET_EBCDIC
+               ebcdic2ascii(oline, oline, strlen(oline));
+#endif
                X509V3_add_value("Registered ID",oline, &ret);
                break;
        }
@@ -383,6 +401,9 @@
 }
 
 if(is_string) {
+#ifdef CHARSET_EBCDIC
+       ebcdic2ascii(value, value, strlen(value));
+#endif
        if(!(gen->d.ia5 = M_ASN1_IA5STRING_new()) ||
                      !ASN1_STRING_set(gen->d.ia5, (unsigned char*)value,
                                       strlen(value))) {
--- crypto/x509v3/v3_utl.c      2002/08/31 03:27:11     1.1
+++ crypto/x509v3/v3_utl.c      2002/08/31 03:28:06
@@ -111,17 +111,25 @@
        OPENSSL_free(conf);
 }
 
+#ifdef CHARSET_EBCDIC
+static const char _true[] = {0x54, 0x52, 0x55, 0x45, 0x00 };
+static const char _false[] = {0x46, 0x41, 0x4c, 0x53, 0x45, 0x00};
+#else
+static const char _true[] = "TRUE";
+static const char _false[] = "FALSE";
+#endif
+
 int X509V3_add_value_bool(const char *name, int asn1_bool,
                                                STACK_OF(CONF_VALUE) **extlist)
 {
-       if(asn1_bool) return X509V3_add_value(name, "TRUE", extlist);
-       return X509V3_add_value(name, "FALSE", extlist);
+       if(asn1_bool) return X509V3_add_value(name, _true, extlist);
+       return X509V3_add_value(name, _false, extlist);
 }

 int X509V3_add_value_bool_nf(char *name, int asn1_bool,
                                                STACK_OF(CONF_VALUE) **extlist)
 {
-       if(asn1_bool) return X509V3_add_value(name, "TRUE", extlist);
+       if(asn1_bool) return X509V3_add_value(name, _true, extlist);
        return 1;
 }


hyc@openldap.org
[Append to This Answer]
Previous: (Answer) Building Berkeley DB 4
Next: (Answer) Building Cyrus SASL 2
This document is: http://www.openldap.org/faq/index.cgi?file=745
[Search] [Appearance]
This is a Faq-O-Matic 2.721.test.
© Copyright 1998-2013, OpenLDAP Foundation, info@OpenLDAP.org