Skip to content

Commit 42659b9

Browse files
author
cqm
committed
add openssl lib and ssl support
1 parent 6a24763 commit 42659b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+39001
-6
lines changed

examples/Console/SioChatDemo/SioChatDemo.vcxproj

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,26 @@
4141
<PropertyGroup Label="UserMacros" />
4242
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
4343
<LinkIncremental>true</LinkIncremental>
44-
<IncludePath>$(SolutionDir)..\..\..\lib\asio\asio\include;$(SolutionDir)..\..\..\lib\websocketpp;$(SolutionDir)..\..\..\lib\rapidjson\include;$(IncludePath)</IncludePath>
45-
<LibraryPath>D:\boost_1_55_0\boost_build\debug\lib;$(SolutionDir)boost\$(Configuration)\lib;$(LibraryPath)</LibraryPath>
44+
<IncludePath>$(SolutionDir)..\..\..\lib\asio\asio\include;$(SolutionDir)..\..\..\lib\openssl\include;$(SolutionDir)..\..\..\lib\websocketpp;$(SolutionDir)..\..\..\lib\rapidjson\include;$(IncludePath)</IncludePath>
45+
<LibraryPath>$(SolutionDir)..\..\..\lib\openssl\win32;$(LibraryPath)</LibraryPath>
4646
</PropertyGroup>
4747
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
4848
<LinkIncremental>false</LinkIncremental>
49-
<IncludePath>$(SolutionDir)..\..\..\lib\asio\asio\include;$(SolutionDir)..\..\..\lib\websocketpp;$(SolutionDir)..\..\..\lib\rapidjson\include;$(IncludePath)</IncludePath>
50-
<LibraryPath>$(SolutionDir)boost\$(Configuration)\lib;$(LibraryPath)</LibraryPath>
49+
<IncludePath>$(SolutionDir)..\..\..\lib\asio\asio\include;$(SolutionDir)..\..\..\lib\openssl\include;$(SolutionDir)..\..\..\lib\websocketpp;$(SolutionDir)..\..\..\lib\rapidjson\include;$(IncludePath)</IncludePath>
50+
<LibraryPath>$(SolutionDir)..\..\..\lib\openssl\win32;$(LibraryPath)</LibraryPath>
5151
</PropertyGroup>
5252
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
5353
<ClCompile>
5454
<PrecompiledHeader>NotUsing</PrecompiledHeader>
5555
<WarningLevel>Level3</WarningLevel>
5656
<Optimization>Disabled</Optimization>
57-
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;ASIO_STANDALONE;BOOST_REGEX_NO_LIB;BOOST_REGEX_NO_LIB;_WEBSOCKETPP_CPP11_STL_;_WEBSOCKETPP_CPP11_FUNCTIONAL_;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
57+
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;SIO_TLS;ASIO_STANDALONE;BOOST_REGEX_NO_LIB;BOOST_REGEX_NO_LIB;_WEBSOCKETPP_CPP11_STL_;_WEBSOCKETPP_CPP11_FUNCTIONAL_;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
5858
<SDLCheck>true</SDLCheck>
5959
</ClCompile>
6060
<Link>
6161
<SubSystem>Console</SubSystem>
6262
<GenerateDebugInformation>true</GenerateDebugInformation>
63+
<AdditionalDependencies>libeay32.lib;ssleay32.lib</AdditionalDependencies>
6364
</Link>
6465
</ItemDefinitionGroup>
6566
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -69,14 +70,15 @@
6970
<Optimization>MaxSpeed</Optimization>
7071
<FunctionLevelLinking>true</FunctionLevelLinking>
7172
<IntrinsicFunctions>true</IntrinsicFunctions>
72-
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;ASIO_STANDALONE;BOOST_REGEX_NO_LIB;BOOST_REGEX_NO_LIB;_WEBSOCKETPP_CPP11_STL_;_WEBSOCKETPP_CPP11_FUNCTIONAL_;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
73+
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;SIO_TLS;ASIO_STANDALONE;BOOST_REGEX_NO_LIB;BOOST_REGEX_NO_LIB;_WEBSOCKETPP_CPP11_STL_;_WEBSOCKETPP_CPP11_FUNCTIONAL_;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
7374
<SDLCheck>true</SDLCheck>
7475
</ClCompile>
7576
<Link>
7677
<SubSystem>Console</SubSystem>
7778
<GenerateDebugInformation>true</GenerateDebugInformation>
7879
<EnableCOMDATFolding>true</EnableCOMDATFolding>
7980
<OptimizeReferences>true</OptimizeReferences>
81+
<AdditionalDependencies>libeay32.lib;ssleay32.lib</AdditionalDependencies>
8082
</Link>
8183
</ItemDefinitionGroup>
8284
<ItemGroup>

lib/openssl/include/openssl/aes.h

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/* crypto/aes/aes.h */
2+
/* ====================================================================
3+
* Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions
7+
* are met:
8+
*
9+
* 1. Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
*
12+
* 2. Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in
14+
* the documentation and/or other materials provided with the
15+
* distribution.
16+
*
17+
* 3. All advertising materials mentioning features or use of this
18+
* software must display the following acknowledgment:
19+
* "This product includes software developed by the OpenSSL Project
20+
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
21+
*
22+
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23+
* endorse or promote products derived from this software without
24+
* prior written permission. For written permission, please contact
25+
* openssl-core@openssl.org.
26+
*
27+
* 5. Products derived from this software may not be called "OpenSSL"
28+
* nor may "OpenSSL" appear in their names without prior written
29+
* permission of the OpenSSL Project.
30+
*
31+
* 6. Redistributions of any form whatsoever must retain the following
32+
* acknowledgment:
33+
* "This product includes software developed by the OpenSSL Project
34+
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
35+
*
36+
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37+
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40+
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47+
* OF THE POSSIBILITY OF SUCH DAMAGE.
48+
* ====================================================================
49+
*
50+
*/
51+
52+
#ifndef HEADER_AES_H
53+
# define HEADER_AES_H
54+
55+
# include <openssl/opensslconf.h>
56+
57+
# ifdef OPENSSL_NO_AES
58+
# error AES is disabled.
59+
# endif
60+
61+
# include <stddef.h>
62+
63+
# define AES_ENCRYPT 1
64+
# define AES_DECRYPT 0
65+
66+
/*
67+
* Because array size can't be a const in C, the following two are macros.
68+
* Both sizes are in bytes.
69+
*/
70+
# define AES_MAXNR 14
71+
# define AES_BLOCK_SIZE 16
72+
73+
#ifdef __cplusplus
74+
extern "C" {
75+
#endif
76+
77+
/* This should be a hidden type, but EVP requires that the size be known */
78+
struct aes_key_st {
79+
# ifdef AES_LONG
80+
unsigned long rd_key[4 * (AES_MAXNR + 1)];
81+
# else
82+
unsigned int rd_key[4 * (AES_MAXNR + 1)];
83+
# endif
84+
int rounds;
85+
};
86+
typedef struct aes_key_st AES_KEY;
87+
88+
const char *AES_options(void);
89+
90+
int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
91+
AES_KEY *key);
92+
int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
93+
AES_KEY *key);
94+
95+
int private_AES_set_encrypt_key(const unsigned char *userKey, const int bits,
96+
AES_KEY *key);
97+
int private_AES_set_decrypt_key(const unsigned char *userKey, const int bits,
98+
AES_KEY *key);
99+
100+
void AES_encrypt(const unsigned char *in, unsigned char *out,
101+
const AES_KEY *key);
102+
void AES_decrypt(const unsigned char *in, unsigned char *out,
103+
const AES_KEY *key);
104+
105+
void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
106+
const AES_KEY *key, const int enc);
107+
void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
108+
size_t length, const AES_KEY *key,
109+
unsigned char *ivec, const int enc);
110+
void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
111+
size_t length, const AES_KEY *key,
112+
unsigned char *ivec, int *num, const int enc);
113+
void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
114+
size_t length, const AES_KEY *key,
115+
unsigned char *ivec, int *num, const int enc);
116+
void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
117+
size_t length, const AES_KEY *key,
118+
unsigned char *ivec, int *num, const int enc);
119+
void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
120+
size_t length, const AES_KEY *key,
121+
unsigned char *ivec, int *num);
122+
void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
123+
size_t length, const AES_KEY *key,
124+
unsigned char ivec[AES_BLOCK_SIZE],
125+
unsigned char ecount_buf[AES_BLOCK_SIZE],
126+
unsigned int *num);
127+
/* NB: the IV is _two_ blocks long */
128+
void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
129+
size_t length, const AES_KEY *key,
130+
unsigned char *ivec, const int enc);
131+
/* NB: the IV is _four_ blocks long */
132+
void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,
133+
size_t length, const AES_KEY *key,
134+
const AES_KEY *key2, const unsigned char *ivec,
135+
const int enc);
136+
137+
int AES_wrap_key(AES_KEY *key, const unsigned char *iv,
138+
unsigned char *out,
139+
const unsigned char *in, unsigned int inlen);
140+
int AES_unwrap_key(AES_KEY *key, const unsigned char *iv,
141+
unsigned char *out,
142+
const unsigned char *in, unsigned int inlen);
143+
144+
145+
#ifdef __cplusplus
146+
}
147+
#endif
148+
149+
#endif /* !HEADER_AES_H */

lib/openssl/include/openssl/applink.c

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#define APPLINK_STDIN 1
2+
#define APPLINK_STDOUT 2
3+
#define APPLINK_STDERR 3
4+
#define APPLINK_FPRINTF 4
5+
#define APPLINK_FGETS 5
6+
#define APPLINK_FREAD 6
7+
#define APPLINK_FWRITE 7
8+
#define APPLINK_FSETMOD 8
9+
#define APPLINK_FEOF 9
10+
#define APPLINK_FCLOSE 10 /* should not be used */
11+
12+
#define APPLINK_FOPEN 11 /* solely for completeness */
13+
#define APPLINK_FSEEK 12
14+
#define APPLINK_FTELL 13
15+
#define APPLINK_FFLUSH 14
16+
#define APPLINK_FERROR 15
17+
#define APPLINK_CLEARERR 16
18+
#define APPLINK_FILENO 17 /* to be used with below */
19+
20+
#define APPLINK_OPEN 18 /* formally can't be used, as flags can vary */
21+
#define APPLINK_READ 19
22+
#define APPLINK_WRITE 20
23+
#define APPLINK_LSEEK 21
24+
#define APPLINK_CLOSE 22
25+
#define APPLINK_MAX 22 /* always same as last macro */
26+
27+
#ifndef APPMACROS_ONLY
28+
# include <stdio.h>
29+
# include <io.h>
30+
# include <fcntl.h>
31+
32+
static void *app_stdin(void)
33+
{
34+
return stdin;
35+
}
36+
37+
static void *app_stdout(void)
38+
{
39+
return stdout;
40+
}
41+
42+
static void *app_stderr(void)
43+
{
44+
return stderr;
45+
}
46+
47+
static int app_feof(FILE *fp)
48+
{
49+
return feof(fp);
50+
}
51+
52+
static int app_ferror(FILE *fp)
53+
{
54+
return ferror(fp);
55+
}
56+
57+
static void app_clearerr(FILE *fp)
58+
{
59+
clearerr(fp);
60+
}
61+
62+
static int app_fileno(FILE *fp)
63+
{
64+
return _fileno(fp);
65+
}
66+
67+
static int app_fsetmod(FILE *fp, char mod)
68+
{
69+
return _setmode(_fileno(fp), mod == 'b' ? _O_BINARY : _O_TEXT);
70+
}
71+
72+
#ifdef __cplusplus
73+
extern "C" {
74+
#endif
75+
76+
__declspec(dllexport)
77+
void **
78+
# if defined(__BORLANDC__)
79+
/*
80+
* __stdcall appears to be the only way to get the name
81+
* decoration right with Borland C. Otherwise it works
82+
* purely incidentally, as we pass no parameters.
83+
*/
84+
__stdcall
85+
# else
86+
__cdecl
87+
# endif
88+
OPENSSL_Applink(void)
89+
{
90+
static int once = 1;
91+
static void *OPENSSL_ApplinkTable[APPLINK_MAX + 1] =
92+
{ (void *)APPLINK_MAX };
93+
94+
if (once) {
95+
OPENSSL_ApplinkTable[APPLINK_STDIN] = app_stdin;
96+
OPENSSL_ApplinkTable[APPLINK_STDOUT] = app_stdout;
97+
OPENSSL_ApplinkTable[APPLINK_STDERR] = app_stderr;
98+
OPENSSL_ApplinkTable[APPLINK_FPRINTF] = fprintf;
99+
OPENSSL_ApplinkTable[APPLINK_FGETS] = fgets;
100+
OPENSSL_ApplinkTable[APPLINK_FREAD] = fread;
101+
OPENSSL_ApplinkTable[APPLINK_FWRITE] = fwrite;
102+
OPENSSL_ApplinkTable[APPLINK_FSETMOD] = app_fsetmod;
103+
OPENSSL_ApplinkTable[APPLINK_FEOF] = app_feof;
104+
OPENSSL_ApplinkTable[APPLINK_FCLOSE] = fclose;
105+
106+
OPENSSL_ApplinkTable[APPLINK_FOPEN] = fopen;
107+
OPENSSL_ApplinkTable[APPLINK_FSEEK] = fseek;
108+
OPENSSL_ApplinkTable[APPLINK_FTELL] = ftell;
109+
OPENSSL_ApplinkTable[APPLINK_FFLUSH] = fflush;
110+
OPENSSL_ApplinkTable[APPLINK_FERROR] = app_ferror;
111+
OPENSSL_ApplinkTable[APPLINK_CLEARERR] = app_clearerr;
112+
OPENSSL_ApplinkTable[APPLINK_FILENO] = app_fileno;
113+
114+
OPENSSL_ApplinkTable[APPLINK_OPEN] = _open;
115+
OPENSSL_ApplinkTable[APPLINK_READ] = _read;
116+
OPENSSL_ApplinkTable[APPLINK_WRITE] = _write;
117+
OPENSSL_ApplinkTable[APPLINK_LSEEK] = _lseek;
118+
OPENSSL_ApplinkTable[APPLINK_CLOSE] = _close;
119+
120+
once = 0;
121+
}
122+
123+
return OPENSSL_ApplinkTable;
124+
}
125+
126+
#ifdef __cplusplus
127+
}
128+
#endif
129+
#endif

0 commit comments

Comments
 (0)