diff options
author | jsing <> | 2014-04-18 13:14:31 +0000 |
---|---|---|
committer | jsing <> | 2014-04-18 13:14:31 +0000 |
commit | 48839e33a53ed2d6e54cb31ec1a93635e0a4dc60 (patch) | |
tree | f569441b32f0a3293eba8921ed58e2489986006c | |
parent | 8a0112534d8764e81ead87d96bc29f9f7087f881 (diff) | |
download | openbsd-48839e33a53ed2d6e54cb31ec1a93635e0a4dc60.tar.gz openbsd-48839e33a53ed2d6e54cb31ec1a93635e0a4dc60.tar.bz2 openbsd-48839e33a53ed2d6e54cb31ec1a93635e0a4dc60.zip |
More KNF.
-rw-r--r-- | src/lib/libcrypto/asn1/t_bitst.c | 39 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/t_crl.c | 68 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/t_pkey.c | 68 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/t_req.c | 220 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/t_spki.c | 38 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/t_x509.c | 469 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/t_x509a.c | 58 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/asn1/t_bitst.c | 39 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/asn1/t_crl.c | 68 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/asn1/t_pkey.c | 68 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/asn1/t_req.c | 220 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/asn1/t_spki.c | 38 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/asn1/t_x509.c | 469 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/asn1/t_x509a.c | 58 |
14 files changed, 1070 insertions, 850 deletions
diff --git a/src/lib/libcrypto/asn1/t_bitst.c b/src/lib/libcrypto/asn1/t_bitst.c index 2e59a25fa1..1dc04beabf 100644 --- a/src/lib/libcrypto/asn1/t_bitst.c +++ b/src/lib/libcrypto/asn1/t_bitst.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -61,15 +61,18 @@ | |||
61 | #include <openssl/conf.h> | 61 | #include <openssl/conf.h> |
62 | #include <openssl/x509v3.h> | 62 | #include <openssl/x509v3.h> |
63 | 63 | ||
64 | int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, | 64 | int |
65 | BIT_STRING_BITNAME *tbl, int indent) | 65 | ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, |
66 | BIT_STRING_BITNAME *tbl, int indent) | ||
66 | { | 67 | { |
67 | BIT_STRING_BITNAME *bnam; | 68 | BIT_STRING_BITNAME *bnam; |
68 | char first = 1; | 69 | char first = 1; |
70 | |||
69 | BIO_printf(out, "%*s", indent, ""); | 71 | BIO_printf(out, "%*s", indent, ""); |
70 | for(bnam = tbl; bnam->lname; bnam++) { | 72 | for (bnam = tbl; bnam->lname; bnam++) { |
71 | if(ASN1_BIT_STRING_get_bit(bs, bnam->bitnum)) { | 73 | if (ASN1_BIT_STRING_get_bit(bs, bnam->bitnum)) { |
72 | if(!first) BIO_puts(out, ", "); | 74 | if (!first) |
75 | BIO_puts(out, ", "); | ||
73 | BIO_puts(out, bnam->lname); | 76 | BIO_puts(out, bnam->lname); |
74 | first = 0; | 77 | first = 0; |
75 | } | 78 | } |
@@ -78,25 +81,31 @@ int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, | |||
78 | return 1; | 81 | return 1; |
79 | } | 82 | } |
80 | 83 | ||
81 | int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value, | 84 | int |
82 | BIT_STRING_BITNAME *tbl) | 85 | ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value, |
86 | BIT_STRING_BITNAME *tbl) | ||
83 | { | 87 | { |
84 | int bitnum; | 88 | int bitnum; |
89 | |||
85 | bitnum = ASN1_BIT_STRING_num_asc(name, tbl); | 90 | bitnum = ASN1_BIT_STRING_num_asc(name, tbl); |
86 | if(bitnum < 0) return 0; | 91 | if (bitnum < 0) |
87 | if(bs) { | 92 | return 0; |
88 | if(!ASN1_BIT_STRING_set_bit(bs, bitnum, value)) | 93 | if (bs) { |
94 | if (!ASN1_BIT_STRING_set_bit(bs, bitnum, value)) | ||
89 | return 0; | 95 | return 0; |
90 | } | 96 | } |
91 | return 1; | 97 | return 1; |
92 | } | 98 | } |
93 | 99 | ||
94 | int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl) | 100 | int |
101 | ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl) | ||
95 | { | 102 | { |
96 | BIT_STRING_BITNAME *bnam; | 103 | BIT_STRING_BITNAME *bnam; |
97 | for(bnam = tbl; bnam->lname; bnam++) { | 104 | |
98 | if(!strcmp(bnam->sname, name) || | 105 | for (bnam = tbl; bnam->lname; bnam++) { |
99 | !strcmp(bnam->lname, name) ) return bnam->bitnum; | 106 | if (!strcmp(bnam->sname, name) || |
107 | !strcmp(bnam->lname, name)) | ||
108 | return bnam->bitnum; | ||
100 | } | 109 | } |
101 | return -1; | 110 | return -1; |
102 | } | 111 | } |
diff --git a/src/lib/libcrypto/asn1/t_crl.c b/src/lib/libcrypto/asn1/t_crl.c index c665a26bce..cd1ed26174 100644 --- a/src/lib/libcrypto/asn1/t_crl.c +++ b/src/lib/libcrypto/asn1/t_crl.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -65,23 +65,25 @@ | |||
65 | #include <openssl/x509v3.h> | 65 | #include <openssl/x509v3.h> |
66 | 66 | ||
67 | #ifndef OPENSSL_NO_FP_API | 67 | #ifndef OPENSSL_NO_FP_API |
68 | int X509_CRL_print_fp(FILE *fp, X509_CRL *x) | 68 | int |
69 | X509_CRL_print_fp(FILE *fp, X509_CRL *x) | ||
69 | { | 70 | { |
70 | BIO *b; | 71 | BIO *b; |
71 | int ret; | 72 | int ret; |
72 | 73 | ||
73 | if ((b=BIO_new(BIO_s_file())) == NULL) { | 74 | if ((b = BIO_new(BIO_s_file())) == NULL) { |
74 | X509err(X509_F_X509_CRL_PRINT_FP,ERR_R_BUF_LIB); | 75 | X509err(X509_F_X509_CRL_PRINT_FP, ERR_R_BUF_LIB); |
75 | return(0); | 76 | return (0); |
76 | } | 77 | } |
77 | BIO_set_fp(b,fp,BIO_NOCLOSE); | 78 | BIO_set_fp(b, fp, BIO_NOCLOSE); |
78 | ret=X509_CRL_print(b, x); | 79 | ret = X509_CRL_print(b, x); |
79 | BIO_free(b); | 80 | BIO_free(b); |
80 | return(ret); | 81 | return (ret); |
81 | } | 82 | } |
82 | #endif | 83 | #endif |
83 | 84 | ||
84 | int X509_CRL_print(BIO *out, X509_CRL *x) | 85 | int |
86 | X509_CRL_print(BIO *out, X509_CRL *x) | ||
85 | { | 87 | { |
86 | STACK_OF(X509_REVOKED) *rev; | 88 | STACK_OF(X509_REVOKED) *rev; |
87 | X509_REVOKED *r; | 89 | X509_REVOKED *r; |
@@ -91,38 +93,40 @@ int X509_CRL_print(BIO *out, X509_CRL *x) | |||
91 | 93 | ||
92 | BIO_printf(out, "Certificate Revocation List (CRL):\n"); | 94 | BIO_printf(out, "Certificate Revocation List (CRL):\n"); |
93 | l = X509_CRL_get_version(x); | 95 | l = X509_CRL_get_version(x); |
94 | BIO_printf(out, "%8sVersion %lu (0x%lx)\n", "", l+1, l); | 96 | BIO_printf(out, "%8sVersion %lu (0x%lx)\n", "", l + 1, l); |
95 | i = OBJ_obj2nid(x->sig_alg->algorithm); | 97 | i = OBJ_obj2nid(x->sig_alg->algorithm); |
96 | X509_signature_print(out, x->sig_alg, NULL); | 98 | X509_signature_print(out, x->sig_alg, NULL); |
97 | p=X509_NAME_oneline(X509_CRL_get_issuer(x),NULL,0); | 99 | p = X509_NAME_oneline(X509_CRL_get_issuer(x), NULL, 0); |
98 | BIO_printf(out,"%8sIssuer: %s\n","",p); | 100 | BIO_printf(out, "%8sIssuer: %s\n", "", p); |
99 | free(p); | 101 | free(p); |
100 | BIO_printf(out,"%8sLast Update: ",""); | 102 | BIO_printf(out, "%8sLast Update: ", ""); |
101 | ASN1_TIME_print(out,X509_CRL_get_lastUpdate(x)); | 103 | ASN1_TIME_print(out, X509_CRL_get_lastUpdate(x)); |
102 | BIO_printf(out,"\n%8sNext Update: ",""); | 104 | BIO_printf(out, "\n%8sNext Update: ", ""); |
103 | if (X509_CRL_get_nextUpdate(x)) | 105 | if (X509_CRL_get_nextUpdate(x)) |
104 | ASN1_TIME_print(out,X509_CRL_get_nextUpdate(x)); | 106 | ASN1_TIME_print(out, X509_CRL_get_nextUpdate(x)); |
105 | else BIO_printf(out,"NONE"); | 107 | else |
106 | BIO_printf(out,"\n"); | 108 | BIO_printf(out, "NONE"); |
109 | BIO_printf(out, "\n"); | ||
107 | 110 | ||
108 | X509V3_extensions_print(out, "CRL extensions", | 111 | X509V3_extensions_print(out, "CRL extensions", |
109 | x->crl->extensions, 0, 8); | 112 | x->crl->extensions, 0, 8); |
110 | 113 | ||
111 | rev = X509_CRL_get_REVOKED(x); | 114 | rev = X509_CRL_get_REVOKED(x); |
112 | 115 | ||
113 | if(sk_X509_REVOKED_num(rev) > 0) | 116 | if (sk_X509_REVOKED_num(rev) > 0) |
114 | BIO_printf(out, "Revoked Certificates:\n"); | 117 | BIO_printf(out, "Revoked Certificates:\n"); |
115 | else BIO_printf(out, "No Revoked Certificates.\n"); | 118 | else |
119 | BIO_printf(out, "No Revoked Certificates.\n"); | ||
116 | 120 | ||
117 | for(i = 0; i < sk_X509_REVOKED_num(rev); i++) { | 121 | for (i = 0; i < sk_X509_REVOKED_num(rev); i++) { |
118 | r = sk_X509_REVOKED_value(rev, i); | 122 | r = sk_X509_REVOKED_value(rev, i); |
119 | BIO_printf(out," Serial Number: "); | 123 | BIO_printf(out, " Serial Number: "); |
120 | i2a_ASN1_INTEGER(out,r->serialNumber); | 124 | i2a_ASN1_INTEGER(out, r->serialNumber); |
121 | BIO_printf(out,"\n Revocation Date: "); | 125 | BIO_printf(out, "\n Revocation Date: "); |
122 | ASN1_TIME_print(out,r->revocationDate); | 126 | ASN1_TIME_print(out, r->revocationDate); |
123 | BIO_printf(out,"\n"); | 127 | BIO_printf(out, "\n"); |
124 | X509V3_extensions_print(out, "CRL entry extensions", | 128 | X509V3_extensions_print(out, "CRL entry extensions", |
125 | r->extensions, 0, 8); | 129 | r->extensions, 0, 8); |
126 | } | 130 | } |
127 | X509_signature_print(out, x->sig_alg, x->signature); | 131 | X509_signature_print(out, x->sig_alg, x->signature); |
128 | 132 | ||
diff --git a/src/lib/libcrypto/asn1/t_pkey.c b/src/lib/libcrypto/asn1/t_pkey.c index 12674e0125..579df8154c 100644 --- a/src/lib/libcrypto/asn1/t_pkey.c +++ b/src/lib/libcrypto/asn1/t_pkey.c | |||
@@ -5,21 +5,21 @@ | |||
5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
8 | * | 8 | * |
9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
11 | * apply to all code found in this distribution, be it the RC4, RSA, | 11 | * apply to all code found in this distribution, be it the RC4, RSA, |
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
13 | * included with this distribution is covered by the same copyright terms | 13 | * included with this distribution is covered by the same copyright terms |
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
15 | * | 15 | * |
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
18 | * If this package is used in a product, Eric Young should be given attribution | 18 | * If this package is used in a product, Eric Young should be given attribution |
19 | * as the author of the parts of the library used. | 19 | * as the author of the parts of the library used. |
20 | * This can be in the form of a textual message at program startup or | 20 | * This can be in the form of a textual message at program startup or |
21 | * in documentation (online or textual) provided with the package. | 21 | * in documentation (online or textual) provided with the package. |
22 | * | 22 | * |
23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
25 | * are met: | 25 | * are met: |
@@ -34,10 +34,10 @@ | |||
34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 37 | * 4. If you include any Windows specific code (or a derivative thereof) from |
38 | * the apps directory (application code) you must include an acknowledgement: | 38 | * the apps directory (application code) you must include an acknowledgement: |
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
40 | * | 40 | * |
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -49,7 +49,7 @@ | |||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
52 | * | 52 | * |
53 | * The licence and distribution terms for any publically available version or | 53 | * The licence and distribution terms for any publically available version or |
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
@@ -62,15 +62,17 @@ | |||
62 | #include <openssl/buffer.h> | 62 | #include <openssl/buffer.h> |
63 | #include <openssl/bn.h> | 63 | #include <openssl/bn.h> |
64 | 64 | ||
65 | int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, | 65 | int |
66 | unsigned char *buf, int off) | 66 | ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, |
67 | unsigned char *buf, int off) | ||
67 | { | 68 | { |
68 | int n,i; | 69 | int n, i; |
69 | const char *neg; | 70 | const char *neg; |
70 | 71 | ||
71 | if (num == NULL) return(1); | 72 | if (num == NULL) |
72 | neg = (BN_is_negative(num))?"-":""; | 73 | return (1); |
73 | if(!BIO_indent(bp,off,128)) | 74 | neg = (BN_is_negative(num)) ? "-" : ""; |
75 | if (!BIO_indent(bp, off, 128)) | ||
74 | return 0; | 76 | return 0; |
75 | if (BN_is_zero(num)) { | 77 | if (BN_is_zero(num)) { |
76 | if (BIO_printf(bp, "%s 0\n", number) <= 0) | 78 | if (BIO_printf(bp, "%s 0\n", number) <= 0) |
@@ -79,30 +81,34 @@ int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, | |||
79 | } | 81 | } |
80 | 82 | ||
81 | if (BN_num_bytes(num) <= BN_BYTES) { | 83 | if (BN_num_bytes(num) <= BN_BYTES) { |
82 | if (BIO_printf(bp,"%s %s%lu (%s0x%lx)\n",number,neg, | 84 | if (BIO_printf(bp, "%s %s%lu (%s0x%lx)\n", number, neg, |
83 | (unsigned long)num->d[0],neg,(unsigned long)num->d[0]) | 85 | (unsigned long)num->d[0], neg, |
84 | <= 0) return(0); | 86 | (unsigned long)num->d[0]) <= 0) |
87 | return (0); | ||
85 | } else { | 88 | } else { |
86 | buf[0]=0; | 89 | buf[0] = 0; |
87 | if (BIO_printf(bp,"%s%s",number, | 90 | if (BIO_printf(bp, "%s%s", number, |
88 | (neg[0] == '-')?" (Negative)":"") <= 0) | 91 | (neg[0] == '-') ? " (Negative)" : "") <= 0) |
89 | return(0); | 92 | return (0); |
90 | n=BN_bn2bin(num,&buf[1]); | 93 | n = BN_bn2bin(num, &buf[1]); |
91 | 94 | ||
92 | if (buf[1] & 0x80) | 95 | if (buf[1] & 0x80) |
93 | n++; | 96 | n++; |
94 | else buf++; | 97 | else |
98 | buf++; | ||
95 | 99 | ||
96 | for (i=0; i<n; i++) { | 100 | for (i = 0; i < n; i++) { |
97 | if ((i%15) == 0) { | 101 | if ((i % 15) == 0) { |
98 | if(BIO_puts(bp,"\n") <= 0 | 102 | if (BIO_puts(bp, "\n") <= 0 || |
99 | || !BIO_indent(bp,off+4,128)) | 103 | !BIO_indent(bp, off + 4, 128)) |
100 | return 0; | 104 | return 0; |
101 | } | 105 | } |
102 | if (BIO_printf(bp,"%02x%s",buf[i],((i+1) == n)?"":":") | 106 | if (BIO_printf(bp, "%02x%s", buf[i], |
103 | <= 0) return(0); | 107 | ((i + 1) == n) ? "" : ":") <= 0) |
108 | return (0); | ||
104 | } | 109 | } |
105 | if (BIO_write(bp,"\n",1) <= 0) return(0); | 110 | if (BIO_write(bp, "\n", 1) <= 0) |
111 | return (0); | ||
106 | } | 112 | } |
107 | return(1); | 113 | return (1); |
108 | } | 114 | } |
diff --git a/src/lib/libcrypto/asn1/t_req.c b/src/lib/libcrypto/asn1/t_req.c index 4457f5291e..331440bed5 100644 --- a/src/lib/libcrypto/asn1/t_req.c +++ b/src/lib/libcrypto/asn1/t_req.c | |||
@@ -5,21 +5,21 @@ | |||
5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
8 | * | 8 | * |
9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
11 | * apply to all code found in this distribution, be it the RC4, RSA, | 11 | * apply to all code found in this distribution, be it the RC4, RSA, |
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
13 | * included with this distribution is covered by the same copyright terms | 13 | * included with this distribution is covered by the same copyright terms |
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
15 | * | 15 | * |
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
18 | * If this package is used in a product, Eric Young should be given attribution | 18 | * If this package is used in a product, Eric Young should be given attribution |
19 | * as the author of the parts of the library used. | 19 | * as the author of the parts of the library used. |
20 | * This can be in the form of a textual message at program startup or | 20 | * This can be in the form of a textual message at program startup or |
21 | * in documentation (online or textual) provided with the package. | 21 | * in documentation (online or textual) provided with the package. |
22 | * | 22 | * |
23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
25 | * are met: | 25 | * are met: |
@@ -34,10 +34,10 @@ | |||
34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 37 | * 4. If you include any Windows specific code (or a derivative thereof) from |
38 | * the apps directory (application code) you must include an acknowledgement: | 38 | * the apps directory (application code) you must include an acknowledgement: |
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
40 | * | 40 | * |
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -49,7 +49,7 @@ | |||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
52 | * | 52 | * |
53 | * The licence and distribution terms for any publically available version or | 53 | * The licence and distribution terms for any publically available version or |
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
@@ -71,23 +71,26 @@ | |||
71 | #endif | 71 | #endif |
72 | 72 | ||
73 | #ifndef OPENSSL_NO_FP_API | 73 | #ifndef OPENSSL_NO_FP_API |
74 | int X509_REQ_print_fp(FILE *fp, X509_REQ *x) | 74 | int |
75 | X509_REQ_print_fp(FILE *fp, X509_REQ *x) | ||
75 | { | 76 | { |
76 | BIO *b; | 77 | BIO *b; |
77 | int ret; | 78 | int ret; |
78 | 79 | ||
79 | if ((b=BIO_new(BIO_s_file())) == NULL) { | 80 | if ((b = BIO_new(BIO_s_file())) == NULL) { |
80 | X509err(X509_F_X509_REQ_PRINT_FP,ERR_R_BUF_LIB); | 81 | X509err(X509_F_X509_REQ_PRINT_FP, ERR_R_BUF_LIB); |
81 | return(0); | 82 | return (0); |
82 | } | 83 | } |
83 | BIO_set_fp(b,fp,BIO_NOCLOSE); | 84 | BIO_set_fp(b, fp, BIO_NOCLOSE); |
84 | ret=X509_REQ_print(b, x); | 85 | ret = X509_REQ_print(b, x); |
85 | BIO_free(b); | 86 | BIO_free(b); |
86 | return(ret); | 87 | return (ret); |
87 | } | 88 | } |
88 | #endif | 89 | #endif |
89 | 90 | ||
90 | int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, unsigned long cflag) | 91 | int |
92 | X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, | ||
93 | unsigned long cflag) | ||
91 | { | 94 | { |
92 | unsigned long l; | 95 | unsigned long l; |
93 | int i; | 96 | int i; |
@@ -99,49 +102,55 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, unsigned long | |||
99 | char mlch = ' '; | 102 | char mlch = ' '; |
100 | int nmindent = 0; | 103 | int nmindent = 0; |
101 | 104 | ||
102 | if((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) { | 105 | if ((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) { |
103 | mlch = '\n'; | 106 | mlch = '\n'; |
104 | nmindent = 12; | 107 | nmindent = 12; |
105 | } | 108 | } |
106 | 109 | ||
107 | if(nmflags == X509_FLAG_COMPAT) | 110 | if (nmflags == X509_FLAG_COMPAT) |
108 | nmindent = 16; | 111 | nmindent = 16; |
109 | 112 | ||
113 | ri = x->req_info; | ||
114 | if (!(cflag & X509_FLAG_NO_HEADER)) { | ||
115 | if (BIO_write(bp, "Certificate Request:\n", 21) <= 0) | ||
116 | goto err; | ||
117 | if (BIO_write(bp, " Data:\n", 10) <= 0) | ||
110 | 118 | ||
111 | ri=x->req_info; | 119 | goto err; |
112 | if(!(cflag & X509_FLAG_NO_HEADER)) { | ||
113 | if (BIO_write(bp,"Certificate Request:\n",21) <= 0) goto err; | ||
114 | if (BIO_write(bp," Data:\n",10) <= 0) goto err; | ||
115 | } | 120 | } |
116 | if(!(cflag & X509_FLAG_NO_VERSION)) { | 121 | if (!(cflag & X509_FLAG_NO_VERSION)) { |
117 | neg=(ri->version->type == V_ASN1_NEG_INTEGER)?"-":""; | 122 | neg = (ri->version->type == V_ASN1_NEG_INTEGER) ? "-" : ""; |
118 | l=0; | 123 | l = 0; |
119 | for (i=0; i<ri->version->length; i++) { | 124 | for (i = 0; i < ri->version->length; i++) { |
120 | l<<=8; l+=ri->version->data[i]; | 125 | l <<= 8; |
126 | l += ri->version->data[i]; | ||
121 | } | 127 | } |
122 | if(BIO_printf(bp,"%8sVersion: %s%lu (%s0x%lx)\n","",neg,l,neg, | 128 | if (BIO_printf(bp, "%8sVersion: %s%lu (%s0x%lx)\n", "", neg, |
123 | l) <= 0) | 129 | l, neg, l) <= 0) |
124 | goto err; | 130 | goto err; |
131 | } | ||
132 | if (!(cflag & X509_FLAG_NO_SUBJECT)) { | ||
133 | if (BIO_printf(bp, " Subject:%c", mlch) <= 0) | ||
134 | goto err; | ||
135 | if (X509_NAME_print_ex(bp, ri->subject, nmindent, nmflags) < 0) | ||
136 | goto err; | ||
137 | if (BIO_write(bp, "\n", 1) <= 0) | ||
138 | goto err; | ||
125 | } | 139 | } |
126 | if(!(cflag & X509_FLAG_NO_SUBJECT)) | 140 | if (!(cflag & X509_FLAG_NO_PUBKEY)) { |
127 | { | 141 | if (BIO_write(bp, " Subject Public Key Info:\n", |
128 | if (BIO_printf(bp," Subject:%c",mlch) <= 0) goto err; | 142 | 33) <= 0) |
129 | if (X509_NAME_print_ex(bp,ri->subject,nmindent, nmflags) < 0) goto err; | ||
130 | if (BIO_write(bp,"\n",1) <= 0) goto err; | ||
131 | } | ||
132 | if(!(cflag & X509_FLAG_NO_PUBKEY)) { | ||
133 | if (BIO_write(bp," Subject Public Key Info:\n",33) <= 0) | ||
134 | goto err; | 143 | goto err; |
135 | if (BIO_printf(bp,"%12sPublic Key Algorithm: ","") <= 0) | 144 | if (BIO_printf(bp, "%12sPublic Key Algorithm: ", "") <= 0) |
136 | goto err; | 145 | goto err; |
137 | if (i2a_ASN1_OBJECT(bp, ri->pubkey->algor->algorithm) <= 0) | 146 | if (i2a_ASN1_OBJECT(bp, ri->pubkey->algor->algorithm) <= 0) |
138 | goto err; | 147 | goto err; |
139 | if (BIO_puts(bp, "\n") <= 0) | 148 | if (BIO_puts(bp, "\n") <= 0) |
140 | goto err; | 149 | goto err; |
141 | 150 | ||
142 | pkey=X509_REQ_get_pubkey(x); | 151 | pkey = X509_REQ_get_pubkey(x); |
143 | if (pkey == NULL) { | 152 | if (pkey == NULL) { |
144 | BIO_printf(bp,"%12sUnable to load Public Key\n",""); | 153 | BIO_printf(bp, "%12sUnable to load Public Key\n", ""); |
145 | ERR_print_errors(bp); | 154 | ERR_print_errors(bp); |
146 | } else { | 155 | } else { |
147 | EVP_PKEY_print_public(bp, pkey, 16, NULL); | 156 | EVP_PKEY_print_public(bp, pkey, 16, NULL); |
@@ -149,95 +158,108 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, unsigned long | |||
149 | } | 158 | } |
150 | } | 159 | } |
151 | 160 | ||
152 | if(!(cflag & X509_FLAG_NO_ATTRIBUTES)) { | 161 | if (!(cflag & X509_FLAG_NO_ATTRIBUTES)) { |
153 | /* may not be */ | 162 | /* may not be */ |
154 | if(BIO_printf(bp,"%8sAttributes:\n","") <= 0) | 163 | if (BIO_printf(bp, "%8sAttributes:\n", "") <= 0) |
155 | goto err; | 164 | goto err; |
156 | 165 | ||
157 | sk=x->req_info->attributes; | 166 | sk = x->req_info->attributes; |
158 | if (sk_X509_ATTRIBUTE_num(sk) == 0) { | 167 | if (sk_X509_ATTRIBUTE_num(sk) == 0) { |
159 | if(BIO_printf(bp,"%12sa0:00\n","") <= 0) | 168 | if (BIO_printf(bp, "%12sa0:00\n", "") <= 0) |
160 | goto err; | 169 | goto err; |
161 | } else { | 170 | } else { |
162 | for (i=0; i<sk_X509_ATTRIBUTE_num(sk); i++) { | 171 | for (i = 0; i < sk_X509_ATTRIBUTE_num(sk); i++) { |
163 | ASN1_TYPE *at; | 172 | ASN1_TYPE *at; |
164 | X509_ATTRIBUTE *a; | 173 | X509_ATTRIBUTE *a; |
165 | ASN1_BIT_STRING *bs=NULL; | 174 | ASN1_BIT_STRING *bs = NULL; |
166 | ASN1_TYPE *t; | 175 | ASN1_TYPE *t; |
167 | int j,type=0,count=1,ii=0; | 176 | int j, type = 0, count = 1, ii = 0; |
168 | 177 | ||
169 | a=sk_X509_ATTRIBUTE_value(sk,i); | 178 | a = sk_X509_ATTRIBUTE_value(sk, i); |
170 | if(X509_REQ_extension_nid(OBJ_obj2nid(a->object))) | 179 | if (X509_REQ_extension_nid( |
171 | continue; | 180 | OBJ_obj2nid(a->object))) |
172 | if(BIO_printf(bp,"%12s","") <= 0) | 181 | continue; |
173 | goto err; | 182 | if (BIO_printf(bp, "%12s", "") <= 0) |
174 | if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0) { | 183 | goto err; |
175 | if (a->single) { | 184 | if ((j = i2a_ASN1_OBJECT(bp, a->object)) > 0) { |
176 | t=a->value.single; | 185 | if (a->single) { |
177 | type=t->type; | 186 | t = a->value.single; |
178 | bs=t->value.bit_string; | 187 | type = t->type; |
179 | } else { | 188 | bs = t->value.bit_string; |
180 | ii=0; | 189 | } else { |
181 | count=sk_ASN1_TYPE_num(a->value.set); | 190 | ii = 0; |
191 | count = sk_ASN1_TYPE_num( | ||
192 | a->value.set); | ||
182 | get_next: | 193 | get_next: |
183 | at=sk_ASN1_TYPE_value(a->value.set,ii); | 194 | at = sk_ASN1_TYPE_value( |
184 | type=at->type; | 195 | a->value.set, ii); |
185 | bs=at->value.asn1_string; | 196 | type = at->type; |
197 | bs = at->value.asn1_string; | ||
198 | } | ||
186 | } | 199 | } |
187 | } | 200 | for (j = 25 - j; j > 0; j--) |
188 | for (j=25-j; j>0; j--) | 201 | if (BIO_write(bp, " ", 1) != 1) |
189 | if (BIO_write(bp," ",1) != 1) goto err; | ||
190 | if (BIO_puts(bp,":") <= 0) goto err; | ||
191 | if ( (type == V_ASN1_PRINTABLESTRING) || | ||
192 | (type == V_ASN1_T61STRING) || | ||
193 | (type == V_ASN1_IA5STRING)) { | ||
194 | if (BIO_write(bp,(char *)bs->data,bs->length) | ||
195 | != bs->length) | ||
196 | goto err; | 202 | goto err; |
197 | BIO_puts(bp,"\n"); | 203 | if (BIO_puts(bp, ":") <= 0) |
204 | goto err; | ||
205 | if ((type == V_ASN1_PRINTABLESTRING) || | ||
206 | (type == V_ASN1_T61STRING) || | ||
207 | (type == V_ASN1_IA5STRING)) { | ||
208 | if (BIO_write(bp, (char *)bs->data, | ||
209 | bs->length) != bs->length) | ||
210 | goto err; | ||
211 | BIO_puts(bp, "\n"); | ||
198 | } else { | 212 | } else { |
199 | BIO_puts(bp,"unable to print attribute\n"); | 213 | BIO_puts(bp, |
214 | "unable to print attribute\n"); | ||
200 | } | 215 | } |
201 | if (++ii < count) goto get_next; | 216 | if (++ii < count) |
217 | goto get_next; | ||
202 | } | 218 | } |
203 | } | 219 | } |
204 | } | 220 | } |
205 | if(!(cflag & X509_FLAG_NO_EXTENSIONS)) { | 221 | if (!(cflag & X509_FLAG_NO_EXTENSIONS)) { |
206 | exts = X509_REQ_get_extensions(x); | 222 | exts = X509_REQ_get_extensions(x); |
207 | if(exts) { | 223 | if (exts) { |
208 | BIO_printf(bp,"%8sRequested Extensions:\n",""); | 224 | BIO_printf(bp, "%8sRequested Extensions:\n", ""); |
209 | for (i=0; i<sk_X509_EXTENSION_num(exts); i++) { | 225 | for (i = 0; i < sk_X509_EXTENSION_num(exts); i++) { |
210 | ASN1_OBJECT *obj; | 226 | ASN1_OBJECT *obj; |
211 | X509_EXTENSION *ex; | 227 | X509_EXTENSION *ex; |
212 | int j; | 228 | int j; |
213 | ex=sk_X509_EXTENSION_value(exts, i); | 229 | ex = sk_X509_EXTENSION_value(exts, i); |
214 | if (BIO_printf(bp,"%12s","") <= 0) goto err; | 230 | if (BIO_printf(bp, "%12s", "") <= 0) |
215 | obj=X509_EXTENSION_get_object(ex); | 231 | goto err; |
216 | i2a_ASN1_OBJECT(bp,obj); | 232 | obj = X509_EXTENSION_get_object(ex); |
217 | j=X509_EXTENSION_get_critical(ex); | 233 | i2a_ASN1_OBJECT(bp, obj); |
218 | if (BIO_printf(bp,": %s\n",j?"critical":"") <= 0) | 234 | j = X509_EXTENSION_get_critical(ex); |
235 | if (BIO_printf(bp, ": %s\n", | ||
236 | j ? "critical" : "") <= 0) | ||
219 | goto err; | 237 | goto err; |
220 | if(!X509V3_EXT_print(bp, ex, cflag, 16)) { | 238 | if (!X509V3_EXT_print(bp, ex, cflag, 16)) { |
221 | BIO_printf(bp, "%16s", ""); | 239 | BIO_printf(bp, "%16s", ""); |
222 | M_ASN1_OCTET_STRING_print(bp,ex->value); | 240 | M_ASN1_OCTET_STRING_print(bp, ex->value); |
223 | } | 241 | } |
224 | if (BIO_write(bp,"\n",1) <= 0) goto err; | 242 | if (BIO_write(bp, "\n", 1) <= 0) |
243 | goto err; | ||
225 | } | 244 | } |
226 | sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free); | 245 | sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free); |
227 | } | 246 | } |
228 | } | 247 | } |
229 | 248 | ||
230 | if(!(cflag & X509_FLAG_NO_SIGDUMP)) { | 249 | if (!(cflag & X509_FLAG_NO_SIGDUMP)) { |
231 | if(!X509_signature_print(bp, x->sig_alg, x->signature)) goto err; | 250 | if (!X509_signature_print(bp, x->sig_alg, x->signature)) |
251 | goto err; | ||
232 | } | 252 | } |
233 | 253 | ||
234 | return(1); | 254 | return (1); |
255 | |||
235 | err: | 256 | err: |
236 | X509err(X509_F_X509_REQ_PRINT_EX,ERR_R_BUF_LIB); | 257 | X509err(X509_F_X509_REQ_PRINT_EX, ERR_R_BUF_LIB); |
237 | return(0); | 258 | return (0); |
238 | } | 259 | } |
239 | 260 | ||
240 | int X509_REQ_print(BIO *bp, X509_REQ *x) | 261 | int |
262 | X509_REQ_print(BIO *bp, X509_REQ *x) | ||
241 | { | 263 | { |
242 | return X509_REQ_print_ex(bp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT); | 264 | return X509_REQ_print_ex(bp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT); |
243 | } | 265 | } |
diff --git a/src/lib/libcrypto/asn1/t_spki.c b/src/lib/libcrypto/asn1/t_spki.c index f135754535..0265461b04 100644 --- a/src/lib/libcrypto/asn1/t_spki.c +++ b/src/lib/libcrypto/asn1/t_spki.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -70,38 +70,40 @@ | |||
70 | 70 | ||
71 | /* Print out an SPKI */ | 71 | /* Print out an SPKI */ |
72 | 72 | ||
73 | int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki) | 73 | int |
74 | NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki) | ||
74 | { | 75 | { |
75 | EVP_PKEY *pkey; | 76 | EVP_PKEY *pkey; |
76 | ASN1_IA5STRING *chal; | 77 | ASN1_IA5STRING *chal; |
77 | int i, n; | 78 | int i, n; |
78 | char *s; | 79 | char *s; |
80 | |||
79 | BIO_printf(out, "Netscape SPKI:\n"); | 81 | BIO_printf(out, "Netscape SPKI:\n"); |
80 | i=OBJ_obj2nid(spki->spkac->pubkey->algor->algorithm); | 82 | i = OBJ_obj2nid(spki->spkac->pubkey->algor->algorithm); |
81 | BIO_printf(out," Public Key Algorithm: %s\n", | 83 | BIO_printf(out, " Public Key Algorithm: %s\n", |
82 | (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)); | 84 | (i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i)); |
83 | pkey = X509_PUBKEY_get(spki->spkac->pubkey); | 85 | pkey = X509_PUBKEY_get(spki->spkac->pubkey); |
84 | if(!pkey) | 86 | if (!pkey) |
85 | BIO_printf(out, " Unable to load public key\n"); | 87 | BIO_printf(out, " Unable to load public key\n"); |
86 | else { | 88 | else { |
87 | EVP_PKEY_print_public(out, pkey, 4, NULL); | 89 | EVP_PKEY_print_public(out, pkey, 4, NULL); |
88 | EVP_PKEY_free(pkey); | 90 | EVP_PKEY_free(pkey); |
89 | } | 91 | } |
90 | chal = spki->spkac->challenge; | 92 | chal = spki->spkac->challenge; |
91 | if(chal->length) | 93 | if (chal->length) |
92 | BIO_printf(out, " Challenge String: %s\n", chal->data); | 94 | BIO_printf(out, " Challenge String: %s\n", chal->data); |
93 | i=OBJ_obj2nid(spki->sig_algor->algorithm); | 95 | i = OBJ_obj2nid(spki->sig_algor->algorithm); |
94 | BIO_printf(out," Signature Algorithm: %s", | 96 | BIO_printf(out, " Signature Algorithm: %s", |
95 | (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)); | 97 | (i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i)); |
96 | 98 | ||
97 | n=spki->signature->length; | 99 | n = spki->signature->length; |
98 | s=(char *)spki->signature->data; | 100 | s = (char *)spki->signature->data; |
99 | for (i=0; i<n; i++) { | 101 | for (i = 0; i < n; i++) { |
100 | if ((i%18) == 0) | 102 | if ((i % 18) == 0) |
101 | BIO_write(out,"\n ",7); | 103 | BIO_write(out, "\n ", 7); |
102 | BIO_printf(out,"%02x%s",(unsigned char)s[i], | 104 | BIO_printf(out, "%02x%s", (unsigned char)s[i], |
103 | ((i+1) == n)?"":":"); | 105 | ((i + 1) == n) ? "" : ":"); |
104 | } | 106 | } |
105 | BIO_write(out,"\n",1); | 107 | BIO_write(out, "\n", 1); |
106 | return 1; | 108 | return 1; |
107 | } | 109 | } |
diff --git a/src/lib/libcrypto/asn1/t_x509.c b/src/lib/libcrypto/asn1/t_x509.c index 32f1a4f4b0..de3fa22171 100644 --- a/src/lib/libcrypto/asn1/t_x509.c +++ b/src/lib/libcrypto/asn1/t_x509.c | |||
@@ -5,21 +5,21 @@ | |||
5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
8 | * | 8 | * |
9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
11 | * apply to all code found in this distribution, be it the RC4, RSA, | 11 | * apply to all code found in this distribution, be it the RC4, RSA, |
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
13 | * included with this distribution is covered by the same copyright terms | 13 | * included with this distribution is covered by the same copyright terms |
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
15 | * | 15 | * |
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
18 | * If this package is used in a product, Eric Young should be given attribution | 18 | * If this package is used in a product, Eric Young should be given attribution |
19 | * as the author of the parts of the library used. | 19 | * as the author of the parts of the library used. |
20 | * This can be in the form of a textual message at program startup or | 20 | * This can be in the form of a textual message at program startup or |
21 | * in documentation (online or textual) provided with the package. | 21 | * in documentation (online or textual) provided with the package. |
22 | * | 22 | * |
23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
25 | * are met: | 25 | * are met: |
@@ -34,10 +34,10 @@ | |||
34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 37 | * 4. If you include any Windows specific code (or a derivative thereof) from |
38 | * the apps directory (application code) you must include an acknowledgement: | 38 | * the apps directory (application code) you must include an acknowledgement: |
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
40 | * | 40 | * |
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -49,7 +49,7 @@ | |||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
52 | * | 52 | * |
53 | * The licence and distribution terms for any publically available version or | 53 | * The licence and distribution terms for any publically available version or |
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
@@ -75,92 +75,102 @@ | |||
75 | #include "asn1_locl.h" | 75 | #include "asn1_locl.h" |
76 | 76 | ||
77 | #ifndef OPENSSL_NO_FP_API | 77 | #ifndef OPENSSL_NO_FP_API |
78 | int X509_print_fp(FILE *fp, X509 *x) | 78 | int |
79 | X509_print_fp(FILE *fp, X509 *x) | ||
79 | { | 80 | { |
80 | return X509_print_ex_fp(fp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT); | 81 | return X509_print_ex_fp(fp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT); |
81 | } | 82 | } |
82 | 83 | ||
83 | int X509_print_ex_fp(FILE *fp, X509 *x, unsigned long nmflag, unsigned long cflag) | 84 | int |
84 | { | 85 | X509_print_ex_fp(FILE *fp, X509 *x, unsigned long nmflag, unsigned long cflag) |
85 | BIO *b; | 86 | { |
86 | int ret; | 87 | BIO *b; |
88 | int ret; | ||
87 | 89 | ||
88 | if ((b=BIO_new(BIO_s_file())) == NULL) { | 90 | if ((b = BIO_new(BIO_s_file())) == NULL) { |
89 | X509err(X509_F_X509_PRINT_EX_FP,ERR_R_BUF_LIB); | 91 | X509err(X509_F_X509_PRINT_EX_FP, ERR_R_BUF_LIB); |
90 | return(0); | 92 | return (0); |
91 | } | 93 | } |
92 | BIO_set_fp(b,fp,BIO_NOCLOSE); | 94 | BIO_set_fp(b, fp, BIO_NOCLOSE); |
93 | ret=X509_print_ex(b, x, nmflag, cflag); | 95 | ret = X509_print_ex(b, x, nmflag, cflag); |
94 | BIO_free(b); | 96 | BIO_free(b); |
95 | return(ret); | 97 | return (ret); |
96 | } | 98 | } |
97 | #endif | 99 | #endif |
98 | 100 | ||
99 | int X509_print(BIO *bp, X509 *x) | 101 | int |
102 | X509_print(BIO *bp, X509 *x) | ||
100 | { | 103 | { |
101 | return X509_print_ex(bp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT); | 104 | return X509_print_ex(bp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT); |
102 | } | 105 | } |
103 | 106 | ||
104 | int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag) | 107 | int |
108 | X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag) | ||
105 | { | 109 | { |
106 | long l; | 110 | long l; |
107 | int ret=0,i; | 111 | int ret = 0, i; |
108 | char *m=NULL,mlch = ' '; | 112 | char *m = NULL, mlch = ' '; |
109 | int nmindent = 0; | 113 | int nmindent = 0; |
110 | X509_CINF *ci; | 114 | X509_CINF *ci; |
111 | ASN1_INTEGER *bs; | 115 | ASN1_INTEGER *bs; |
112 | EVP_PKEY *pkey=NULL; | 116 | EVP_PKEY *pkey = NULL; |
113 | const char *neg; | 117 | const char *neg; |
114 | 118 | ||
115 | if((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) { | 119 | if ((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) { |
116 | mlch = '\n'; | 120 | mlch = '\n'; |
117 | nmindent = 12; | 121 | nmindent = 12; |
118 | } | 122 | } |
119 | 123 | ||
120 | if(nmflags == X509_FLAG_COMPAT) | 124 | if (nmflags == X509_FLAG_COMPAT) |
121 | nmindent = 16; | 125 | nmindent = 16; |
122 | 126 | ||
123 | ci=x->cert_info; | 127 | ci = x->cert_info; |
124 | if(!(cflag & X509_FLAG_NO_HEADER)) { | 128 | if (!(cflag & X509_FLAG_NO_HEADER)) { |
125 | if (BIO_write(bp,"Certificate:\n",13) <= 0) goto err; | 129 | if (BIO_write(bp, "Certificate:\n", 13) <= 0) |
126 | if (BIO_write(bp," Data:\n",10) <= 0) goto err; | 130 | goto err; |
131 | if (BIO_write(bp, " Data:\n", 10) <= 0) | ||
132 | goto err; | ||
127 | } | 133 | } |
128 | if(!(cflag & X509_FLAG_NO_VERSION)) { | 134 | if (!(cflag & X509_FLAG_NO_VERSION)) { |
129 | l=X509_get_version(x); | 135 | l = X509_get_version(x); |
130 | if (BIO_printf(bp,"%8sVersion: %lu (0x%lx)\n","",l+1,l) <= 0) goto err; | 136 | if (BIO_printf(bp, "%8sVersion: %lu (0x%lx)\n", |
137 | "", l + 1, l) <= 0) | ||
138 | goto err; | ||
131 | } | 139 | } |
132 | if(!(cflag & X509_FLAG_NO_SERIAL)) { | 140 | if (!(cflag & X509_FLAG_NO_SERIAL)) { |
133 | 141 | if (BIO_write(bp, " Serial Number:", 22) <= 0) | |
134 | if (BIO_write(bp," Serial Number:",22) <= 0) goto err; | 142 | goto err; |
135 | 143 | ||
136 | bs=X509_get_serialNumber(x); | 144 | bs = X509_get_serialNumber(x); |
137 | if (bs->length <= (int)sizeof(long)) { | 145 | if (bs->length <= (int)sizeof(long)) { |
138 | l=ASN1_INTEGER_get(bs); | 146 | l = ASN1_INTEGER_get(bs); |
139 | if (bs->type == V_ASN1_NEG_INTEGER) { | 147 | if (bs->type == V_ASN1_NEG_INTEGER) { |
140 | l= -l; | 148 | l = -l; |
141 | neg="-"; | 149 | neg = "-"; |
142 | } else | 150 | } else |
143 | neg=""; | 151 | neg = ""; |
144 | if (BIO_printf(bp," %s%lu (%s0x%lx)\n",neg,l,neg,l) <= 0) | 152 | if (BIO_printf(bp, " %s%lu (%s0x%lx)\n", |
153 | neg, l, neg, l) <= 0) | ||
145 | goto err; | 154 | goto err; |
146 | } else { | 155 | } else { |
147 | neg=(bs->type == V_ASN1_NEG_INTEGER)?" (Negative)":""; | 156 | neg = (bs->type == V_ASN1_NEG_INTEGER) ? |
148 | if (BIO_printf(bp,"\n%12s%s","",neg) <= 0) goto err; | 157 | " (Negative)" : ""; |
149 | 158 | if (BIO_printf(bp, "\n%12s%s", "", neg) <= 0) | |
150 | for (i=0; i<bs->length; i++) { | 159 | goto err; |
151 | if (BIO_printf(bp,"%02x%c",bs->data[i], | 160 | for (i = 0; i < bs->length; i++) { |
152 | ((i+1 == bs->length)?'\n':':')) <= 0) | 161 | if (BIO_printf(bp, "%02x%c", bs->data[i], |
162 | ((i + 1 == bs->length) ? '\n' : ':')) <= 0) | ||
153 | goto err; | 163 | goto err; |
154 | } | 164 | } |
155 | } | 165 | } |
156 | 166 | ||
157 | } | 167 | } |
158 | 168 | ||
159 | if(!(cflag & X509_FLAG_NO_SIGNAME)) { | 169 | if (!(cflag & X509_FLAG_NO_SIGNAME)) { |
160 | if(X509_signature_print(bp, x->sig_alg, NULL) <= 0) | 170 | if (X509_signature_print(bp, x->sig_alg, NULL) <= 0) |
161 | goto err; | 171 | goto err; |
162 | #if 0 | 172 | #if 0 |
163 | if (BIO_printf(bp,"%8sSignature Algorithm: ","") <= 0) | 173 | if (BIO_printf(bp, "%8sSignature Algorithm: ", "") <= 0) |
164 | goto err; | 174 | goto err; |
165 | if (i2a_ASN1_OBJECT(bp, ci->signature->algorithm) <= 0) | 175 | if (i2a_ASN1_OBJECT(bp, ci->signature->algorithm) <= 0) |
166 | goto err; | 176 | goto err; |
@@ -169,37 +179,52 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag) | |||
169 | #endif | 179 | #endif |
170 | } | 180 | } |
171 | 181 | ||
172 | if(!(cflag & X509_FLAG_NO_ISSUER)) { | 182 | if (!(cflag & X509_FLAG_NO_ISSUER)) { |
173 | if (BIO_printf(bp," Issuer:%c",mlch) <= 0) goto err; | 183 | if (BIO_printf(bp, " Issuer:%c", mlch) <= 0) |
174 | if (X509_NAME_print_ex(bp,X509_get_issuer_name(x),nmindent, nmflags) < 0) goto err; | 184 | goto err; |
175 | if (BIO_write(bp,"\n",1) <= 0) goto err; | 185 | if (X509_NAME_print_ex(bp, X509_get_issuer_name(x), |
186 | nmindent, nmflags) < 0) | ||
187 | goto err; | ||
188 | if (BIO_write(bp, "\n", 1) <= 0) | ||
189 | goto err; | ||
176 | } | 190 | } |
177 | if(!(cflag & X509_FLAG_NO_VALIDITY)) { | 191 | if (!(cflag & X509_FLAG_NO_VALIDITY)) { |
178 | if (BIO_write(bp," Validity\n",17) <= 0) goto err; | 192 | if (BIO_write(bp, " Validity\n", 17) <= 0) |
179 | if (BIO_write(bp," Not Before: ",24) <= 0) goto err; | 193 | goto err; |
180 | if (!ASN1_TIME_print(bp,X509_get_notBefore(x))) goto err; | 194 | if (BIO_write(bp, " Not Before: ", 24) <= 0) |
181 | if (BIO_write(bp,"\n Not After : ",25) <= 0) goto err; | 195 | goto err; |
182 | if (!ASN1_TIME_print(bp,X509_get_notAfter(x))) goto err; | 196 | if (!ASN1_TIME_print(bp, X509_get_notBefore(x))) |
183 | if (BIO_write(bp,"\n",1) <= 0) goto err; | 197 | goto err; |
198 | if (BIO_write(bp, "\n Not After : ", 25) <= 0) | ||
199 | goto err; | ||
200 | if (!ASN1_TIME_print(bp, X509_get_notAfter(x))) | ||
201 | goto err; | ||
202 | if (BIO_write(bp, "\n", 1) <= 0) | ||
203 | goto err; | ||
184 | } | 204 | } |
185 | if(!(cflag & X509_FLAG_NO_SUBJECT)) { | 205 | if (!(cflag & X509_FLAG_NO_SUBJECT)) { |
186 | if (BIO_printf(bp," Subject:%c",mlch) <= 0) goto err; | 206 | if (BIO_printf(bp, " Subject:%c", mlch) <= 0) |
187 | if (X509_NAME_print_ex(bp,X509_get_subject_name(x),nmindent, nmflags) < 0) goto err; | 207 | goto err; |
188 | if (BIO_write(bp,"\n",1) <= 0) goto err; | 208 | if (X509_NAME_print_ex(bp, X509_get_subject_name(x), |
209 | nmindent, nmflags) < 0) | ||
210 | goto err; | ||
211 | if (BIO_write(bp, "\n", 1) <= 0) | ||
212 | goto err; | ||
189 | } | 213 | } |
190 | if(!(cflag & X509_FLAG_NO_PUBKEY)) { | 214 | if (!(cflag & X509_FLAG_NO_PUBKEY)) { |
191 | if (BIO_write(bp," Subject Public Key Info:\n",33) <= 0) | 215 | if (BIO_write(bp, " Subject Public Key Info:\n", |
216 | 33) <= 0) | ||
192 | goto err; | 217 | goto err; |
193 | if (BIO_printf(bp,"%12sPublic Key Algorithm: ","") <= 0) | 218 | if (BIO_printf(bp, "%12sPublic Key Algorithm: ", "") <= 0) |
194 | goto err; | 219 | goto err; |
195 | if (i2a_ASN1_OBJECT(bp, ci->key->algor->algorithm) <= 0) | 220 | if (i2a_ASN1_OBJECT(bp, ci->key->algor->algorithm) <= 0) |
196 | goto err; | 221 | goto err; |
197 | if (BIO_puts(bp, "\n") <= 0) | 222 | if (BIO_puts(bp, "\n") <= 0) |
198 | goto err; | 223 | goto err; |
199 | 224 | ||
200 | pkey=X509_get_pubkey(x); | 225 | pkey = X509_get_pubkey(x); |
201 | if (pkey == NULL) { | 226 | if (pkey == NULL) { |
202 | BIO_printf(bp,"%12sUnable to load Public Key\n",""); | 227 | BIO_printf(bp, "%12sUnable to load Public Key\n", ""); |
203 | ERR_print_errors(bp); | 228 | ERR_print_errors(bp); |
204 | } else { | 229 | } else { |
205 | EVP_PKEY_print_public(bp, pkey, 16, NULL); | 230 | EVP_PKEY_print_public(bp, pkey, 16, NULL); |
@@ -209,23 +234,27 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag) | |||
209 | 234 | ||
210 | if (!(cflag & X509_FLAG_NO_EXTENSIONS)) | 235 | if (!(cflag & X509_FLAG_NO_EXTENSIONS)) |
211 | X509V3_extensions_print(bp, "X509v3 extensions", | 236 | X509V3_extensions_print(bp, "X509v3 extensions", |
212 | ci->extensions, cflag, 8); | 237 | ci->extensions, cflag, 8); |
213 | 238 | ||
214 | if(!(cflag & X509_FLAG_NO_SIGDUMP)) { | 239 | if (!(cflag & X509_FLAG_NO_SIGDUMP)) { |
215 | if(X509_signature_print(bp, x->sig_alg, x->signature) <= 0) goto err; | 240 | if (X509_signature_print(bp, x->sig_alg, x->signature) <= 0) |
241 | goto err; | ||
216 | } | 242 | } |
217 | if(!(cflag & X509_FLAG_NO_AUX)) { | 243 | if (!(cflag & X509_FLAG_NO_AUX)) { |
218 | if (!X509_CERT_AUX_print(bp, x->aux, 0)) goto err; | 244 | if (!X509_CERT_AUX_print(bp, x->aux, 0)) |
245 | goto err; | ||
219 | } | 246 | } |
220 | ret=1; | 247 | ret = 1; |
248 | |||
221 | err: | 249 | err: |
222 | if (m != NULL) free(m); | 250 | if (m != NULL) |
223 | return(ret); | 251 | free(m); |
252 | return (ret); | ||
224 | } | 253 | } |
225 | 254 | ||
226 | int X509_ocspid_print (BIO *bp, X509 *x) | 255 | int X509_ocspid_print (BIO *bp, X509 *x) |
227 | { | 256 | { |
228 | unsigned char *der=NULL ; | 257 | unsigned char *der = NULL; |
229 | unsigned char *dertmp; | 258 | unsigned char *dertmp; |
230 | int derlen; | 259 | int derlen; |
231 | int i; | 260 | int i; |
@@ -233,7 +262,7 @@ int X509_ocspid_print (BIO *bp, X509 *x) | |||
233 | 262 | ||
234 | /* display the hash of the subject as it would appear | 263 | /* display the hash of the subject as it would appear |
235 | in OCSP requests */ | 264 | in OCSP requests */ |
236 | if (BIO_printf(bp," Subject OCSP hash: ") <= 0) | 265 | if (BIO_printf(bp, " Subject OCSP hash: ") <= 0) |
237 | goto err; | 266 | goto err; |
238 | derlen = i2d_X509_NAME(x->cert_info->subject, NULL); | 267 | derlen = i2d_X509_NAME(x->cert_info->subject, NULL); |
239 | if ((der = dertmp = (unsigned char *)malloc (derlen)) == NULL) | 268 | if ((der = dertmp = (unsigned char *)malloc (derlen)) == NULL) |
@@ -242,58 +271,69 @@ int X509_ocspid_print (BIO *bp, X509 *x) | |||
242 | 271 | ||
243 | if (!EVP_Digest(der, derlen, SHA1md, NULL, EVP_sha1(), NULL)) | 272 | if (!EVP_Digest(der, derlen, SHA1md, NULL, EVP_sha1(), NULL)) |
244 | goto err; | 273 | goto err; |
245 | for (i=0; i < SHA_DIGEST_LENGTH; i++) { | 274 | for (i = 0; i < SHA_DIGEST_LENGTH; i++) { |
246 | if (BIO_printf(bp,"%02X",SHA1md[i]) <= 0) goto err; | 275 | if (BIO_printf(bp, "%02X", SHA1md[i]) <= 0) |
276 | goto err; | ||
247 | } | 277 | } |
248 | free (der); | 278 | free (der); |
249 | der=NULL; | 279 | der = NULL; |
250 | 280 | ||
251 | /* display the hash of the public key as it would appear | 281 | /* display the hash of the public key as it would appear |
252 | in OCSP requests */ | 282 | in OCSP requests */ |
253 | if (BIO_printf(bp,"\n Public key OCSP hash: ") <= 0) | 283 | if (BIO_printf(bp, "\n Public key OCSP hash: ") <= 0) |
254 | goto err; | 284 | goto err; |
255 | 285 | ||
256 | if (!EVP_Digest(x->cert_info->key->public_key->data, | 286 | if (!EVP_Digest(x->cert_info->key->public_key->data, |
257 | x->cert_info->key->public_key->length, | 287 | x->cert_info->key->public_key->length, |
258 | SHA1md, NULL, EVP_sha1(), NULL)) | 288 | SHA1md, NULL, EVP_sha1(), NULL)) |
259 | goto err; | 289 | goto err; |
260 | for (i=0; i < SHA_DIGEST_LENGTH; i++) { | 290 | for (i = 0; i < SHA_DIGEST_LENGTH; i++) { |
261 | if (BIO_printf(bp,"%02X",SHA1md[i]) <= 0) | 291 | if (BIO_printf(bp, "%02X", SHA1md[i]) <= 0) |
262 | goto err; | 292 | goto err; |
263 | } | 293 | } |
264 | BIO_printf(bp,"\n"); | 294 | BIO_printf(bp, "\n"); |
265 | 295 | ||
266 | return (1); | 296 | return (1); |
297 | |||
267 | err: | 298 | err: |
268 | if (der != NULL) free(der); | 299 | if (der != NULL) |
269 | return(0); | 300 | free(der); |
301 | return (0); | ||
270 | } | 302 | } |
271 | 303 | ||
272 | int X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent) | 304 | int |
305 | X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent) | ||
273 | { | 306 | { |
274 | const unsigned char *s; | 307 | const unsigned char *s; |
275 | int i, n; | 308 | int i, n; |
276 | 309 | ||
277 | n=sig->length; | 310 | n = sig->length; |
278 | s=sig->data; | 311 | s = sig->data; |
279 | for (i=0; i<n; i++) { | 312 | for (i = 0; i < n; i++) { |
280 | if ((i%18) == 0) { | 313 | if ((i % 18) == 0) { |
281 | if (BIO_write(bp,"\n",1) <= 0) return 0; | 314 | if (BIO_write(bp, "\n", 1) <= 0) |
282 | if (BIO_indent(bp, indent, indent) <= 0) return 0; | 315 | return 0; |
316 | if (BIO_indent(bp, indent, indent) <= 0) | ||
317 | return 0; | ||
283 | } | 318 | } |
284 | if (BIO_printf(bp,"%02x%s",s[i], | 319 | if (BIO_printf(bp, "%02x%s", s[i], |
285 | ((i+1) == n)?"":":") <= 0) return 0; | 320 | ((i + 1) == n) ? "" : ":") <= 0) |
321 | return 0; | ||
286 | } | 322 | } |
287 | if (BIO_write(bp,"\n",1) != 1) return 0; | 323 | if (BIO_write(bp, "\n", 1) != 1) |
324 | return 0; | ||
288 | 325 | ||
289 | return 1; | 326 | return 1; |
290 | } | 327 | } |
291 | 328 | ||
292 | int X509_signature_print(BIO *bp, X509_ALGOR *sigalg, ASN1_STRING *sig) | 329 | int |
330 | X509_signature_print(BIO *bp, X509_ALGOR *sigalg, ASN1_STRING *sig) | ||
293 | { | 331 | { |
294 | int sig_nid; | 332 | int sig_nid; |
295 | if (BIO_puts(bp," Signature Algorithm: ") <= 0) return 0; | 333 | if (BIO_puts(bp, " Signature Algorithm: ") <= 0) |
296 | if (i2a_ASN1_OBJECT(bp, sigalg->algorithm) <= 0) return 0; | 334 | return 0; |
335 | if (i2a_ASN1_OBJECT(bp, sigalg->algorithm) <= 0) | ||
336 | return 0; | ||
297 | 337 | ||
298 | sig_nid = OBJ_obj2nid(sigalg->algorithm); | 338 | sig_nid = OBJ_obj2nid(sigalg->algorithm); |
299 | if (sig_nid != NID_undef) { | 339 | if (sig_nid != NID_undef) { |
@@ -312,172 +352,191 @@ int X509_signature_print(BIO *bp, X509_ALGOR *sigalg, ASN1_STRING *sig) | |||
312 | return 1; | 352 | return 1; |
313 | } | 353 | } |
314 | 354 | ||
315 | int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v) | 355 | int |
356 | ASN1_STRING_print(BIO *bp, const ASN1_STRING *v) | ||
316 | { | 357 | { |
317 | int i,n; | 358 | int i, n; |
318 | char buf[80]; | 359 | char buf[80]; |
319 | const char *p; | 360 | const char *p; |
320 | 361 | ||
321 | if (v == NULL) return(0); | 362 | if (v == NULL) |
322 | n=0; | 363 | return (0); |
323 | p=(const char *)v->data; | 364 | n = 0; |
324 | for (i=0; i<v->length; i++) { | 365 | p = (const char *)v->data; |
366 | for (i = 0; i < v->length; i++) { | ||
325 | if ((p[i] > '~') || ((p[i] < ' ') && | 367 | if ((p[i] > '~') || ((p[i] < ' ') && |
326 | (p[i] != '\n') && (p[i] != '\r'))) | 368 | (p[i] != '\n') && (p[i] != '\r'))) |
327 | buf[n]='.'; | 369 | buf[n] = '.'; |
328 | else | 370 | else |
329 | buf[n]=p[i]; | 371 | buf[n] = p[i]; |
330 | n++; | 372 | n++; |
331 | if (n >= 80) { | 373 | if (n >= 80) { |
332 | if (BIO_write(bp,buf,n) <= 0) | 374 | if (BIO_write(bp, buf, n) <= 0) |
333 | return(0); | 375 | return (0); |
334 | n=0; | 376 | n = 0; |
335 | } | 377 | } |
336 | } | 378 | } |
337 | if (n > 0) | 379 | if (n > 0) |
338 | if (BIO_write(bp,buf,n) <= 0) | 380 | if (BIO_write(bp, buf, n) <= 0) |
339 | return(0); | 381 | return (0); |
340 | return(1); | 382 | return (1); |
341 | } | 383 | } |
342 | 384 | ||
343 | int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm) | 385 | int |
386 | ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm) | ||
344 | { | 387 | { |
345 | if(tm->type == V_ASN1_UTCTIME) return ASN1_UTCTIME_print(bp, tm); | 388 | if (tm->type == V_ASN1_UTCTIME) |
346 | if(tm->type == V_ASN1_GENERALIZEDTIME) | 389 | return ASN1_UTCTIME_print(bp, tm); |
347 | return ASN1_GENERALIZEDTIME_print(bp, tm); | 390 | if (tm->type == V_ASN1_GENERALIZEDTIME) |
348 | BIO_write(bp,"Bad time value",14); | 391 | return ASN1_GENERALIZEDTIME_print(bp, tm); |
349 | return(0); | 392 | BIO_write(bp, "Bad time value", 14); |
393 | return (0); | ||
350 | } | 394 | } |
351 | 395 | ||
352 | static const char *mon[12]= | 396 | static const char *mon[12] = { |
353 | { | 397 | "Jan", "Feb", "Mar", "Apr", "May", "Jun", |
354 | "Jan","Feb","Mar","Apr","May","Jun", | 398 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" |
355 | "Jul","Aug","Sep","Oct","Nov","Dec" | 399 | }; |
356 | }; | ||
357 | 400 | ||
358 | int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm) | 401 | int |
402 | ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm) | ||
359 | { | 403 | { |
360 | char *v; | 404 | char *v; |
361 | int gmt=0; | 405 | int gmt = 0; |
362 | int i; | 406 | int i; |
363 | int y=0,M=0,d=0,h=0,m=0,s=0; | 407 | int y = 0, M = 0, d = 0, h = 0, m = 0, s = 0; |
364 | char *f = NULL; | 408 | char *f = NULL; |
365 | int f_len = 0; | 409 | int f_len = 0; |
366 | 410 | ||
367 | i=tm->length; | 411 | i = tm->length; |
368 | v=(char *)tm->data; | 412 | v = (char *)tm->data; |
369 | 413 | ||
370 | if (i < 12) goto err; | 414 | if (i < 12) |
371 | if (v[i-1] == 'Z') gmt=1; | 415 | goto err; |
372 | for (i=0; i<12; i++) | 416 | if (v[i-1] == 'Z') |
373 | if ((v[i] > '9') || (v[i] < '0')) goto err; | 417 | gmt = 1; |
374 | y= (v[0]-'0')*1000+(v[1]-'0')*100 + (v[2]-'0')*10+(v[3]-'0'); | 418 | for (i = 0; i < 12; i++) |
375 | M= (v[4]-'0')*10+(v[5]-'0'); | 419 | if ((v[i] > '9') || (v[i] < '0')) |
376 | if ((M > 12) || (M < 1)) goto err; | 420 | goto err; |
377 | d= (v[6]-'0')*10+(v[7]-'0'); | 421 | y = (v[0] - '0') * 1000 + (v[1] - '0') * 100 + |
378 | h= (v[8]-'0')*10+(v[9]-'0'); | 422 | (v[2] - '0') * 10 + (v[3] - '0'); |
379 | m= (v[10]-'0')*10+(v[11]-'0'); | 423 | M = (v[4] - '0') * 10 + (v[5] - '0'); |
424 | if ((M > 12) || (M < 1)) | ||
425 | goto err; | ||
426 | d = (v[6] - '0') * 10 + (v[7] - '0'); | ||
427 | h = (v[8] - '0') * 10 + (v[9] - '0'); | ||
428 | m = (v[10] - '0') * 10 + (v[11] - '0'); | ||
380 | if (tm->length >= 14 && | 429 | if (tm->length >= 14 && |
381 | (v[12] >= '0') && (v[12] <= '9') && | 430 | (v[12] >= '0') && (v[12] <= '9') && |
382 | (v[13] >= '0') && (v[13] <= '9')) { | 431 | (v[13] >= '0') && (v[13] <= '9')) { |
383 | s= (v[12]-'0')*10+(v[13]-'0'); | 432 | s = (v[12] - '0') * 10 + (v[13] - '0'); |
384 | /* Check for fractions of seconds. */ | 433 | /* Check for fractions of seconds. */ |
385 | if (tm->length >= 15 && v[14] == '.') { | 434 | if (tm->length >= 15 && v[14] == '.') { |
386 | int l = tm->length; | 435 | int l = tm->length; |
387 | f = &v[14]; /* The decimal point. */ | 436 | f = &v[14]; /* The decimal point. */ |
388 | f_len = 1; | 437 | f_len = 1; |
389 | while (14 + f_len < l && f[f_len] >= '0' && f[f_len] <= '9') | 438 | while (14 + f_len < l && f[f_len] >= '0' && |
439 | f[f_len] <= '9') | ||
390 | ++f_len; | 440 | ++f_len; |
391 | } | 441 | } |
392 | } | 442 | } |
393 | 443 | ||
394 | if (BIO_printf(bp,"%s %2d %02d:%02d:%02d%.*s %d%s", | 444 | if (BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s", |
395 | mon[M-1],d,h,m,s,f_len,f,y,(gmt)?" GMT":"") <= 0) | 445 | mon[M - 1], d, h, m, s, f_len, f, y, (gmt) ? " GMT" : "") <= 0) |
396 | return(0); | 446 | return (0); |
397 | else | 447 | else |
398 | return(1); | 448 | return (1); |
449 | |||
399 | err: | 450 | err: |
400 | BIO_write(bp,"Bad time value",14); | 451 | BIO_write(bp, "Bad time value", 14); |
401 | return(0); | 452 | return (0); |
402 | } | 453 | } |
403 | 454 | ||
404 | int ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm) | 455 | int |
456 | ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm) | ||
405 | { | 457 | { |
406 | const char *v; | 458 | const char *v; |
407 | int gmt=0; | 459 | int gmt = 0; |
408 | int i; | 460 | int i; |
409 | int y=0,M=0,d=0,h=0,m=0,s=0; | 461 | int y = 0, M = 0, d = 0, h = 0, m = 0, s = 0; |
410 | 462 | ||
411 | i=tm->length; | 463 | i = tm->length; |
412 | v=(const char *)tm->data; | 464 | v = (const char *)tm->data; |
413 | 465 | ||
414 | if (i < 10) goto err; | 466 | if (i < 10) |
415 | if (v[i-1] == 'Z') gmt=1; | 467 | goto err; |
416 | for (i=0; i<10; i++) | 468 | if (v[i-1] == 'Z') |
417 | if ((v[i] > '9') || (v[i] < '0')) goto err; | 469 | gmt = 1; |
418 | y= (v[0]-'0')*10+(v[1]-'0'); | 470 | for (i = 0; i < 10; i++) |
419 | if (y < 50) y+=100; | 471 | if ((v[i] > '9') || (v[i] < '0')) |
420 | M= (v[2]-'0')*10+(v[3]-'0'); | 472 | goto err; |
421 | if ((M > 12) || (M < 1)) goto err; | 473 | y = (v[0] - '0') * 10 + (v[1] - '0'); |
422 | d= (v[4]-'0')*10+(v[5]-'0'); | 474 | if (y < 50) |
423 | h= (v[6]-'0')*10+(v[7]-'0'); | 475 | y += 100; |
424 | m= (v[8]-'0')*10+(v[9]-'0'); | 476 | M = (v[2] - '0') * 10 + (v[3] - '0'); |
477 | if ((M > 12) || (M < 1)) | ||
478 | goto err; | ||
479 | d = (v[4] - '0') * 10 + (v[5] - '0'); | ||
480 | h = (v[6] - '0') * 10 + (v[7] - '0'); | ||
481 | m = (v[8] - '0') * 10 + (v[9] - '0'); | ||
425 | if (tm->length >=12 && | 482 | if (tm->length >=12 && |
426 | (v[10] >= '0') && (v[10] <= '9') && | 483 | (v[10] >= '0') && (v[10] <= '9') && |
427 | (v[11] >= '0') && (v[11] <= '9')) | 484 | (v[11] >= '0') && (v[11] <= '9')) |
428 | s= (v[10]-'0')*10+(v[11]-'0'); | 485 | s = (v[10] - '0') * 10 + (v[11] - '0'); |
429 | 486 | ||
430 | if (BIO_printf(bp,"%s %2d %02d:%02d:%02d %d%s", | 487 | if (BIO_printf(bp, "%s %2d %02d:%02d:%02d %d%s", |
431 | mon[M-1],d,h,m,s,y+1900,(gmt)?" GMT":"") <= 0) | 488 | mon[M - 1], d, h, m, s, y + 1900, (gmt) ? " GMT" : "") <= 0) |
432 | return(0); | 489 | return (0); |
433 | else | 490 | else |
434 | return(1); | 491 | return (1); |
492 | |||
435 | err: | 493 | err: |
436 | BIO_write(bp,"Bad time value",14); | 494 | BIO_write(bp, "Bad time value", 14); |
437 | return(0); | 495 | return (0); |
438 | } | 496 | } |
439 | 497 | ||
440 | int X509_NAME_print(BIO *bp, X509_NAME *name, int obase) | 498 | int |
499 | X509_NAME_print(BIO *bp, X509_NAME *name, int obase) | ||
441 | { | 500 | { |
442 | char *s,*c,*b; | 501 | char *s, *c, *b; |
443 | int ret=0,l,i; | 502 | int ret = 0, l, i; |
444 | 503 | ||
445 | l=80-2-obase; | 504 | l = 80 - 2 - obase; |
446 | 505 | ||
447 | b=X509_NAME_oneline(name,NULL,0); | 506 | b = X509_NAME_oneline(name, NULL, 0); |
448 | if (!*b) { | 507 | if (!*b) { |
449 | free(b); | 508 | free(b); |
450 | return 1; | 509 | return 1; |
451 | } | 510 | } |
452 | s=b+1; /* skip the first slash */ | 511 | s = b + 1; /* skip the first slash */ |
453 | 512 | ||
454 | c=s; | 513 | c = s; |
455 | for (;;) { | 514 | for (;;) { |
456 | if ( ((*s == '/') && | 515 | if (((*s == '/') && |
457 | ((s[1] >= 'A') && (s[1] <= 'Z') && ( | 516 | ((s[1] >= 'A') && (s[1] <= 'Z') && |
458 | (s[2] == '=') || | 517 | ((s[2] == '=') || ((s[2] >= 'A') && (s[2] <= 'Z') && |
459 | ((s[2] >= 'A') && (s[2] <= 'Z') && | 518 | (s[3] == '='))))) || (*s == '\0')) { |
460 | (s[3] == '=')) | 519 | i = s - c; |
461 | ))) || | 520 | if (BIO_write(bp, c, i) != i) |
462 | (*s == '\0')) { | 521 | goto err; |
463 | i=s-c; | 522 | c = s + 1; /* skip following slash */ |
464 | if (BIO_write(bp,c,i) != i) goto err; | ||
465 | c=s+1; /* skip following slash */ | ||
466 | if (*s != '\0') { | 523 | if (*s != '\0') { |
467 | if (BIO_write(bp,", ",2) != 2) goto err; | 524 | if (BIO_write(bp, ", ", 2) != 2) |
525 | goto err; | ||
468 | } | 526 | } |
469 | l--; | 527 | l--; |
470 | } | 528 | } |
471 | if (*s == '\0') break; | 529 | if (*s == '\0') |
530 | break; | ||
472 | s++; | 531 | s++; |
473 | l--; | 532 | l--; |
474 | } | 533 | } |
475 | 534 | ||
476 | ret=1; | 535 | ret = 1; |
477 | if (0) { | 536 | if (0) { |
478 | err: | 537 | err: |
479 | X509err(X509_F_X509_NAME_PRINT,ERR_R_BUF_LIB); | 538 | X509err(X509_F_X509_NAME_PRINT, ERR_R_BUF_LIB); |
480 | } | 539 | } |
481 | free(b); | 540 | free(b); |
482 | return(ret); | 541 | return (ret); |
483 | } | 542 | } |
diff --git a/src/lib/libcrypto/asn1/t_x509a.c b/src/lib/libcrypto/asn1/t_x509a.c index 8b18801a17..49d1be19db 100644 --- a/src/lib/libcrypto/asn1/t_x509a.c +++ b/src/lib/libcrypto/asn1/t_x509a.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -65,46 +65,54 @@ | |||
65 | /* X509_CERT_AUX and string set routines | 65 | /* X509_CERT_AUX and string set routines |
66 | */ | 66 | */ |
67 | 67 | ||
68 | int X509_CERT_AUX_print(BIO *out, X509_CERT_AUX *aux, int indent) | 68 | int |
69 | X509_CERT_AUX_print(BIO *out, X509_CERT_AUX *aux, int indent) | ||
69 | { | 70 | { |
70 | char oidstr[80], first; | 71 | char oidstr[80], first; |
71 | int i; | 72 | int i; |
72 | if(!aux) return 1; | 73 | if (!aux) |
73 | if(aux->trust) { | 74 | return 1; |
75 | if (aux->trust) { | ||
74 | first = 1; | 76 | first = 1; |
75 | BIO_printf(out, "%*sTrusted Uses:\n%*s", | 77 | BIO_printf(out, "%*sTrusted Uses:\n%*s", |
76 | indent, "", indent + 2, ""); | 78 | indent, "", indent + 2, ""); |
77 | for(i = 0; i < sk_ASN1_OBJECT_num(aux->trust); i++) { | 79 | for (i = 0; i < sk_ASN1_OBJECT_num(aux->trust); i++) { |
78 | if(!first) BIO_puts(out, ", "); | 80 | if (!first) |
79 | else first = 0; | 81 | BIO_puts(out, ", "); |
82 | else | ||
83 | first = 0; | ||
80 | OBJ_obj2txt(oidstr, sizeof oidstr, | 84 | OBJ_obj2txt(oidstr, sizeof oidstr, |
81 | sk_ASN1_OBJECT_value(aux->trust, i), 0); | 85 | sk_ASN1_OBJECT_value(aux->trust, i), 0); |
82 | BIO_puts(out, oidstr); | 86 | BIO_puts(out, oidstr); |
83 | } | 87 | } |
84 | BIO_puts(out, "\n"); | 88 | BIO_puts(out, "\n"); |
85 | } else BIO_printf(out, "%*sNo Trusted Uses.\n", indent, ""); | 89 | } else |
86 | if(aux->reject) { | 90 | BIO_printf(out, "%*sNo Trusted Uses.\n", indent, ""); |
91 | if (aux->reject) { | ||
87 | first = 1; | 92 | first = 1; |
88 | BIO_printf(out, "%*sRejected Uses:\n%*s", | 93 | BIO_printf(out, "%*sRejected Uses:\n%*s", |
89 | indent, "", indent + 2, ""); | 94 | indent, "", indent + 2, ""); |
90 | for(i = 0; i < sk_ASN1_OBJECT_num(aux->reject); i++) { | 95 | for (i = 0; i < sk_ASN1_OBJECT_num(aux->reject); i++) { |
91 | if(!first) BIO_puts(out, ", "); | 96 | if (!first) |
92 | else first = 0; | 97 | BIO_puts(out, ", "); |
98 | else | ||
99 | first = 0; | ||
93 | OBJ_obj2txt(oidstr, sizeof oidstr, | 100 | OBJ_obj2txt(oidstr, sizeof oidstr, |
94 | sk_ASN1_OBJECT_value(aux->reject, i), 0); | 101 | sk_ASN1_OBJECT_value(aux->reject, i), 0); |
95 | BIO_puts(out, oidstr); | 102 | BIO_puts(out, oidstr); |
96 | } | 103 | } |
97 | BIO_puts(out, "\n"); | 104 | BIO_puts(out, "\n"); |
98 | } else BIO_printf(out, "%*sNo Rejected Uses.\n", indent, ""); | 105 | } else |
99 | if(aux->alias) BIO_printf(out, "%*sAlias: %s\n", indent, "", | 106 | BIO_printf(out, "%*sNo Rejected Uses.\n", indent, ""); |
100 | aux->alias->data); | 107 | if (aux->alias) |
101 | if(aux->keyid) { | 108 | BIO_printf(out, "%*sAlias: %s\n", indent, "", |
109 | aux->alias->data); | ||
110 | if (aux->keyid) { | ||
102 | BIO_printf(out, "%*sKey Id: ", indent, ""); | 111 | BIO_printf(out, "%*sKey Id: ", indent, ""); |
103 | for(i = 0; i < aux->keyid->length; i++) | 112 | for (i = 0; i < aux->keyid->length; i++) |
104 | BIO_printf(out, "%s%02X", | 113 | BIO_printf(out, "%s%02X", i ? ":" : "", |
105 | i ? ":" : "", | 114 | aux->keyid->data[i]); |
106 | aux->keyid->data[i]); | 115 | BIO_write(out, "\n", 1); |
107 | BIO_write(out,"\n",1); | ||
108 | } | 116 | } |
109 | return 1; | 117 | return 1; |
110 | } | 118 | } |
diff --git a/src/lib/libssl/src/crypto/asn1/t_bitst.c b/src/lib/libssl/src/crypto/asn1/t_bitst.c index 2e59a25fa1..1dc04beabf 100644 --- a/src/lib/libssl/src/crypto/asn1/t_bitst.c +++ b/src/lib/libssl/src/crypto/asn1/t_bitst.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -61,15 +61,18 @@ | |||
61 | #include <openssl/conf.h> | 61 | #include <openssl/conf.h> |
62 | #include <openssl/x509v3.h> | 62 | #include <openssl/x509v3.h> |
63 | 63 | ||
64 | int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, | 64 | int |
65 | BIT_STRING_BITNAME *tbl, int indent) | 65 | ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, |
66 | BIT_STRING_BITNAME *tbl, int indent) | ||
66 | { | 67 | { |
67 | BIT_STRING_BITNAME *bnam; | 68 | BIT_STRING_BITNAME *bnam; |
68 | char first = 1; | 69 | char first = 1; |
70 | |||
69 | BIO_printf(out, "%*s", indent, ""); | 71 | BIO_printf(out, "%*s", indent, ""); |
70 | for(bnam = tbl; bnam->lname; bnam++) { | 72 | for (bnam = tbl; bnam->lname; bnam++) { |
71 | if(ASN1_BIT_STRING_get_bit(bs, bnam->bitnum)) { | 73 | if (ASN1_BIT_STRING_get_bit(bs, bnam->bitnum)) { |
72 | if(!first) BIO_puts(out, ", "); | 74 | if (!first) |
75 | BIO_puts(out, ", "); | ||
73 | BIO_puts(out, bnam->lname); | 76 | BIO_puts(out, bnam->lname); |
74 | first = 0; | 77 | first = 0; |
75 | } | 78 | } |
@@ -78,25 +81,31 @@ int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, | |||
78 | return 1; | 81 | return 1; |
79 | } | 82 | } |
80 | 83 | ||
81 | int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value, | 84 | int |
82 | BIT_STRING_BITNAME *tbl) | 85 | ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value, |
86 | BIT_STRING_BITNAME *tbl) | ||
83 | { | 87 | { |
84 | int bitnum; | 88 | int bitnum; |
89 | |||
85 | bitnum = ASN1_BIT_STRING_num_asc(name, tbl); | 90 | bitnum = ASN1_BIT_STRING_num_asc(name, tbl); |
86 | if(bitnum < 0) return 0; | 91 | if (bitnum < 0) |
87 | if(bs) { | 92 | return 0; |
88 | if(!ASN1_BIT_STRING_set_bit(bs, bitnum, value)) | 93 | if (bs) { |
94 | if (!ASN1_BIT_STRING_set_bit(bs, bitnum, value)) | ||
89 | return 0; | 95 | return 0; |
90 | } | 96 | } |
91 | return 1; | 97 | return 1; |
92 | } | 98 | } |
93 | 99 | ||
94 | int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl) | 100 | int |
101 | ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl) | ||
95 | { | 102 | { |
96 | BIT_STRING_BITNAME *bnam; | 103 | BIT_STRING_BITNAME *bnam; |
97 | for(bnam = tbl; bnam->lname; bnam++) { | 104 | |
98 | if(!strcmp(bnam->sname, name) || | 105 | for (bnam = tbl; bnam->lname; bnam++) { |
99 | !strcmp(bnam->lname, name) ) return bnam->bitnum; | 106 | if (!strcmp(bnam->sname, name) || |
107 | !strcmp(bnam->lname, name)) | ||
108 | return bnam->bitnum; | ||
100 | } | 109 | } |
101 | return -1; | 110 | return -1; |
102 | } | 111 | } |
diff --git a/src/lib/libssl/src/crypto/asn1/t_crl.c b/src/lib/libssl/src/crypto/asn1/t_crl.c index c665a26bce..cd1ed26174 100644 --- a/src/lib/libssl/src/crypto/asn1/t_crl.c +++ b/src/lib/libssl/src/crypto/asn1/t_crl.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -65,23 +65,25 @@ | |||
65 | #include <openssl/x509v3.h> | 65 | #include <openssl/x509v3.h> |
66 | 66 | ||
67 | #ifndef OPENSSL_NO_FP_API | 67 | #ifndef OPENSSL_NO_FP_API |
68 | int X509_CRL_print_fp(FILE *fp, X509_CRL *x) | 68 | int |
69 | X509_CRL_print_fp(FILE *fp, X509_CRL *x) | ||
69 | { | 70 | { |
70 | BIO *b; | 71 | BIO *b; |
71 | int ret; | 72 | int ret; |
72 | 73 | ||
73 | if ((b=BIO_new(BIO_s_file())) == NULL) { | 74 | if ((b = BIO_new(BIO_s_file())) == NULL) { |
74 | X509err(X509_F_X509_CRL_PRINT_FP,ERR_R_BUF_LIB); | 75 | X509err(X509_F_X509_CRL_PRINT_FP, ERR_R_BUF_LIB); |
75 | return(0); | 76 | return (0); |
76 | } | 77 | } |
77 | BIO_set_fp(b,fp,BIO_NOCLOSE); | 78 | BIO_set_fp(b, fp, BIO_NOCLOSE); |
78 | ret=X509_CRL_print(b, x); | 79 | ret = X509_CRL_print(b, x); |
79 | BIO_free(b); | 80 | BIO_free(b); |
80 | return(ret); | 81 | return (ret); |
81 | } | 82 | } |
82 | #endif | 83 | #endif |
83 | 84 | ||
84 | int X509_CRL_print(BIO *out, X509_CRL *x) | 85 | int |
86 | X509_CRL_print(BIO *out, X509_CRL *x) | ||
85 | { | 87 | { |
86 | STACK_OF(X509_REVOKED) *rev; | 88 | STACK_OF(X509_REVOKED) *rev; |
87 | X509_REVOKED *r; | 89 | X509_REVOKED *r; |
@@ -91,38 +93,40 @@ int X509_CRL_print(BIO *out, X509_CRL *x) | |||
91 | 93 | ||
92 | BIO_printf(out, "Certificate Revocation List (CRL):\n"); | 94 | BIO_printf(out, "Certificate Revocation List (CRL):\n"); |
93 | l = X509_CRL_get_version(x); | 95 | l = X509_CRL_get_version(x); |
94 | BIO_printf(out, "%8sVersion %lu (0x%lx)\n", "", l+1, l); | 96 | BIO_printf(out, "%8sVersion %lu (0x%lx)\n", "", l + 1, l); |
95 | i = OBJ_obj2nid(x->sig_alg->algorithm); | 97 | i = OBJ_obj2nid(x->sig_alg->algorithm); |
96 | X509_signature_print(out, x->sig_alg, NULL); | 98 | X509_signature_print(out, x->sig_alg, NULL); |
97 | p=X509_NAME_oneline(X509_CRL_get_issuer(x),NULL,0); | 99 | p = X509_NAME_oneline(X509_CRL_get_issuer(x), NULL, 0); |
98 | BIO_printf(out,"%8sIssuer: %s\n","",p); | 100 | BIO_printf(out, "%8sIssuer: %s\n", "", p); |
99 | free(p); | 101 | free(p); |
100 | BIO_printf(out,"%8sLast Update: ",""); | 102 | BIO_printf(out, "%8sLast Update: ", ""); |
101 | ASN1_TIME_print(out,X509_CRL_get_lastUpdate(x)); | 103 | ASN1_TIME_print(out, X509_CRL_get_lastUpdate(x)); |
102 | BIO_printf(out,"\n%8sNext Update: ",""); | 104 | BIO_printf(out, "\n%8sNext Update: ", ""); |
103 | if (X509_CRL_get_nextUpdate(x)) | 105 | if (X509_CRL_get_nextUpdate(x)) |
104 | ASN1_TIME_print(out,X509_CRL_get_nextUpdate(x)); | 106 | ASN1_TIME_print(out, X509_CRL_get_nextUpdate(x)); |
105 | else BIO_printf(out,"NONE"); | 107 | else |
106 | BIO_printf(out,"\n"); | 108 | BIO_printf(out, "NONE"); |
109 | BIO_printf(out, "\n"); | ||
107 | 110 | ||
108 | X509V3_extensions_print(out, "CRL extensions", | 111 | X509V3_extensions_print(out, "CRL extensions", |
109 | x->crl->extensions, 0, 8); | 112 | x->crl->extensions, 0, 8); |
110 | 113 | ||
111 | rev = X509_CRL_get_REVOKED(x); | 114 | rev = X509_CRL_get_REVOKED(x); |
112 | 115 | ||
113 | if(sk_X509_REVOKED_num(rev) > 0) | 116 | if (sk_X509_REVOKED_num(rev) > 0) |
114 | BIO_printf(out, "Revoked Certificates:\n"); | 117 | BIO_printf(out, "Revoked Certificates:\n"); |
115 | else BIO_printf(out, "No Revoked Certificates.\n"); | 118 | else |
119 | BIO_printf(out, "No Revoked Certificates.\n"); | ||
116 | 120 | ||
117 | for(i = 0; i < sk_X509_REVOKED_num(rev); i++) { | 121 | for (i = 0; i < sk_X509_REVOKED_num(rev); i++) { |
118 | r = sk_X509_REVOKED_value(rev, i); | 122 | r = sk_X509_REVOKED_value(rev, i); |
119 | BIO_printf(out," Serial Number: "); | 123 | BIO_printf(out, " Serial Number: "); |
120 | i2a_ASN1_INTEGER(out,r->serialNumber); | 124 | i2a_ASN1_INTEGER(out, r->serialNumber); |
121 | BIO_printf(out,"\n Revocation Date: "); | 125 | BIO_printf(out, "\n Revocation Date: "); |
122 | ASN1_TIME_print(out,r->revocationDate); | 126 | ASN1_TIME_print(out, r->revocationDate); |
123 | BIO_printf(out,"\n"); | 127 | BIO_printf(out, "\n"); |
124 | X509V3_extensions_print(out, "CRL entry extensions", | 128 | X509V3_extensions_print(out, "CRL entry extensions", |
125 | r->extensions, 0, 8); | 129 | r->extensions, 0, 8); |
126 | } | 130 | } |
127 | X509_signature_print(out, x->sig_alg, x->signature); | 131 | X509_signature_print(out, x->sig_alg, x->signature); |
128 | 132 | ||
diff --git a/src/lib/libssl/src/crypto/asn1/t_pkey.c b/src/lib/libssl/src/crypto/asn1/t_pkey.c index 12674e0125..579df8154c 100644 --- a/src/lib/libssl/src/crypto/asn1/t_pkey.c +++ b/src/lib/libssl/src/crypto/asn1/t_pkey.c | |||
@@ -5,21 +5,21 @@ | |||
5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
8 | * | 8 | * |
9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
11 | * apply to all code found in this distribution, be it the RC4, RSA, | 11 | * apply to all code found in this distribution, be it the RC4, RSA, |
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
13 | * included with this distribution is covered by the same copyright terms | 13 | * included with this distribution is covered by the same copyright terms |
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
15 | * | 15 | * |
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
18 | * If this package is used in a product, Eric Young should be given attribution | 18 | * If this package is used in a product, Eric Young should be given attribution |
19 | * as the author of the parts of the library used. | 19 | * as the author of the parts of the library used. |
20 | * This can be in the form of a textual message at program startup or | 20 | * This can be in the form of a textual message at program startup or |
21 | * in documentation (online or textual) provided with the package. | 21 | * in documentation (online or textual) provided with the package. |
22 | * | 22 | * |
23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
25 | * are met: | 25 | * are met: |
@@ -34,10 +34,10 @@ | |||
34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 37 | * 4. If you include any Windows specific code (or a derivative thereof) from |
38 | * the apps directory (application code) you must include an acknowledgement: | 38 | * the apps directory (application code) you must include an acknowledgement: |
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
40 | * | 40 | * |
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -49,7 +49,7 @@ | |||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
52 | * | 52 | * |
53 | * The licence and distribution terms for any publically available version or | 53 | * The licence and distribution terms for any publically available version or |
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
@@ -62,15 +62,17 @@ | |||
62 | #include <openssl/buffer.h> | 62 | #include <openssl/buffer.h> |
63 | #include <openssl/bn.h> | 63 | #include <openssl/bn.h> |
64 | 64 | ||
65 | int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, | 65 | int |
66 | unsigned char *buf, int off) | 66 | ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, |
67 | unsigned char *buf, int off) | ||
67 | { | 68 | { |
68 | int n,i; | 69 | int n, i; |
69 | const char *neg; | 70 | const char *neg; |
70 | 71 | ||
71 | if (num == NULL) return(1); | 72 | if (num == NULL) |
72 | neg = (BN_is_negative(num))?"-":""; | 73 | return (1); |
73 | if(!BIO_indent(bp,off,128)) | 74 | neg = (BN_is_negative(num)) ? "-" : ""; |
75 | if (!BIO_indent(bp, off, 128)) | ||
74 | return 0; | 76 | return 0; |
75 | if (BN_is_zero(num)) { | 77 | if (BN_is_zero(num)) { |
76 | if (BIO_printf(bp, "%s 0\n", number) <= 0) | 78 | if (BIO_printf(bp, "%s 0\n", number) <= 0) |
@@ -79,30 +81,34 @@ int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, | |||
79 | } | 81 | } |
80 | 82 | ||
81 | if (BN_num_bytes(num) <= BN_BYTES) { | 83 | if (BN_num_bytes(num) <= BN_BYTES) { |
82 | if (BIO_printf(bp,"%s %s%lu (%s0x%lx)\n",number,neg, | 84 | if (BIO_printf(bp, "%s %s%lu (%s0x%lx)\n", number, neg, |
83 | (unsigned long)num->d[0],neg,(unsigned long)num->d[0]) | 85 | (unsigned long)num->d[0], neg, |
84 | <= 0) return(0); | 86 | (unsigned long)num->d[0]) <= 0) |
87 | return (0); | ||
85 | } else { | 88 | } else { |
86 | buf[0]=0; | 89 | buf[0] = 0; |
87 | if (BIO_printf(bp,"%s%s",number, | 90 | if (BIO_printf(bp, "%s%s", number, |
88 | (neg[0] == '-')?" (Negative)":"") <= 0) | 91 | (neg[0] == '-') ? " (Negative)" : "") <= 0) |
89 | return(0); | 92 | return (0); |
90 | n=BN_bn2bin(num,&buf[1]); | 93 | n = BN_bn2bin(num, &buf[1]); |
91 | 94 | ||
92 | if (buf[1] & 0x80) | 95 | if (buf[1] & 0x80) |
93 | n++; | 96 | n++; |
94 | else buf++; | 97 | else |
98 | buf++; | ||
95 | 99 | ||
96 | for (i=0; i<n; i++) { | 100 | for (i = 0; i < n; i++) { |
97 | if ((i%15) == 0) { | 101 | if ((i % 15) == 0) { |
98 | if(BIO_puts(bp,"\n") <= 0 | 102 | if (BIO_puts(bp, "\n") <= 0 || |
99 | || !BIO_indent(bp,off+4,128)) | 103 | !BIO_indent(bp, off + 4, 128)) |
100 | return 0; | 104 | return 0; |
101 | } | 105 | } |
102 | if (BIO_printf(bp,"%02x%s",buf[i],((i+1) == n)?"":":") | 106 | if (BIO_printf(bp, "%02x%s", buf[i], |
103 | <= 0) return(0); | 107 | ((i + 1) == n) ? "" : ":") <= 0) |
108 | return (0); | ||
104 | } | 109 | } |
105 | if (BIO_write(bp,"\n",1) <= 0) return(0); | 110 | if (BIO_write(bp, "\n", 1) <= 0) |
111 | return (0); | ||
106 | } | 112 | } |
107 | return(1); | 113 | return (1); |
108 | } | 114 | } |
diff --git a/src/lib/libssl/src/crypto/asn1/t_req.c b/src/lib/libssl/src/crypto/asn1/t_req.c index 4457f5291e..331440bed5 100644 --- a/src/lib/libssl/src/crypto/asn1/t_req.c +++ b/src/lib/libssl/src/crypto/asn1/t_req.c | |||
@@ -5,21 +5,21 @@ | |||
5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
8 | * | 8 | * |
9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
11 | * apply to all code found in this distribution, be it the RC4, RSA, | 11 | * apply to all code found in this distribution, be it the RC4, RSA, |
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
13 | * included with this distribution is covered by the same copyright terms | 13 | * included with this distribution is covered by the same copyright terms |
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
15 | * | 15 | * |
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
18 | * If this package is used in a product, Eric Young should be given attribution | 18 | * If this package is used in a product, Eric Young should be given attribution |
19 | * as the author of the parts of the library used. | 19 | * as the author of the parts of the library used. |
20 | * This can be in the form of a textual message at program startup or | 20 | * This can be in the form of a textual message at program startup or |
21 | * in documentation (online or textual) provided with the package. | 21 | * in documentation (online or textual) provided with the package. |
22 | * | 22 | * |
23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
25 | * are met: | 25 | * are met: |
@@ -34,10 +34,10 @@ | |||
34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 37 | * 4. If you include any Windows specific code (or a derivative thereof) from |
38 | * the apps directory (application code) you must include an acknowledgement: | 38 | * the apps directory (application code) you must include an acknowledgement: |
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
40 | * | 40 | * |
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -49,7 +49,7 @@ | |||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
52 | * | 52 | * |
53 | * The licence and distribution terms for any publically available version or | 53 | * The licence and distribution terms for any publically available version or |
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
@@ -71,23 +71,26 @@ | |||
71 | #endif | 71 | #endif |
72 | 72 | ||
73 | #ifndef OPENSSL_NO_FP_API | 73 | #ifndef OPENSSL_NO_FP_API |
74 | int X509_REQ_print_fp(FILE *fp, X509_REQ *x) | 74 | int |
75 | X509_REQ_print_fp(FILE *fp, X509_REQ *x) | ||
75 | { | 76 | { |
76 | BIO *b; | 77 | BIO *b; |
77 | int ret; | 78 | int ret; |
78 | 79 | ||
79 | if ((b=BIO_new(BIO_s_file())) == NULL) { | 80 | if ((b = BIO_new(BIO_s_file())) == NULL) { |
80 | X509err(X509_F_X509_REQ_PRINT_FP,ERR_R_BUF_LIB); | 81 | X509err(X509_F_X509_REQ_PRINT_FP, ERR_R_BUF_LIB); |
81 | return(0); | 82 | return (0); |
82 | } | 83 | } |
83 | BIO_set_fp(b,fp,BIO_NOCLOSE); | 84 | BIO_set_fp(b, fp, BIO_NOCLOSE); |
84 | ret=X509_REQ_print(b, x); | 85 | ret = X509_REQ_print(b, x); |
85 | BIO_free(b); | 86 | BIO_free(b); |
86 | return(ret); | 87 | return (ret); |
87 | } | 88 | } |
88 | #endif | 89 | #endif |
89 | 90 | ||
90 | int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, unsigned long cflag) | 91 | int |
92 | X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, | ||
93 | unsigned long cflag) | ||
91 | { | 94 | { |
92 | unsigned long l; | 95 | unsigned long l; |
93 | int i; | 96 | int i; |
@@ -99,49 +102,55 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, unsigned long | |||
99 | char mlch = ' '; | 102 | char mlch = ' '; |
100 | int nmindent = 0; | 103 | int nmindent = 0; |
101 | 104 | ||
102 | if((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) { | 105 | if ((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) { |
103 | mlch = '\n'; | 106 | mlch = '\n'; |
104 | nmindent = 12; | 107 | nmindent = 12; |
105 | } | 108 | } |
106 | 109 | ||
107 | if(nmflags == X509_FLAG_COMPAT) | 110 | if (nmflags == X509_FLAG_COMPAT) |
108 | nmindent = 16; | 111 | nmindent = 16; |
109 | 112 | ||
113 | ri = x->req_info; | ||
114 | if (!(cflag & X509_FLAG_NO_HEADER)) { | ||
115 | if (BIO_write(bp, "Certificate Request:\n", 21) <= 0) | ||
116 | goto err; | ||
117 | if (BIO_write(bp, " Data:\n", 10) <= 0) | ||
110 | 118 | ||
111 | ri=x->req_info; | 119 | goto err; |
112 | if(!(cflag & X509_FLAG_NO_HEADER)) { | ||
113 | if (BIO_write(bp,"Certificate Request:\n",21) <= 0) goto err; | ||
114 | if (BIO_write(bp," Data:\n",10) <= 0) goto err; | ||
115 | } | 120 | } |
116 | if(!(cflag & X509_FLAG_NO_VERSION)) { | 121 | if (!(cflag & X509_FLAG_NO_VERSION)) { |
117 | neg=(ri->version->type == V_ASN1_NEG_INTEGER)?"-":""; | 122 | neg = (ri->version->type == V_ASN1_NEG_INTEGER) ? "-" : ""; |
118 | l=0; | 123 | l = 0; |
119 | for (i=0; i<ri->version->length; i++) { | 124 | for (i = 0; i < ri->version->length; i++) { |
120 | l<<=8; l+=ri->version->data[i]; | 125 | l <<= 8; |
126 | l += ri->version->data[i]; | ||
121 | } | 127 | } |
122 | if(BIO_printf(bp,"%8sVersion: %s%lu (%s0x%lx)\n","",neg,l,neg, | 128 | if (BIO_printf(bp, "%8sVersion: %s%lu (%s0x%lx)\n", "", neg, |
123 | l) <= 0) | 129 | l, neg, l) <= 0) |
124 | goto err; | 130 | goto err; |
131 | } | ||
132 | if (!(cflag & X509_FLAG_NO_SUBJECT)) { | ||
133 | if (BIO_printf(bp, " Subject:%c", mlch) <= 0) | ||
134 | goto err; | ||
135 | if (X509_NAME_print_ex(bp, ri->subject, nmindent, nmflags) < 0) | ||
136 | goto err; | ||
137 | if (BIO_write(bp, "\n", 1) <= 0) | ||
138 | goto err; | ||
125 | } | 139 | } |
126 | if(!(cflag & X509_FLAG_NO_SUBJECT)) | 140 | if (!(cflag & X509_FLAG_NO_PUBKEY)) { |
127 | { | 141 | if (BIO_write(bp, " Subject Public Key Info:\n", |
128 | if (BIO_printf(bp," Subject:%c",mlch) <= 0) goto err; | 142 | 33) <= 0) |
129 | if (X509_NAME_print_ex(bp,ri->subject,nmindent, nmflags) < 0) goto err; | ||
130 | if (BIO_write(bp,"\n",1) <= 0) goto err; | ||
131 | } | ||
132 | if(!(cflag & X509_FLAG_NO_PUBKEY)) { | ||
133 | if (BIO_write(bp," Subject Public Key Info:\n",33) <= 0) | ||
134 | goto err; | 143 | goto err; |
135 | if (BIO_printf(bp,"%12sPublic Key Algorithm: ","") <= 0) | 144 | if (BIO_printf(bp, "%12sPublic Key Algorithm: ", "") <= 0) |
136 | goto err; | 145 | goto err; |
137 | if (i2a_ASN1_OBJECT(bp, ri->pubkey->algor->algorithm) <= 0) | 146 | if (i2a_ASN1_OBJECT(bp, ri->pubkey->algor->algorithm) <= 0) |
138 | goto err; | 147 | goto err; |
139 | if (BIO_puts(bp, "\n") <= 0) | 148 | if (BIO_puts(bp, "\n") <= 0) |
140 | goto err; | 149 | goto err; |
141 | 150 | ||
142 | pkey=X509_REQ_get_pubkey(x); | 151 | pkey = X509_REQ_get_pubkey(x); |
143 | if (pkey == NULL) { | 152 | if (pkey == NULL) { |
144 | BIO_printf(bp,"%12sUnable to load Public Key\n",""); | 153 | BIO_printf(bp, "%12sUnable to load Public Key\n", ""); |
145 | ERR_print_errors(bp); | 154 | ERR_print_errors(bp); |
146 | } else { | 155 | } else { |
147 | EVP_PKEY_print_public(bp, pkey, 16, NULL); | 156 | EVP_PKEY_print_public(bp, pkey, 16, NULL); |
@@ -149,95 +158,108 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, unsigned long | |||
149 | } | 158 | } |
150 | } | 159 | } |
151 | 160 | ||
152 | if(!(cflag & X509_FLAG_NO_ATTRIBUTES)) { | 161 | if (!(cflag & X509_FLAG_NO_ATTRIBUTES)) { |
153 | /* may not be */ | 162 | /* may not be */ |
154 | if(BIO_printf(bp,"%8sAttributes:\n","") <= 0) | 163 | if (BIO_printf(bp, "%8sAttributes:\n", "") <= 0) |
155 | goto err; | 164 | goto err; |
156 | 165 | ||
157 | sk=x->req_info->attributes; | 166 | sk = x->req_info->attributes; |
158 | if (sk_X509_ATTRIBUTE_num(sk) == 0) { | 167 | if (sk_X509_ATTRIBUTE_num(sk) == 0) { |
159 | if(BIO_printf(bp,"%12sa0:00\n","") <= 0) | 168 | if (BIO_printf(bp, "%12sa0:00\n", "") <= 0) |
160 | goto err; | 169 | goto err; |
161 | } else { | 170 | } else { |
162 | for (i=0; i<sk_X509_ATTRIBUTE_num(sk); i++) { | 171 | for (i = 0; i < sk_X509_ATTRIBUTE_num(sk); i++) { |
163 | ASN1_TYPE *at; | 172 | ASN1_TYPE *at; |
164 | X509_ATTRIBUTE *a; | 173 | X509_ATTRIBUTE *a; |
165 | ASN1_BIT_STRING *bs=NULL; | 174 | ASN1_BIT_STRING *bs = NULL; |
166 | ASN1_TYPE *t; | 175 | ASN1_TYPE *t; |
167 | int j,type=0,count=1,ii=0; | 176 | int j, type = 0, count = 1, ii = 0; |
168 | 177 | ||
169 | a=sk_X509_ATTRIBUTE_value(sk,i); | 178 | a = sk_X509_ATTRIBUTE_value(sk, i); |
170 | if(X509_REQ_extension_nid(OBJ_obj2nid(a->object))) | 179 | if (X509_REQ_extension_nid( |
171 | continue; | 180 | OBJ_obj2nid(a->object))) |
172 | if(BIO_printf(bp,"%12s","") <= 0) | 181 | continue; |
173 | goto err; | 182 | if (BIO_printf(bp, "%12s", "") <= 0) |
174 | if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0) { | 183 | goto err; |
175 | if (a->single) { | 184 | if ((j = i2a_ASN1_OBJECT(bp, a->object)) > 0) { |
176 | t=a->value.single; | 185 | if (a->single) { |
177 | type=t->type; | 186 | t = a->value.single; |
178 | bs=t->value.bit_string; | 187 | type = t->type; |
179 | } else { | 188 | bs = t->value.bit_string; |
180 | ii=0; | 189 | } else { |
181 | count=sk_ASN1_TYPE_num(a->value.set); | 190 | ii = 0; |
191 | count = sk_ASN1_TYPE_num( | ||
192 | a->value.set); | ||
182 | get_next: | 193 | get_next: |
183 | at=sk_ASN1_TYPE_value(a->value.set,ii); | 194 | at = sk_ASN1_TYPE_value( |
184 | type=at->type; | 195 | a->value.set, ii); |
185 | bs=at->value.asn1_string; | 196 | type = at->type; |
197 | bs = at->value.asn1_string; | ||
198 | } | ||
186 | } | 199 | } |
187 | } | 200 | for (j = 25 - j; j > 0; j--) |
188 | for (j=25-j; j>0; j--) | 201 | if (BIO_write(bp, " ", 1) != 1) |
189 | if (BIO_write(bp," ",1) != 1) goto err; | ||
190 | if (BIO_puts(bp,":") <= 0) goto err; | ||
191 | if ( (type == V_ASN1_PRINTABLESTRING) || | ||
192 | (type == V_ASN1_T61STRING) || | ||
193 | (type == V_ASN1_IA5STRING)) { | ||
194 | if (BIO_write(bp,(char *)bs->data,bs->length) | ||
195 | != bs->length) | ||
196 | goto err; | 202 | goto err; |
197 | BIO_puts(bp,"\n"); | 203 | if (BIO_puts(bp, ":") <= 0) |
204 | goto err; | ||
205 | if ((type == V_ASN1_PRINTABLESTRING) || | ||
206 | (type == V_ASN1_T61STRING) || | ||
207 | (type == V_ASN1_IA5STRING)) { | ||
208 | if (BIO_write(bp, (char *)bs->data, | ||
209 | bs->length) != bs->length) | ||
210 | goto err; | ||
211 | BIO_puts(bp, "\n"); | ||
198 | } else { | 212 | } else { |
199 | BIO_puts(bp,"unable to print attribute\n"); | 213 | BIO_puts(bp, |
214 | "unable to print attribute\n"); | ||
200 | } | 215 | } |
201 | if (++ii < count) goto get_next; | 216 | if (++ii < count) |
217 | goto get_next; | ||
202 | } | 218 | } |
203 | } | 219 | } |
204 | } | 220 | } |
205 | if(!(cflag & X509_FLAG_NO_EXTENSIONS)) { | 221 | if (!(cflag & X509_FLAG_NO_EXTENSIONS)) { |
206 | exts = X509_REQ_get_extensions(x); | 222 | exts = X509_REQ_get_extensions(x); |
207 | if(exts) { | 223 | if (exts) { |
208 | BIO_printf(bp,"%8sRequested Extensions:\n",""); | 224 | BIO_printf(bp, "%8sRequested Extensions:\n", ""); |
209 | for (i=0; i<sk_X509_EXTENSION_num(exts); i++) { | 225 | for (i = 0; i < sk_X509_EXTENSION_num(exts); i++) { |
210 | ASN1_OBJECT *obj; | 226 | ASN1_OBJECT *obj; |
211 | X509_EXTENSION *ex; | 227 | X509_EXTENSION *ex; |
212 | int j; | 228 | int j; |
213 | ex=sk_X509_EXTENSION_value(exts, i); | 229 | ex = sk_X509_EXTENSION_value(exts, i); |
214 | if (BIO_printf(bp,"%12s","") <= 0) goto err; | 230 | if (BIO_printf(bp, "%12s", "") <= 0) |
215 | obj=X509_EXTENSION_get_object(ex); | 231 | goto err; |
216 | i2a_ASN1_OBJECT(bp,obj); | 232 | obj = X509_EXTENSION_get_object(ex); |
217 | j=X509_EXTENSION_get_critical(ex); | 233 | i2a_ASN1_OBJECT(bp, obj); |
218 | if (BIO_printf(bp,": %s\n",j?"critical":"") <= 0) | 234 | j = X509_EXTENSION_get_critical(ex); |
235 | if (BIO_printf(bp, ": %s\n", | ||
236 | j ? "critical" : "") <= 0) | ||
219 | goto err; | 237 | goto err; |
220 | if(!X509V3_EXT_print(bp, ex, cflag, 16)) { | 238 | if (!X509V3_EXT_print(bp, ex, cflag, 16)) { |
221 | BIO_printf(bp, "%16s", ""); | 239 | BIO_printf(bp, "%16s", ""); |
222 | M_ASN1_OCTET_STRING_print(bp,ex->value); | 240 | M_ASN1_OCTET_STRING_print(bp, ex->value); |
223 | } | 241 | } |
224 | if (BIO_write(bp,"\n",1) <= 0) goto err; | 242 | if (BIO_write(bp, "\n", 1) <= 0) |
243 | goto err; | ||
225 | } | 244 | } |
226 | sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free); | 245 | sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free); |
227 | } | 246 | } |
228 | } | 247 | } |
229 | 248 | ||
230 | if(!(cflag & X509_FLAG_NO_SIGDUMP)) { | 249 | if (!(cflag & X509_FLAG_NO_SIGDUMP)) { |
231 | if(!X509_signature_print(bp, x->sig_alg, x->signature)) goto err; | 250 | if (!X509_signature_print(bp, x->sig_alg, x->signature)) |
251 | goto err; | ||
232 | } | 252 | } |
233 | 253 | ||
234 | return(1); | 254 | return (1); |
255 | |||
235 | err: | 256 | err: |
236 | X509err(X509_F_X509_REQ_PRINT_EX,ERR_R_BUF_LIB); | 257 | X509err(X509_F_X509_REQ_PRINT_EX, ERR_R_BUF_LIB); |
237 | return(0); | 258 | return (0); |
238 | } | 259 | } |
239 | 260 | ||
240 | int X509_REQ_print(BIO *bp, X509_REQ *x) | 261 | int |
262 | X509_REQ_print(BIO *bp, X509_REQ *x) | ||
241 | { | 263 | { |
242 | return X509_REQ_print_ex(bp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT); | 264 | return X509_REQ_print_ex(bp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT); |
243 | } | 265 | } |
diff --git a/src/lib/libssl/src/crypto/asn1/t_spki.c b/src/lib/libssl/src/crypto/asn1/t_spki.c index f135754535..0265461b04 100644 --- a/src/lib/libssl/src/crypto/asn1/t_spki.c +++ b/src/lib/libssl/src/crypto/asn1/t_spki.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -70,38 +70,40 @@ | |||
70 | 70 | ||
71 | /* Print out an SPKI */ | 71 | /* Print out an SPKI */ |
72 | 72 | ||
73 | int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki) | 73 | int |
74 | NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki) | ||
74 | { | 75 | { |
75 | EVP_PKEY *pkey; | 76 | EVP_PKEY *pkey; |
76 | ASN1_IA5STRING *chal; | 77 | ASN1_IA5STRING *chal; |
77 | int i, n; | 78 | int i, n; |
78 | char *s; | 79 | char *s; |
80 | |||
79 | BIO_printf(out, "Netscape SPKI:\n"); | 81 | BIO_printf(out, "Netscape SPKI:\n"); |
80 | i=OBJ_obj2nid(spki->spkac->pubkey->algor->algorithm); | 82 | i = OBJ_obj2nid(spki->spkac->pubkey->algor->algorithm); |
81 | BIO_printf(out," Public Key Algorithm: %s\n", | 83 | BIO_printf(out, " Public Key Algorithm: %s\n", |
82 | (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)); | 84 | (i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i)); |
83 | pkey = X509_PUBKEY_get(spki->spkac->pubkey); | 85 | pkey = X509_PUBKEY_get(spki->spkac->pubkey); |
84 | if(!pkey) | 86 | if (!pkey) |
85 | BIO_printf(out, " Unable to load public key\n"); | 87 | BIO_printf(out, " Unable to load public key\n"); |
86 | else { | 88 | else { |
87 | EVP_PKEY_print_public(out, pkey, 4, NULL); | 89 | EVP_PKEY_print_public(out, pkey, 4, NULL); |
88 | EVP_PKEY_free(pkey); | 90 | EVP_PKEY_free(pkey); |
89 | } | 91 | } |
90 | chal = spki->spkac->challenge; | 92 | chal = spki->spkac->challenge; |
91 | if(chal->length) | 93 | if (chal->length) |
92 | BIO_printf(out, " Challenge String: %s\n", chal->data); | 94 | BIO_printf(out, " Challenge String: %s\n", chal->data); |
93 | i=OBJ_obj2nid(spki->sig_algor->algorithm); | 95 | i = OBJ_obj2nid(spki->sig_algor->algorithm); |
94 | BIO_printf(out," Signature Algorithm: %s", | 96 | BIO_printf(out, " Signature Algorithm: %s", |
95 | (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)); | 97 | (i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i)); |
96 | 98 | ||
97 | n=spki->signature->length; | 99 | n = spki->signature->length; |
98 | s=(char *)spki->signature->data; | 100 | s = (char *)spki->signature->data; |
99 | for (i=0; i<n; i++) { | 101 | for (i = 0; i < n; i++) { |
100 | if ((i%18) == 0) | 102 | if ((i % 18) == 0) |
101 | BIO_write(out,"\n ",7); | 103 | BIO_write(out, "\n ", 7); |
102 | BIO_printf(out,"%02x%s",(unsigned char)s[i], | 104 | BIO_printf(out, "%02x%s", (unsigned char)s[i], |
103 | ((i+1) == n)?"":":"); | 105 | ((i + 1) == n) ? "" : ":"); |
104 | } | 106 | } |
105 | BIO_write(out,"\n",1); | 107 | BIO_write(out, "\n", 1); |
106 | return 1; | 108 | return 1; |
107 | } | 109 | } |
diff --git a/src/lib/libssl/src/crypto/asn1/t_x509.c b/src/lib/libssl/src/crypto/asn1/t_x509.c index 32f1a4f4b0..de3fa22171 100644 --- a/src/lib/libssl/src/crypto/asn1/t_x509.c +++ b/src/lib/libssl/src/crypto/asn1/t_x509.c | |||
@@ -5,21 +5,21 @@ | |||
5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
8 | * | 8 | * |
9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
11 | * apply to all code found in this distribution, be it the RC4, RSA, | 11 | * apply to all code found in this distribution, be it the RC4, RSA, |
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
13 | * included with this distribution is covered by the same copyright terms | 13 | * included with this distribution is covered by the same copyright terms |
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
15 | * | 15 | * |
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
18 | * If this package is used in a product, Eric Young should be given attribution | 18 | * If this package is used in a product, Eric Young should be given attribution |
19 | * as the author of the parts of the library used. | 19 | * as the author of the parts of the library used. |
20 | * This can be in the form of a textual message at program startup or | 20 | * This can be in the form of a textual message at program startup or |
21 | * in documentation (online or textual) provided with the package. | 21 | * in documentation (online or textual) provided with the package. |
22 | * | 22 | * |
23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
25 | * are met: | 25 | * are met: |
@@ -34,10 +34,10 @@ | |||
34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 37 | * 4. If you include any Windows specific code (or a derivative thereof) from |
38 | * the apps directory (application code) you must include an acknowledgement: | 38 | * the apps directory (application code) you must include an acknowledgement: |
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
40 | * | 40 | * |
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -49,7 +49,7 @@ | |||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
52 | * | 52 | * |
53 | * The licence and distribution terms for any publically available version or | 53 | * The licence and distribution terms for any publically available version or |
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
@@ -75,92 +75,102 @@ | |||
75 | #include "asn1_locl.h" | 75 | #include "asn1_locl.h" |
76 | 76 | ||
77 | #ifndef OPENSSL_NO_FP_API | 77 | #ifndef OPENSSL_NO_FP_API |
78 | int X509_print_fp(FILE *fp, X509 *x) | 78 | int |
79 | X509_print_fp(FILE *fp, X509 *x) | ||
79 | { | 80 | { |
80 | return X509_print_ex_fp(fp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT); | 81 | return X509_print_ex_fp(fp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT); |
81 | } | 82 | } |
82 | 83 | ||
83 | int X509_print_ex_fp(FILE *fp, X509 *x, unsigned long nmflag, unsigned long cflag) | 84 | int |
84 | { | 85 | X509_print_ex_fp(FILE *fp, X509 *x, unsigned long nmflag, unsigned long cflag) |
85 | BIO *b; | 86 | { |
86 | int ret; | 87 | BIO *b; |
88 | int ret; | ||
87 | 89 | ||
88 | if ((b=BIO_new(BIO_s_file())) == NULL) { | 90 | if ((b = BIO_new(BIO_s_file())) == NULL) { |
89 | X509err(X509_F_X509_PRINT_EX_FP,ERR_R_BUF_LIB); | 91 | X509err(X509_F_X509_PRINT_EX_FP, ERR_R_BUF_LIB); |
90 | return(0); | 92 | return (0); |
91 | } | 93 | } |
92 | BIO_set_fp(b,fp,BIO_NOCLOSE); | 94 | BIO_set_fp(b, fp, BIO_NOCLOSE); |
93 | ret=X509_print_ex(b, x, nmflag, cflag); | 95 | ret = X509_print_ex(b, x, nmflag, cflag); |
94 | BIO_free(b); | 96 | BIO_free(b); |
95 | return(ret); | 97 | return (ret); |
96 | } | 98 | } |
97 | #endif | 99 | #endif |
98 | 100 | ||
99 | int X509_print(BIO *bp, X509 *x) | 101 | int |
102 | X509_print(BIO *bp, X509 *x) | ||
100 | { | 103 | { |
101 | return X509_print_ex(bp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT); | 104 | return X509_print_ex(bp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT); |
102 | } | 105 | } |
103 | 106 | ||
104 | int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag) | 107 | int |
108 | X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag) | ||
105 | { | 109 | { |
106 | long l; | 110 | long l; |
107 | int ret=0,i; | 111 | int ret = 0, i; |
108 | char *m=NULL,mlch = ' '; | 112 | char *m = NULL, mlch = ' '; |
109 | int nmindent = 0; | 113 | int nmindent = 0; |
110 | X509_CINF *ci; | 114 | X509_CINF *ci; |
111 | ASN1_INTEGER *bs; | 115 | ASN1_INTEGER *bs; |
112 | EVP_PKEY *pkey=NULL; | 116 | EVP_PKEY *pkey = NULL; |
113 | const char *neg; | 117 | const char *neg; |
114 | 118 | ||
115 | if((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) { | 119 | if ((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) { |
116 | mlch = '\n'; | 120 | mlch = '\n'; |
117 | nmindent = 12; | 121 | nmindent = 12; |
118 | } | 122 | } |
119 | 123 | ||
120 | if(nmflags == X509_FLAG_COMPAT) | 124 | if (nmflags == X509_FLAG_COMPAT) |
121 | nmindent = 16; | 125 | nmindent = 16; |
122 | 126 | ||
123 | ci=x->cert_info; | 127 | ci = x->cert_info; |
124 | if(!(cflag & X509_FLAG_NO_HEADER)) { | 128 | if (!(cflag & X509_FLAG_NO_HEADER)) { |
125 | if (BIO_write(bp,"Certificate:\n",13) <= 0) goto err; | 129 | if (BIO_write(bp, "Certificate:\n", 13) <= 0) |
126 | if (BIO_write(bp," Data:\n",10) <= 0) goto err; | 130 | goto err; |
131 | if (BIO_write(bp, " Data:\n", 10) <= 0) | ||
132 | goto err; | ||
127 | } | 133 | } |
128 | if(!(cflag & X509_FLAG_NO_VERSION)) { | 134 | if (!(cflag & X509_FLAG_NO_VERSION)) { |
129 | l=X509_get_version(x); | 135 | l = X509_get_version(x); |
130 | if (BIO_printf(bp,"%8sVersion: %lu (0x%lx)\n","",l+1,l) <= 0) goto err; | 136 | if (BIO_printf(bp, "%8sVersion: %lu (0x%lx)\n", |
137 | "", l + 1, l) <= 0) | ||
138 | goto err; | ||
131 | } | 139 | } |
132 | if(!(cflag & X509_FLAG_NO_SERIAL)) { | 140 | if (!(cflag & X509_FLAG_NO_SERIAL)) { |
133 | 141 | if (BIO_write(bp, " Serial Number:", 22) <= 0) | |
134 | if (BIO_write(bp," Serial Number:",22) <= 0) goto err; | 142 | goto err; |
135 | 143 | ||
136 | bs=X509_get_serialNumber(x); | 144 | bs = X509_get_serialNumber(x); |
137 | if (bs->length <= (int)sizeof(long)) { | 145 | if (bs->length <= (int)sizeof(long)) { |
138 | l=ASN1_INTEGER_get(bs); | 146 | l = ASN1_INTEGER_get(bs); |
139 | if (bs->type == V_ASN1_NEG_INTEGER) { | 147 | if (bs->type == V_ASN1_NEG_INTEGER) { |
140 | l= -l; | 148 | l = -l; |
141 | neg="-"; | 149 | neg = "-"; |
142 | } else | 150 | } else |
143 | neg=""; | 151 | neg = ""; |
144 | if (BIO_printf(bp," %s%lu (%s0x%lx)\n",neg,l,neg,l) <= 0) | 152 | if (BIO_printf(bp, " %s%lu (%s0x%lx)\n", |
153 | neg, l, neg, l) <= 0) | ||
145 | goto err; | 154 | goto err; |
146 | } else { | 155 | } else { |
147 | neg=(bs->type == V_ASN1_NEG_INTEGER)?" (Negative)":""; | 156 | neg = (bs->type == V_ASN1_NEG_INTEGER) ? |
148 | if (BIO_printf(bp,"\n%12s%s","",neg) <= 0) goto err; | 157 | " (Negative)" : ""; |
149 | 158 | if (BIO_printf(bp, "\n%12s%s", "", neg) <= 0) | |
150 | for (i=0; i<bs->length; i++) { | 159 | goto err; |
151 | if (BIO_printf(bp,"%02x%c",bs->data[i], | 160 | for (i = 0; i < bs->length; i++) { |
152 | ((i+1 == bs->length)?'\n':':')) <= 0) | 161 | if (BIO_printf(bp, "%02x%c", bs->data[i], |
162 | ((i + 1 == bs->length) ? '\n' : ':')) <= 0) | ||
153 | goto err; | 163 | goto err; |
154 | } | 164 | } |
155 | } | 165 | } |
156 | 166 | ||
157 | } | 167 | } |
158 | 168 | ||
159 | if(!(cflag & X509_FLAG_NO_SIGNAME)) { | 169 | if (!(cflag & X509_FLAG_NO_SIGNAME)) { |
160 | if(X509_signature_print(bp, x->sig_alg, NULL) <= 0) | 170 | if (X509_signature_print(bp, x->sig_alg, NULL) <= 0) |
161 | goto err; | 171 | goto err; |
162 | #if 0 | 172 | #if 0 |
163 | if (BIO_printf(bp,"%8sSignature Algorithm: ","") <= 0) | 173 | if (BIO_printf(bp, "%8sSignature Algorithm: ", "") <= 0) |
164 | goto err; | 174 | goto err; |
165 | if (i2a_ASN1_OBJECT(bp, ci->signature->algorithm) <= 0) | 175 | if (i2a_ASN1_OBJECT(bp, ci->signature->algorithm) <= 0) |
166 | goto err; | 176 | goto err; |
@@ -169,37 +179,52 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag) | |||
169 | #endif | 179 | #endif |
170 | } | 180 | } |
171 | 181 | ||
172 | if(!(cflag & X509_FLAG_NO_ISSUER)) { | 182 | if (!(cflag & X509_FLAG_NO_ISSUER)) { |
173 | if (BIO_printf(bp," Issuer:%c",mlch) <= 0) goto err; | 183 | if (BIO_printf(bp, " Issuer:%c", mlch) <= 0) |
174 | if (X509_NAME_print_ex(bp,X509_get_issuer_name(x),nmindent, nmflags) < 0) goto err; | 184 | goto err; |
175 | if (BIO_write(bp,"\n",1) <= 0) goto err; | 185 | if (X509_NAME_print_ex(bp, X509_get_issuer_name(x), |
186 | nmindent, nmflags) < 0) | ||
187 | goto err; | ||
188 | if (BIO_write(bp, "\n", 1) <= 0) | ||
189 | goto err; | ||
176 | } | 190 | } |
177 | if(!(cflag & X509_FLAG_NO_VALIDITY)) { | 191 | if (!(cflag & X509_FLAG_NO_VALIDITY)) { |
178 | if (BIO_write(bp," Validity\n",17) <= 0) goto err; | 192 | if (BIO_write(bp, " Validity\n", 17) <= 0) |
179 | if (BIO_write(bp," Not Before: ",24) <= 0) goto err; | 193 | goto err; |
180 | if (!ASN1_TIME_print(bp,X509_get_notBefore(x))) goto err; | 194 | if (BIO_write(bp, " Not Before: ", 24) <= 0) |
181 | if (BIO_write(bp,"\n Not After : ",25) <= 0) goto err; | 195 | goto err; |
182 | if (!ASN1_TIME_print(bp,X509_get_notAfter(x))) goto err; | 196 | if (!ASN1_TIME_print(bp, X509_get_notBefore(x))) |
183 | if (BIO_write(bp,"\n",1) <= 0) goto err; | 197 | goto err; |
198 | if (BIO_write(bp, "\n Not After : ", 25) <= 0) | ||
199 | goto err; | ||
200 | if (!ASN1_TIME_print(bp, X509_get_notAfter(x))) | ||
201 | goto err; | ||
202 | if (BIO_write(bp, "\n", 1) <= 0) | ||
203 | goto err; | ||
184 | } | 204 | } |
185 | if(!(cflag & X509_FLAG_NO_SUBJECT)) { | 205 | if (!(cflag & X509_FLAG_NO_SUBJECT)) { |
186 | if (BIO_printf(bp," Subject:%c",mlch) <= 0) goto err; | 206 | if (BIO_printf(bp, " Subject:%c", mlch) <= 0) |
187 | if (X509_NAME_print_ex(bp,X509_get_subject_name(x),nmindent, nmflags) < 0) goto err; | 207 | goto err; |
188 | if (BIO_write(bp,"\n",1) <= 0) goto err; | 208 | if (X509_NAME_print_ex(bp, X509_get_subject_name(x), |
209 | nmindent, nmflags) < 0) | ||
210 | goto err; | ||
211 | if (BIO_write(bp, "\n", 1) <= 0) | ||
212 | goto err; | ||
189 | } | 213 | } |
190 | if(!(cflag & X509_FLAG_NO_PUBKEY)) { | 214 | if (!(cflag & X509_FLAG_NO_PUBKEY)) { |
191 | if (BIO_write(bp," Subject Public Key Info:\n",33) <= 0) | 215 | if (BIO_write(bp, " Subject Public Key Info:\n", |
216 | 33) <= 0) | ||
192 | goto err; | 217 | goto err; |
193 | if (BIO_printf(bp,"%12sPublic Key Algorithm: ","") <= 0) | 218 | if (BIO_printf(bp, "%12sPublic Key Algorithm: ", "") <= 0) |
194 | goto err; | 219 | goto err; |
195 | if (i2a_ASN1_OBJECT(bp, ci->key->algor->algorithm) <= 0) | 220 | if (i2a_ASN1_OBJECT(bp, ci->key->algor->algorithm) <= 0) |
196 | goto err; | 221 | goto err; |
197 | if (BIO_puts(bp, "\n") <= 0) | 222 | if (BIO_puts(bp, "\n") <= 0) |
198 | goto err; | 223 | goto err; |
199 | 224 | ||
200 | pkey=X509_get_pubkey(x); | 225 | pkey = X509_get_pubkey(x); |
201 | if (pkey == NULL) { | 226 | if (pkey == NULL) { |
202 | BIO_printf(bp,"%12sUnable to load Public Key\n",""); | 227 | BIO_printf(bp, "%12sUnable to load Public Key\n", ""); |
203 | ERR_print_errors(bp); | 228 | ERR_print_errors(bp); |
204 | } else { | 229 | } else { |
205 | EVP_PKEY_print_public(bp, pkey, 16, NULL); | 230 | EVP_PKEY_print_public(bp, pkey, 16, NULL); |
@@ -209,23 +234,27 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag) | |||
209 | 234 | ||
210 | if (!(cflag & X509_FLAG_NO_EXTENSIONS)) | 235 | if (!(cflag & X509_FLAG_NO_EXTENSIONS)) |
211 | X509V3_extensions_print(bp, "X509v3 extensions", | 236 | X509V3_extensions_print(bp, "X509v3 extensions", |
212 | ci->extensions, cflag, 8); | 237 | ci->extensions, cflag, 8); |
213 | 238 | ||
214 | if(!(cflag & X509_FLAG_NO_SIGDUMP)) { | 239 | if (!(cflag & X509_FLAG_NO_SIGDUMP)) { |
215 | if(X509_signature_print(bp, x->sig_alg, x->signature) <= 0) goto err; | 240 | if (X509_signature_print(bp, x->sig_alg, x->signature) <= 0) |
241 | goto err; | ||
216 | } | 242 | } |
217 | if(!(cflag & X509_FLAG_NO_AUX)) { | 243 | if (!(cflag & X509_FLAG_NO_AUX)) { |
218 | if (!X509_CERT_AUX_print(bp, x->aux, 0)) goto err; | 244 | if (!X509_CERT_AUX_print(bp, x->aux, 0)) |
245 | goto err; | ||
219 | } | 246 | } |
220 | ret=1; | 247 | ret = 1; |
248 | |||
221 | err: | 249 | err: |
222 | if (m != NULL) free(m); | 250 | if (m != NULL) |
223 | return(ret); | 251 | free(m); |
252 | return (ret); | ||
224 | } | 253 | } |
225 | 254 | ||
226 | int X509_ocspid_print (BIO *bp, X509 *x) | 255 | int X509_ocspid_print (BIO *bp, X509 *x) |
227 | { | 256 | { |
228 | unsigned char *der=NULL ; | 257 | unsigned char *der = NULL; |
229 | unsigned char *dertmp; | 258 | unsigned char *dertmp; |
230 | int derlen; | 259 | int derlen; |
231 | int i; | 260 | int i; |
@@ -233,7 +262,7 @@ int X509_ocspid_print (BIO *bp, X509 *x) | |||
233 | 262 | ||
234 | /* display the hash of the subject as it would appear | 263 | /* display the hash of the subject as it would appear |
235 | in OCSP requests */ | 264 | in OCSP requests */ |
236 | if (BIO_printf(bp," Subject OCSP hash: ") <= 0) | 265 | if (BIO_printf(bp, " Subject OCSP hash: ") <= 0) |
237 | goto err; | 266 | goto err; |
238 | derlen = i2d_X509_NAME(x->cert_info->subject, NULL); | 267 | derlen = i2d_X509_NAME(x->cert_info->subject, NULL); |
239 | if ((der = dertmp = (unsigned char *)malloc (derlen)) == NULL) | 268 | if ((der = dertmp = (unsigned char *)malloc (derlen)) == NULL) |
@@ -242,58 +271,69 @@ int X509_ocspid_print (BIO *bp, X509 *x) | |||
242 | 271 | ||
243 | if (!EVP_Digest(der, derlen, SHA1md, NULL, EVP_sha1(), NULL)) | 272 | if (!EVP_Digest(der, derlen, SHA1md, NULL, EVP_sha1(), NULL)) |
244 | goto err; | 273 | goto err; |
245 | for (i=0; i < SHA_DIGEST_LENGTH; i++) { | 274 | for (i = 0; i < SHA_DIGEST_LENGTH; i++) { |
246 | if (BIO_printf(bp,"%02X",SHA1md[i]) <= 0) goto err; | 275 | if (BIO_printf(bp, "%02X", SHA1md[i]) <= 0) |
276 | goto err; | ||
247 | } | 277 | } |
248 | free (der); | 278 | free (der); |
249 | der=NULL; | 279 | der = NULL; |
250 | 280 | ||
251 | /* display the hash of the public key as it would appear | 281 | /* display the hash of the public key as it would appear |
252 | in OCSP requests */ | 282 | in OCSP requests */ |
253 | if (BIO_printf(bp,"\n Public key OCSP hash: ") <= 0) | 283 | if (BIO_printf(bp, "\n Public key OCSP hash: ") <= 0) |
254 | goto err; | 284 | goto err; |
255 | 285 | ||
256 | if (!EVP_Digest(x->cert_info->key->public_key->data, | 286 | if (!EVP_Digest(x->cert_info->key->public_key->data, |
257 | x->cert_info->key->public_key->length, | 287 | x->cert_info->key->public_key->length, |
258 | SHA1md, NULL, EVP_sha1(), NULL)) | 288 | SHA1md, NULL, EVP_sha1(), NULL)) |
259 | goto err; | 289 | goto err; |
260 | for (i=0; i < SHA_DIGEST_LENGTH; i++) { | 290 | for (i = 0; i < SHA_DIGEST_LENGTH; i++) { |
261 | if (BIO_printf(bp,"%02X",SHA1md[i]) <= 0) | 291 | if (BIO_printf(bp, "%02X", SHA1md[i]) <= 0) |
262 | goto err; | 292 | goto err; |
263 | } | 293 | } |
264 | BIO_printf(bp,"\n"); | 294 | BIO_printf(bp, "\n"); |
265 | 295 | ||
266 | return (1); | 296 | return (1); |
297 | |||
267 | err: | 298 | err: |
268 | if (der != NULL) free(der); | 299 | if (der != NULL) |
269 | return(0); | 300 | free(der); |
301 | return (0); | ||
270 | } | 302 | } |
271 | 303 | ||
272 | int X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent) | 304 | int |
305 | X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent) | ||
273 | { | 306 | { |
274 | const unsigned char *s; | 307 | const unsigned char *s; |
275 | int i, n; | 308 | int i, n; |
276 | 309 | ||
277 | n=sig->length; | 310 | n = sig->length; |
278 | s=sig->data; | 311 | s = sig->data; |
279 | for (i=0; i<n; i++) { | 312 | for (i = 0; i < n; i++) { |
280 | if ((i%18) == 0) { | 313 | if ((i % 18) == 0) { |
281 | if (BIO_write(bp,"\n",1) <= 0) return 0; | 314 | if (BIO_write(bp, "\n", 1) <= 0) |
282 | if (BIO_indent(bp, indent, indent) <= 0) return 0; | 315 | return 0; |
316 | if (BIO_indent(bp, indent, indent) <= 0) | ||
317 | return 0; | ||
283 | } | 318 | } |
284 | if (BIO_printf(bp,"%02x%s",s[i], | 319 | if (BIO_printf(bp, "%02x%s", s[i], |
285 | ((i+1) == n)?"":":") <= 0) return 0; | 320 | ((i + 1) == n) ? "" : ":") <= 0) |
321 | return 0; | ||
286 | } | 322 | } |
287 | if (BIO_write(bp,"\n",1) != 1) return 0; | 323 | if (BIO_write(bp, "\n", 1) != 1) |
324 | return 0; | ||
288 | 325 | ||
289 | return 1; | 326 | return 1; |
290 | } | 327 | } |
291 | 328 | ||
292 | int X509_signature_print(BIO *bp, X509_ALGOR *sigalg, ASN1_STRING *sig) | 329 | int |
330 | X509_signature_print(BIO *bp, X509_ALGOR *sigalg, ASN1_STRING *sig) | ||
293 | { | 331 | { |
294 | int sig_nid; | 332 | int sig_nid; |
295 | if (BIO_puts(bp," Signature Algorithm: ") <= 0) return 0; | 333 | if (BIO_puts(bp, " Signature Algorithm: ") <= 0) |
296 | if (i2a_ASN1_OBJECT(bp, sigalg->algorithm) <= 0) return 0; | 334 | return 0; |
335 | if (i2a_ASN1_OBJECT(bp, sigalg->algorithm) <= 0) | ||
336 | return 0; | ||
297 | 337 | ||
298 | sig_nid = OBJ_obj2nid(sigalg->algorithm); | 338 | sig_nid = OBJ_obj2nid(sigalg->algorithm); |
299 | if (sig_nid != NID_undef) { | 339 | if (sig_nid != NID_undef) { |
@@ -312,172 +352,191 @@ int X509_signature_print(BIO *bp, X509_ALGOR *sigalg, ASN1_STRING *sig) | |||
312 | return 1; | 352 | return 1; |
313 | } | 353 | } |
314 | 354 | ||
315 | int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v) | 355 | int |
356 | ASN1_STRING_print(BIO *bp, const ASN1_STRING *v) | ||
316 | { | 357 | { |
317 | int i,n; | 358 | int i, n; |
318 | char buf[80]; | 359 | char buf[80]; |
319 | const char *p; | 360 | const char *p; |
320 | 361 | ||
321 | if (v == NULL) return(0); | 362 | if (v == NULL) |
322 | n=0; | 363 | return (0); |
323 | p=(const char *)v->data; | 364 | n = 0; |
324 | for (i=0; i<v->length; i++) { | 365 | p = (const char *)v->data; |
366 | for (i = 0; i < v->length; i++) { | ||
325 | if ((p[i] > '~') || ((p[i] < ' ') && | 367 | if ((p[i] > '~') || ((p[i] < ' ') && |
326 | (p[i] != '\n') && (p[i] != '\r'))) | 368 | (p[i] != '\n') && (p[i] != '\r'))) |
327 | buf[n]='.'; | 369 | buf[n] = '.'; |
328 | else | 370 | else |
329 | buf[n]=p[i]; | 371 | buf[n] = p[i]; |
330 | n++; | 372 | n++; |
331 | if (n >= 80) { | 373 | if (n >= 80) { |
332 | if (BIO_write(bp,buf,n) <= 0) | 374 | if (BIO_write(bp, buf, n) <= 0) |
333 | return(0); | 375 | return (0); |
334 | n=0; | 376 | n = 0; |
335 | } | 377 | } |
336 | } | 378 | } |
337 | if (n > 0) | 379 | if (n > 0) |
338 | if (BIO_write(bp,buf,n) <= 0) | 380 | if (BIO_write(bp, buf, n) <= 0) |
339 | return(0); | 381 | return (0); |
340 | return(1); | 382 | return (1); |
341 | } | 383 | } |
342 | 384 | ||
343 | int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm) | 385 | int |
386 | ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm) | ||
344 | { | 387 | { |
345 | if(tm->type == V_ASN1_UTCTIME) return ASN1_UTCTIME_print(bp, tm); | 388 | if (tm->type == V_ASN1_UTCTIME) |
346 | if(tm->type == V_ASN1_GENERALIZEDTIME) | 389 | return ASN1_UTCTIME_print(bp, tm); |
347 | return ASN1_GENERALIZEDTIME_print(bp, tm); | 390 | if (tm->type == V_ASN1_GENERALIZEDTIME) |
348 | BIO_write(bp,"Bad time value",14); | 391 | return ASN1_GENERALIZEDTIME_print(bp, tm); |
349 | return(0); | 392 | BIO_write(bp, "Bad time value", 14); |
393 | return (0); | ||
350 | } | 394 | } |
351 | 395 | ||
352 | static const char *mon[12]= | 396 | static const char *mon[12] = { |
353 | { | 397 | "Jan", "Feb", "Mar", "Apr", "May", "Jun", |
354 | "Jan","Feb","Mar","Apr","May","Jun", | 398 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" |
355 | "Jul","Aug","Sep","Oct","Nov","Dec" | 399 | }; |
356 | }; | ||
357 | 400 | ||
358 | int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm) | 401 | int |
402 | ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm) | ||
359 | { | 403 | { |
360 | char *v; | 404 | char *v; |
361 | int gmt=0; | 405 | int gmt = 0; |
362 | int i; | 406 | int i; |
363 | int y=0,M=0,d=0,h=0,m=0,s=0; | 407 | int y = 0, M = 0, d = 0, h = 0, m = 0, s = 0; |
364 | char *f = NULL; | 408 | char *f = NULL; |
365 | int f_len = 0; | 409 | int f_len = 0; |
366 | 410 | ||
367 | i=tm->length; | 411 | i = tm->length; |
368 | v=(char *)tm->data; | 412 | v = (char *)tm->data; |
369 | 413 | ||
370 | if (i < 12) goto err; | 414 | if (i < 12) |
371 | if (v[i-1] == 'Z') gmt=1; | 415 | goto err; |
372 | for (i=0; i<12; i++) | 416 | if (v[i-1] == 'Z') |
373 | if ((v[i] > '9') || (v[i] < '0')) goto err; | 417 | gmt = 1; |
374 | y= (v[0]-'0')*1000+(v[1]-'0')*100 + (v[2]-'0')*10+(v[3]-'0'); | 418 | for (i = 0; i < 12; i++) |
375 | M= (v[4]-'0')*10+(v[5]-'0'); | 419 | if ((v[i] > '9') || (v[i] < '0')) |
376 | if ((M > 12) || (M < 1)) goto err; | 420 | goto err; |
377 | d= (v[6]-'0')*10+(v[7]-'0'); | 421 | y = (v[0] - '0') * 1000 + (v[1] - '0') * 100 + |
378 | h= (v[8]-'0')*10+(v[9]-'0'); | 422 | (v[2] - '0') * 10 + (v[3] - '0'); |
379 | m= (v[10]-'0')*10+(v[11]-'0'); | 423 | M = (v[4] - '0') * 10 + (v[5] - '0'); |
424 | if ((M > 12) || (M < 1)) | ||
425 | goto err; | ||
426 | d = (v[6] - '0') * 10 + (v[7] - '0'); | ||
427 | h = (v[8] - '0') * 10 + (v[9] - '0'); | ||
428 | m = (v[10] - '0') * 10 + (v[11] - '0'); | ||
380 | if (tm->length >= 14 && | 429 | if (tm->length >= 14 && |
381 | (v[12] >= '0') && (v[12] <= '9') && | 430 | (v[12] >= '0') && (v[12] <= '9') && |
382 | (v[13] >= '0') && (v[13] <= '9')) { | 431 | (v[13] >= '0') && (v[13] <= '9')) { |
383 | s= (v[12]-'0')*10+(v[13]-'0'); | 432 | s = (v[12] - '0') * 10 + (v[13] - '0'); |
384 | /* Check for fractions of seconds. */ | 433 | /* Check for fractions of seconds. */ |
385 | if (tm->length >= 15 && v[14] == '.') { | 434 | if (tm->length >= 15 && v[14] == '.') { |
386 | int l = tm->length; | 435 | int l = tm->length; |
387 | f = &v[14]; /* The decimal point. */ | 436 | f = &v[14]; /* The decimal point. */ |
388 | f_len = 1; | 437 | f_len = 1; |
389 | while (14 + f_len < l && f[f_len] >= '0' && f[f_len] <= '9') | 438 | while (14 + f_len < l && f[f_len] >= '0' && |
439 | f[f_len] <= '9') | ||
390 | ++f_len; | 440 | ++f_len; |
391 | } | 441 | } |
392 | } | 442 | } |
393 | 443 | ||
394 | if (BIO_printf(bp,"%s %2d %02d:%02d:%02d%.*s %d%s", | 444 | if (BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s", |
395 | mon[M-1],d,h,m,s,f_len,f,y,(gmt)?" GMT":"") <= 0) | 445 | mon[M - 1], d, h, m, s, f_len, f, y, (gmt) ? " GMT" : "") <= 0) |
396 | return(0); | 446 | return (0); |
397 | else | 447 | else |
398 | return(1); | 448 | return (1); |
449 | |||
399 | err: | 450 | err: |
400 | BIO_write(bp,"Bad time value",14); | 451 | BIO_write(bp, "Bad time value", 14); |
401 | return(0); | 452 | return (0); |
402 | } | 453 | } |
403 | 454 | ||
404 | int ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm) | 455 | int |
456 | ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm) | ||
405 | { | 457 | { |
406 | const char *v; | 458 | const char *v; |
407 | int gmt=0; | 459 | int gmt = 0; |
408 | int i; | 460 | int i; |
409 | int y=0,M=0,d=0,h=0,m=0,s=0; | 461 | int y = 0, M = 0, d = 0, h = 0, m = 0, s = 0; |
410 | 462 | ||
411 | i=tm->length; | 463 | i = tm->length; |
412 | v=(const char *)tm->data; | 464 | v = (const char *)tm->data; |
413 | 465 | ||
414 | if (i < 10) goto err; | 466 | if (i < 10) |
415 | if (v[i-1] == 'Z') gmt=1; | 467 | goto err; |
416 | for (i=0; i<10; i++) | 468 | if (v[i-1] == 'Z') |
417 | if ((v[i] > '9') || (v[i] < '0')) goto err; | 469 | gmt = 1; |
418 | y= (v[0]-'0')*10+(v[1]-'0'); | 470 | for (i = 0; i < 10; i++) |
419 | if (y < 50) y+=100; | 471 | if ((v[i] > '9') || (v[i] < '0')) |
420 | M= (v[2]-'0')*10+(v[3]-'0'); | 472 | goto err; |
421 | if ((M > 12) || (M < 1)) goto err; | 473 | y = (v[0] - '0') * 10 + (v[1] - '0'); |
422 | d= (v[4]-'0')*10+(v[5]-'0'); | 474 | if (y < 50) |
423 | h= (v[6]-'0')*10+(v[7]-'0'); | 475 | y += 100; |
424 | m= (v[8]-'0')*10+(v[9]-'0'); | 476 | M = (v[2] - '0') * 10 + (v[3] - '0'); |
477 | if ((M > 12) || (M < 1)) | ||
478 | goto err; | ||
479 | d = (v[4] - '0') * 10 + (v[5] - '0'); | ||
480 | h = (v[6] - '0') * 10 + (v[7] - '0'); | ||
481 | m = (v[8] - '0') * 10 + (v[9] - '0'); | ||
425 | if (tm->length >=12 && | 482 | if (tm->length >=12 && |
426 | (v[10] >= '0') && (v[10] <= '9') && | 483 | (v[10] >= '0') && (v[10] <= '9') && |
427 | (v[11] >= '0') && (v[11] <= '9')) | 484 | (v[11] >= '0') && (v[11] <= '9')) |
428 | s= (v[10]-'0')*10+(v[11]-'0'); | 485 | s = (v[10] - '0') * 10 + (v[11] - '0'); |
429 | 486 | ||
430 | if (BIO_printf(bp,"%s %2d %02d:%02d:%02d %d%s", | 487 | if (BIO_printf(bp, "%s %2d %02d:%02d:%02d %d%s", |
431 | mon[M-1],d,h,m,s,y+1900,(gmt)?" GMT":"") <= 0) | 488 | mon[M - 1], d, h, m, s, y + 1900, (gmt) ? " GMT" : "") <= 0) |
432 | return(0); | 489 | return (0); |
433 | else | 490 | else |
434 | return(1); | 491 | return (1); |
492 | |||
435 | err: | 493 | err: |
436 | BIO_write(bp,"Bad time value",14); | 494 | BIO_write(bp, "Bad time value", 14); |
437 | return(0); | 495 | return (0); |
438 | } | 496 | } |
439 | 497 | ||
440 | int X509_NAME_print(BIO *bp, X509_NAME *name, int obase) | 498 | int |
499 | X509_NAME_print(BIO *bp, X509_NAME *name, int obase) | ||
441 | { | 500 | { |
442 | char *s,*c,*b; | 501 | char *s, *c, *b; |
443 | int ret=0,l,i; | 502 | int ret = 0, l, i; |
444 | 503 | ||
445 | l=80-2-obase; | 504 | l = 80 - 2 - obase; |
446 | 505 | ||
447 | b=X509_NAME_oneline(name,NULL,0); | 506 | b = X509_NAME_oneline(name, NULL, 0); |
448 | if (!*b) { | 507 | if (!*b) { |
449 | free(b); | 508 | free(b); |
450 | return 1; | 509 | return 1; |
451 | } | 510 | } |
452 | s=b+1; /* skip the first slash */ | 511 | s = b + 1; /* skip the first slash */ |
453 | 512 | ||
454 | c=s; | 513 | c = s; |
455 | for (;;) { | 514 | for (;;) { |
456 | if ( ((*s == '/') && | 515 | if (((*s == '/') && |
457 | ((s[1] >= 'A') && (s[1] <= 'Z') && ( | 516 | ((s[1] >= 'A') && (s[1] <= 'Z') && |
458 | (s[2] == '=') || | 517 | ((s[2] == '=') || ((s[2] >= 'A') && (s[2] <= 'Z') && |
459 | ((s[2] >= 'A') && (s[2] <= 'Z') && | 518 | (s[3] == '='))))) || (*s == '\0')) { |
460 | (s[3] == '=')) | 519 | i = s - c; |
461 | ))) || | 520 | if (BIO_write(bp, c, i) != i) |
462 | (*s == '\0')) { | 521 | goto err; |
463 | i=s-c; | 522 | c = s + 1; /* skip following slash */ |
464 | if (BIO_write(bp,c,i) != i) goto err; | ||
465 | c=s+1; /* skip following slash */ | ||
466 | if (*s != '\0') { | 523 | if (*s != '\0') { |
467 | if (BIO_write(bp,", ",2) != 2) goto err; | 524 | if (BIO_write(bp, ", ", 2) != 2) |
525 | goto err; | ||
468 | } | 526 | } |
469 | l--; | 527 | l--; |
470 | } | 528 | } |
471 | if (*s == '\0') break; | 529 | if (*s == '\0') |
530 | break; | ||
472 | s++; | 531 | s++; |
473 | l--; | 532 | l--; |
474 | } | 533 | } |
475 | 534 | ||
476 | ret=1; | 535 | ret = 1; |
477 | if (0) { | 536 | if (0) { |
478 | err: | 537 | err: |
479 | X509err(X509_F_X509_NAME_PRINT,ERR_R_BUF_LIB); | 538 | X509err(X509_F_X509_NAME_PRINT, ERR_R_BUF_LIB); |
480 | } | 539 | } |
481 | free(b); | 540 | free(b); |
482 | return(ret); | 541 | return (ret); |
483 | } | 542 | } |
diff --git a/src/lib/libssl/src/crypto/asn1/t_x509a.c b/src/lib/libssl/src/crypto/asn1/t_x509a.c index 8b18801a17..49d1be19db 100644 --- a/src/lib/libssl/src/crypto/asn1/t_x509a.c +++ b/src/lib/libssl/src/crypto/asn1/t_x509a.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -65,46 +65,54 @@ | |||
65 | /* X509_CERT_AUX and string set routines | 65 | /* X509_CERT_AUX and string set routines |
66 | */ | 66 | */ |
67 | 67 | ||
68 | int X509_CERT_AUX_print(BIO *out, X509_CERT_AUX *aux, int indent) | 68 | int |
69 | X509_CERT_AUX_print(BIO *out, X509_CERT_AUX *aux, int indent) | ||
69 | { | 70 | { |
70 | char oidstr[80], first; | 71 | char oidstr[80], first; |
71 | int i; | 72 | int i; |
72 | if(!aux) return 1; | 73 | if (!aux) |
73 | if(aux->trust) { | 74 | return 1; |
75 | if (aux->trust) { | ||
74 | first = 1; | 76 | first = 1; |
75 | BIO_printf(out, "%*sTrusted Uses:\n%*s", | 77 | BIO_printf(out, "%*sTrusted Uses:\n%*s", |
76 | indent, "", indent + 2, ""); | 78 | indent, "", indent + 2, ""); |
77 | for(i = 0; i < sk_ASN1_OBJECT_num(aux->trust); i++) { | 79 | for (i = 0; i < sk_ASN1_OBJECT_num(aux->trust); i++) { |
78 | if(!first) BIO_puts(out, ", "); | 80 | if (!first) |
79 | else first = 0; | 81 | BIO_puts(out, ", "); |
82 | else | ||
83 | first = 0; | ||
80 | OBJ_obj2txt(oidstr, sizeof oidstr, | 84 | OBJ_obj2txt(oidstr, sizeof oidstr, |
81 | sk_ASN1_OBJECT_value(aux->trust, i), 0); | 85 | sk_ASN1_OBJECT_value(aux->trust, i), 0); |
82 | BIO_puts(out, oidstr); | 86 | BIO_puts(out, oidstr); |
83 | } | 87 | } |
84 | BIO_puts(out, "\n"); | 88 | BIO_puts(out, "\n"); |
85 | } else BIO_printf(out, "%*sNo Trusted Uses.\n", indent, ""); | 89 | } else |
86 | if(aux->reject) { | 90 | BIO_printf(out, "%*sNo Trusted Uses.\n", indent, ""); |
91 | if (aux->reject) { | ||
87 | first = 1; | 92 | first = 1; |
88 | BIO_printf(out, "%*sRejected Uses:\n%*s", | 93 | BIO_printf(out, "%*sRejected Uses:\n%*s", |
89 | indent, "", indent + 2, ""); | 94 | indent, "", indent + 2, ""); |
90 | for(i = 0; i < sk_ASN1_OBJECT_num(aux->reject); i++) { | 95 | for (i = 0; i < sk_ASN1_OBJECT_num(aux->reject); i++) { |
91 | if(!first) BIO_puts(out, ", "); | 96 | if (!first) |
92 | else first = 0; | 97 | BIO_puts(out, ", "); |
98 | else | ||
99 | first = 0; | ||
93 | OBJ_obj2txt(oidstr, sizeof oidstr, | 100 | OBJ_obj2txt(oidstr, sizeof oidstr, |
94 | sk_ASN1_OBJECT_value(aux->reject, i), 0); | 101 | sk_ASN1_OBJECT_value(aux->reject, i), 0); |
95 | BIO_puts(out, oidstr); | 102 | BIO_puts(out, oidstr); |
96 | } | 103 | } |
97 | BIO_puts(out, "\n"); | 104 | BIO_puts(out, "\n"); |
98 | } else BIO_printf(out, "%*sNo Rejected Uses.\n", indent, ""); | 105 | } else |
99 | if(aux->alias) BIO_printf(out, "%*sAlias: %s\n", indent, "", | 106 | BIO_printf(out, "%*sNo Rejected Uses.\n", indent, ""); |
100 | aux->alias->data); | 107 | if (aux->alias) |
101 | if(aux->keyid) { | 108 | BIO_printf(out, "%*sAlias: %s\n", indent, "", |
109 | aux->alias->data); | ||
110 | if (aux->keyid) { | ||
102 | BIO_printf(out, "%*sKey Id: ", indent, ""); | 111 | BIO_printf(out, "%*sKey Id: ", indent, ""); |
103 | for(i = 0; i < aux->keyid->length; i++) | 112 | for (i = 0; i < aux->keyid->length; i++) |
104 | BIO_printf(out, "%s%02X", | 113 | BIO_printf(out, "%s%02X", i ? ":" : "", |
105 | i ? ":" : "", | 114 | aux->keyid->data[i]); |
106 | aux->keyid->data[i]); | 115 | BIO_write(out, "\n", 1); |
107 | BIO_write(out,"\n",1); | ||
108 | } | 116 | } |
109 | return 1; | 117 | return 1; |
110 | } | 118 | } |