aboutsummaryrefslogtreecommitdiffstats
path: root/src/tls/tls_handshake_state.h
blob: b2ed0dd207bfb41aa7a4fcd2b1253d0b7e2a8e50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* TLS Handshake State
* (C) 2004-2006 Jack Lloyd
*
* Released under the terms of the Botan license
*/

#ifndef BOTAN_TLS_HANDSHAKE_STATE_H__
#define BOTAN_TLS_HANDSHAKE_STATE_H__

#include <botan/internal/tls_handshake_hash.h>
#include <botan/internal/tls_session_key.h>
#include <botan/secqueue.h>
#include <botan/pk_keys.h>
#include <botan/pubkey.h>

#include <utility>

#if defined(BOTAN_USE_STD_TR1)

#if defined(BOTAN_BUILD_COMPILER_IS_MSVC)
    #include <functional>
#else
    #include <tr1/functional>
#endif

#elif defined(BOTAN_USE_BOOST_TR1)
  #include <boost/tr1/functional.hpp>
#else
  #error "No TR1 library defined for use"
#endif

namespace Botan {

/**
* SSL/TLS Handshake State
*/
class TLS_Handshake_State
   {
   public:
      TLS_Handshake_State();
      ~TLS_Handshake_State();

      bool received_handshake_msg(Handshake_Type handshake_msg) const;

      void confirm_transition_to(Handshake_Type handshake_msg);
      void set_expected_next(Handshake_Type handshake_msg);

      std::pair<std::string, Signature_Format>
         understand_sig_format(const Public_Key* key,
                               std::string hash_algo,
                               std::string sig_algo,
                               bool for_client_auth);

      std::pair<std::string, Signature_Format>
         choose_sig_format(const Private_Key* key,
                           std::string& hash_algo,
                           std::string& sig_algo,
                           bool for_client_auth);

      Version_Code version;

      class Client_Hello* client_hello;
      class Server_Hello* server_hello;
      class Certificate* server_certs;
      class Server_Key_Exchange* server_kex;
      class Certificate_Req* cert_req;
      class Server_Hello_Done* server_hello_done;

      class Certificate* client_certs;
      class Client_Key_Exchange* client_kex;
      class Certificate_Verify* client_verify;

      class Next_Protocol* next_protocol;

      class Finished* client_finished;
      class Finished* server_finished;

      Public_Key* kex_pub;
      Private_Key* kex_priv;

      TLS_Ciphersuite suite;
      Session_Keys keys;
      TLS_Handshake_Hash hash;

      SecureQueue queue;

      /*
      * Only used by clients for session resumption
      */
      SecureVector<byte> resume_master_secret;

      /**
      * Used by client using NPN
      */
      std::tr1::function<std::string (std::vector<std::string>)> client_npn_cb;

   private:
      u32bit hand_expecting_mask, hand_received_mask;
   };

}

#endif