Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:02

0001 //
0002 // ssl/context_base.hpp
0003 // ~~~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 
0011 #ifndef BOOST_ASIO_SSL_CONTEXT_BASE_HPP
0012 #define BOOST_ASIO_SSL_CONTEXT_BASE_HPP
0013 
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0017 
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/ssl/detail/openssl_types.hpp>
0020 
0021 #include <boost/asio/detail/push_options.hpp>
0022 
0023 namespace boost {
0024 namespace asio {
0025 namespace ssl {
0026 
0027 /// The context_base class is used as a base for the basic_context class
0028 /// template so that we have a common place to define various enums.
0029 class context_base
0030 {
0031 public:
0032   /// Different methods supported by a context.
0033   enum method
0034   {
0035     /// Generic SSL version 2.
0036     sslv2,
0037 
0038     /// SSL version 2 client.
0039     sslv2_client,
0040 
0041     /// SSL version 2 server.
0042     sslv2_server,
0043 
0044     /// Generic SSL version 3.
0045     sslv3,
0046 
0047     /// SSL version 3 client.
0048     sslv3_client,
0049 
0050     /// SSL version 3 server.
0051     sslv3_server,
0052 
0053     /// Generic TLS version 1.
0054     tlsv1,
0055 
0056     /// TLS version 1 client.
0057     tlsv1_client,
0058 
0059     /// TLS version 1 server.
0060     tlsv1_server,
0061 
0062     /// Generic SSL/TLS.
0063     sslv23,
0064 
0065     /// SSL/TLS client.
0066     sslv23_client,
0067 
0068     /// SSL/TLS server.
0069     sslv23_server,
0070 
0071     /// Generic TLS version 1.1.
0072     tlsv11,
0073 
0074     /// TLS version 1.1 client.
0075     tlsv11_client,
0076 
0077     /// TLS version 1.1 server.
0078     tlsv11_server,
0079 
0080     /// Generic TLS version 1.2.
0081     tlsv12,
0082 
0083     /// TLS version 1.2 client.
0084     tlsv12_client,
0085 
0086     /// TLS version 1.2 server.
0087     tlsv12_server,
0088 
0089     /// Generic TLS version 1.3.
0090     tlsv13,
0091 
0092     /// TLS version 1.3 client.
0093     tlsv13_client,
0094 
0095     /// TLS version 1.3 server.
0096     tlsv13_server,
0097 
0098     /// Generic TLS.
0099     tls,
0100 
0101     /// TLS client.
0102     tls_client,
0103 
0104     /// TLS server.
0105     tls_server
0106   };
0107 
0108   /// Bitmask type for SSL options.
0109   typedef uint64_t options;
0110 
0111 #if defined(GENERATING_DOCUMENTATION)
0112   /// Implement various bug workarounds.
0113   static const uint64_t default_workarounds = implementation_defined;
0114 
0115   /// Always create a new key when using tmp_dh parameters.
0116   static const uint64_t single_dh_use = implementation_defined;
0117 
0118   /// Disable SSL v2.
0119   static const uint64_t no_sslv2 = implementation_defined;
0120 
0121   /// Disable SSL v3.
0122   static const uint64_t no_sslv3 = implementation_defined;
0123 
0124   /// Disable TLS v1.
0125   static const uint64_t no_tlsv1 = implementation_defined;
0126 
0127   /// Disable TLS v1.1.
0128   static const uint64_t no_tlsv1_1 = implementation_defined;
0129 
0130   /// Disable TLS v1.2.
0131   static const uint64_t no_tlsv1_2 = implementation_defined;
0132 
0133   /// Disable TLS v1.3.
0134   static const uint64_t no_tlsv1_3 = implementation_defined;
0135 
0136   /// Disable compression. Compression is disabled by default.
0137   static const uint64_t no_compression = implementation_defined;
0138 #else
0139   BOOST_ASIO_STATIC_CONSTANT(uint64_t, default_workarounds = SSL_OP_ALL);
0140   BOOST_ASIO_STATIC_CONSTANT(uint64_t, single_dh_use = SSL_OP_SINGLE_DH_USE);
0141   BOOST_ASIO_STATIC_CONSTANT(uint64_t, no_sslv2 = SSL_OP_NO_SSLv2);
0142   BOOST_ASIO_STATIC_CONSTANT(uint64_t, no_sslv3 = SSL_OP_NO_SSLv3);
0143   BOOST_ASIO_STATIC_CONSTANT(uint64_t, no_tlsv1 = SSL_OP_NO_TLSv1);
0144 # if defined(SSL_OP_NO_TLSv1_1)
0145   BOOST_ASIO_STATIC_CONSTANT(uint64_t, no_tlsv1_1 = SSL_OP_NO_TLSv1_1);
0146 # else // defined(SSL_OP_NO_TLSv1_1)
0147   BOOST_ASIO_STATIC_CONSTANT(uint64_t, no_tlsv1_1 = 0x10000000L);
0148 # endif // defined(SSL_OP_NO_TLSv1_1)
0149 # if defined(SSL_OP_NO_TLSv1_2)
0150   BOOST_ASIO_STATIC_CONSTANT(uint64_t, no_tlsv1_2 = SSL_OP_NO_TLSv1_2);
0151 # else // defined(SSL_OP_NO_TLSv1_2)
0152   BOOST_ASIO_STATIC_CONSTANT(uint64_t, no_tlsv1_2 = 0x08000000L);
0153 # endif // defined(SSL_OP_NO_TLSv1_2)
0154 # if defined(SSL_OP_NO_TLSv1_3)
0155   BOOST_ASIO_STATIC_CONSTANT(uint64_t, no_tlsv1_3 = SSL_OP_NO_TLSv1_3);
0156 # else // defined(SSL_OP_NO_TLSv1_3)
0157   BOOST_ASIO_STATIC_CONSTANT(uint64_t, no_tlsv1_3 = 0x20000000L);
0158 # endif // defined(SSL_OP_NO_TLSv1_3)
0159 # if defined(SSL_OP_NO_COMPRESSION)
0160   BOOST_ASIO_STATIC_CONSTANT(uint64_t, no_compression = SSL_OP_NO_COMPRESSION);
0161 # else // defined(SSL_OP_NO_COMPRESSION)
0162   BOOST_ASIO_STATIC_CONSTANT(uint64_t, no_compression = 0x20000L);
0163 # endif // defined(SSL_OP_NO_COMPRESSION)
0164 #endif
0165 
0166   /// File format types.
0167   enum file_format
0168   {
0169     /// ASN.1 file.
0170     asn1,
0171 
0172     /// PEM file.
0173     pem
0174   };
0175 
0176 #if !defined(GENERATING_DOCUMENTATION)
0177   // The following types and constants are preserved for backward compatibility.
0178   // New programs should use the equivalents of the same names that are defined
0179   // in the boost::asio::ssl namespace.
0180   typedef int verify_mode;
0181   BOOST_ASIO_STATIC_CONSTANT(int, verify_none = SSL_VERIFY_NONE);
0182   BOOST_ASIO_STATIC_CONSTANT(int, verify_peer = SSL_VERIFY_PEER);
0183   BOOST_ASIO_STATIC_CONSTANT(int,
0184       verify_fail_if_no_peer_cert = SSL_VERIFY_FAIL_IF_NO_PEER_CERT);
0185   BOOST_ASIO_STATIC_CONSTANT(int, verify_client_once = SSL_VERIFY_CLIENT_ONCE);
0186 #endif
0187 
0188   /// Purpose of PEM password.
0189   enum password_purpose
0190   {
0191     /// The password is needed for reading/decryption.
0192     for_reading,
0193 
0194     /// The password is needed for writing/encryption.
0195     for_writing
0196   };
0197 
0198 protected:
0199   /// Protected destructor to prevent deletion through this type.
0200   ~context_base()
0201   {
0202   }
0203 };
0204 
0205 } // namespace ssl
0206 } // namespace asio
0207 } // namespace boost
0208 
0209 #include <boost/asio/detail/pop_options.hpp>
0210 
0211 #endif // BOOST_ASIO_SSL_CONTEXT_BASE_HPP