1 // Copyright (C) 2010-2014 David Sugar, Tycho Softworks.
2 // Copyright (C) 2015 Cherokees of Idaho.
3 //
4 // This file is part of GNU uCommon C++.
5 //
6 // GNU uCommon C++ is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU Lesser General Public License as published
8 // by the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // GNU uCommon C++ is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with GNU uCommon C++.  If not, see <http://www.gnu.org/licenses/>.
18 
19 #include "local.h"
20 
21 namespace ucommon {
22 #ifdef  _MSWINDOWS_
23 HCRYPTPROV __handle = (HCRYPTPROV)NULL;
24 #endif
25 
~secure()26 secure::~secure()
27 {
28 }
29 
fips(void)30 bool secure::fips(void)
31 {
32     return false;
33 }
34 
init(void)35 bool secure::init(void)
36 {
37     Thread::init();
38     Socket::init();
39 
40 #ifdef  _MSWINDOWS_
41     if(__handle != (HCRYPTPROV)NULL)
42         return false;
43 
44     if(CryptAcquireContext(&__handle, NULL, NULL, PROV_RSA_FULL, 0))
45         return false;
46     if(GetLastError() == (DWORD)NTE_BAD_KEYSET) {
47         if(CryptAcquireContext(&__handle, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET))
48             return false;
49     }
50 
51     __handle = (HCRYPTPROV)NULL;
52 #endif
53 
54     return false;
55 }
56 
server(const char * cert,const char * key)57 secure::server_t secure::server(const char *cert, const char *key)
58 {
59     return NULL;
60 }
61 
client(const char * ca)62 secure::client_t secure::client(const char *ca)
63 {
64     return NULL;
65 }
66 
cipher(secure * context,const char * ciphers)67 void secure::cipher(secure *context, const char *ciphers)
68 {
69 }
70 
71 } // namespace ucommon
72