Skip to content

Commit 8e1c768

Browse files
committed
Add support for building MSVC shared libraries
1 parent 7bb1a7e commit 8e1c768

Some content is hidden

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

63 files changed

+831
-641
lines changed

3rdparty/everest/include/everest/everest.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ typedef struct {
5858
*
5959
* \return \c 0 on success.
6060
*/
61-
int mbedtls_everest_setup( mbedtls_ecdh_context_everest *ctx, int grp_id );
61+
MBEDCRYPTO_EXPORT int mbedtls_everest_setup( mbedtls_ecdh_context_everest *ctx, int grp_id );
6262

6363
/**
6464
* \brief This function frees a context.
6565
*
6666
* \param ctx The context to free.
6767
*/
68-
void mbedtls_everest_free( mbedtls_ecdh_context_everest *ctx );
68+
MBEDCRYPTO_EXPORT void mbedtls_everest_free( mbedtls_ecdh_context_everest *ctx );
6969

7070
/**
7171
* \brief This function generates a public key and a TLS
@@ -90,7 +90,7 @@ void mbedtls_everest_free( mbedtls_ecdh_context_everest *ctx );
9090
* \return \c 0 on success.
9191
* \return An \c MBEDTLS_ERR_ECP_XXX error code on failure.
9292
*/
93-
int mbedtls_everest_make_params( mbedtls_ecdh_context_everest *ctx, size_t *olen,
93+
MBEDCRYPTO_EXPORT int mbedtls_everest_make_params( mbedtls_ecdh_context_everest *ctx, size_t *olen,
9494
unsigned char *buf, size_t blen,
9595
int( *f_rng )( void *, unsigned char *, size_t ),
9696
void *p_rng );
@@ -112,7 +112,7 @@ int mbedtls_everest_make_params( mbedtls_ecdh_context_everest *ctx, size_t *olen
112112
* \return An \c MBEDTLS_ERR_ECP_XXX error code on failure.
113113
*
114114
*/
115-
int mbedtls_everest_read_params( mbedtls_ecdh_context_everest *ctx,
115+
MBEDCRYPTO_EXPORT int mbedtls_everest_read_params( mbedtls_ecdh_context_everest *ctx,
116116
const unsigned char **buf, const unsigned char *end );
117117

118118
/**
@@ -132,7 +132,7 @@ int mbedtls_everest_read_params( mbedtls_ecdh_context_everest *ctx,
132132
* \return An \c MBEDTLS_ERR_ECP_XXX error code on failure.
133133
*
134134
*/
135-
int mbedtls_everest_read_params( mbedtls_ecdh_context_everest *ctx,
135+
MBEDCRYPTO_EXPORT int mbedtls_everest_read_params( mbedtls_ecdh_context_everest *ctx,
136136
const unsigned char **buf, const unsigned char *end );
137137

138138
/**
@@ -153,7 +153,7 @@ int mbedtls_everest_read_params( mbedtls_ecdh_context_everest *ctx,
153153
* \return An \c MBEDTLS_ERR_ECP_XXX error code on failure.
154154
*
155155
*/
156-
int mbedtls_everest_get_params( mbedtls_ecdh_context_everest *ctx, const mbedtls_ecp_keypair *key,
156+
MBEDCRYPTO_EXPORT int mbedtls_everest_get_params( mbedtls_ecdh_context_everest *ctx, const mbedtls_ecp_keypair *key,
157157
mbedtls_everest_ecdh_side side );
158158

159159
/**
@@ -175,7 +175,7 @@ int mbedtls_everest_get_params( mbedtls_ecdh_context_everest *ctx, const mbedtls
175175
* \return \c 0 on success.
176176
* \return An \c MBEDTLS_ERR_ECP_XXX error code on failure.
177177
*/
178-
int mbedtls_everest_make_public( mbedtls_ecdh_context_everest *ctx, size_t *olen,
178+
MBEDCRYPTO_EXPORT int mbedtls_everest_make_public( mbedtls_ecdh_context_everest *ctx, size_t *olen,
179179
unsigned char *buf, size_t blen,
180180
int( *f_rng )( void *, unsigned char *, size_t ),
181181
void *p_rng );
@@ -197,7 +197,7 @@ int mbedtls_everest_make_public( mbedtls_ecdh_context_everest *ctx, size_t *olen
197197
* \return \c 0 on success.
198198
* \return An \c MBEDTLS_ERR_ECP_XXX error code on failure.
199199
*/
200-
int mbedtls_everest_read_public( mbedtls_ecdh_context_everest *ctx,
200+
MBEDCRYPTO_EXPORT int mbedtls_everest_read_public( mbedtls_ecdh_context_everest *ctx,
201201
const unsigned char *buf, size_t blen );
202202

203203
/**
@@ -222,7 +222,7 @@ int mbedtls_everest_read_public( mbedtls_ecdh_context_everest *ctx,
222222
* \return \c 0 on success.
223223
* \return An \c MBEDTLS_ERR_ECP_XXX error code on failure.
224224
*/
225-
int mbedtls_everest_calc_secret( mbedtls_ecdh_context_everest *ctx, size_t *olen,
225+
MBEDCRYPTO_EXPORT int mbedtls_everest_calc_secret( mbedtls_ecdh_context_everest *ctx, size_t *olen,
226226
unsigned char *buf, size_t blen,
227227
int( *f_rng )( void *, unsigned char *, size_t ),
228228
void *p_rng );

3rdparty/everest/include/everest/x25519.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ typedef struct
5252
*
5353
* \param ctx The x25519 context to initialize.
5454
*/
55-
void mbedtls_x25519_init( mbedtls_x25519_context *ctx );
55+
MBEDCRYPTO_EXPORT void mbedtls_x25519_init( mbedtls_x25519_context *ctx );
5656

5757
/**
5858
* \brief This function frees a context.
5959
*
6060
* \param ctx The context to free.
6161
*/
62-
void mbedtls_x25519_free( mbedtls_x25519_context *ctx );
62+
MBEDCRYPTO_EXPORT void mbedtls_x25519_free( mbedtls_x25519_context *ctx );
6363

6464
/**
6565
* \brief This function generates a public key and a TLS
@@ -78,7 +78,7 @@ void mbedtls_x25519_free( mbedtls_x25519_context *ctx );
7878
* \return \c 0 on success.
7979
* \return An \c MBEDTLS_ERR_ECP_XXX error code on failure.
8080
*/
81-
int mbedtls_x25519_make_params( mbedtls_x25519_context *ctx, size_t *olen,
81+
MBEDCRYPTO_EXPORT int mbedtls_x25519_make_params( mbedtls_x25519_context *ctx, size_t *olen,
8282
unsigned char *buf, size_t blen,
8383
int( *f_rng )(void *, unsigned char *, size_t),
8484
void *p_rng );
@@ -96,7 +96,7 @@ int mbedtls_x25519_make_params( mbedtls_x25519_context *ctx, size_t *olen,
9696
* \return An \c MBEDTLS_ERR_ECP_XXX error code on failure.
9797
*
9898
*/
99-
int mbedtls_x25519_read_params( mbedtls_x25519_context *ctx,
99+
MBEDCRYPTO_EXPORT int mbedtls_x25519_read_params( mbedtls_x25519_context *ctx,
100100
const unsigned char **buf, const unsigned char *end );
101101

102102
/**
@@ -117,7 +117,7 @@ int mbedtls_x25519_read_params( mbedtls_x25519_context *ctx,
117117
* \return An \c MBEDTLS_ERR_ECP_XXX error code on failure.
118118
*
119119
*/
120-
int mbedtls_x25519_get_params( mbedtls_x25519_context *ctx, const mbedtls_ecp_keypair *key,
120+
MBEDCRYPTO_EXPORT int mbedtls_x25519_get_params( mbedtls_x25519_context *ctx, const mbedtls_ecp_keypair *key,
121121
mbedtls_x25519_ecdh_side side );
122122

123123
/**
@@ -137,7 +137,7 @@ int mbedtls_x25519_get_params( mbedtls_x25519_context *ctx, const mbedtls_ecp_ke
137137
* \return \c 0 on success.
138138
* \return An \c MBEDTLS_ERR_ECP_XXX error code on failure.
139139
*/
140-
int mbedtls_x25519_calc_secret( mbedtls_x25519_context *ctx, size_t *olen,
140+
MBEDCRYPTO_EXPORT int mbedtls_x25519_calc_secret( mbedtls_x25519_context *ctx, size_t *olen,
141141
unsigned char *buf, size_t blen,
142142
int( *f_rng )(void *, unsigned char *, size_t),
143143
void *p_rng );
@@ -160,7 +160,7 @@ int mbedtls_x25519_calc_secret( mbedtls_x25519_context *ctx, size_t *olen,
160160
* \return \c 0 on success.
161161
* \return An \c MBEDTLS_ERR_ECP_XXX error code on failure.
162162
*/
163-
int mbedtls_x25519_make_public( mbedtls_x25519_context *ctx, size_t *olen,
163+
MBEDCRYPTO_EXPORT int mbedtls_x25519_make_public( mbedtls_x25519_context *ctx, size_t *olen,
164164
unsigned char *buf, size_t blen,
165165
int( *f_rng )(void *, unsigned char *, size_t),
166166
void *p_rng );
@@ -180,7 +180,7 @@ int mbedtls_x25519_make_public( mbedtls_x25519_context *ctx, size_t *olen,
180180
* \return \c 0 on success.
181181
* \return An \c MBEDTLS_ERR_ECP_XXX error code on failure.
182182
*/
183-
int mbedtls_x25519_read_public( mbedtls_x25519_context *ctx,
183+
MBEDCRYPTO_EXPORT int mbedtls_x25519_read_public( mbedtls_x25519_context *ctx,
184184
const unsigned char *buf, size_t blen );
185185

186186
#ifdef __cplusplus

include/mbedtls/aes.h

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
#include MBEDTLS_CONFIG_FILE
4848
#endif
4949

50+
#include "mbedtls/export.h"
51+
5052
#include <stddef.h>
5153
#include <stdint.h>
5254

@@ -123,7 +125,7 @@ typedef struct mbedtls_aes_xts_context
123125
*
124126
* \param ctx The AES context to initialize. This must not be \c NULL.
125127
*/
126-
void mbedtls_aes_init( mbedtls_aes_context *ctx );
128+
MBEDCRYPTO_EXPORT void mbedtls_aes_init( mbedtls_aes_context *ctx );
127129

128130
/**
129131
* \brief This function releases and clears the specified AES context.
@@ -132,7 +134,7 @@ void mbedtls_aes_init( mbedtls_aes_context *ctx );
132134
* If this is \c NULL, this function does nothing.
133135
* Otherwise, the context must have been at least initialized.
134136
*/
135-
void mbedtls_aes_free( mbedtls_aes_context *ctx );
137+
MBEDCRYPTO_EXPORT void mbedtls_aes_free( mbedtls_aes_context *ctx );
136138

137139
#if defined(MBEDTLS_CIPHER_MODE_XTS)
138140
/**
@@ -143,7 +145,7 @@ void mbedtls_aes_free( mbedtls_aes_context *ctx );
143145
*
144146
* \param ctx The AES XTS context to initialize. This must not be \c NULL.
145147
*/
146-
void mbedtls_aes_xts_init( mbedtls_aes_xts_context *ctx );
148+
MBEDCRYPTO_EXPORT void mbedtls_aes_xts_init( mbedtls_aes_xts_context *ctx );
147149

148150
/**
149151
* \brief This function releases and clears the specified AES XTS context.
@@ -152,7 +154,7 @@ void mbedtls_aes_xts_init( mbedtls_aes_xts_context *ctx );
152154
* If this is \c NULL, this function does nothing.
153155
* Otherwise, the context must have been at least initialized.
154156
*/
155-
void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx );
157+
MBEDCRYPTO_EXPORT void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx );
156158
#endif /* MBEDTLS_CIPHER_MODE_XTS */
157159

158160
/**
@@ -170,7 +172,7 @@ void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx );
170172
* \return \c 0 on success.
171173
* \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
172174
*/
173-
int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
175+
MBEDCRYPTO_EXPORT int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
174176
unsigned int keybits );
175177

176178
/**
@@ -188,7 +190,7 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
188190
* \return \c 0 on success.
189191
* \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
190192
*/
191-
int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
193+
MBEDCRYPTO_EXPORT int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
192194
unsigned int keybits );
193195

194196
#if defined(MBEDTLS_CIPHER_MODE_XTS)
@@ -208,7 +210,7 @@ int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
208210
* \return \c 0 on success.
209211
* \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
210212
*/
211-
int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx,
213+
MBEDCRYPTO_EXPORT int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx,
212214
const unsigned char *key,
213215
unsigned int keybits );
214216

@@ -228,7 +230,7 @@ int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx,
228230
* \return \c 0 on success.
229231
* \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
230232
*/
231-
int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx,
233+
MBEDCRYPTO_EXPORT int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx,
232234
const unsigned char *key,
233235
unsigned int keybits );
234236
#endif /* MBEDTLS_CIPHER_MODE_XTS */
@@ -256,7 +258,7 @@ int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx,
256258
257259
* \return \c 0 on success.
258260
*/
259-
int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
261+
MBEDCRYPTO_EXPORT int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
260262
int mode,
261263
const unsigned char input[16],
262264
unsigned char output[16] );
@@ -303,7 +305,7 @@ int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
303305
* \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH
304306
* on failure.
305307
*/
306-
int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
308+
MBEDCRYPTO_EXPORT int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
307309
int mode,
308310
size_t length,
309311
unsigned char iv[16],
@@ -347,7 +349,7 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
347349
* smaller than an AES block in size (16 Bytes) or if \p
348350
* length is larger than 2^20 blocks (16 MiB).
349351
*/
350-
int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx,
352+
MBEDCRYPTO_EXPORT int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx,
351353
int mode,
352354
size_t length,
353355
const unsigned char data_unit[16],
@@ -395,7 +397,7 @@ int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx,
395397
*
396398
* \return \c 0 on success.
397399
*/
398-
int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
400+
MBEDCRYPTO_EXPORT int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
399401
int mode,
400402
size_t length,
401403
size_t *iv_off,
@@ -439,7 +441,7 @@ int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
439441
*
440442
* \return \c 0 on success.
441443
*/
442-
int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx,
444+
MBEDCRYPTO_EXPORT int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx,
443445
int mode,
444446
size_t length,
445447
unsigned char iv[16],
@@ -493,7 +495,7 @@ int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx,
493495
*
494496
* \return \c 0 on success.
495497
*/
496-
int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx,
498+
MBEDCRYPTO_EXPORT int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx,
497499
size_t length,
498500
size_t *iv_off,
499501
unsigned char iv[16],
@@ -579,7 +581,7 @@ int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx,
579581
*
580582
* \return \c 0 on success.
581583
*/
582-
int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
584+
MBEDCRYPTO_EXPORT int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
583585
size_t length,
584586
size_t *nc_off,
585587
unsigned char nonce_counter[16],
@@ -599,7 +601,7 @@ int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
599601
*
600602
* \return \c 0 on success.
601603
*/
602-
int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx,
604+
MBEDCRYPTO_EXPORT int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx,
603605
const unsigned char input[16],
604606
unsigned char output[16] );
605607

@@ -614,7 +616,7 @@ int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx,
614616
*
615617
* \return \c 0 on success.
616618
*/
617-
int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx,
619+
MBEDCRYPTO_EXPORT int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx,
618620
const unsigned char input[16],
619621
unsigned char output[16] );
620622

@@ -663,7 +665,7 @@ MBEDTLS_DEPRECATED void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
663665
* \return \c 0 on success.
664666
* \return \c 1 on failure.
665667
*/
666-
int mbedtls_aes_self_test( int verbose );
668+
MBEDCRYPTO_EXPORT int mbedtls_aes_self_test( int verbose );
667669

668670
#endif /* MBEDTLS_SELF_TEST */
669671

include/mbedtls/aesni.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#include MBEDTLS_CONFIG_FILE
3434
#endif
3535

36+
#include "mbedtls/export.h"
37+
3638
#include "mbedtls/aes.h"
3739

3840
#define MBEDTLS_AESNI_AES 0x02000000u
@@ -61,7 +63,7 @@ extern "C" {
6163
*
6264
* \return 1 if CPU has support for the feature, 0 otherwise
6365
*/
64-
int mbedtls_aesni_has_support( unsigned int what );
66+
MBEDCRYPTO_EXPORT int mbedtls_aesni_has_support( unsigned int what );
6567

6668
/**
6769
* \brief Internal AES-NI AES-ECB block encryption and decryption
@@ -76,7 +78,7 @@ int mbedtls_aesni_has_support( unsigned int what );
7678
*
7779
* \return 0 on success (cannot fail)
7880
*/
79-
int mbedtls_aesni_crypt_ecb( mbedtls_aes_context *ctx,
81+
MBEDCRYPTO_EXPORT int mbedtls_aesni_crypt_ecb( mbedtls_aes_context *ctx,
8082
int mode,
8183
const unsigned char input[16],
8284
unsigned char output[16] );
@@ -94,7 +96,7 @@ int mbedtls_aesni_crypt_ecb( mbedtls_aes_context *ctx,
9496
* \note Both operands and result are bit strings interpreted as
9597
* elements of GF(2^128) as per the GCM spec.
9698
*/
97-
void mbedtls_aesni_gcm_mult( unsigned char c[16],
99+
MBEDCRYPTO_EXPORT void mbedtls_aesni_gcm_mult( unsigned char c[16],
98100
const unsigned char a[16],
99101
const unsigned char b[16] );
100102

@@ -109,7 +111,7 @@ void mbedtls_aesni_gcm_mult( unsigned char c[16],
109111
* \param fwdkey Original round keys (for encryption)
110112
* \param nr Number of rounds (that is, number of round keys minus one)
111113
*/
112-
void mbedtls_aesni_inverse_key( unsigned char *invkey,
114+
MBEDCRYPTO_EXPORT void mbedtls_aesni_inverse_key( unsigned char *invkey,
113115
const unsigned char *fwdkey,
114116
int nr );
115117

@@ -125,7 +127,7 @@ void mbedtls_aesni_inverse_key( unsigned char *invkey,
125127
*
126128
* \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_KEY_LENGTH
127129
*/
128-
int mbedtls_aesni_setkey_enc( unsigned char *rk,
130+
MBEDCRYPTO_EXPORT int mbedtls_aesni_setkey_enc( unsigned char *rk,
129131
const unsigned char *key,
130132
size_t bits );
131133

0 commit comments

Comments
 (0)