Skip to content

Commit ec0920e

Browse files
committed
update(vendor): OpenSSL for WIndows
1 parent d18c7e6 commit ec0920e

Some content is hidden

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

110 files changed

+32140
-5
lines changed

.vscode/c_cpp_properties.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
"_UNICODE",
1919
"WIN32",
2020
"COMPILER_GCC",
21-
"META_IS_SOURCE2"
21+
"META_IS_SOURCE2",
22+
"NO_SSL_DL",
23+
"OPENSSL_API_1_1"
2224
],
2325
"cStandard": "c17",
2426
"cppStandard": "c++17",

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
"xstring": "cpp",
7171
"codecvt": "cpp",
7272
"future": "cpp",
73-
"variant": "cpp"
73+
"variant": "cpp",
74+
"bn.h": "c",
75+
"opensslv.h": "c"
7476
}
7577
}

AMBuilder

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ for sdk_target in MMSPlugin.sdk_targets:
8989
"PLATFORM_64BITS",
9090
"META_IS_SOURCE2",
9191
"_GLIBCXX_USE_CXX11_ABI=0",
92-
"OPENSSL_API_1_1",
9392
]
9493
else:
9594
binary.compiler.cxxflags += [
@@ -105,6 +104,8 @@ for sdk_target in MMSPlugin.sdk_targets:
105104
"/Z7"
106105
]
107106
binary.compiler.postlink += [
107+
os.path.join(builder.sourcePath, 'vendor', 'openssl', 'libcrypto.lib'),
108+
os.path.join(builder.sourcePath, 'vendor', 'openssl', 'libssl.lib'),
108109
"psapi.lib",
109110
"winmm.lib",
110111
"ws2_32.lib",
@@ -146,14 +147,15 @@ for sdk_target in MMSPlugin.sdk_targets:
146147
"META_IS_SOURCE2",
147148
"X64BITS",
148149
"PLATFORM_64BITS",
149-
"NDEBUG"
150+
"NDEBUG",
150151
]
151152

152153
binary.compiler.defines += [
153154
"HAVE_STRUCT_TIMESPEC",
154155
"BUILDING",
155156
"NO_SSL_DL",
156-
"USE_WEBSOCKET"
157+
"USE_WEBSOCKET",
158+
"OPENSSL_API_1_1",
157159
]
158160

159161
if os.getenv("VERSION") != None:

vendor/openssl/aes.h

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
3+
*
4+
* Licensed under the OpenSSL license (the "License"). You may not use
5+
* this file except in compliance with the License. You can obtain a copy
6+
* in the file LICENSE in the source distribution or at
7+
* https://www.openssl.org/source/license.html
8+
*/
9+
10+
#ifndef HEADER_AES_H
11+
# define HEADER_AES_H
12+
13+
# include <openssl/opensslconf.h>
14+
15+
# include <stddef.h>
16+
# ifdef __cplusplus
17+
extern "C" {
18+
# endif
19+
20+
# define AES_ENCRYPT 1
21+
# define AES_DECRYPT 0
22+
23+
/*
24+
* Because array size can't be a const in C, the following two are macros.
25+
* Both sizes are in bytes.
26+
*/
27+
# define AES_MAXNR 14
28+
# define AES_BLOCK_SIZE 16
29+
30+
/* This should be a hidden type, but EVP requires that the size be known */
31+
struct aes_key_st {
32+
# ifdef AES_LONG
33+
unsigned long rd_key[4 * (AES_MAXNR + 1)];
34+
# else
35+
unsigned int rd_key[4 * (AES_MAXNR + 1)];
36+
# endif
37+
int rounds;
38+
};
39+
typedef struct aes_key_st AES_KEY;
40+
41+
const char *AES_options(void);
42+
43+
int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
44+
AES_KEY *key);
45+
int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
46+
AES_KEY *key);
47+
48+
void AES_encrypt(const unsigned char *in, unsigned char *out,
49+
const AES_KEY *key);
50+
void AES_decrypt(const unsigned char *in, unsigned char *out,
51+
const AES_KEY *key);
52+
53+
void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
54+
const AES_KEY *key, const int enc);
55+
void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
56+
size_t length, const AES_KEY *key,
57+
unsigned char *ivec, const int enc);
58+
void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
59+
size_t length, const AES_KEY *key,
60+
unsigned char *ivec, int *num, const int enc);
61+
void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
62+
size_t length, const AES_KEY *key,
63+
unsigned char *ivec, int *num, const int enc);
64+
void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
65+
size_t length, const AES_KEY *key,
66+
unsigned char *ivec, int *num, const int enc);
67+
void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
68+
size_t length, const AES_KEY *key,
69+
unsigned char *ivec, int *num);
70+
/* NB: the IV is _two_ blocks long */
71+
void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
72+
size_t length, const AES_KEY *key,
73+
unsigned char *ivec, const int enc);
74+
/* NB: the IV is _four_ blocks long */
75+
void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,
76+
size_t length, const AES_KEY *key,
77+
const AES_KEY *key2, const unsigned char *ivec,
78+
const int enc);
79+
80+
int AES_wrap_key(AES_KEY *key, const unsigned char *iv,
81+
unsigned char *out,
82+
const unsigned char *in, unsigned int inlen);
83+
int AES_unwrap_key(AES_KEY *key, const unsigned char *iv,
84+
unsigned char *out,
85+
const unsigned char *in, unsigned int inlen);
86+
87+
88+
# ifdef __cplusplus
89+
}
90+
# endif
91+
92+
#endif

vendor/openssl/applink.c

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

0 commit comments

Comments
 (0)