diff options
| author | inoguchi <> | 2020-07-10 12:25:57 +0000 |
|---|---|---|
| committer | inoguchi <> | 2020-07-10 12:25:57 +0000 |
| commit | d504e61a409f63f8ce6c117fe828cd0babb37589 (patch) | |
| tree | e0cf5bf38e98e3c1e2ccc8556afb1ae0d6c37b55 /src | |
| parent | 17bb315b266a4191e12fb8abc998315718b262d9 (diff) | |
| download | openbsd-d504e61a409f63f8ce6c117fe828cd0babb37589.tar.gz openbsd-d504e61a409f63f8ce6c117fe828cd0babb37589.tar.bz2 openbsd-d504e61a409f63f8ce6c117fe828cd0babb37589.zip | |
Clean up s_client.c
- Remove space between '*' and pointer variable.
- Add function prototype.
- Move callback function to bottom.
- Move typedef struct to up.
Diffstat (limited to 'src')
| -rw-r--r-- | src/usr.bin/openssl/s_client.c | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/src/usr.bin/openssl/s_client.c b/src/usr.bin/openssl/s_client.c index 54fcc75bb4..614effe960 100644 --- a/src/usr.bin/openssl/s_client.c +++ b/src/usr.bin/openssl/s_client.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: s_client.c,v 1.50 2020/07/10 12:05:52 inoguchi Exp $ */ | 1 | /* $OpenBSD: s_client.c,v 1.51 2020/07/10 12:25:57 inoguchi Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -171,8 +171,9 @@ | |||
| 171 | #define BUFSIZZ 1024*8 | 171 | #define BUFSIZZ 1024*8 |
| 172 | 172 | ||
| 173 | static void sc_usage(void); | 173 | static void sc_usage(void); |
| 174 | static void print_stuff(BIO * berr, SSL * con, int full); | 174 | static void print_stuff(BIO *berr, SSL *con, int full); |
| 175 | static int ocsp_resp_cb(SSL * s, void *arg); | 175 | static int ocsp_resp_cb(SSL *s, void *arg); |
| 176 | static int ssl_servername_cb(SSL *s, int *ad, void *arg); | ||
| 176 | 177 | ||
| 177 | enum { | 178 | enum { |
| 178 | PROTO_OFF = 0, | 179 | PROTO_OFF = 0, |
| @@ -184,6 +185,12 @@ enum { | |||
| 184 | PROTO_XMPP, | 185 | PROTO_XMPP, |
| 185 | }; | 186 | }; |
| 186 | 187 | ||
| 188 | /* This is a context that we pass to callbacks */ | ||
| 189 | typedef struct tlsextctx_st { | ||
| 190 | BIO *biodebug; | ||
| 191 | int ack; | ||
| 192 | } tlsextctx; | ||
| 193 | |||
| 187 | static struct { | 194 | static struct { |
| 188 | int af; | 195 | int af; |
| 189 | char *alpn_in; | 196 | char *alpn_in; |
| @@ -839,25 +846,6 @@ sc_usage(void) | |||
| 839 | fprintf(stderr, "\n"); | 846 | fprintf(stderr, "\n"); |
| 840 | } | 847 | } |
| 841 | 848 | ||
| 842 | /* This is a context that we pass to callbacks */ | ||
| 843 | typedef struct tlsextctx_st { | ||
| 844 | BIO *biodebug; | ||
| 845 | int ack; | ||
| 846 | } tlsextctx; | ||
| 847 | |||
| 848 | static int | ||
| 849 | ssl_servername_cb(SSL * s, int *ad, void *arg) | ||
| 850 | { | ||
| 851 | tlsextctx *p = (tlsextctx *) arg; | ||
| 852 | const char *hn = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name); | ||
| 853 | if (SSL_get_servername_type(s) != -1) | ||
| 854 | p->ack = !SSL_session_reused(s) && hn != NULL; | ||
| 855 | else | ||
| 856 | BIO_printf(bio_err, "Can't use SSL_get_servername\n"); | ||
| 857 | |||
| 858 | return SSL_TLSEXT_ERR_OK; | ||
| 859 | } | ||
| 860 | |||
| 861 | int | 849 | int |
| 862 | s_client_main(int argc, char **argv) | 850 | s_client_main(int argc, char **argv) |
| 863 | { | 851 | { |
| @@ -1626,14 +1614,14 @@ s_client_main(int argc, char **argv) | |||
| 1626 | } | 1614 | } |
| 1627 | 1615 | ||
| 1628 | static void | 1616 | static void |
| 1629 | print_stuff(BIO * bio, SSL * s, int full) | 1617 | print_stuff(BIO *bio, SSL *s, int full) |
| 1630 | { | 1618 | { |
| 1631 | X509 *peer = NULL; | 1619 | X509 *peer = NULL; |
| 1632 | char *p; | 1620 | char *p; |
| 1633 | static const char *space = " "; | 1621 | static const char *space = " "; |
| 1634 | char buf[BUFSIZ]; | 1622 | char buf[BUFSIZ]; |
| 1635 | STACK_OF(X509) * sk; | 1623 | STACK_OF(X509) *sk; |
| 1636 | STACK_OF(X509_NAME) * sk2; | 1624 | STACK_OF(X509_NAME) *sk2; |
| 1637 | const SSL_CIPHER *c; | 1625 | const SSL_CIPHER *c; |
| 1638 | X509_NAME *xn; | 1626 | X509_NAME *xn; |
| 1639 | int j, i; | 1627 | int j, i; |
| @@ -1814,7 +1802,7 @@ print_stuff(BIO * bio, SSL * s, int full) | |||
| 1814 | } | 1802 | } |
| 1815 | 1803 | ||
| 1816 | static int | 1804 | static int |
| 1817 | ocsp_resp_cb(SSL * s, void *arg) | 1805 | ocsp_resp_cb(SSL *s, void *arg) |
| 1818 | { | 1806 | { |
| 1819 | const unsigned char *p; | 1807 | const unsigned char *p; |
| 1820 | int len; | 1808 | int len; |
| @@ -1838,3 +1826,16 @@ ocsp_resp_cb(SSL * s, void *arg) | |||
| 1838 | return 1; | 1826 | return 1; |
| 1839 | } | 1827 | } |
| 1840 | 1828 | ||
| 1829 | static int | ||
| 1830 | ssl_servername_cb(SSL *s, int *ad, void *arg) | ||
| 1831 | { | ||
| 1832 | tlsextctx *p = (tlsextctx *) arg; | ||
| 1833 | const char *hn = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name); | ||
| 1834 | if (SSL_get_servername_type(s) != -1) | ||
| 1835 | p->ack = !SSL_session_reused(s) && hn != NULL; | ||
| 1836 | else | ||
| 1837 | BIO_printf(bio_err, "Can't use SSL_get_servername\n"); | ||
| 1838 | |||
| 1839 | return SSL_TLSEXT_ERR_OK; | ||
| 1840 | } | ||
| 1841 | |||
