1 /* 2 * ngtcp2 3 * 4 * Copyright (c) 2022 ngtcp2 contributors 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining 7 * a copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including 9 * without limitation the rights to use, copy, modify, merge, publish, 10 * distribute, sublicense, and/or sell copies of the Software, and to 11 * permit persons to whom the Software is furnished to do so, subject to 12 * the following conditions: 13 * 14 * The above copyright notice and this permission notice shall be 15 * included in all copies or substantial portions of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 */ 25 #ifndef NGTCP2_CRYPTO_WOLFSSL_H 26 #define NGTCP2_CRYPTO_WOLFSSL_H 27 28 #include <ngtcp2/ngtcp2.h> 29 30 #include <wolfssl/options.h> 31 #include <wolfssl/ssl.h> 32 #include <wolfssl/quic.h> 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 /** 39 * @function 40 * 41 * `ngtcp2_crypto_wolfssl_from_wolfssl_encryption_level` translates 42 * |wolfssl_level| to :type:`ngtcp2_crypto_level`. This function is only 43 * available for wolfSSL backend. 44 */ 45 NGTCP2_EXTERN ngtcp2_crypto_level 46 ngtcp2_crypto_wolfssl_from_wolfssl_encryption_level( 47 WOLFSSL_ENCRYPTION_LEVEL wolfssl_level); 48 49 /** 50 * @function 51 * 52 * `ngtcp2_crypto_wolfssl_from_ngtcp2_crypto_level` translates 53 * |crypto_level| to WOLFSSL_ENCRYPTION_LEVEL. This function is only 54 * available for wolfSSL backend. 55 */ 56 NGTCP2_EXTERN WOLFSSL_ENCRYPTION_LEVEL 57 ngtcp2_crypto_wolfssl_from_ngtcp2_crypto_level( 58 ngtcp2_crypto_level crypto_level); 59 60 /** 61 * @function 62 * 63 * `ngtcp2_crypto_wolfssl_configure_server_context` configures 64 * |ssl_ctx| for server side QUIC connection. It performs the 65 * following modifications: 66 * 67 * - Set minimum and maximum TLS version to TLSv1.3. 68 * - Set WOLFSSL_QUIC_METHOD by calling wolfSSL_CTX_set_quic_method. 69 * 70 * Application must set a pointer to :type:`ngtcp2_crypto_conn_ref` to 71 * WOLFSSL object by calling wolfSSL_set_app_data, and 72 * :type:`ngtcp2_crypto_conn_ref` object must have 73 * :member:`ngtcp2_crypto_conn_ref.get_conn` field assigned to get 74 * :type:`ngtcp2_conn`. 75 * 76 * It returns 0 if it succeeds, or -1. 77 */ 78 NGTCP2_EXTERN int 79 ngtcp2_crypto_wolfssl_configure_server_context(WOLFSSL_CTX *ssl_ctx); 80 81 /** 82 * @function 83 * 84 * `ngtcp2_crypto_wolfssl_configure_client_context` configures 85 * |ssl_ctx| for client side QUIC connection. It performs the 86 * following modifications: 87 * 88 * - Set minimum and maximum TLS version to TLSv1.3. 89 * - Set WOLFSSL_QUIC_METHOD by calling wolfSSL_CTX_set_quic_method. 90 * 91 * Application must set a pointer to :type:`ngtcp2_crypto_conn_ref` to 92 * SSL object by calling wolfSSL_set_app_data, and 93 * :type:`ngtcp2_crypto_conn_ref` object must have 94 * :member:`ngtcp2_crypto_conn_ref.get_conn` field assigned to get 95 * :type:`ngtcp2_conn`. 96 * 97 * It returns 0 if it succeeds, or -1. 98 */ 99 NGTCP2_EXTERN int 100 ngtcp2_crypto_wolfssl_configure_client_context(WOLFSSL_CTX *ssl_ctx); 101 102 #ifdef __cplusplus 103 } 104 #endif 105 106 #endif /* NGTCP2_CRYPTO_WOLFSSL_H */ 107