mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 12:14:38 +02:00
adding implementation of wolfSSL_get_client_ciphers
This commit is contained in:
@@ -8364,6 +8364,8 @@ void FreeSuites(WOLFSSL* ssl)
|
|||||||
wolfSSL_sk_SSL_CIPHER_free(ssl->suitesStack);
|
wolfSSL_sk_SSL_CIPHER_free(ssl->suitesStack);
|
||||||
ssl->suitesStack = NULL;
|
ssl->suitesStack = NULL;
|
||||||
}
|
}
|
||||||
|
XFREE(ssl->clSuites, ssl->heap, DYNAMIC_TYPE_SUITES);
|
||||||
|
ssl->clSuites = NULL;
|
||||||
#endif
|
#endif
|
||||||
XFREE(ssl->suites, ssl->heap, DYNAMIC_TYPE_SUITES);
|
XFREE(ssl->suites, ssl->heap, DYNAMIC_TYPE_SUITES);
|
||||||
ssl->suites = NULL;
|
ssl->suites = NULL;
|
||||||
@@ -37553,7 +37555,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
|||||||
{
|
{
|
||||||
byte b;
|
byte b;
|
||||||
ProtocolVersion pv;
|
ProtocolVersion pv;
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
#if defined(WOLFSSL_SMALL_STACK) || defined(OPENSSL_ALL)
|
||||||
Suites* clSuites = NULL;
|
Suites* clSuites = NULL;
|
||||||
#else
|
#else
|
||||||
Suites clSuites[1];
|
Suites clSuites[1];
|
||||||
@@ -37855,13 +37857,14 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
#if defined(WOLFSSL_SMALL_STACK) || defined(OPENSSL_ALL)
|
||||||
clSuites = (Suites*)XMALLOC(sizeof(Suites), ssl->heap,
|
clSuites = (Suites*)XMALLOC(sizeof(Suites), ssl->heap,
|
||||||
DYNAMIC_TYPE_SUITES);
|
DYNAMIC_TYPE_SUITES);
|
||||||
if (clSuites == NULL) {
|
if (clSuites == NULL) {
|
||||||
ret = MEMORY_E;
|
ret = MEMORY_E;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
ssl->clSuites = clSuites;
|
||||||
#endif
|
#endif
|
||||||
XMEMSET(clSuites, 0, sizeof(Suites));
|
XMEMSET(clSuites, 0, sizeof(Suites));
|
||||||
ato16(&input[i], &clSuites->suiteSz);
|
ato16(&input[i], &clSuites->suiteSz);
|
||||||
@@ -38140,13 +38143,6 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OPENSSL_EXTRA
|
#ifdef OPENSSL_EXTRA
|
||||||
ssl->clSuites = clSuites; /* cppcheck-suppress autoVariables
|
|
||||||
*
|
|
||||||
* (suppress warning that ssl, a persistent
|
|
||||||
* non-local allocation, has its ->clSuites
|
|
||||||
* set to clSuites, a local stack allocation.
|
|
||||||
* we clear this assignment before returning.)
|
|
||||||
*/
|
|
||||||
/* Give user last chance to provide a cert for cipher selection */
|
/* Give user last chance to provide a cert for cipher selection */
|
||||||
if (ret == 0 && ssl->ctx->certSetupCb != NULL)
|
if (ret == 0 && ssl->ctx->certSetupCb != NULL)
|
||||||
ret = CertSetupCbWrapper(ssl);
|
ret = CertSetupCbWrapper(ssl);
|
||||||
@@ -38170,10 +38166,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
out:
|
out:
|
||||||
#if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY)
|
#if defined(WOLFSSL_SMALL_STACK) && !defined(OPENSSL_ALL)
|
||||||
ssl->clSuites = NULL;
|
|
||||||
#endif
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
|
||||||
XFREE(clSuites, ssl->heap, DYNAMIC_TYPE_SUITES);
|
XFREE(clSuites, ssl->heap, DYNAMIC_TYPE_SUITES);
|
||||||
#endif
|
#endif
|
||||||
WOLFSSL_LEAVE("DoClientHello", ret);
|
WOLFSSL_LEAVE("DoClientHello", ret);
|
||||||
|
82
src/ssl.c
82
src/ssl.c
@@ -15046,16 +15046,6 @@ word32 wolfSSL_lib_version_hex(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef OPENSSL_EXTRA
|
|
||||||
WOLF_STACK_OF(WOLFSSL_CIPHER)* wolfSSL_get_client_ciphers(WOLFSSL* ssl)
|
|
||||||
{
|
|
||||||
WOLFSSL_STUB("wolfSSL_get_client_ciphers");
|
|
||||||
(void)ssl;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
int wolfSSL_get_current_cipher_suite(WOLFSSL* ssl)
|
int wolfSSL_get_current_cipher_suite(WOLFSSL* ssl)
|
||||||
{
|
{
|
||||||
WOLFSSL_ENTER("wolfSSL_get_current_cipher_suite");
|
WOLFSSL_ENTER("wolfSSL_get_current_cipher_suite");
|
||||||
@@ -21916,6 +21906,78 @@ WOLF_STACK_OF(WOLFSSL_CIPHER) *wolfSSL_get_ciphers_compat(const WOLFSSL *ssl)
|
|||||||
return ssl->suitesStack;
|
return ssl->suitesStack;
|
||||||
}
|
}
|
||||||
#endif /* OPENSSL_EXTRA || OPENSSL_ALL || WOLFSSL_NGINX || WOLFSSL_HAPROXY */
|
#endif /* OPENSSL_EXTRA || OPENSSL_ALL || WOLFSSL_NGINX || WOLFSSL_HAPROXY */
|
||||||
|
#ifdef OPENSSL_ALL
|
||||||
|
WOLF_STACK_OF(WOLFSSL_CIPHER)* wolfSSL_get_client_ciphers(WOLFSSL* ssl)
|
||||||
|
{
|
||||||
|
WOLF_STACK_OF(WOLFSSL_CIPHER)* ret = NULL;
|
||||||
|
const CipherSuiteInfo* cipher_names = GetCipherNames();
|
||||||
|
int cipherSz = GetCipherNamesSize();
|
||||||
|
const Suites* suites;
|
||||||
|
|
||||||
|
WOLFSSL_ENTER("wolfSSL_get_client_ciphers");
|
||||||
|
|
||||||
|
if (ssl == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* return NULL if is client side */
|
||||||
|
if (wolfSSL_is_server(ssl) == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
suites = ssl->clSuites;
|
||||||
|
if (suites == NULL) {
|
||||||
|
WOLFSSL_MSG("No client suites stored");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
/* higher priority of cipher suite will be on top of stack */
|
||||||
|
for (i = suites->suiteSz - 2; i >=0; i-=2) {
|
||||||
|
WOLFSSL_STACK* add;
|
||||||
|
|
||||||
|
/* A couple of suites are placeholders for special options,
|
||||||
|
* skip those. */
|
||||||
|
if (SCSV_Check(suites->suites[i], suites->suites[i+1])
|
||||||
|
|| sslCipherMinMaxCheck(ssl, suites->suites[i],
|
||||||
|
suites->suites[i+1])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
add = wolfSSL_sk_new_node(ssl->heap);
|
||||||
|
if (add != NULL) {
|
||||||
|
add->type = STACK_TYPE_CIPHER;
|
||||||
|
add->data.cipher.cipherSuite0 = suites->suites[i];
|
||||||
|
add->data.cipher.cipherSuite = suites->suites[i+1];
|
||||||
|
add->data.cipher.ssl = ssl;
|
||||||
|
for (j = 0; j < cipherSz; j++) {
|
||||||
|
if (cipher_names[j].cipherSuite0 ==
|
||||||
|
add->data.cipher.cipherSuite0 &&
|
||||||
|
cipher_names[j].cipherSuite ==
|
||||||
|
add->data.cipher.cipherSuite) {
|
||||||
|
add->data.cipher.offset = (unsigned long)j;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* in_stack is checked in wolfSSL_CIPHER_description */
|
||||||
|
add->data.cipher.in_stack = 1;
|
||||||
|
|
||||||
|
add->next = ret;
|
||||||
|
if (ret != NULL) {
|
||||||
|
add->num = ret->num + 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
add->num = 1;
|
||||||
|
}
|
||||||
|
ret = add;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif /* OPENSSL_ALL */
|
||||||
|
|
||||||
#if defined(OPENSSL_EXTRA) || defined(HAVE_SECRET_CALLBACK)
|
#if defined(OPENSSL_EXTRA) || defined(HAVE_SECRET_CALLBACK)
|
||||||
long wolfSSL_SSL_CTX_get_timeout(const WOLFSSL_CTX *ctx)
|
long wolfSSL_SSL_CTX_get_timeout(const WOLFSSL_CTX *ctx)
|
||||||
|
10
src/tls13.c
10
src/tls13.c
@@ -6682,17 +6682,19 @@ typedef struct Dch13Args {
|
|||||||
|
|
||||||
static void FreeDch13Args(WOLFSSL* ssl, void* pArgs)
|
static void FreeDch13Args(WOLFSSL* ssl, void* pArgs)
|
||||||
{
|
{
|
||||||
|
/* openssl compat builds hang on to the client suites until WOLFSSL object
|
||||||
|
* is destroyed */
|
||||||
|
#ifndef OPENSSL_EXTRA
|
||||||
Dch13Args* args = (Dch13Args*)pArgs;
|
Dch13Args* args = (Dch13Args*)pArgs;
|
||||||
|
|
||||||
(void)ssl;
|
|
||||||
|
|
||||||
if (args && args->clSuites) {
|
if (args && args->clSuites) {
|
||||||
XFREE(args->clSuites, ssl->heap, DYNAMIC_TYPE_SUITES);
|
XFREE(args->clSuites, ssl->heap, DYNAMIC_TYPE_SUITES);
|
||||||
args->clSuites = NULL;
|
args->clSuites = NULL;
|
||||||
}
|
}
|
||||||
#ifdef OPENSSL_EXTRA
|
|
||||||
ssl->clSuites = NULL;
|
|
||||||
#endif
|
#endif
|
||||||
|
(void)ssl;
|
||||||
|
(void)pArgs;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int DoTls13ClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
int DoTls13ClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
||||||
|
@@ -5786,7 +5786,7 @@ struct WOLFSSL {
|
|||||||
* object needs separate instance of suites use
|
* object needs separate instance of suites use
|
||||||
* AllocateSuites(). */
|
* AllocateSuites(). */
|
||||||
#ifdef OPENSSL_EXTRA
|
#ifdef OPENSSL_EXTRA
|
||||||
const Suites* clSuites;
|
Suites* clSuites;
|
||||||
#endif
|
#endif
|
||||||
#if defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL) || \
|
#if defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL) || \
|
||||||
defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY)
|
defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY)
|
||||||
|
Reference in New Issue
Block a user