diff options
author | msvensson@shellback.(none) <> | 2006-04-07 11:35:12 +0200 |
---|---|---|
committer | msvensson@shellback.(none) <> | 2006-04-07 11:35:12 +0200 |
commit | e8723ca453c4bef12083ca7252aef1814cda1458 (patch) | |
tree | 9cad353f5a7f89b9f7ee3d3d7e2de065f3dadab7 /extra/yassl/include | |
parent | cd15f309fb05b8cbfd4f4030c68cf2b9a56672c4 (diff) | |
download | mariadb-git-e8723ca453c4bef12083ca7252aef1814cda1458.tar.gz |
Update yassl to 1.2.2
Diffstat (limited to 'extra/yassl/include')
-rw-r--r-- | extra/yassl/include/cert_wrapper.hpp | 3 | ||||
-rw-r--r-- | extra/yassl/include/crypto_wrapper.hpp | 6 | ||||
-rw-r--r-- | extra/yassl/include/openssl/ssl.h | 7 | ||||
-rw-r--r-- | extra/yassl/include/socket_wrapper.hpp | 2 | ||||
-rw-r--r-- | extra/yassl/include/yassl.hpp | 88 | ||||
-rw-r--r-- | extra/yassl/include/yassl_error.hpp | 4 | ||||
-rw-r--r-- | extra/yassl/include/yassl_imp.hpp | 2 | ||||
-rw-r--r-- | extra/yassl/include/yassl_int.hpp | 8 | ||||
-rw-r--r-- | extra/yassl/include/yassl_types.hpp | 73 |
9 files changed, 160 insertions, 33 deletions
diff --git a/extra/yassl/include/cert_wrapper.hpp b/extra/yassl/include/cert_wrapper.hpp index 2381347c27e..2a214c529fd 100644 --- a/extra/yassl/include/cert_wrapper.hpp +++ b/extra/yassl/include/cert_wrapper.hpp @@ -83,6 +83,7 @@ class CertManager { SignerList signers_; // decoded CA keys and names // plus verified chained certs bool verifyPeer_; + bool verifyNone_; // no error if verify fails bool failNoCert_; bool sendVerify_; public: @@ -107,10 +108,12 @@ public: uint get_privateKeyLength() const; bool verifyPeer() const; + bool verifyNone() const; bool failNoCert() const; bool sendVerify() const; void setVerifyPeer(); + void setVerifyNone(); void setFailNoCert(); void setSendVerify(); private: diff --git a/extra/yassl/include/crypto_wrapper.hpp b/extra/yassl/include/crypto_wrapper.hpp index ca9d870677e..cb542c25a67 100644 --- a/extra/yassl/include/crypto_wrapper.hpp +++ b/extra/yassl/include/crypto_wrapper.hpp @@ -41,8 +41,8 @@ namespace yaSSL { -// Digest policy should implement a get_digest, update, and get sizes for pad and -// digest +// Digest policy should implement a get_digest, update, and get sizes for pad +// and digest struct Digest : public virtual_base { virtual void get_digest(byte*) = 0; virtual void get_digest(byte*, const byte*, unsigned int) = 0; @@ -380,7 +380,7 @@ public: uint get_agreedKeyLength() const; const byte* get_agreedKey() const; const byte* get_publicKey() const; - void makeAgreement(const byte*); + void makeAgreement(const byte*, unsigned int); void set_sizes(int&, int&, int&) const; void get_parms(byte*, byte*, byte*) const; diff --git a/extra/yassl/include/openssl/ssl.h b/extra/yassl/include/openssl/ssl.h index 1c8291c2f13..d6b91bc66c4 100644 --- a/extra/yassl/include/openssl/ssl.h +++ b/extra/yassl/include/openssl/ssl.h @@ -23,6 +23,8 @@ * */ + + #ifndef ysSSL_openssl_h__ #define yaSSL_openssl_h__ @@ -49,7 +51,7 @@ extern "C" { class X509_NAME; #else typedef struct SSL SSL; - typedef struct SSL_SESION SSL_SESSION; + typedef struct SSL_SESSION SSL_SESSION; typedef struct SSL_METHOD SSL_METHOD; typedef struct SSL_CTX SSL_CTX; typedef struct SSL_CIPHER SSL_CIPHER; @@ -258,6 +260,8 @@ int SSL_pending(SSL*); enum { /* ssl Constants */ + SSL_BAD_STAT = -7, + SSL_BAD_PATH = -6, SSL_BAD_FILETYPE = -5, SSL_BAD_FILE = -4, SSL_NOT_IMPLEMENTED = -3, @@ -341,7 +345,6 @@ long SSL_CTX_sess_set_cache_size(SSL_CTX*, long); long SSL_CTX_set_tmp_dh(SSL_CTX*, DH*); void OpenSSL_add_all_algorithms(void); -void SSL_library_init(); void SSLeay_add_ssl_algorithms(void); diff --git a/extra/yassl/include/socket_wrapper.hpp b/extra/yassl/include/socket_wrapper.hpp index 38a9ce3bd25..d2258a93723 100644 --- a/extra/yassl/include/socket_wrapper.hpp +++ b/extra/yassl/include/socket_wrapper.hpp @@ -77,7 +77,7 @@ public: uint send(const byte* buf, unsigned int len, int flags = 0) const; uint receive(byte* buf, unsigned int len, int flags = 0) const; - void wait() const; + bool wait() const; void closeSocket(); void shutDown(int how = SD_SEND); diff --git a/extra/yassl/include/yassl.hpp b/extra/yassl/include/yassl.hpp new file mode 100644 index 00000000000..edb8e416eb6 --- /dev/null +++ b/extra/yassl/include/yassl.hpp @@ -0,0 +1,88 @@ +/* yassl.hpp + * + * Copyright (C) 2003 Sawtooth Consulting Ltd. + * + * This file is part of yaSSL. + * + * yaSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * yaSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + + +/* yaSSL externel header defines yaSSL API + */ + + +#ifndef yaSSL_EXT_HPP +#define yaSSL_EXT_HPP + + +namespace yaSSL { + + +#ifdef _WIN32 + typedef unsigned int SOCKET_T; +#else + typedef int SOCKET_T; +#endif + + +class Client { +public: + Client(); + ~Client(); + + // basics + int Connect(SOCKET_T); + int Write(const void*, int); + int Read(void*, int); + + // options + void SetCA(const char*); + void SetCert(const char*); + void SetKey(const char*); +private: + struct ClientImpl; + ClientImpl* pimpl_; + + Client(const Client&); // hide copy + Client& operator=(const Client&); // and assign +}; + + +class Server { +public: + Server(); + ~Server(); + + // basics + int Accept(SOCKET_T); + int Write(const void*, int); + int Read(void*, int); + + // options + void SetCA(const char*); + void SetCert(const char*); + void SetKey(const char*); +private: + struct ServerImpl; + ServerImpl* pimpl_; + + Server(const Server&); // hide copy + Server& operator=(const Server&); // and assign +}; + + +} // namespace yaSSL +#endif // yaSSL_EXT_HPP diff --git a/extra/yassl/include/yassl_error.hpp b/extra/yassl/include/yassl_error.hpp index 0b06a37a635..9c12b06e34a 100644 --- a/extra/yassl/include/yassl_error.hpp +++ b/extra/yassl/include/yassl_error.hpp @@ -59,6 +59,10 @@ enum YasslError { enum Library { yaSSL_Lib = 0, CryptoLib, SocketLib }; +enum { MAX_ERROR_SZ = 80 }; + +void SetErrorString(YasslError, char*); + // Base class for all yaSSL exceptions class Error : public mySTL::runtime_error { diff --git a/extra/yassl/include/yassl_imp.hpp b/extra/yassl/include/yassl_imp.hpp index 3de58901f8e..2f240b71c03 100644 --- a/extra/yassl/include/yassl_imp.hpp +++ b/extra/yassl/include/yassl_imp.hpp @@ -662,7 +662,7 @@ struct Parameters { uint8 suites_size_; Cipher suites_[MAX_SUITE_SZ]; char cipher_name_[MAX_SUITE_NAME]; - char cipher_list_[MAX_CIPHER_LIST]; + char cipher_list_[MAX_CIPHERS][MAX_SUITE_NAME]; Parameters(ConnectionEnd, const Ciphers&, ProtocolVersion); diff --git a/extra/yassl/include/yassl_int.hpp b/extra/yassl/include/yassl_int.hpp index 60a78a3970e..ce22d4edb1d 100644 --- a/extra/yassl/include/yassl_int.hpp +++ b/extra/yassl/include/yassl_int.hpp @@ -77,8 +77,6 @@ enum ServerState { // combines all states class States { - enum {MAX_ERROR_SZ = 80 }; - RecordLayerState recordLayer_; HandShakeState handshakeLayer_; ClientState clientState_; @@ -231,7 +229,8 @@ sslFactory& GetSSL_Factory(); class SSL_METHOD { ProtocolVersion version_; ConnectionEnd side_; - bool verifyPeer_; + bool verifyPeer_; // request or send certificate + bool verifyNone_; // whether to verify certificate bool failNoCert_; public: explicit SSL_METHOD(ConnectionEnd ce, ProtocolVersion pv); @@ -240,9 +239,11 @@ public: ConnectionEnd getSide() const; void setVerifyPeer(); + void setVerifyNone(); void setFailNoCert(); bool verifyPeer() const; + bool verifyNone() const; bool failNoCert() const; private: SSL_METHOD(const SSL_METHOD&); // hide copy @@ -335,6 +336,7 @@ public: const Stats& GetStats() const; void setVerifyPeer(); + void setVerifyNone(); void setFailNoCert(); bool SetCipherList(const char*); bool SetDH(const DH&); diff --git a/extra/yassl/include/yassl_types.hpp b/extra/yassl/include/yassl_types.hpp index ec9e6fb7ceb..be219d2cead 100644 --- a/extra/yassl/include/yassl_types.hpp +++ b/extra/yassl/include/yassl_types.hpp @@ -34,32 +34,34 @@ namespace yaSSL { -// library allocation -struct new_t {}; // yaSSL New type -extern new_t ys; // pass in parameter +#ifdef YASSL_PURE_C -} // namespace yaSSL + // library allocation + struct new_t {}; // yaSSL New type + extern new_t ys; // pass in parameter -void* operator new (size_t, yaSSL::new_t); -void* operator new[](size_t, yaSSL::new_t); + } // namespace yaSSL -void operator delete (void*, yaSSL::new_t); -void operator delete[](void*, yaSSL::new_t); + void* operator new (size_t, yaSSL::new_t); + void* operator new[](size_t, yaSSL::new_t); + void operator delete (void*, yaSSL::new_t); + void operator delete[](void*, yaSSL::new_t); -namespace yaSSL { + namespace yaSSL { -template<typename T> -void ysDelete(T* ptr) -{ + + template<typename T> + void ysDelete(T* ptr) + { if (ptr) ptr->~T(); ::operator delete(ptr, yaSSL::ys); -} + } -template<typename T> -void ysArrayDelete(T* ptr) -{ + template<typename T> + void ysArrayDelete(T* ptr) + { // can't do array placement destruction since not tracking size in // allocation, only allow builtins to use array placement since they // don't need destructors called @@ -67,15 +69,40 @@ void ysArrayDelete(T* ptr) (void)sizeof(builtin); ::operator delete[](ptr, yaSSL::ys); -} + } + #define NEW_YS new (ys) -// to resolve compiler generated operator delete on base classes with -// virtual destructors (when on stack), make sure doesn't get called -class virtual_base { -public: + // to resolve compiler generated operator delete on base classes with + // virtual destructors (when on stack), make sure doesn't get called + class virtual_base { + public: static void operator delete(void*) { assert(0); } -}; + }; + + +#else // YASSL_PURE_C + + + template<typename T> + void ysDelete(T* ptr) + { + delete ptr; + } + + template<typename T> + void ysArrayDelete(T* ptr) + { + delete[] ptr; + } + + #define NEW_YS new + + class virtual_base {}; + + + +#endif // YASSL_PURE_C typedef unsigned char uint8; @@ -105,7 +132,7 @@ const int KEY_PREFIX = 7; // up to 7 prefix letters for key rounds const int FORTEZZA_MAX = 128; // Maximum Fortezza Key length const int MAX_SUITE_SZ = 64; // 32 max suites * sizeof(suite) const int MAX_SUITE_NAME = 48; // max length of suite name -const int MAX_CIPHER_LIST = 512; // max length of cipher list names +const int MAX_CIPHERS = 32; // max supported ciphers for cipher list const int SIZEOF_ENUM = 1; // SSL considers an enum 1 byte, not 4 const int SIZEOF_SENDER = 4; // Sender constant, for finished generation const int PAD_MD5 = 48; // pad length 1 and 2 for md5 finished |