| OLD | NEW |
| 1 /* a_strex.c */ | 1 /* a_strex.c */ |
| 2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 * project 2000. | 3 * project 2000. |
| 4 */ | 4 */ |
| 5 /* ==================================================================== | 5 /* ==================================================================== |
| 6 * Copyright (c) 2000 The OpenSSL Project. All rights reserved. | 6 * Copyright (c) 2000 The OpenSSL Project. All rights reserved. |
| 7 * | 7 * |
| 8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
| 10 * are met: | 10 * are met: |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 /* ASN1_STRING_print_ex() and X509_NAME_print_ex(). | 68 /* ASN1_STRING_print_ex() and X509_NAME_print_ex(). |
| 69 * Enhanced string and name printing routines handling | 69 * Enhanced string and name printing routines handling |
| 70 * multibyte characters, RFC2253 and a host of other | 70 * multibyte characters, RFC2253 and a host of other |
| 71 * options. | 71 * options. |
| 72 */ | 72 */ |
| 73 | 73 |
| 74 | 74 |
| 75 #define CHARTYPE_BS_ESC (ASN1_STRFLGS_ESC_2253 | CHARTYPE_FIRST_ESC_2253
| CHARTYPE_LAST_ESC_2253) | 75 #define CHARTYPE_BS_ESC (ASN1_STRFLGS_ESC_2253 | CHARTYPE_FIRST_ESC_2253
| CHARTYPE_LAST_ESC_2253) |
| 76 | 76 |
| 77 #define ESC_FLAGS (ASN1_STRFLGS_ESC_2253 | \ |
| 78 ASN1_STRFLGS_ESC_QUOTE | \ |
| 79 ASN1_STRFLGS_ESC_CTRL | \ |
| 80 ASN1_STRFLGS_ESC_MSB) |
| 81 |
| 77 | 82 |
| 78 /* Three IO functions for sending data to memory, a BIO and | 83 /* Three IO functions for sending data to memory, a BIO and |
| 79 * and a FILE pointer. | 84 * and a FILE pointer. |
| 80 */ | 85 */ |
| 81 #if 0 /* never used */ | 86 #if 0 /* never used */ |
| 82 static int send_mem_chars(void *arg, const void *buf, int len) | 87 static int send_mem_chars(void *arg, const void *buf, int len) |
| 83 { | 88 { |
| 84 unsigned char **out = arg; | 89 unsigned char **out = arg; |
| 85 if(!out) return 1; | 90 if(!out) return 1; |
| 86 memcpy(*out, buf, len); | 91 memcpy(*out, buf, len); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } | 146 } |
| 142 if(!io_ch(arg, "\\", 1)) return -1; | 147 if(!io_ch(arg, "\\", 1)) return -1; |
| 143 if(!io_ch(arg, &chtmp, 1)) return -1; | 148 if(!io_ch(arg, &chtmp, 1)) return -1; |
| 144 return 2; | 149 return 2; |
| 145 } | 150 } |
| 146 if(chflgs & (ASN1_STRFLGS_ESC_CTRL|ASN1_STRFLGS_ESC_MSB)) { | 151 if(chflgs & (ASN1_STRFLGS_ESC_CTRL|ASN1_STRFLGS_ESC_MSB)) { |
| 147 BIO_snprintf(tmphex, 11, "\\%02X", chtmp); | 152 BIO_snprintf(tmphex, 11, "\\%02X", chtmp); |
| 148 if(!io_ch(arg, tmphex, 3)) return -1; | 153 if(!io_ch(arg, tmphex, 3)) return -1; |
| 149 return 3; | 154 return 3; |
| 150 } | 155 } |
| 156 /* If we get this far and do any escaping at all must escape |
| 157 * the escape character itself: backslash. |
| 158 */ |
| 159 if (chtmp == '\\' && flags & ESC_FLAGS) { |
| 160 if(!io_ch(arg, "\\\\", 2)) return -1; |
| 161 return 2; |
| 162 } |
| 151 if(!io_ch(arg, &chtmp, 1)) return -1; | 163 if(!io_ch(arg, &chtmp, 1)) return -1; |
| 152 return 1; | 164 return 1; |
| 153 } | 165 } |
| 154 | 166 |
| 155 #define BUF_TYPE_WIDTH_MASK 0x7 | 167 #define BUF_TYPE_WIDTH_MASK 0x7 |
| 156 #define BUF_TYPE_CONVUTF8 0x8 | 168 #define BUF_TYPE_CONVUTF8 0x8 |
| 157 | 169 |
| 158 /* This function sends each character in a buffer to | 170 /* This function sends each character in a buffer to |
| 159 * do_esc_char(). It interprets the content formats | 171 * do_esc_char(). It interprets the content formats |
| 160 * and converts to or from UTF8 as appropriate. | 172 * and converts to or from UTF8 as appropriate. |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 -1, -1, -1, -1, -1, /* 0-4 */ | 297 -1, -1, -1, -1, -1, /* 0-4 */ |
| 286 -1, -1, -1, -1, -1, /* 5-9 */ | 298 -1, -1, -1, -1, -1, /* 5-9 */ |
| 287 -1, -1, 0, -1, /* 10-13 */ | 299 -1, -1, 0, -1, /* 10-13 */ |
| 288 -1, -1, -1, -1, /* 15-17 */ | 300 -1, -1, -1, -1, /* 15-17 */ |
| 289 -1, 1, 1, /* 18-20 */ | 301 -1, 1, 1, /* 18-20 */ |
| 290 -1, 1, 1, 1, /* 21-24 */ | 302 -1, 1, 1, 1, /* 21-24 */ |
| 291 -1, 1, -1, /* 25-27 */ | 303 -1, 1, -1, /* 25-27 */ |
| 292 4, -1, 2 /* 28-30 */ | 304 4, -1, 2 /* 28-30 */ |
| 293 }; | 305 }; |
| 294 | 306 |
| 295 #define ESC_FLAGS (ASN1_STRFLGS_ESC_2253 | \ | |
| 296 ASN1_STRFLGS_ESC_QUOTE | \ | |
| 297 ASN1_STRFLGS_ESC_CTRL | \ | |
| 298 ASN1_STRFLGS_ESC_MSB) | |
| 299 | |
| 300 /* This is the main function, print out an | 307 /* This is the main function, print out an |
| 301 * ASN1_STRING taking note of various escape | 308 * ASN1_STRING taking note of various escape |
| 302 * and display options. Returns number of | 309 * and display options. Returns number of |
| 303 * characters written or -1 if an error | 310 * characters written or -1 if an error |
| 304 * occurred. | 311 * occurred. |
| 305 */ | 312 */ |
| 306 | 313 |
| 307 static int do_print_ex(char_io *io_ch, void *arg, unsigned long lflags, ASN1_STR
ING *str) | 314 static int do_print_ex(char_io *io_ch, void *arg, unsigned long lflags, ASN1_STR
ING *str) |
| 308 { | 315 { |
| 309 int outlen, len; | 316 int outlen, len; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 if((type < 0) || (type > 30)) return -1; | 565 if((type < 0) || (type > 30)) return -1; |
| 559 mbflag = tag2nbyte[type]; | 566 mbflag = tag2nbyte[type]; |
| 560 if(mbflag == -1) return -1; | 567 if(mbflag == -1) return -1; |
| 561 mbflag |= MBSTRING_FLAG; | 568 mbflag |= MBSTRING_FLAG; |
| 562 stmp.data = NULL; | 569 stmp.data = NULL; |
| 563 ret = ASN1_mbstring_copy(&str, in->data, in->length, mbflag, B_ASN1_UTF8
STRING); | 570 ret = ASN1_mbstring_copy(&str, in->data, in->length, mbflag, B_ASN1_UTF8
STRING); |
| 564 if(ret < 0) return ret; | 571 if(ret < 0) return ret; |
| 565 *out = stmp.data; | 572 *out = stmp.data; |
| 566 return stmp.length; | 573 return stmp.length; |
| 567 } | 574 } |
| OLD | NEW |