Skip to content

Commit be79c5b

Browse files
ThePassionatelws-team
authored andcommitted
[PATCH] lws/mbedtls-wrapper: Align SSL_CTX_new function declaration
with OpenSSL SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth) is the declaration of openssl Signed-off-by: makejian <makejian@xiaomi.com>
1 parent c1ceb70 commit be79c5b

File tree

11 files changed

+36
-33
lines changed

11 files changed

+36
-33
lines changed

lib/tls/mbedtls/mbedtls-client.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ lws_tls_client_create_vhost_context(struct lws_vhost *vh,
407407
return 1;
408408
}
409409
/* create context */
410-
vh->tls.ssl_client_ctx = SSL_CTX_new(method, &vh->context->mcdc);
410+
vh->tls.ssl_client_ctx = SSL_CTX_new(method);
411411
if (!vh->tls.ssl_client_ctx) {
412412
error = (unsigned long)ERR_get_error();
413413
lwsl_err("problem creating ssl context %lu: %s\n",
@@ -416,6 +416,7 @@ lws_tls_client_create_vhost_context(struct lws_vhost *vh,
416416
return 1;
417417
}
418418

419+
vh->tls.ssl_client_ctx->rngctx = &vh->context->mcdc;
419420
if (!ca_filepath && (!ca_mem || !ca_mem_len)) {
420421
#if defined(LWS_HAVE_SSL_CTX_load_verify_dir)
421422
if (!SSL_CTX_load_verify_dir(

lib/tls/mbedtls/mbedtls-server.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,13 @@ lws_tls_server_vhost_backend_init(const struct lws_context_creation_info *info,
199199
lws_filepos_t flen;
200200
int n;
201201

202-
vhost->tls.ssl_ctx = SSL_CTX_new(method, &vhost->context->mcdc); /* create context */
202+
vhost->tls.ssl_ctx = SSL_CTX_new(method); /* create context */
203203
if (!vhost->tls.ssl_ctx) {
204204
lwsl_err("problem creating ssl context\n");
205205
return 1;
206206
}
207207

208+
vhost->tls.ssl_ctx->rngctx = &vhost->context->mcdc;
208209
if (!vhost->tls.use_ssl ||
209210
(!info->ssl_cert_filepath && !info->server_ssl_cert_mem))
210211
return 0;

lib/tls/mbedtls/wrapper/include/internal/ssl_cert.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*
2929
* @return certification object point
3030
*/
31-
CERT *__ssl_cert_new(CERT *ic, void *rngctx);
31+
CERT *__ssl_cert_new(CERT *ic);
3232

3333
/**
3434
* @brief create a certification object include private key object
@@ -37,7 +37,7 @@ CERT *__ssl_cert_new(CERT *ic, void *rngctx);
3737
*
3838
* @return certification object point
3939
*/
40-
CERT* ssl_cert_new(void *rngctx);
40+
CERT* ssl_cert_new(void);
4141

4242
/**
4343
* @brief free a certification object

lib/tls/mbedtls/wrapper/include/internal/ssl_pkey.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*
2929
* @return new private key object point
3030
*/
31-
EVP_PKEY* __EVP_PKEY_new(EVP_PKEY *ipk, void *rngctx);
31+
EVP_PKEY* __EVP_PKEY_new(EVP_PKEY *ipk);
3232

3333
/**
3434
* @brief create a private key object
@@ -37,7 +37,7 @@ EVP_PKEY* __EVP_PKEY_new(EVP_PKEY *ipk, void *rngctx);
3737
*
3838
* @return private key object point
3939
*/
40-
EVP_PKEY* EVP_PKEY_new(void *rngctx);
40+
EVP_PKEY* EVP_PKEY_new(void);
4141

4242
/**
4343
* @brief load a character key context into system context. If '*a' is pointed to the
@@ -53,7 +53,7 @@ EVP_PKEY* EVP_PKEY_new(void *rngctx);
5353
EVP_PKEY* d2i_PrivateKey(int type,
5454
EVP_PKEY **a,
5555
const unsigned char **pp,
56-
long length, void *rngctx);
56+
long length);
5757

5858
/**
5959
* @brief free a private key object

lib/tls/mbedtls/wrapper/include/internal/ssl_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ struct x509_method_st {
306306

307307
struct pkey_method_st {
308308

309-
int (*pkey_new)(EVP_PKEY *pkey, EVP_PKEY *m_pkey, void *rngctx);
309+
int (*pkey_new)(EVP_PKEY *pkey, EVP_PKEY *m_pkey);
310310

311311
void (*pkey_free)(EVP_PKEY *pkey);
312312

lib/tls/mbedtls/wrapper/include/openssl/ssl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
*
6161
* @return the context point
6262
*/
63-
SSL_CTX* SSL_CTX_new(const SSL_METHOD *method, void *rngctx);
63+
SSL_CTX* SSL_CTX_new(const SSL_METHOD *method);
6464

6565
/**
6666
* @brief free a SSL context

lib/tls/mbedtls/wrapper/include/platform/ssl_pm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ int x509_pm_load(X509 *x, const unsigned char *buffer, int len);
5050
int x509_pm_load_file(X509 *x, const char *path);
5151
int x509_pm_load_path(X509 *x, const char *path);
5252

53-
int pkey_pm_new(EVP_PKEY *pk, EVP_PKEY *m_pk, void *rngctx);
53+
int pkey_pm_new(EVP_PKEY *pk, EVP_PKEY *m_pk);
5454
void pkey_pm_free(EVP_PKEY *pk);
5555
int pkey_pm_load(EVP_PKEY *pk, const unsigned char *buffer, int len);
5656

lib/tls/mbedtls/wrapper/library/ssl_cert.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
/**
2424
* @brief create a certification object according to input certification
2525
*/
26-
CERT *__ssl_cert_new(CERT *ic, void *rngctx)
26+
CERT *__ssl_cert_new(CERT *ic)
2727
{
2828
CERT *cert;
2929

@@ -44,7 +44,7 @@ CERT *__ssl_cert_new(CERT *ic, void *rngctx)
4444
ix = NULL;
4545
}
4646

47-
cert->pkey = __EVP_PKEY_new(ipk, rngctx);
47+
cert->pkey = __EVP_PKEY_new(ipk);
4848
if (!cert->pkey) {
4949
SSL_DEBUG(SSL_CERT_ERROR_LEVEL, "__EVP_PKEY_new() return NULL");
5050
goto pkey_err;
@@ -69,9 +69,9 @@ CERT *__ssl_cert_new(CERT *ic, void *rngctx)
6969
/**
7070
* @brief create a certification object include private key object
7171
*/
72-
CERT *ssl_cert_new(void *rngctx)
72+
CERT *ssl_cert_new(void)
7373
{
74-
return __ssl_cert_new(NULL, rngctx);
74+
return __ssl_cert_new(NULL);
7575
}
7676

7777
/**

lib/tls/mbedtls/wrapper/library/ssl_lib.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ const char *mbedtls_client_preload_filepath;
185185
/**
186186
* @brief create a SSL context
187187
*/
188-
SSL_CTX* SSL_CTX_new(const SSL_METHOD *method, void *rngctx)
188+
SSL_CTX* SSL_CTX_new(const SSL_METHOD *method)
189189
{
190190
SSL_CTX *ctx;
191191
CERT *cert;
@@ -205,7 +205,7 @@ SSL_CTX* SSL_CTX_new(const SSL_METHOD *method, void *rngctx)
205205
goto failed1;
206206
}
207207

208-
cert = ssl_cert_new(rngctx);
208+
cert = ssl_cert_new();
209209
if (!cert) {
210210
SSL_DEBUG(SSL_LIB_ERROR_LEVEL, "ssl_cert_new() return NULL");
211211
goto failed2;
@@ -220,7 +220,6 @@ SSL_CTX* SSL_CTX_new(const SSL_METHOD *method, void *rngctx)
220220
ctx->method = method;
221221
ctx->client_CA = client_ca;
222222
ctx->cert = cert;
223-
ctx->rngctx = rngctx;
224223

225224
ctx->version = method->version;
226225

@@ -330,7 +329,7 @@ SSL *SSL_new(SSL_CTX *ctx)
330329
goto failed2;
331330
}
332331

333-
ssl->cert = __ssl_cert_new(ctx->cert, ctx->rngctx);
332+
ssl->cert = __ssl_cert_new(ctx->cert);
334333
if (!ssl->cert) {
335334
SSL_DEBUG(SSL_LIB_ERROR_LEVEL, "__ssl_cert_new() return NULL");
336335
goto failed3;

lib/tls/mbedtls/wrapper/library/ssl_pkey.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/**
2323
* @brief create a private key object according to input private key
2424
*/
25-
EVP_PKEY* __EVP_PKEY_new(EVP_PKEY *ipk, void *rngctx)
25+
EVP_PKEY* __EVP_PKEY_new(EVP_PKEY *ipk)
2626
{
2727
int ret;
2828
EVP_PKEY *pkey;
@@ -39,7 +39,7 @@ EVP_PKEY* __EVP_PKEY_new(EVP_PKEY *ipk, void *rngctx)
3939
pkey->method = EVP_PKEY_method();
4040
}
4141

42-
ret = EVP_PKEY_METHOD_CALL(new, pkey, ipk, rngctx);
42+
ret = EVP_PKEY_METHOD_CALL(new, pkey, ipk);
4343
if (ret) {
4444
SSL_DEBUG(SSL_PKEY_ERROR_LEVEL, "EVP_PKEY_METHOD_CALL(new) return %d", ret);
4545
goto failed;
@@ -56,9 +56,9 @@ EVP_PKEY* __EVP_PKEY_new(EVP_PKEY *ipk, void *rngctx)
5656
/**
5757
* @brief create a private key object
5858
*/
59-
EVP_PKEY* EVP_PKEY_new(void *rngctx)
59+
EVP_PKEY* EVP_PKEY_new(void)
6060
{
61-
return __EVP_PKEY_new(NULL, rngctx);
61+
return __EVP_PKEY_new(NULL);
6262
}
6363

6464
/**
@@ -80,7 +80,7 @@ void EVP_PKEY_free(EVP_PKEY *pkey)
8080
EVP_PKEY *d2i_PrivateKey(int type,
8181
EVP_PKEY **a,
8282
const unsigned char **pp,
83-
long length, void *rngctx)
83+
long length)
8484
{
8585
int m = 0;
8686
int ret;
@@ -93,7 +93,7 @@ EVP_PKEY *d2i_PrivateKey(int type,
9393
if (a && *a) {
9494
pkey = *a;
9595
} else {
96-
pkey = EVP_PKEY_new(rngctx);
96+
pkey = EVP_PKEY_new();
9797
if (!pkey) {
9898
SSL_DEBUG(SSL_PKEY_ERROR_LEVEL, "EVP_PKEY_new() return NULL");
9999
goto failed1;
@@ -167,7 +167,7 @@ int SSL_CTX_use_PrivateKey_ASN1(int type, SSL_CTX *ctx,
167167
int ret;
168168
EVP_PKEY *pk;
169169

170-
pk = d2i_PrivateKey(0, NULL, &d, len, ctx->rngctx);
170+
pk = d2i_PrivateKey(0, NULL, &d, len);
171171
if (!pk) {
172172
SSL_DEBUG(SSL_PKEY_ERROR_LEVEL, "d2i_PrivateKey() return NULL");
173173
goto failed1;
@@ -196,7 +196,7 @@ int SSL_use_PrivateKey_ASN1(int type, SSL *ssl,
196196
int ret;
197197
EVP_PKEY *pk;
198198

199-
pk = d2i_PrivateKey(0, NULL, &d, len, ssl->ctx->rngctx);
199+
pk = d2i_PrivateKey(0, NULL, &d, len);
200200
if (!pk) {
201201
SSL_DEBUG(SSL_PKEY_ERROR_LEVEL, "d2i_PrivateKey() return NULL");
202202
goto failed1;

0 commit comments

Comments
 (0)