forked from wolfSSL/wolfssl
Compiling with g++ when configured with --enable-distro
This commit is contained in:
11
src/crl.c
11
src/crl.c
@ -95,11 +95,12 @@ static int InitCRL_Entry(CRL_Entry* crle, DecodedCRL* dcrl, const byte* buff,
|
|||||||
crle->tbsSz = dcrl->sigIndex - dcrl->certBegin;
|
crle->tbsSz = dcrl->sigIndex - dcrl->certBegin;
|
||||||
crle->signatureSz = dcrl->sigLength;
|
crle->signatureSz = dcrl->sigLength;
|
||||||
crle->signatureOID = dcrl->signatureOID;
|
crle->signatureOID = dcrl->signatureOID;
|
||||||
crle->toBeSigned = XMALLOC(crle->tbsSz, heap, DYNAMIC_TYPE_CRL_ENTRY);
|
crle->toBeSigned = (byte*)XMALLOC(crle->tbsSz, heap,
|
||||||
|
DYNAMIC_TYPE_CRL_ENTRY);
|
||||||
if (crle->toBeSigned == NULL)
|
if (crle->toBeSigned == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
crle->signature = XMALLOC(crle->signatureSz, heap,
|
crle->signature = (byte*)XMALLOC(crle->signatureSz, heap,
|
||||||
DYNAMIC_TYPE_CRL_ENTRY);
|
DYNAMIC_TYPE_CRL_ENTRY);
|
||||||
if (crle->signature == NULL) {
|
if (crle->signature == NULL) {
|
||||||
XFREE(crle->toBeSigned, heap, DYNAMIC_TYPE_CRL_ENTRY);
|
XFREE(crle->toBeSigned, heap, DYNAMIC_TYPE_CRL_ENTRY);
|
||||||
return -1;
|
return -1;
|
||||||
@ -214,12 +215,12 @@ static int CheckCertCRLList(WOLFSSL_CRL* crl, DecodedCert* cert, int *pFoundEntr
|
|||||||
word32 sigOID = crle->signatureOID;
|
word32 sigOID = crle->signatureOID;
|
||||||
SignatureCtx sigCtx;
|
SignatureCtx sigCtx;
|
||||||
|
|
||||||
tbs = XMALLOC(tbsSz, crl->heap, DYNAMIC_TYPE_CRL_ENTRY);
|
tbs = (byte*)XMALLOC(tbsSz, crl->heap, DYNAMIC_TYPE_CRL_ENTRY);
|
||||||
if (tbs == NULL) {
|
if (tbs == NULL) {
|
||||||
wc_UnLockMutex(&crl->crlLock);
|
wc_UnLockMutex(&crl->crlLock);
|
||||||
return MEMORY_E;
|
return MEMORY_E;
|
||||||
}
|
}
|
||||||
sig = XMALLOC(sigSz, crl->heap, DYNAMIC_TYPE_CRL_ENTRY);
|
sig = (byte*)XMALLOC(sigSz, crl->heap, DYNAMIC_TYPE_CRL_ENTRY);
|
||||||
if (sig == NULL) {
|
if (sig == NULL) {
|
||||||
XFREE(tbs, crl->heap, DYNAMIC_TYPE_CRL_ENTRY);
|
XFREE(tbs, crl->heap, DYNAMIC_TYPE_CRL_ENTRY);
|
||||||
wc_UnLockMutex(&crl->crlLock);
|
wc_UnLockMutex(&crl->crlLock);
|
||||||
|
@ -21453,7 +21453,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
|||||||
else {
|
else {
|
||||||
#ifdef WOLFSSL_TLS13
|
#ifdef WOLFSSL_TLS13
|
||||||
/* Client adds to ticket age to obfuscate. */
|
/* Client adds to ticket age to obfuscate. */
|
||||||
ret = wc_RNG_GenerateBlock(ssl->rng, (void*)&it.ageAdd,
|
ret = wc_RNG_GenerateBlock(ssl->rng, (byte*)&it.ageAdd,
|
||||||
sizeof(it.ageAdd));
|
sizeof(it.ageAdd));
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return BAD_TICKET_ENCRYPT;
|
return BAD_TICKET_ENCRYPT;
|
||||||
|
36
src/tls.c
36
src/tls.c
@ -4269,7 +4269,7 @@ int TLSX_UseQSHScheme(TLSX** extensions, word16 name, byte* pKey, word16 pkeySz,
|
|||||||
* data The SSL/TLS object.
|
* data The SSL/TLS object.
|
||||||
* returns the length of data that will be in the extension.
|
* returns the length of data that will be in the extension.
|
||||||
*/
|
*/
|
||||||
static word16 TLSX_SupportedVersions_GetSize(byte* data)
|
static word16 TLSX_SupportedVersions_GetSize(void* data)
|
||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
|
|
||||||
@ -4290,7 +4290,7 @@ static word16 TLSX_SupportedVersions_GetSize(byte* data)
|
|||||||
* output The buffer to write the extension into.
|
* output The buffer to write the extension into.
|
||||||
* returns the length of data that was written.
|
* returns the length of data that was written.
|
||||||
*/
|
*/
|
||||||
static word16 TLSX_SupportedVersions_Write(byte* data, byte* output)
|
static word16 TLSX_SupportedVersions_Write(void* data, byte* output)
|
||||||
{
|
{
|
||||||
WOLFSSL* ssl = (WOLFSSL*)data;
|
WOLFSSL* ssl = (WOLFSSL*)data;
|
||||||
ProtocolVersion pv = ssl->ctx->method->version;
|
ProtocolVersion pv = ssl->ctx->method->version;
|
||||||
@ -4426,7 +4426,7 @@ static int TLSX_SetSupportedVersions(TLSX** extensions, const void* data,
|
|||||||
* data Unused
|
* data Unused
|
||||||
* returns the length of data that will be in the extension.
|
* returns the length of data that will be in the extension.
|
||||||
*/
|
*/
|
||||||
static word16 TLSX_SignatureAlgorithms_GetSize(byte* data)
|
static word16 TLSX_SignatureAlgorithms_GetSize(void* data)
|
||||||
{
|
{
|
||||||
WOLFSSL* ssl = (WOLFSSL*)data;
|
WOLFSSL* ssl = (WOLFSSL*)data;
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
@ -4488,7 +4488,7 @@ static word16 TLSX_SignatureAlgorithms_GetSize(byte* data)
|
|||||||
* output The buffer to write the extension into.
|
* output The buffer to write the extension into.
|
||||||
* returns the length of data that was written.
|
* returns the length of data that was written.
|
||||||
*/
|
*/
|
||||||
static word16 TLSX_SignatureAlgorithms_Write(byte* data, byte* output)
|
static word16 TLSX_SignatureAlgorithms_Write(void* data, byte* output)
|
||||||
{
|
{
|
||||||
WOLFSSL* ssl = (WOLFSSL*)data;
|
WOLFSSL* ssl = (WOLFSSL*)data;
|
||||||
int idx = OPAQUE16_LEN;
|
int idx = OPAQUE16_LEN;
|
||||||
@ -4700,7 +4700,8 @@ static int TLSX_KeyShare_GenDhKey(WOLFSSL *ssl, KeyShareEntry* kse)
|
|||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
/* Generate a new key pair. */
|
/* Generate a new key pair. */
|
||||||
ret = wc_DhGenerateKeyPair(&dhKey, ssl->rng, key, &keySz, keyData, &dataSz);
|
ret = wc_DhGenerateKeyPair(&dhKey, ssl->rng, (byte*)key, &keySz, keyData,
|
||||||
|
&dataSz);
|
||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||||
/* TODO: Make this function non-blocking */
|
/* TODO: Make this function non-blocking */
|
||||||
if (ret == WC_PENDING_E) {
|
if (ret == WC_PENDING_E) {
|
||||||
@ -4812,7 +4813,8 @@ static int TLSX_KeyShare_GenEccKey(WOLFSSL *ssl, KeyShareEntry* kse)
|
|||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
/* Allocate space for the public key. */
|
/* Allocate space for the public key. */
|
||||||
keyData = XMALLOC(dataSize, ssl->heap, DYNAMIC_TYPE_TLSX);
|
keyData = (byte*)XMALLOC(dataSize, ssl->heap,
|
||||||
|
DYNAMIC_TYPE_TLSX);
|
||||||
if (keyData == NULL) {
|
if (keyData == NULL) {
|
||||||
WOLFSSL_MSG("Key data Memory error");
|
WOLFSSL_MSG("Key data Memory error");
|
||||||
ret = MEMORY_E;
|
ret = MEMORY_E;
|
||||||
@ -4870,7 +4872,7 @@ static int TLSX_KeyShare_GenEccKey(WOLFSSL *ssl, KeyShareEntry* kse)
|
|||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
/* Allocate space for the public key. */
|
/* Allocate space for the public key. */
|
||||||
keyData = XMALLOC(dataSize, ssl->heap, DYNAMIC_TYPE_TLSX);
|
keyData = (byte*)XMALLOC(dataSize, ssl->heap, DYNAMIC_TYPE_TLSX);
|
||||||
if (keyData == NULL) {
|
if (keyData == NULL) {
|
||||||
WOLFSSL_MSG("Key data Memory error");
|
WOLFSSL_MSG("Key data Memory error");
|
||||||
ret = MEMORY_E;
|
ret = MEMORY_E;
|
||||||
@ -5100,7 +5102,7 @@ static int TLSX_KeyShare_ProcessDh(WOLFSSL* ssl, KeyShareEntry* keyShareEntry)
|
|||||||
/* Derive secret from private key and peer's public key. */
|
/* Derive secret from private key and peer's public key. */
|
||||||
ret = wc_DhAgree(&dhKey,
|
ret = wc_DhAgree(&dhKey,
|
||||||
ssl->arrays->preMasterSecret, &ssl->arrays->preMasterSz,
|
ssl->arrays->preMasterSecret, &ssl->arrays->preMasterSz,
|
||||||
keyShareEntry->key, keyShareEntry->keyLen,
|
(const byte*)keyShareEntry->key, keyShareEntry->keyLen,
|
||||||
keyShareEntry->ke, keyShareEntry->keLen);
|
keyShareEntry->ke, keyShareEntry->keLen);
|
||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||||
/* TODO: Make this function non-blocking */
|
/* TODO: Make this function non-blocking */
|
||||||
@ -5313,7 +5315,7 @@ static int TLSX_KeyShareEntry_Parse(WOLFSSL* ssl, byte* input, word16 length,
|
|||||||
return BUFFER_ERROR;
|
return BUFFER_ERROR;
|
||||||
|
|
||||||
/* Store a copy in the key share object. */
|
/* Store a copy in the key share object. */
|
||||||
ke = XMALLOC(keLen, ssl->heap, DYNAMIC_TYPE_TLSX);
|
ke = (byte*)XMALLOC(keLen, ssl->heap, DYNAMIC_TYPE_TLSX);
|
||||||
if (ke == NULL)
|
if (ke == NULL)
|
||||||
return MEMORY_E;
|
return MEMORY_E;
|
||||||
XMEMCPY(ke, &input[offset], keLen);
|
XMEMCPY(ke, &input[offset], keLen);
|
||||||
@ -5547,7 +5549,7 @@ int TLSX_KeyShare_Empty(WOLFSSL* ssl)
|
|||||||
ret = TLSX_Push(&ssl->extensions, TLSX_KEY_SHARE, NULL, ssl->heap);
|
ret = TLSX_Push(&ssl->extensions, TLSX_KEY_SHARE, NULL, ssl->heap);
|
||||||
}
|
}
|
||||||
else if (extension->data != NULL) {
|
else if (extension->data != NULL) {
|
||||||
TLSX_KeyShare_FreeAll(extension->data, ssl->heap);
|
TLSX_KeyShare_FreeAll((KeyShareEntry*)extension->data, ssl->heap);
|
||||||
extension->data = NULL;
|
extension->data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5643,7 +5645,7 @@ static int TLSX_KeyShare_SetSupported(WOLFSSL* ssl)
|
|||||||
/* Delete the old key share data list. */
|
/* Delete the old key share data list. */
|
||||||
extension = TLSX_Find(ssl->extensions, TLSX_KEY_SHARE);
|
extension = TLSX_Find(ssl->extensions, TLSX_KEY_SHARE);
|
||||||
if (extension != NULL) {
|
if (extension != NULL) {
|
||||||
TLSX_KeyShare_FreeAll(extension->data, ssl->heap);
|
TLSX_KeyShare_FreeAll((KeyShareEntry*)extension->data, ssl->heap);
|
||||||
extension->data = NULL;
|
extension->data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6532,12 +6534,12 @@ static word16 TLSX_GetSize(TLSX* list, byte* semaphore, byte msgType)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TLSX_KEY_SHARE:
|
case TLSX_KEY_SHARE:
|
||||||
length += KS_GET_SIZE(extension->data, msgType);
|
length += KS_GET_SIZE((KeyShareEntry*)extension->data, msgType);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifndef NO_PSK
|
#ifndef NO_PSK
|
||||||
case TLSX_PRE_SHARED_KEY:
|
case TLSX_PRE_SHARED_KEY:
|
||||||
length += PSK_GET_SIZE(extension->data, msgType);
|
length += PSK_GET_SIZE((PreSharedKey*)extension->data, msgType);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TLSX_PSK_KEY_EXCHANGE_MODES:
|
case TLSX_PSK_KEY_EXCHANGE_MODES:
|
||||||
@ -6659,13 +6661,15 @@ static word16 TLSX_Write(TLSX* list, byte* output, byte* semaphore,
|
|||||||
|
|
||||||
case TLSX_KEY_SHARE:
|
case TLSX_KEY_SHARE:
|
||||||
WOLFSSL_MSG("Key Share extension to write");
|
WOLFSSL_MSG("Key Share extension to write");
|
||||||
offset += KS_WRITE(extension->data, output + offset, msgType);
|
offset += KS_WRITE((KeyShareEntry*)extension->data,
|
||||||
|
output + offset, msgType);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifndef NO_PSK
|
#ifndef NO_PSK
|
||||||
case TLSX_PRE_SHARED_KEY:
|
case TLSX_PRE_SHARED_KEY:
|
||||||
WOLFSSL_MSG("Pre-Shared Key extension to write");
|
WOLFSSL_MSG("Pre-Shared Key extension to write");
|
||||||
offset += PSK_WRITE(extension->data, output + offset, msgType);
|
offset += PSK_WRITE((PreSharedKey*)extension->data,
|
||||||
|
output + offset, msgType);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TLSX_PSK_KEY_EXCHANGE_MODES:
|
case TLSX_PSK_KEY_EXCHANGE_MODES:
|
||||||
@ -7160,7 +7164,7 @@ int TLSX_PopulateExtensions(WOLFSSL* ssl, byte isServer)
|
|||||||
/* Pre-shared key is mandatory extension for resumption. */
|
/* Pre-shared key is mandatory extension for resumption. */
|
||||||
ret = TLSX_PreSharedKey_Use(ssl, sess->ticket, sess->ticketLen,
|
ret = TLSX_PreSharedKey_Use(ssl, sess->ticket, sess->ticketLen,
|
||||||
milli, ssl->specs.mac_algorithm, 1,
|
milli, ssl->specs.mac_algorithm, 1,
|
||||||
ssl->heap);
|
NULL);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
14
src/tls13.c
14
src/tls13.c
@ -1730,14 +1730,15 @@ static int WritePSKBinders(WOLFSSL* ssl, byte* output, word32 idx)
|
|||||||
return SANITY_MSG_E;
|
return SANITY_MSG_E;
|
||||||
|
|
||||||
/* Get the size of the binders to determine where to write binders. */
|
/* Get the size of the binders to determine where to write binders. */
|
||||||
idx -= TLSX_PreSharedKey_GetSizeBinders(ext->data, client_hello);
|
idx -= TLSX_PreSharedKey_GetSizeBinders((PreSharedKey*)ext->data,
|
||||||
|
client_hello);
|
||||||
|
|
||||||
/* Hash truncated ClientHello - up to binders. */
|
/* Hash truncated ClientHello - up to binders. */
|
||||||
ret = HashOutput(ssl, output, idx, 0);
|
ret = HashOutput(ssl, output, idx, 0);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
current = ext->data;
|
current = (PreSharedKey*)ext->data;
|
||||||
/* Calculate the binder for each identity based on previous handshake data.
|
/* Calculate the binder for each identity based on previous handshake data.
|
||||||
*/
|
*/
|
||||||
while (current != NULL) {
|
while (current != NULL) {
|
||||||
@ -1792,7 +1793,8 @@ static int WritePSKBinders(WOLFSSL* ssl, byte* output, word32 idx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Data entered into extension, now write to message. */
|
/* Data entered into extension, now write to message. */
|
||||||
len = TLSX_PreSharedKey_WriteBinders(ext->data, output + idx, client_hello);
|
len = TLSX_PreSharedKey_WriteBinders((PreSharedKey*)ext->data, output + idx,
|
||||||
|
client_hello);
|
||||||
|
|
||||||
/* Hash binders to complete the hash of the ClientHello. */
|
/* Hash binders to complete the hash of the ClientHello. */
|
||||||
return HashOutputRaw(ssl, output + idx, len);
|
return HashOutputRaw(ssl, output + idx, len);
|
||||||
@ -2264,7 +2266,8 @@ static int DoPreSharedKeys(WOLFSSL *ssl, const byte* input, word32 helloSz,
|
|||||||
/* Find the pre-shared key extension and calculate hash of truncated
|
/* Find the pre-shared key extension and calculate hash of truncated
|
||||||
* ClientHello for binders.
|
* ClientHello for binders.
|
||||||
*/
|
*/
|
||||||
bindersLen = TLSX_PreSharedKey_GetSizeBinders(ext->data, client_hello);
|
bindersLen = TLSX_PreSharedKey_GetSizeBinders((PreSharedKey*)ext->data,
|
||||||
|
client_hello);
|
||||||
|
|
||||||
/* Hash data up to binders for deriving binders in PSK extension. */
|
/* Hash data up to binders for deriving binders in PSK extension. */
|
||||||
ret = HashInput(ssl, input, helloSz - bindersLen);
|
ret = HashInput(ssl, input, helloSz - bindersLen);
|
||||||
@ -3909,7 +3912,8 @@ static int DoTls13CertificateVerify(WOLFSSL* ssl, byte* input,
|
|||||||
WOLFSSL_MSG("Oops, peer sent RSA key but not in verify");
|
WOLFSSL_MSG("Oops, peer sent RSA key but not in verify");
|
||||||
}
|
}
|
||||||
|
|
||||||
sig->buffer = XMALLOC(args->sz, ssl->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
sig->buffer = (byte*)XMALLOC(args->sz, ssl->heap,
|
||||||
|
DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
if (sig->buffer == NULL) {
|
if (sig->buffer == NULL) {
|
||||||
ERROR_OUT(MEMORY_E, exit_dcv);
|
ERROR_OUT(MEMORY_E, exit_dcv);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user