diff options
author | lloyd <[email protected]> | 2010-02-16 23:32:21 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-02-16 23:32:21 +0000 |
commit | 6a2f1e84538afed55f92eb9550f886a51301a84c (patch) | |
tree | 498c3804d684e8f7f4ad0a423c2ba92310679c8f | |
parent | e30f46ad200bd724caf72ccbf74bc416e1612b47 (diff) |
Remove use of old PKCS8_ and X509_ typedefs
-rw-r--r-- | src/ssl/c_kex.cpp | 4 | ||||
-rw-r--r-- | src/ssl/cert_ver.cpp | 4 | ||||
-rw-r--r-- | src/ssl/hello.cpp | 2 | ||||
-rw-r--r-- | src/ssl/s_kex.cpp | 12 | ||||
-rw-r--r-- | src/ssl/tls_client.cpp | 4 | ||||
-rw-r--r-- | src/ssl/tls_client.h | 24 | ||||
-rw-r--r-- | src/ssl/tls_messages.h | 31 | ||||
-rw-r--r-- | src/ssl/tls_server.cpp | 6 | ||||
-rw-r--r-- | src/ssl/tls_server.h | 20 | ||||
-rw-r--r-- | src/ssl/tls_state.h | 4 |
10 files changed, 62 insertions, 49 deletions
diff --git a/src/ssl/c_kex.cpp b/src/ssl/c_kex.cpp index bc16f4e86..802946bb9 100644 --- a/src/ssl/c_kex.cpp +++ b/src/ssl/c_kex.cpp @@ -21,7 +21,7 @@ namespace Botan { Client_Key_Exchange::Client_Key_Exchange(RandomNumberGenerator& rng, Record_Writer& writer, HandshakeHash& hash, - const X509_PublicKey* pub_key, + const Public_Key* pub_key, Version_Code using_version, Version_Code pref_version) { @@ -117,7 +117,7 @@ void Client_Key_Exchange::deserialize(const MemoryRegion<byte>& buf) */ SecureVector<byte> Client_Key_Exchange::pre_master_secret(RandomNumberGenerator& rng, - const PKCS8_PrivateKey* priv_key, + const Private_Key* priv_key, Version_Code version) { const DH_PrivateKey* dh_priv = dynamic_cast<const DH_PrivateKey*>(priv_key); diff --git a/src/ssl/cert_ver.cpp b/src/ssl/cert_ver.cpp index 8fccb7508..5ac28dd2e 100644 --- a/src/ssl/cert_ver.cpp +++ b/src/ssl/cert_ver.cpp @@ -20,7 +20,7 @@ namespace Botan { Certificate_Verify::Certificate_Verify(RandomNumberGenerator& rng, Record_Writer& writer, HandshakeHash& hash, - const PKCS8_PrivateKey* priv_key) + const Private_Key* priv_key) { const PK_Signing_Key* sign_key = dynamic_cast<const PK_Signing_Key*>(priv_key); @@ -88,7 +88,7 @@ bool Certificate_Verify::verify(const X509_Certificate& cert, { // FIXME: duplicate of Server_Key_Exchange::verify - std::auto_ptr<X509_PublicKey> key(cert.subject_public_key()); + std::auto_ptr<Public_Key> key(cert.subject_public_key()); DSA_PublicKey* dsa_pub = dynamic_cast<DSA_PublicKey*>(key.get()); RSA_PublicKey* rsa_pub = dynamic_cast<RSA_PublicKey*>(key.get()); diff --git a/src/ssl/hello.cpp b/src/ssl/hello.cpp index c3e89c6cf..53f680fba 100644 --- a/src/ssl/hello.cpp +++ b/src/ssl/hello.cpp @@ -174,7 +174,7 @@ Server_Hello::Server_Hello(RandomNumberGenerator& rng, bool have_rsa = false, have_dsa = false; for(u32bit j = 0; j != certs.size(); j++) { - X509_PublicKey* key = certs[j].subject_public_key(); + Public_Key* key = certs[j].subject_public_key(); if(key->algo_name() == "RSA") have_rsa = true; if(key->algo_name() == "DSA") have_dsa = true; } diff --git a/src/ssl/s_kex.cpp b/src/ssl/s_kex.cpp index 335b3f707..fd49fcb8c 100644 --- a/src/ssl/s_kex.cpp +++ b/src/ssl/s_kex.cpp @@ -1,6 +1,6 @@ /** -* Server Key Exchange Message -* (C) 2004-2006 Jack Lloyd +* Server Key Exchange Message +* (C) 2004-2010 Jack Lloyd * * Released under the terms of the Botan license */ @@ -20,8 +20,8 @@ namespace Botan { */ Server_Key_Exchange::Server_Key_Exchange(RandomNumberGenerator& rng, Record_Writer& writer, - const X509_PublicKey* kex_key, - const PKCS8_PrivateKey* priv_key, + const Public_Key* kex_key, + const Private_Key* priv_key, const MemoryRegion<byte>& c_random, const MemoryRegion<byte>& s_random, HandshakeHash& hash) @@ -150,7 +150,7 @@ void Server_Key_Exchange::deserialize(const MemoryRegion<byte>& buf) /** * Return the public key */ -X509_PublicKey* Server_Key_Exchange::key() const +Public_Key* Server_Key_Exchange::key() const { if(params.size() == 2) return new RSA_PublicKey(params[0], params[1]); @@ -167,7 +167,7 @@ bool Server_Key_Exchange::verify(const X509_Certificate& cert, const MemoryRegion<byte>& c_random, const MemoryRegion<byte>& s_random) const { - std::auto_ptr<X509_PublicKey> key(cert.subject_public_key()); + std::auto_ptr<Public_Key> key(cert.subject_public_key()); DSA_PublicKey* dsa_pub = dynamic_cast<DSA_PublicKey*>(key.get()); RSA_PublicKey* rsa_pub = dynamic_cast<RSA_PublicKey*>(key.get()); diff --git a/src/ssl/tls_client.cpp b/src/ssl/tls_client.cpp index 3cad7ef77..ce33573f5 100644 --- a/src/ssl/tls_client.cpp +++ b/src/ssl/tls_client.cpp @@ -95,7 +95,7 @@ TLS_Client::TLS_Client(RandomNumberGenerator& r, */ TLS_Client::TLS_Client(RandomNumberGenerator& r, Socket& sock, const X509_Certificate& cert, - const PKCS8_PrivateKey& key, const TLS_Policy* pol) : + const Private_Key& key, const TLS_Policy* pol) : rng(r), writer(sock), reader(sock), policy(pol ? pol : new TLS_Policy) { peer_id = sock.peer_id(); @@ -502,7 +502,7 @@ void TLS_Client::process_handshake_msg(Handshake_Type type, if(state->do_client_auth) { - PKCS8_PrivateKey* key_matching_cert = 0; // FIXME + Private_Key* key_matching_cert = 0; // FIXME state->client_verify = new Certificate_Verify(rng, writer, state->hash, key_matching_cert); diff --git a/src/ssl/tls_client.h b/src/ssl/tls_client.h index 27172029c..896decdf9 100644 --- a/src/ssl/tls_client.h +++ b/src/ssl/tls_client.h @@ -1,6 +1,6 @@ /** -* TLS Client -* (C) 2004-2006 Jack Lloyd +* TLS Client +* (C) 2004-2010 Jack Lloyd * * Released under the terms of the Botan license */ @@ -23,8 +23,8 @@ namespace Botan { class BOTAN_DLL TLS_Client : public TLS_Connection { public: - u32bit read(byte[], u32bit); - void write(const byte[], u32bit); + u32bit read(byte buf[], u32bit buf_len); + void write(const byte buf[], u32bit buf_len); std::vector<X509_Certificate> peer_cert_chain() const; @@ -32,12 +32,20 @@ class BOTAN_DLL TLS_Client : public TLS_Connection bool is_closed() const; TLS_Client(RandomNumberGenerator& rng, - Socket&, const TLS_Policy* = 0); + Socket& peer, + const TLS_Policy* policy = 0); + +#if 0 + void add_cert(const X509_Certificate& cert, + const Private_Key& cert_key); +#endif // FIXME: support multiple cert/key pairs TLS_Client(RandomNumberGenerator& rng, - Socket&, const X509_Certificate&, const PKCS8_PrivateKey&, - const TLS_Policy* = 0); + Socket& peer, + const X509_Certificate& cert, + const Private_Key& cert_key, + const TLS_Policy* policy = 0); ~TLS_Client(); private: @@ -57,7 +65,7 @@ class BOTAN_DLL TLS_Client : public TLS_Connection const TLS_Policy* policy; std::vector<X509_Certificate> certs, peer_certs; - std::vector<PKCS8_PrivateKey*> keys; + std::vector<Private_Key*> keys; Handshake_State* state; SecureVector<byte> session_id; diff --git a/src/ssl/tls_messages.h b/src/ssl/tls_messages.h index 4750a1d1d..4b512a963 100644 --- a/src/ssl/tls_messages.h +++ b/src/ssl/tls_messages.h @@ -1,6 +1,6 @@ /** * TLS Messages -* (C) 2004-2006 Jack Lloyd +* (C) 2004-2010 Jack Lloyd * * Released under the terms of the Botan license */ @@ -74,16 +74,21 @@ class BOTAN_DLL Client_Key_Exchange : public HandshakeMessage Handshake_Type type() const { return CLIENT_KEX; } SecureVector<byte> pre_master_secret() const; - SecureVector<byte> pre_master_secret(RandomNumberGenerator&, - const PKCS8_PrivateKey*, - Version_Code); - Client_Key_Exchange(RandomNumberGenerator&, - Record_Writer&, HandshakeHash&, - const X509_PublicKey*, Version_Code, Version_Code); + SecureVector<byte> pre_master_secret(RandomNumberGenerator& rng, + const Private_Key* key, + Version_Code version); - Client_Key_Exchange(const MemoryRegion<byte>&, const CipherSuite&, - Version_Code); + Client_Key_Exchange(RandomNumberGenerator& rng, + Record_Writer& output, + HandshakeHash& hash, + const Public_Key* my_key, + Version_Code using_version, + Version_Code pref_version); + + Client_Key_Exchange(const MemoryRegion<byte>& buf, + const CipherSuite& suite, + Version_Code using_version); private: SecureVector<byte> serialize() const; void deserialize(const MemoryRegion<byte>&); @@ -149,7 +154,7 @@ class BOTAN_DLL Certificate_Verify : public HandshakeMessage Certificate_Verify(RandomNumberGenerator& rng, Record_Writer&, HandshakeHash&, - const PKCS8_PrivateKey*); + const Private_Key*); Certificate_Verify(const MemoryRegion<byte>& buf) { deserialize(buf); } private: @@ -237,14 +242,14 @@ class BOTAN_DLL Server_Key_Exchange : public HandshakeMessage { public: Handshake_Type type() const { return SERVER_KEX; } - X509_PublicKey* key() const; + Public_Key* key() const; bool verify(const X509_Certificate&, const MemoryRegion<byte>&, const MemoryRegion<byte>&) const; Server_Key_Exchange(RandomNumberGenerator& rng, - Record_Writer&, const X509_PublicKey*, - const PKCS8_PrivateKey*, const MemoryRegion<byte>&, + Record_Writer&, const Public_Key*, + const Private_Key*, const MemoryRegion<byte>&, const MemoryRegion<byte>&, HandshakeHash&); Server_Key_Exchange(const MemoryRegion<byte>& buf) { deserialize(buf); } diff --git a/src/ssl/tls_server.cpp b/src/ssl/tls_server.cpp index 84d961423..37d9dbcd1 100644 --- a/src/ssl/tls_server.cpp +++ b/src/ssl/tls_server.cpp @@ -1,6 +1,6 @@ /** -* TLS Server -* (C) 2004-2008 Jack Lloyd +* TLS Server +* (C) 2004-2010 Jack Lloyd * * Released under the terms of the Botan license */ @@ -87,7 +87,7 @@ void server_check_state(Handshake_Type new_msg, Handshake_State* state) */ TLS_Server::TLS_Server(RandomNumberGenerator& r, Socket& sock, const X509_Certificate& cert, - const PKCS8_PrivateKey& key, const TLS_Policy* pol) : + const Private_Key& key, const TLS_Policy* pol) : rng(r), writer(sock), reader(sock), policy(pol ? pol : new TLS_Policy) { peer_id = sock.peer_id(); diff --git a/src/ssl/tls_server.h b/src/ssl/tls_server.h index c191c1663..683c3413a 100644 --- a/src/ssl/tls_server.h +++ b/src/ssl/tls_server.h @@ -1,6 +1,6 @@ /** -* TLS Server -* (C) 2004-2006 Jack Lloyd +* TLS Server +* (C) 2004-2010 Jack Lloyd * * Released under the terms of the Botan license */ @@ -18,12 +18,11 @@ namespace Botan { * TLS Server */ -// FIXME: much of this can probably be moved up to TLS_Connection -class BOTAN_DLL TLS_Server +class BOTAN_DLL TLS_Server : public TLS_Connection { public: - u32bit read(byte[], u32bit); - void write(const byte[], u32bit); + u32bit read(byte buf[], u32bit buf_len); + void write(const byte buf[], u32bit buf_len); std::vector<X509_Certificate> peer_cert_chain() const; @@ -33,9 +32,10 @@ class BOTAN_DLL TLS_Server // FIXME: support cert chains (!) // FIXME: support anonymous servers TLS_Server(RandomNumberGenerator& rng, - Socket&, - const X509_Certificate&, const PKCS8_PrivateKey&, - const TLS_Policy* = 0); + Socket& peer, + const X509_Certificate& cert, + const Private_Key& cert_key, + const TLS_Policy* policy = 0); ~TLS_Server(); private: @@ -55,7 +55,7 @@ class BOTAN_DLL TLS_Server // FIXME: rename to match TLS_Client std::vector<X509_Certificate> cert_chain, peer_certs; - PKCS8_PrivateKey* private_key; + Private_Key* private_key; Handshake_State* state; SecureVector<byte> session_id; diff --git a/src/ssl/tls_state.h b/src/ssl/tls_state.h index 5a3aa894a..ddf03a822 100644 --- a/src/ssl/tls_state.h +++ b/src/ssl/tls_state.h @@ -32,8 +32,8 @@ class BOTAN_DLL Handshake_State Finished* client_finished; Finished* server_finished; - X509_PublicKey* kex_pub; - PKCS8_PrivateKey* kex_priv; + Public_Key* kex_pub; + Private_Key* kex_priv; CipherSuite suite; SessionKeys keys; |