1e1051a39Sopenharmony_ci/*
2e1051a39Sopenharmony_ci * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
3e1051a39Sopenharmony_ci *
4e1051a39Sopenharmony_ci * Licensed under the Apache License 2.0 (the "License").  You may not use
5e1051a39Sopenharmony_ci * this file except in compliance with the License.  You can obtain a copy
6e1051a39Sopenharmony_ci * in the file LICENSE in the source distribution or at
7e1051a39Sopenharmony_ci * https://www.openssl.org/source/license.html
8e1051a39Sopenharmony_ci */
9e1051a39Sopenharmony_ci
10e1051a39Sopenharmony_ci#include <openssl/opensslconf.h>
11e1051a39Sopenharmony_ci
12e1051a39Sopenharmony_ci#include <openssl/ssl.h>
13e1051a39Sopenharmony_ci#include <openssl/srp.h>
14e1051a39Sopenharmony_ci
15e1051a39Sopenharmony_ci#define PORT            "4433"
16e1051a39Sopenharmony_ci#define PROTOCOL        "tcp"
17e1051a39Sopenharmony_ci
18e1051a39Sopenharmony_citypedef int (*do_server_cb)(int s, int stype, int prot, unsigned char *context);
19e1051a39Sopenharmony_ciint report_server_accept(BIO *out, int asock, int with_address, int with_pid);
20e1051a39Sopenharmony_ciint do_server(int *accept_sock, const char *host, const char *port,
21e1051a39Sopenharmony_ci              int family, int type, int protocol, do_server_cb cb,
22e1051a39Sopenharmony_ci              unsigned char *context, int naccept, BIO *bio_s_out);
23e1051a39Sopenharmony_ci
24e1051a39Sopenharmony_ciint verify_callback(int ok, X509_STORE_CTX *ctx);
25e1051a39Sopenharmony_ci
26e1051a39Sopenharmony_ciint set_cert_stuff(SSL_CTX *ctx, char *cert_file, char *key_file);
27e1051a39Sopenharmony_ciint set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key,
28e1051a39Sopenharmony_ci                       STACK_OF(X509) *chain, int build_chain);
29e1051a39Sopenharmony_ciint ssl_print_sigalgs(BIO *out, SSL *s);
30e1051a39Sopenharmony_ciint ssl_print_point_formats(BIO *out, SSL *s);
31e1051a39Sopenharmony_ciint ssl_print_groups(BIO *out, SSL *s, int noshared);
32e1051a39Sopenharmony_ciint ssl_print_tmp_key(BIO *out, SSL *s);
33e1051a39Sopenharmony_ciint init_client(int *sock, const char *host, const char *port,
34e1051a39Sopenharmony_ci                const char *bindhost, const char *bindport,
35e1051a39Sopenharmony_ci                int family, int type, int protocol);
36e1051a39Sopenharmony_ciint should_retry(int i);
37e1051a39Sopenharmony_civoid do_ssl_shutdown(SSL *ssl);
38e1051a39Sopenharmony_ci
39e1051a39Sopenharmony_cilong bio_dump_callback(BIO *bio, int cmd, const char *argp, size_t len,
40e1051a39Sopenharmony_ci                       int argi, long argl, int ret, size_t *processed);
41e1051a39Sopenharmony_ci
42e1051a39Sopenharmony_civoid apps_ssl_info_callback(const SSL *s, int where, int ret);
43e1051a39Sopenharmony_civoid msg_cb(int write_p, int version, int content_type, const void *buf,
44e1051a39Sopenharmony_ci            size_t len, SSL *ssl, void *arg);
45e1051a39Sopenharmony_civoid tlsext_cb(SSL *s, int client_server, int type, const unsigned char *data,
46e1051a39Sopenharmony_ci               int len, void *arg);
47e1051a39Sopenharmony_ci
48e1051a39Sopenharmony_ciint generate_cookie_callback(SSL *ssl, unsigned char *cookie,
49e1051a39Sopenharmony_ci                             unsigned int *cookie_len);
50e1051a39Sopenharmony_ciint verify_cookie_callback(SSL *ssl, const unsigned char *cookie,
51e1051a39Sopenharmony_ci                           unsigned int cookie_len);
52e1051a39Sopenharmony_ci
53e1051a39Sopenharmony_ci#ifdef __VMS                     /* 31 char symbol name limit */
54e1051a39Sopenharmony_ci# define generate_stateless_cookie_callback      generate_stateless_cookie_cb
55e1051a39Sopenharmony_ci# define verify_stateless_cookie_callback        verify_stateless_cookie_cb
56e1051a39Sopenharmony_ci#endif
57e1051a39Sopenharmony_ci
58e1051a39Sopenharmony_ciint generate_stateless_cookie_callback(SSL *ssl, unsigned char *cookie,
59e1051a39Sopenharmony_ci                                       size_t *cookie_len);
60e1051a39Sopenharmony_ciint verify_stateless_cookie_callback(SSL *ssl, const unsigned char *cookie,
61e1051a39Sopenharmony_ci                                     size_t cookie_len);
62e1051a39Sopenharmony_ci
63e1051a39Sopenharmony_citypedef struct ssl_excert_st SSL_EXCERT;
64e1051a39Sopenharmony_ci
65e1051a39Sopenharmony_civoid ssl_ctx_set_excert(SSL_CTX *ctx, SSL_EXCERT *exc);
66e1051a39Sopenharmony_civoid ssl_excert_free(SSL_EXCERT *exc);
67e1051a39Sopenharmony_ciint args_excert(int option, SSL_EXCERT **pexc);
68e1051a39Sopenharmony_ciint load_excert(SSL_EXCERT **pexc);
69e1051a39Sopenharmony_civoid print_verify_detail(SSL *s, BIO *bio);
70e1051a39Sopenharmony_civoid print_ssl_summary(SSL *s);
71e1051a39Sopenharmony_ciint config_ctx(SSL_CONF_CTX *cctx, STACK_OF(OPENSSL_STRING) *str, SSL_CTX *ctx);
72e1051a39Sopenharmony_ciint ssl_ctx_add_crls(SSL_CTX *ctx, STACK_OF(X509_CRL) *crls,
73e1051a39Sopenharmony_ci                     int crl_download);
74e1051a39Sopenharmony_ciint ssl_load_stores(SSL_CTX *ctx, const char *vfyCApath,
75e1051a39Sopenharmony_ci                    const char *vfyCAfile, const char *vfyCAstore,
76e1051a39Sopenharmony_ci                    const char *chCApath, const char *chCAfile,
77e1051a39Sopenharmony_ci                    const char *chCAstore, STACK_OF(X509_CRL) *crls,
78e1051a39Sopenharmony_ci                    int crl_download);
79e1051a39Sopenharmony_civoid ssl_ctx_security_debug(SSL_CTX *ctx, int verbose);
80e1051a39Sopenharmony_ciint set_keylog_file(SSL_CTX *ctx, const char *keylog_file);
81e1051a39Sopenharmony_civoid print_ca_names(BIO *bio, SSL *s);
82e1051a39Sopenharmony_ci
83e1051a39Sopenharmony_ci#ifndef OPENSSL_NO_SRP
84e1051a39Sopenharmony_ci/* The client side SRP context that we pass to all SRP related callbacks */
85e1051a39Sopenharmony_citypedef struct srp_arg_st {
86e1051a39Sopenharmony_ci    char *srppassin;
87e1051a39Sopenharmony_ci    char *srplogin;
88e1051a39Sopenharmony_ci    int msg;                    /* copy from c_msg */
89e1051a39Sopenharmony_ci    int debug;                  /* copy from c_debug */
90e1051a39Sopenharmony_ci    int amp;                    /* allow more groups */
91e1051a39Sopenharmony_ci    int strength;               /* minimal size for N */
92e1051a39Sopenharmony_ci} SRP_ARG;
93e1051a39Sopenharmony_ci
94e1051a39Sopenharmony_ciint set_up_srp_arg(SSL_CTX *ctx, SRP_ARG *srp_arg, int srp_lateuser, int c_msg,
95e1051a39Sopenharmony_ci                   int c_debug);
96e1051a39Sopenharmony_civoid set_up_dummy_srp(SSL_CTX *ctx);
97e1051a39Sopenharmony_ci
98e1051a39Sopenharmony_ci/* The server side SRP context that we pass to all SRP related callbacks */
99e1051a39Sopenharmony_citypedef struct srpsrvparm_st {
100e1051a39Sopenharmony_ci    char *login;
101e1051a39Sopenharmony_ci    SRP_VBASE *vb;
102e1051a39Sopenharmony_ci    SRP_user_pwd *user;
103e1051a39Sopenharmony_ci} srpsrvparm;
104e1051a39Sopenharmony_ci
105e1051a39Sopenharmony_ciint set_up_srp_verifier_file(SSL_CTX *ctx, srpsrvparm *srp_callback_parm,
106e1051a39Sopenharmony_ci                             char *srpuserseed, char *srp_verifier_file);
107e1051a39Sopenharmony_civoid lookup_srp_user(srpsrvparm *srp_callback_parm, BIO *bio_s_out);
108e1051a39Sopenharmony_ci#endif /* OPENSSL_NO_SRP */
109