diff options
Diffstat (limited to 'src/lib/libcrypto/x509/x509_obj.c')
-rw-r--r-- | src/lib/libcrypto/x509/x509_obj.c | 72 |
1 files changed, 58 insertions, 14 deletions
diff --git a/src/lib/libcrypto/x509/x509_obj.c b/src/lib/libcrypto/x509/x509_obj.c index c0576fd6f6..691b71f031 100644 --- a/src/lib/libcrypto/x509/x509_obj.c +++ b/src/lib/libcrypto/x509/x509_obj.c | |||
@@ -58,27 +58,27 @@ | |||
58 | 58 | ||
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
61 | #include "lhash.h" | 61 | #include <openssl/lhash.h> |
62 | #include "objects.h" | 62 | #include <openssl/objects.h> |
63 | #include "x509.h" | 63 | #include <openssl/x509.h> |
64 | #include "buffer.h" | 64 | #include <openssl/buffer.h> |
65 | 65 | ||
66 | char *X509_NAME_oneline(a,buf,len) | 66 | char *X509_NAME_oneline(X509_NAME *a, char *buf, int len) |
67 | X509_NAME *a; | ||
68 | char *buf; | ||
69 | int len; | ||
70 | { | 67 | { |
71 | X509_NAME_ENTRY *ne; | 68 | X509_NAME_ENTRY *ne; |
72 | unsigned int i; | 69 | int i; |
73 | int n,lold,l,l1,l2,num,j,type; | 70 | int n,lold,l,l1,l2,num,j,type; |
74 | char *s,*p; | 71 | const char *s; |
72 | char *p; | ||
75 | unsigned char *q; | 73 | unsigned char *q; |
76 | BUF_MEM *b=NULL; | 74 | BUF_MEM *b=NULL; |
77 | static char hex[17]="0123456789ABCDEF"; | 75 | static char hex[17]="0123456789ABCDEF"; |
78 | int gs_doit[4]; | 76 | int gs_doit[4]; |
79 | char tmp_buf[80]; | 77 | char tmp_buf[80]; |
78 | #ifdef CHARSET_EBCDIC | ||
79 | char ebcdic_buf[1024]; | ||
80 | #endif | ||
80 | 81 | ||
81 | if (a == NULL) return("NO X509_NAME"); | ||
82 | if (buf == NULL) | 82 | if (buf == NULL) |
83 | { | 83 | { |
84 | if ((b=BUF_MEM_new()) == NULL) goto err; | 84 | if ((b=BUF_MEM_new()) == NULL) goto err; |
@@ -86,12 +86,22 @@ int len; | |||
86 | b->data[0]='\0'; | 86 | b->data[0]='\0'; |
87 | len=200; | 87 | len=200; |
88 | } | 88 | } |
89 | if (a == NULL) | ||
90 | { | ||
91 | if(b) | ||
92 | { | ||
93 | buf=b->data; | ||
94 | Free(b); | ||
95 | } | ||
96 | strncpy(buf,"NO X509_NAME",len); | ||
97 | return buf; | ||
98 | } | ||
89 | 99 | ||
90 | len--; /* space for '\0' */ | 100 | len--; /* space for '\0' */ |
91 | l=0; | 101 | l=0; |
92 | for (i=0; (int)i<sk_num(a->entries); i++) | 102 | for (i=0; i<sk_X509_NAME_ENTRY_num(a->entries); i++) |
93 | { | 103 | { |
94 | ne=(X509_NAME_ENTRY *)sk_value(a->entries,i); | 104 | ne=sk_X509_NAME_ENTRY_value(a->entries,i); |
95 | n=OBJ_obj2nid(ne->object); | 105 | n=OBJ_obj2nid(ne->object); |
96 | if ((n == NID_undef) || ((s=OBJ_nid2sn(n)) == NULL)) | 106 | if ((n == NID_undef) || ((s=OBJ_nid2sn(n)) == NULL)) |
97 | { | 107 | { |
@@ -103,6 +113,19 @@ int len; | |||
103 | type=ne->value->type; | 113 | type=ne->value->type; |
104 | num=ne->value->length; | 114 | num=ne->value->length; |
105 | q=ne->value->data; | 115 | q=ne->value->data; |
116 | #ifdef CHARSET_EBCDIC | ||
117 | if (type == V_ASN1_GENERALSTRING || | ||
118 | type == V_ASN1_VISIBLESTRING || | ||
119 | type == V_ASN1_PRINTABLESTRING || | ||
120 | type == V_ASN1_TELETEXSTRING || | ||
121 | type == V_ASN1_VISIBLESTRING || | ||
122 | type == V_ASN1_IA5STRING) { | ||
123 | ascii2ebcdic(ebcdic_buf, q, | ||
124 | (num > sizeof ebcdic_buf) | ||
125 | ? sizeof ebcdic_buf : num); | ||
126 | q=ebcdic_buf; | ||
127 | } | ||
128 | #endif | ||
106 | 129 | ||
107 | if ((type == V_ASN1_GENERALSTRING) && ((num%4) == 0)) | 130 | if ((type == V_ASN1_GENERALSTRING) && ((num%4) == 0)) |
108 | { | 131 | { |
@@ -125,7 +148,12 @@ int len; | |||
125 | { | 148 | { |
126 | if (!gs_doit[j&3]) continue; | 149 | if (!gs_doit[j&3]) continue; |
127 | l2++; | 150 | l2++; |
151 | #ifndef CHARSET_EBCDIC | ||
128 | if ((q[j] < ' ') || (q[j] > '~')) l2+=3; | 152 | if ((q[j] < ' ') || (q[j] > '~')) l2+=3; |
153 | #else | ||
154 | if ((os_toascii[q[j]] < os_toascii[' ']) || | ||
155 | (os_toascii[q[j]] > os_toascii['~'])) l2+=3; | ||
156 | #endif | ||
129 | } | 157 | } |
130 | 158 | ||
131 | lold=l; | 159 | lold=l; |
@@ -145,11 +173,14 @@ int len; | |||
145 | memcpy(p,s,(unsigned int)l1); p+=l1; | 173 | memcpy(p,s,(unsigned int)l1); p+=l1; |
146 | *(p++)='='; | 174 | *(p++)='='; |
147 | 175 | ||
176 | #ifndef CHARSET_EBCDIC /* q was assigned above already. */ | ||
148 | q=ne->value->data; | 177 | q=ne->value->data; |
178 | #endif | ||
149 | 179 | ||
150 | for (j=0; j<num; j++) | 180 | for (j=0; j<num; j++) |
151 | { | 181 | { |
152 | if (!gs_doit[j&3]) continue; | 182 | if (!gs_doit[j&3]) continue; |
183 | #ifndef CHARSET_EBCDIC | ||
153 | n=q[j]; | 184 | n=q[j]; |
154 | if ((n < ' ') || (n > '~')) | 185 | if ((n < ' ') || (n > '~')) |
155 | { | 186 | { |
@@ -160,13 +191,26 @@ int len; | |||
160 | } | 191 | } |
161 | else | 192 | else |
162 | *(p++)=n; | 193 | *(p++)=n; |
194 | #else | ||
195 | n=os_toascii[q[j]]; | ||
196 | if ((n < os_toascii[' ']) || | ||
197 | (n > os_toascii['~'])) | ||
198 | { | ||
199 | *(p++)='\\'; | ||
200 | *(p++)='x'; | ||
201 | *(p++)=hex[(n>>4)&0x0f]; | ||
202 | *(p++)=hex[n&0x0f]; | ||
203 | } | ||
204 | else | ||
205 | *(p++)=q[j]; | ||
206 | #endif | ||
163 | } | 207 | } |
164 | *p='\0'; | 208 | *p='\0'; |
165 | } | 209 | } |
166 | if (b != NULL) | 210 | if (b != NULL) |
167 | { | 211 | { |
168 | p=b->data; | 212 | p=b->data; |
169 | Free((char *)b); | 213 | Free(b); |
170 | } | 214 | } |
171 | else | 215 | else |
172 | p=buf; | 216 | p=buf; |