Alexandre Lision | ddd731e | 2014-01-31 11:50:08 -0500 | [diff] [blame] | 1 | // Copyright (C) 2010 David Sugar, Tycho Softworks. |
| 2 | // |
| 3 | // This file is part of GNU uCommon C++. |
| 4 | // |
| 5 | // GNU uCommon C++ is free software: you can redistribute it and/or modify |
| 6 | // it under the terms of the GNU Lesser General Public License as published |
| 7 | // by the Free Software Foundation, either version 3 of the License, or |
| 8 | // (at your option) any later version. |
| 9 | // |
| 10 | // GNU uCommon C++ is distributed in the hope that it will be useful, |
| 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | // GNU Lesser General Public License for more details. |
| 14 | // |
| 15 | // You should have received a copy of the GNU Lesser General Public License |
| 16 | // along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | #include <ucommon-config.h> |
| 19 | #include <ucommon/ucommon.h> |
| 20 | #include <ucommon/export.h> |
| 21 | #include <ucommon/secure.h> |
| 22 | #include <gnutls/gnutls.h> |
| 23 | #include <gnutls/crypto.h> |
| 24 | |
| 25 | #ifdef _MSWINDOWS_ |
| 26 | #include <wincrypt.h> |
| 27 | #endif |
| 28 | |
| 29 | #define NAMESPACE_LOCAL namespace __secure__ { |
| 30 | #define LOCAL_NAMESPACE __secure__ |
| 31 | |
| 32 | NAMESPACE_LOCAL |
| 33 | using namespace UCOMMON_NAMESPACE; |
| 34 | |
| 35 | class __LOCAL context : public secure |
| 36 | { |
| 37 | public: |
| 38 | ~context(); |
| 39 | |
| 40 | unsigned int connect; |
| 41 | gnutls_credentials_type_t xtype; |
| 42 | gnutls_certificate_credentials_t xcred; |
| 43 | gnutls_dh_params_t dh; |
| 44 | |
| 45 | static gnutls_priority_t priority_cache; |
| 46 | |
| 47 | static gnutls_session_t session(context *ctx); |
| 48 | |
| 49 | static int map_digest(const char *type); |
| 50 | static int map_cipher(const char *type); |
| 51 | static int map_hmac(const char *type); |
| 52 | }; |
| 53 | |
| 54 | typedef gnutls_session_t SSL; |
| 55 | typedef gnutls_mac_algorithm_t HMAC_ID; |
| 56 | typedef gnutls_hmac_hd_t HMAC_CTX; |
| 57 | typedef gnutls_digest_algorithm_t MD_ID; |
| 58 | typedef gnutls_hash_hd_t MD_CTX; |
| 59 | typedef gnutls_cipher_hd_t CIPHER_CTX; |
| 60 | typedef gnutls_cipher_algorithm_t CIPHER_ID; |
| 61 | typedef gnutls_datum_t CIPHER_KEYDATA; |
| 62 | typedef context *SSL_CTX; |
| 63 | |
| 64 | END_NAMESPACE |
| 65 | |
| 66 | using namespace UCOMMON_NAMESPACE; |
| 67 | using namespace LOCAL_NAMESPACE; |