From 31683601b72b2a5980f5f5d968711f4a1fba7a52 Mon Sep 17 00:00:00 2001 From: tb <> Date: Thu, 2 Jan 2025 13:10:03 +0000 Subject: Merge s_apps.h into apps.h discussed with jsing --- src/usr.bin/openssl/apps.h | 42 +++++++++++- src/usr.bin/openssl/openssl.c | 4 +- src/usr.bin/openssl/s_apps.h | 150 ----------------------------------------- src/usr.bin/openssl/s_cb.c | 4 +- src/usr.bin/openssl/s_client.c | 4 +- src/usr.bin/openssl/s_server.c | 4 +- src/usr.bin/openssl/s_socket.c | 4 +- src/usr.bin/openssl/s_time.c | 4 +- 8 files changed, 47 insertions(+), 169 deletions(-) delete mode 100644 src/usr.bin/openssl/s_apps.h diff --git a/src/usr.bin/openssl/apps.h b/src/usr.bin/openssl/apps.h index f8d67ccacd..c8d6154b9f 100644 --- a/src/usr.bin/openssl/apps.h +++ b/src/usr.bin/openssl/apps.h @@ -1,4 +1,4 @@ -/* $OpenBSD: apps.h,v 1.40 2025/01/02 12:36:21 tb Exp $ */ +/* $OpenBSD: apps.h,v 1.41 2025/01/02 13:10:03 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -126,6 +126,8 @@ #include #endif +#include + #include /* numbers in us */ @@ -364,4 +366,42 @@ int verify_main(int argc, char **argv); int version_main(int argc, char **argv); int x509_main(int argc, char **argv); +#define PORT 4433 +#define PORT_STR "4433" +#define PROTOCOL "tcp" + +extern int verify_depth; +extern int verify_return_error; + +int do_server(int port, int type, int *ret, + int (*cb)(int s, unsigned char *context), + unsigned char *context, int naccept); +#ifdef HEADER_X509_H +int verify_callback(int ok, X509_STORE_CTX *ctx); +#endif +#ifdef HEADER_SSL_H +int set_cert_stuff(SSL_CTX *ctx, char *cert_file, char *key_file); +int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key); +#endif +int ssl_print_tmp_key(BIO *out, SSL *s); +int init_client(int *sock, char *server, char *port, int type, int af); +int extract_port(char *str, short *port_ptr); +int extract_host_port(char *str, char **host_ptr, unsigned char *ip, char **p); + +long bio_dump_callback(BIO *bio, int cmd, const char *argp, int argi, + long argl, long ret); + +#ifdef HEADER_SSL_H +void apps_ssl_info_callback(const SSL *s, int where, int ret); +void msg_cb(int write_p, int version, int content_type, const void *buf, + size_t len, SSL *ssl, void *arg); +void tlsext_cb(SSL *s, int client_server, int type, unsigned char *data, + int len, void *arg); +#endif + +int generate_cookie_callback(SSL *ssl, unsigned char *cookie, + unsigned int *cookie_len); +int verify_cookie_callback(SSL *ssl, const unsigned char *cookie, + unsigned int cookie_len); + #endif diff --git a/src/usr.bin/openssl/openssl.c b/src/usr.bin/openssl/openssl.c index eaa5401ece..75a0e4d266 100644 --- a/src/usr.bin/openssl/openssl.c +++ b/src/usr.bin/openssl/openssl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: openssl.c,v 1.38 2025/01/02 12:31:44 tb Exp $ */ +/* $OpenBSD: openssl.c,v 1.39 2025/01/02 13:10:03 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -127,8 +127,6 @@ #include #include -#include "s_apps.h" - #define FUNC_TYPE_GENERAL 1 #define FUNC_TYPE_MD 2 #define FUNC_TYPE_CIPHER 3 diff --git a/src/usr.bin/openssl/s_apps.h b/src/usr.bin/openssl/s_apps.h deleted file mode 100644 index d8217d9eee..0000000000 --- a/src/usr.bin/openssl/s_apps.h +++ /dev/null @@ -1,150 +0,0 @@ -/* $OpenBSD: s_apps.h,v 1.8 2024/05/18 08:47:13 jsg Exp $ */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ -/* ==================================================================== - * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ -#include -#include - -#define PORT 4433 -#define PORT_STR "4433" -#define PROTOCOL "tcp" - -extern int verify_depth; -extern int verify_return_error; - -int do_server(int port, int type, int *ret, - int (*cb)(int s, unsigned char *context), - unsigned char *context, int naccept); -#ifdef HEADER_X509_H -int verify_callback(int ok, X509_STORE_CTX *ctx); -#endif -#ifdef HEADER_SSL_H -int set_cert_stuff(SSL_CTX *ctx, char *cert_file, char *key_file); -int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key); -#endif -int ssl_print_tmp_key(BIO *out, SSL *s); -int init_client(int *sock, char *server, char *port, int type, int af); -int extract_port(char *str, short *port_ptr); -int extract_host_port(char *str, char **host_ptr, unsigned char *ip, char **p); - -long bio_dump_callback(BIO *bio, int cmd, const char *argp, int argi, - long argl, long ret); - -#ifdef HEADER_SSL_H -void apps_ssl_info_callback(const SSL *s, int where, int ret); -void msg_cb(int write_p, int version, int content_type, const void *buf, - size_t len, SSL *ssl, void *arg); -void tlsext_cb(SSL *s, int client_server, int type, unsigned char *data, - int len, void *arg); -#endif - -int generate_cookie_callback(SSL *ssl, unsigned char *cookie, - unsigned int *cookie_len); -int verify_cookie_callback(SSL *ssl, const unsigned char *cookie, - unsigned int cookie_len); diff --git a/src/usr.bin/openssl/s_cb.c b/src/usr.bin/openssl/s_cb.c index d503b8cf27..fcb2cd3076 100644 --- a/src/usr.bin/openssl/s_cb.c +++ b/src/usr.bin/openssl/s_cb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_cb.c,v 1.21 2023/04/14 15:27:13 tb Exp $ */ +/* $OpenBSD: s_cb.c,v 1.22 2025/01/02 13:10:03 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -124,8 +124,6 @@ #include #include -#include "s_apps.h" - #define COOKIE_SECRET_LENGTH 16 int verify_depth = 0; diff --git a/src/usr.bin/openssl/s_client.c b/src/usr.bin/openssl/s_client.c index 45260ac875..96cf92d4f2 100644 --- a/src/usr.bin/openssl/s_client.c +++ b/src/usr.bin/openssl/s_client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_client.c,v 1.65 2025/01/02 12:36:21 tb Exp $ */ +/* $OpenBSD: s_client.c,v 1.66 2025/01/02 13:10:03 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -159,8 +159,6 @@ #include #include -#include "s_apps.h" - /*#define SSL_HOST_NAME "www.netscape.com" */ /*#define SSL_HOST_NAME "193.118.187.102" */ #define SSL_HOST_NAME "localhost" diff --git a/src/usr.bin/openssl/s_server.c b/src/usr.bin/openssl/s_server.c index 8984586ab5..f56042a4b4 100644 --- a/src/usr.bin/openssl/s_server.c +++ b/src/usr.bin/openssl/s_server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_server.c,v 1.60 2025/01/02 12:36:21 tb Exp $ */ +/* $OpenBSD: s_server.c,v 1.61 2025/01/02 13:10:03 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -174,8 +174,6 @@ #include -#include "s_apps.h" - static void s_server_init(void); static void sv_usage(void); static void print_stats(BIO *bp, SSL_CTX *ctx); diff --git a/src/usr.bin/openssl/s_socket.c b/src/usr.bin/openssl/s_socket.c index db125c1ed3..86a23c56d1 100644 --- a/src/usr.bin/openssl/s_socket.c +++ b/src/usr.bin/openssl/s_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_socket.c,v 1.13 2021/12/06 11:06:58 tb Exp $ */ +/* $OpenBSD: s_socket.c,v 1.14 2025/01/02 13:10:03 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -71,8 +71,6 @@ #include -#include "s_apps.h" - static int init_server(int *sock, int port, int type); static int init_server_long(int *sock, int port, char *ip, int type); static int do_accept(int acc_sock, int *sock); diff --git a/src/usr.bin/openssl/s_time.c b/src/usr.bin/openssl/s_time.c index 7eed6d486e..c90be33f28 100644 --- a/src/usr.bin/openssl/s_time.c +++ b/src/usr.bin/openssl/s_time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_time.c,v 1.38 2023/03/06 14:32:06 tb Exp $ */ +/* $OpenBSD: s_time.c,v 1.39 2025/01/02 13:10:03 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -78,8 +78,6 @@ #include #include -#include "s_apps.h" - #define SSL_CONNECT_NAME "localhost:4433" #define BUFSIZZ 1024*10 -- cgit v1.2.3-55-g6feb