Merge pull request #1657 from JacobBarthelmeh/Testing

casts for tls 1.3 windows warnings
This commit is contained in:
Sean Parkinson 2018-07-03 08:25:01 +10:00 committed by GitHub
commit 52d9803d72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 23 deletions

View File

@ -12640,8 +12640,8 @@ int ProcessReply(WOLFSSL* ssl)
ssl->keys.decryptedCur = 1; ssl->keys.decryptedCur = 1;
#ifdef WOLFSSL_TLS13 #ifdef WOLFSSL_TLS13
if (ssl->options.tls1_3) { if (ssl->options.tls1_3) {
word16 i = ssl->buffers.inputBuffer.length - word16 i = (word16)(ssl->buffers.inputBuffer.length -
ssl->keys.padSz; ssl->keys.padSz);
/* Remove padding from end of plain text. */ /* Remove padding from end of plain text. */
for (--i; i > ssl->buffers.inputBuffer.idx; i--) { for (--i; i > ssl->buffers.inputBuffer.idx; i--) {
if (ssl->buffers.inputBuffer.buffer[i] != 0) if (ssl->buffers.inputBuffer.buffer[i] != 0)
@ -20478,7 +20478,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
/* TLS v1.3 capable server downgraded. */ /* TLS v1.3 capable server downgraded. */
XMEMCPY(output + idx + RAN_LEN - (TLS13_DOWNGRADE_SZ + 1), XMEMCPY(output + idx + RAN_LEN - (TLS13_DOWNGRADE_SZ + 1),
tls13Downgrade, TLS13_DOWNGRADE_SZ); tls13Downgrade, TLS13_DOWNGRADE_SZ);
output[idx + RAN_LEN - 1] = IsAtLeastTLSv1_2(ssl); output[idx + RAN_LEN - 1] = (byte)IsAtLeastTLSv1_2(ssl);
} }
else else
#endif #endif

View File

@ -5211,7 +5211,7 @@ static int TLSX_SupportedVersions_Write(void* data, byte* output,
#endif #endif
*(output++) = pv.major; *(output++) = pv.major;
*(output++) = pv.minor - i; *(output++) = (byte)(pv.minor - i);
} }
*pSz += (word16)(OPAQUE8_LEN + cnt * OPAQUE16_LEN); *pSz += (word16)(OPAQUE8_LEN + cnt * OPAQUE16_LEN);
@ -6225,10 +6225,10 @@ static word16 TLSX_KeyShare_Write(KeyShareEntry* list, byte* output,
c16toa(current->group, &output[i]); c16toa(current->group, &output[i]);
i += KE_GROUP_LEN; i += KE_GROUP_LEN;
c16toa(current->pubKeyLen, &output[i]); c16toa((word16)(current->pubKeyLen), &output[i]);
i += OPAQUE16_LEN; i += OPAQUE16_LEN;
XMEMCPY(&output[i], current->pubKey, current->pubKeyLen); XMEMCPY(&output[i], current->pubKey, current->pubKeyLen);
i += current->pubKeyLen; i += (word16)current->pubKeyLen;
} }
/* Write the length of the list if required. */ /* Write the length of the list if required. */
if (isRequest) if (isRequest)
@ -6766,7 +6766,7 @@ static int TLSX_KeyShare_New(KeyShareEntry** list, int group, void *heap,
return MEMORY_E; return MEMORY_E;
XMEMSET(kse, 0, sizeof(*kse)); XMEMSET(kse, 0, sizeof(*kse));
kse->group = group; kse->group = (word16)group;
/* Add it to the back and maintain the links. */ /* Add it to the back and maintain the links. */
while (*list != NULL) while (*list != NULL)

View File

@ -231,10 +231,10 @@ static int HKDF_Expand_Label(byte* okm, word32 okmLen,
byte data[MAX_HKDF_LABEL_SZ]; byte data[MAX_HKDF_LABEL_SZ];
/* Output length. */ /* Output length. */
data[idx++] = okmLen >> 8; data[idx++] = (byte)(okmLen >> 8);
data[idx++] = okmLen; data[idx++] = (byte)okmLen;
/* Length of protocol | label. */ /* Length of protocol | label. */
data[idx++] = protocolLen + labelLen; data[idx++] = (byte)(protocolLen + labelLen);
/* Protocol */ /* Protocol */
XMEMCPY(&data[idx], protocol, protocolLen); XMEMCPY(&data[idx], protocol, protocolLen);
idx += protocolLen; idx += protocolLen;
@ -242,7 +242,7 @@ static int HKDF_Expand_Label(byte* okm, word32 okmLen,
XMEMCPY(&data[idx], label, labelLen); XMEMCPY(&data[idx], label, labelLen);
idx += labelLen; idx += labelLen;
/* Length of hash of messages */ /* Length of hash of messages */
data[idx++] = infoLen; data[idx++] = (byte)infoLen;
/* Hash of messages */ /* Hash of messages */
XMEMCPY(&data[idx], info, infoLen); XMEMCPY(&data[idx], info, infoLen);
idx += infoLen; idx += infoLen;
@ -2115,7 +2115,7 @@ int BuildTls13Message(WOLFSSL* ssl, byte* output, int outSz, const byte* input,
case BUILD_MSG_ENCRYPT: case BUILD_MSG_ENCRYPT:
{ {
/* The real record content type goes at the end of the data. */ /* The real record content type goes at the end of the data. */
output[args->idx++] = type; output[args->idx++] = (byte)type;
#ifdef ATOMIC_USER #ifdef ATOMIC_USER
if (ssl->ctx->MacEncryptCb) { if (ssl->ctx->MacEncryptCb) {
@ -4410,7 +4410,7 @@ static int SendTls13CertificateRequest(WOLFSSL* ssl, byte* reqCtx,
ext->resp = 0; ext->resp = 0;
i = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ; i = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ;
reqSz = OPAQUE8_LEN + reqCtxLen; reqSz = (word16)(OPAQUE8_LEN + reqCtxLen);
ret = TLSX_GetRequestSize(ssl, certificate_request, &reqSz); ret = TLSX_GetRequestSize(ssl, certificate_request, &reqSz);
if (ret != 0) if (ret != 0)
return ret; return ret;
@ -4431,7 +4431,7 @@ static int SendTls13CertificateRequest(WOLFSSL* ssl, byte* reqCtx,
AddTls13Headers(output, reqSz, certificate_request, ssl); AddTls13Headers(output, reqSz, certificate_request, ssl);
/* Certificate request context. */ /* Certificate request context. */
output[i++] = reqCtxLen; output[i++] = (byte)reqCtxLen;
if (reqCtxLen != 0) { if (reqCtxLen != 0) {
XMEMCPY(output + i, reqCtx, reqCtxLen); XMEMCPY(output + i, reqCtx, reqCtxLen);
i += reqCtxLen; i += reqCtxLen;
@ -4625,7 +4625,7 @@ static int CreateSigData(WOLFSSL* ssl, byte* sigData, word16* sigDataSz,
if (ret < 0) if (ret < 0)
return ret; return ret;
*sigDataSz = idx + ret; *sigDataSz = (word16)(idx + ret);
ret = 0; ret = 0;
return ret; return ret;
@ -5257,7 +5257,7 @@ static int SendTls13CertificateVerify(WOLFSSL* ssl)
args->sigDataSz, ssl->suites->hashAlgo); args->sigDataSz, ssl->suites->hashAlgo);
if (ret < 0) if (ret < 0)
goto exit_scv; goto exit_scv;
args->sigDataSz = ret; args->sigDataSz = (word16)ret;
ret = 0; ret = 0;
} }
#endif /* HAVE_ECC */ #endif /* HAVE_ECC */
@ -5290,7 +5290,7 @@ static int SendTls13CertificateVerify(WOLFSSL* ssl)
NULL, NULL NULL, NULL
#endif #endif
); );
args->length = sig->length; args->length = (word16)sig->length;
} }
#endif /* HAVE_ECC */ #endif /* HAVE_ECC */
#ifdef HAVE_ED25519 #ifdef HAVE_ED25519
@ -5322,7 +5322,7 @@ static int SendTls13CertificateVerify(WOLFSSL* ssl)
NULL NULL
#endif #endif
); );
args->length = args->sigLen; args->length = (word16)args->sigLen;
} }
#endif /* !NO_RSA */ #endif /* !NO_RSA */
@ -5649,7 +5649,7 @@ static int DoTls13CertificateVerify(WOLFSSL* ssl, byte* input,
args->sigDataSz, args->hashAlgo); args->sigDataSz, args->hashAlgo);
if (ret < 0) if (ret < 0)
goto exit_dcv; goto exit_dcv;
args->sigDataSz = ret; args->sigDataSz = (word16)ret;
ret = 0; ret = 0;
} }
#endif #endif
@ -7887,8 +7887,8 @@ int wolfSSL_CTX_set_groups(WOLFSSL_CTX* ctx, int* groups, int count)
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
ctx->group[i] = groups[i]; ctx->group[i] = (word16)groups[i];
ctx->numGroups = count; ctx->numGroups = (byte)count;
return WOLFSSL_SUCCESS; return WOLFSSL_SUCCESS;
} }
@ -7911,8 +7911,8 @@ int wolfSSL_set_groups(WOLFSSL* ssl, int* groups, int count)
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
ssl->group[i] = groups[i]; ssl->group[i] = (word16)groups[i];
ssl->numGroups = count; ssl->numGroups = (byte)count;
return WOLFSSL_SUCCESS; return WOLFSSL_SUCCESS;
} }