diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libssl/ssl_txt.c | 211 |
1 files changed, 107 insertions, 104 deletions
diff --git a/src/lib/libssl/ssl_txt.c b/src/lib/libssl/ssl_txt.c index 6479d52c0c..5186e396ec 100644 --- a/src/lib/libssl/ssl_txt.c +++ b/src/lib/libssl/ssl_txt.c | |||
| @@ -87,30 +87,33 @@ | |||
| 87 | #include "ssl_locl.h" | 87 | #include "ssl_locl.h" |
| 88 | 88 | ||
| 89 | #ifndef OPENSSL_NO_FP_API | 89 | #ifndef OPENSSL_NO_FP_API |
| 90 | int SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *x) | 90 | int |
| 91 | { | 91 | SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *x) |
| 92 | { | ||
| 92 | BIO *b; | 93 | BIO *b; |
| 93 | int ret; | 94 | int ret; |
| 94 | 95 | ||
| 95 | if ((b=BIO_new(BIO_s_file_internal())) == NULL) | 96 | if ((b = BIO_new(BIO_s_file_internal())) == NULL) { |
| 96 | { | 97 | SSLerr(SSL_F_SSL_SESSION_PRINT_FP, ERR_R_BUF_LIB); |
| 97 | SSLerr(SSL_F_SSL_SESSION_PRINT_FP,ERR_R_BUF_LIB); | 98 | return (0); |
| 98 | return(0); | ||
| 99 | } | ||
| 100 | BIO_set_fp(b,fp,BIO_NOCLOSE); | ||
| 101 | ret=SSL_SESSION_print(b,x); | ||
| 102 | BIO_free(b); | ||
| 103 | return(ret); | ||
| 104 | } | 99 | } |
| 100 | BIO_set_fp(b, fp, BIO_NOCLOSE); | ||
| 101 | ret = SSL_SESSION_print(b, x); | ||
| 102 | BIO_free(b); | ||
| 103 | return (ret); | ||
| 104 | } | ||
| 105 | #endif | 105 | #endif |
| 106 | 106 | ||
| 107 | int SSL_SESSION_print(BIO *bp, const SSL_SESSION *x) | 107 | int |
| 108 | { | 108 | SSL_SESSION_print(BIO *bp, const SSL_SESSION *x) |
| 109 | { | ||
| 109 | unsigned int i; | 110 | unsigned int i; |
| 110 | const char *s; | 111 | const char *s; |
| 111 | 112 | ||
| 112 | if (x == NULL) goto err; | 113 | if (x == NULL) |
| 113 | if (BIO_puts(bp,"SSL-Session:\n") <= 0) goto err; | 114 | goto err; |
| 115 | if (BIO_puts(bp, "SSL-Session:\n") | ||
| 116 | <= 0) goto err; | ||
| 114 | if (x->ssl_version == SSL2_VERSION) | 117 | if (x->ssl_version == SSL2_VERSION) |
| 115 | s="SSLv2"; | 118 | s="SSLv2"; |
| 116 | else if (x->ssl_version == SSL3_VERSION) | 119 | else if (x->ssl_version == SSL3_VERSION) |
| @@ -127,122 +130,122 @@ int SSL_SESSION_print(BIO *bp, const SSL_SESSION *x) | |||
| 127 | s="DTLSv1-bad"; | 130 | s="DTLSv1-bad"; |
| 128 | else | 131 | else |
| 129 | s="unknown"; | 132 | s="unknown"; |
| 130 | if (BIO_printf(bp," Protocol : %s\n",s) <= 0) goto err; | 133 | if (BIO_printf(bp, " Protocol : %s\n", s) |
| 134 | <= 0) goto err; | ||
| 131 | 135 | ||
| 132 | if (x->cipher == NULL) | 136 | if (x->cipher == NULL) { |
| 133 | { | 137 | if (((x->cipher_id) & 0xff000000) == 0x02000000) { |
| 134 | if (((x->cipher_id) & 0xff000000) == 0x02000000) | 138 | if (BIO_printf(bp, " Cipher : %06lX\n", x->cipher_id&0xffffff) <= 0) |
| 135 | { | ||
| 136 | if (BIO_printf(bp," Cipher : %06lX\n",x->cipher_id&0xffffff) <= 0) | ||
| 137 | goto err; | 139 | goto err; |
| 138 | } | 140 | } else { |
| 139 | else | 141 | if (BIO_printf(bp, " Cipher : %04lX\n", x->cipher_id&0xffff) <= 0) |
| 140 | { | ||
| 141 | if (BIO_printf(bp," Cipher : %04lX\n",x->cipher_id&0xffff) <= 0) | ||
| 142 | goto err; | 142 | goto err; |
| 143 | } | ||
| 144 | } | 143 | } |
| 145 | else | 144 | } else { |
| 146 | { | 145 | if (BIO_printf(bp, " Cipher : %s\n",((x->cipher == NULL)?"unknown":x->cipher->name)) <= 0) |
| 147 | if (BIO_printf(bp," Cipher : %s\n",((x->cipher == NULL)?"unknown":x->cipher->name)) <= 0) | ||
| 148 | goto err; | 146 | goto err; |
| 149 | } | 147 | } |
| 150 | if (BIO_puts(bp," Session-ID: ") <= 0) goto err; | 148 | if (BIO_puts(bp, " Session-ID: ") |
| 151 | for (i=0; i<x->session_id_length; i++) | 149 | <= 0) goto err; |
| 152 | { | 150 | for (i = 0; i < x->session_id_length; i++) { |
| 153 | if (BIO_printf(bp,"%02X",x->session_id[i]) <= 0) goto err; | 151 | if (BIO_printf(bp, "%02X", x->session_id[i]) |
| 154 | } | 152 | <= 0) goto err; |
| 155 | if (BIO_puts(bp,"\n Session-ID-ctx: ") <= 0) goto err; | 153 | } |
| 156 | for (i=0; i<x->sid_ctx_length; i++) | 154 | if (BIO_puts(bp, "\n Session-ID-ctx: ") |
| 157 | { | 155 | <= 0) goto err; |
| 158 | if (BIO_printf(bp,"%02X",x->sid_ctx[i]) <= 0) | 156 | for (i = 0; i < x->sid_ctx_length; i++) { |
| 157 | if (BIO_printf(bp, "%02X", x->sid_ctx[i]) <= 0) | ||
| 159 | goto err; | 158 | goto err; |
| 160 | } | 159 | } |
| 161 | if (BIO_puts(bp,"\n Master-Key: ") <= 0) goto err; | 160 | if (BIO_puts(bp, "\n Master-Key: ") |
| 162 | for (i=0; i<(unsigned int)x->master_key_length; i++) | 161 | <= 0) goto err; |
| 163 | { | 162 | for (i = 0; i < (unsigned int)x->master_key_length; i++) { |
| 164 | if (BIO_printf(bp,"%02X",x->master_key[i]) <= 0) goto err; | 163 | if (BIO_printf(bp, "%02X", x->master_key[i]) |
| 165 | } | 164 | <= 0) goto err; |
| 166 | if (BIO_puts(bp,"\n Key-Arg : ") <= 0) goto err; | 165 | } |
| 167 | if (x->key_arg_length == 0) | 166 | if (BIO_puts(bp, "\n Key-Arg : ") |
| 168 | { | 167 | <= 0) goto err; |
| 169 | if (BIO_puts(bp,"None") <= 0) goto err; | 168 | if (x->key_arg_length == 0) { |
| 170 | } | 169 | if (BIO_puts(bp, "None") |
| 171 | else | 170 | <= 0) goto err; |
| 172 | for (i=0; i<x->key_arg_length; i++) | 171 | } else |
| 173 | { | 172 | for (i = 0; i < x->key_arg_length; i++) { |
| 174 | if (BIO_printf(bp,"%02X",x->key_arg[i]) <= 0) goto err; | 173 | if (BIO_printf(bp, "%02X", x->key_arg[i]) |
| 175 | } | 174 | <= 0) goto err; |
| 175 | } | ||
| 176 | #ifndef OPENSSL_NO_KRB5 | 176 | #ifndef OPENSSL_NO_KRB5 |
| 177 | if (BIO_puts(bp,"\n Krb5 Principal: ") <= 0) goto err; | 177 | if (BIO_puts(bp, "\n Krb5 Principal: ") |
| 178 | if (x->krb5_client_princ_len == 0) | 178 | <= 0) goto err; |
| 179 | { | 179 | if (x->krb5_client_princ_len == 0) { |
| 180 | if (BIO_puts(bp,"None") <= 0) goto err; | 180 | if (BIO_puts(bp, "None") |
| 181 | } | 181 | <= 0) goto err; |
| 182 | else | 182 | } else |
| 183 | for (i=0; i<x->krb5_client_princ_len; i++) | 183 | for (i = 0; i < x->krb5_client_princ_len; i++) { |
| 184 | { | 184 | if (BIO_printf(bp, "%02X", x->krb5_client_princ[i]) |
| 185 | if (BIO_printf(bp,"%02X",x->krb5_client_princ[i]) <= 0) goto err; | 185 | <= 0) goto err; |
| 186 | } | 186 | } |
| 187 | #endif /* OPENSSL_NO_KRB5 */ | 187 | #endif /* OPENSSL_NO_KRB5 */ |
| 188 | #ifndef OPENSSL_NO_PSK | 188 | #ifndef OPENSSL_NO_PSK |
| 189 | if (BIO_puts(bp,"\n PSK identity: ") <= 0) goto err; | 189 | if (BIO_puts(bp, "\n PSK identity: ") |
| 190 | if (BIO_printf(bp, "%s", x->psk_identity ? x->psk_identity : "None") <= 0) goto err; | 190 | <= 0) goto err; |
| 191 | if (BIO_puts(bp,"\n PSK identity hint: ") <= 0) goto err; | 191 | if (BIO_printf(bp, "%s", x->psk_identity ? x->psk_identity : "None") |
| 192 | if (BIO_printf(bp, "%s", x->psk_identity_hint ? x->psk_identity_hint : "None") <= 0) goto err; | 192 | <= 0) goto err; |
| 193 | if (BIO_puts(bp, "\n PSK identity hint: ") | ||
| 194 | <= 0) goto err; | ||
| 195 | if (BIO_printf(bp, "%s", x->psk_identity_hint ? x->psk_identity_hint : "None") | ||
| 196 | <= 0) goto err; | ||
| 193 | #endif | 197 | #endif |
| 194 | #ifndef OPENSSL_NO_SRP | 198 | #ifndef OPENSSL_NO_SRP |
| 195 | if (BIO_puts(bp,"\n SRP username: ") <= 0) goto err; | 199 | if (BIO_puts(bp, "\n SRP username: ") |
| 196 | if (BIO_printf(bp, "%s", x->srp_username ? x->srp_username : "None") <= 0) goto err; | 200 | <= 0) goto err; |
| 201 | if (BIO_printf(bp, "%s", x->srp_username ? x->srp_username : "None") | ||
| 202 | <= 0) goto err; | ||
| 197 | #endif | 203 | #endif |
| 198 | #ifndef OPENSSL_NO_TLSEXT | 204 | #ifndef OPENSSL_NO_TLSEXT |
| 199 | if (x->tlsext_tick_lifetime_hint) | 205 | if (x->tlsext_tick_lifetime_hint) { |
| 200 | { | ||
| 201 | if (BIO_printf(bp, | 206 | if (BIO_printf(bp, |
| 202 | "\n TLS session ticket lifetime hint: %ld (seconds)", | 207 | "\n TLS session ticket lifetime hint: %ld (seconds)", |
| 203 | x->tlsext_tick_lifetime_hint) <=0) | 208 | x->tlsext_tick_lifetime_hint) <=0) |
| 204 | goto err; | 209 | goto err; |
| 205 | } | 210 | } |
| 206 | if (x->tlsext_tick) | 211 | if (x->tlsext_tick) { |
| 207 | { | 212 | if (BIO_puts(bp, "\n TLS session ticket:\n") |
| 208 | if (BIO_puts(bp, "\n TLS session ticket:\n") <= 0) goto err; | 213 | <= 0) goto err; |
| 209 | if (BIO_dump_indent(bp, (char *)x->tlsext_tick, x->tlsext_ticklen, 4) <= 0) | 214 | if (BIO_dump_indent(bp, (char *)x->tlsext_tick, x->tlsext_ticklen, 4) <= 0) |
| 210 | goto err; | 215 | goto err; |
| 211 | } | 216 | } |
| 212 | #endif | 217 | #endif |
| 213 | 218 | ||
| 214 | #ifndef OPENSSL_NO_COMP | 219 | #ifndef OPENSSL_NO_COMP |
| 215 | if (x->compress_meth != 0) | 220 | if (x->compress_meth != 0) { |
| 216 | { | ||
| 217 | SSL_COMP *comp = NULL; | 221 | SSL_COMP *comp = NULL; |
| 218 | 222 | ||
| 219 | ssl_cipher_get_evp(x,NULL,NULL,NULL,NULL,&comp); | 223 | ssl_cipher_get_evp(x, NULL, NULL, NULL, NULL, &comp); |
| 220 | if (comp == NULL) | 224 | if (comp == NULL) { |
| 221 | { | 225 | if (BIO_printf(bp, "\n Compression: %d", x->compress_meth) |
| 222 | if (BIO_printf(bp,"\n Compression: %d",x->compress_meth) <= 0) goto err; | 226 | <= 0) goto err; |
| 227 | } else { | ||
| 228 | if (BIO_printf(bp, "\n Compression: %d (%s)", comp->id, comp->method->name) <= 0) goto err; | ||
| 223 | } | 229 | } |
| 224 | else | 230 | } |
| 225 | { | ||
| 226 | if (BIO_printf(bp,"\n Compression: %d (%s)", comp->id,comp->method->name) <= 0) goto err; | ||
| 227 | } | ||
| 228 | } | ||
| 229 | #endif | 231 | #endif |
| 230 | if (x->time != 0L) | 232 | if (x->time != 0L) { |
| 231 | { | 233 | if (BIO_printf(bp, "\n Start Time: %ld", x->time) |
| 232 | if (BIO_printf(bp, "\n Start Time: %ld",x->time) <= 0) goto err; | 234 | <= 0) goto err; |
| 233 | } | 235 | } |
| 234 | if (x->timeout != 0L) | 236 | if (x->timeout != 0L) { |
| 235 | { | 237 | if (BIO_printf(bp, "\n Timeout : %ld (sec)", x->timeout) <= 0) goto err; |
| 236 | if (BIO_printf(bp, "\n Timeout : %ld (sec)",x->timeout) <= 0) goto err; | ||
| 237 | } | 238 | } |
| 238 | if (BIO_puts(bp,"\n") <= 0) goto err; | 239 | if (BIO_puts(bp, "\n") |
| 240 | <= 0) goto err; | ||
| 239 | 241 | ||
| 240 | if (BIO_puts(bp, " Verify return code: ") <= 0) goto err; | 242 | if (BIO_puts(bp, " Verify return code: ") |
| 243 | <= 0) goto err; | ||
| 241 | if (BIO_printf(bp, "%ld (%s)\n", x->verify_result, | 244 | if (BIO_printf(bp, "%ld (%s)\n", x->verify_result, |
| 242 | X509_verify_cert_error_string(x->verify_result)) <= 0) goto err; | 245 | X509_verify_cert_error_string(x->verify_result)) <= 0) goto err; |
| 243 | 246 | ||
| 244 | return(1); | 247 | return (1); |
| 245 | err: | 248 | err: |
| 246 | return(0); | 249 | return (0); |
| 247 | } | 250 | } |
| 248 | 251 | ||
