mirror of https://github.com/wolfSSL/wolfssl.git
api type conversion errors, first half of tls* files
parent
73786112ec
commit
65db4b15d6
14
src/tls.c
14
src/tls.c
|
@ -999,12 +999,12 @@ static int Hmac_UpdateFinal_CT(Hmac* hmac, byte* digest, const byte* in,
|
|||
/* Number of blocks to create for hash. */
|
||||
lenBlock = (realLen + extraLen) >> blockBits;
|
||||
/* Block containing EOC byte. */
|
||||
eocBlock = realLen >> blockBits;
|
||||
eocBlock = (int)(realLen >> (word32)blockBits);
|
||||
/* Index of EOC byte in block. */
|
||||
eocIndex = realLen & blockMask;
|
||||
eocIndex = (int)(realLen & (word32)blockMask);
|
||||
|
||||
/* Add length of hmac's ipad to total length. */
|
||||
realLen += blockSz;
|
||||
realLen += (word32)blockSz;
|
||||
/* Length as bits - 8 bytes bigendian. */
|
||||
c32toa(realLen >> ((sizeof(word32) * 8) - 3), lenBytes);
|
||||
c32toa(realLen << 3, lenBytes + sizeof(word32));
|
||||
|
@ -1019,8 +1019,8 @@ static int Hmac_UpdateFinal_CT(Hmac* hmac, byte* digest, const byte* in,
|
|||
ret = Hmac_HashUpdate(hmac, header, WOLFSSL_TLS_HMAC_INNER_SZ);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
ret = Hmac_HashUpdate(hmac, in, safeBlocks * blockSz -
|
||||
WOLFSSL_TLS_HMAC_INNER_SZ);
|
||||
ret = Hmac_HashUpdate(hmac, in, (word32)(safeBlocks * blockSz -
|
||||
WOLFSSL_TLS_HMAC_INNER_SZ));
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
}
|
||||
|
@ -1278,7 +1278,7 @@ int TLS_hmac(WOLFSSL* ssl, byte* digest, const byte* in, word32 sz, int padSz,
|
|||
#endif
|
||||
{
|
||||
ret = Hmac_UpdateFinal_CT(&hmac, digest, in,
|
||||
sz + hashSz + padSz + 1, hashSz, myInner);
|
||||
(sz + hashSz + (word32)padSz + 1), (int)hashSz, myInner);
|
||||
}
|
||||
#else
|
||||
ret = Hmac_UpdateFinal(&hmac, digest, in, sz + hashSz + padSz + 1,
|
||||
|
@ -7663,7 +7663,7 @@ static int TLSX_KeyShare_GenEccKey(WOLFSSL *ssl, KeyShareEntry* kse)
|
|||
#endif
|
||||
{
|
||||
/* set curve info for EccMakeKey "peer" info */
|
||||
ret = wc_ecc_set_curve(eccKey, kse->keyLen, curveId);
|
||||
ret = wc_ecc_set_curve(eccKey, (int)kse->keyLen, curveId);
|
||||
if (ret == 0) {
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
/* Detect when private key generation is done */
|
||||
|
|
36
src/tls13.c
36
src/tls13.c
|
@ -7014,7 +7014,7 @@ int DoTls13ClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
|||
if (ret != 0)
|
||||
goto exit_dch;
|
||||
#else
|
||||
if ((ret = HashInput(ssl, input + args->begin, helloSz)) != 0)
|
||||
if ((ret = HashInput(ssl, input + args->begin, (int)helloSz)) != 0)
|
||||
goto exit_dch;
|
||||
#endif
|
||||
|
||||
|
@ -7458,7 +7458,7 @@ int SendTls13ServerHello(WOLFSSL* ssl, byte extMsgType)
|
|||
}
|
||||
#endif /* WOLFSSL_DTLS13 */
|
||||
|
||||
ssl->buffers.outputBuffer.length += sendSz;
|
||||
ssl->buffers.outputBuffer.length += (word32)sendSz;
|
||||
|
||||
if (!ssl->options.groupMessages || extMsgType != server_hello)
|
||||
ret = SendBuffered(ssl);
|
||||
|
@ -7606,11 +7606,11 @@ static int SendTls13EncryptedExtensions(WOLFSSL* ssl)
|
|||
|
||||
/* This handshake message is always encrypted. */
|
||||
sendSz = BuildTls13Message(ssl, output, sendSz, output + RECORD_HEADER_SZ,
|
||||
idx - RECORD_HEADER_SZ, handshake, 1, 0, 0);
|
||||
(int)(idx - RECORD_HEADER_SZ), handshake, 1, 0, 0);
|
||||
if (sendSz < 0)
|
||||
return sendSz;
|
||||
|
||||
ssl->buffers.outputBuffer.length += sendSz;
|
||||
ssl->buffers.outputBuffer.length += (word32)sendSz;
|
||||
ssl->options.buildingMsg = 0;
|
||||
ssl->options.serverState = SERVER_ENCRYPTED_EXTENSIONS_COMPLETE;
|
||||
|
||||
|
@ -7636,7 +7636,7 @@ static int SendTls13EncryptedExtensions(WOLFSSL* ssl)
|
|||
* returns 0 on success, otherwise failure.
|
||||
*/
|
||||
static int SendTls13CertificateRequest(WOLFSSL* ssl, byte* reqCtx,
|
||||
int reqCtxLen)
|
||||
word32 reqCtxLen)
|
||||
{
|
||||
byte* output;
|
||||
int ret;
|
||||
|
@ -7724,7 +7724,7 @@ static int SendTls13CertificateRequest(WOLFSSL* ssl, byte* reqCtx,
|
|||
|
||||
/* Always encrypted. */
|
||||
sendSz = BuildTls13Message(ssl, output, sendSz, output + RECORD_HEADER_SZ,
|
||||
i - RECORD_HEADER_SZ, handshake, 1, 0, 0);
|
||||
(int)(i - RECORD_HEADER_SZ), handshake, 1, 0, 0);
|
||||
if (sendSz < 0)
|
||||
return sendSz;
|
||||
|
||||
|
@ -7739,7 +7739,7 @@ static int SendTls13CertificateRequest(WOLFSSL* ssl, byte* reqCtx,
|
|||
}
|
||||
#endif
|
||||
|
||||
ssl->buffers.outputBuffer.length += sendSz;
|
||||
ssl->buffers.outputBuffer.length += (word32)sendSz;
|
||||
ssl->options.buildingMsg = 0;
|
||||
if (!ssl->options.groupMessages)
|
||||
ret = SendBuffered(ssl);
|
||||
|
@ -8510,7 +8510,7 @@ static int SendTls13Certificate(WOLFSSL* ssl)
|
|||
certSz = 0;
|
||||
certChainSz = 0;
|
||||
headerSz = OPAQUE8_LEN + certReqCtxLen + CERT_HEADER_SZ;
|
||||
length = headerSz;
|
||||
length = (sword32)headerSz;
|
||||
listSz = 0;
|
||||
}
|
||||
else {
|
||||
|
@ -8542,7 +8542,7 @@ static int SendTls13Certificate(WOLFSSL* ssl)
|
|||
}
|
||||
|
||||
/* Length of message data with one certificate and extensions. */
|
||||
length = headerSz + certSz + extSz;
|
||||
length = (sword32)(headerSz + certSz + extSz);
|
||||
/* Length of list data with one certificate and extensions. */
|
||||
listSz = CERT_HEADER_SZ + certSz + extSz;
|
||||
|
||||
|
@ -8551,7 +8551,7 @@ static int SendTls13Certificate(WOLFSSL* ssl)
|
|||
p = ssl->buffers.certChain->buffer;
|
||||
/* Chain length including extensions. */
|
||||
certChainSz = ssl->buffers.certChain->length +
|
||||
OPAQUE16_LEN * ssl->buffers.certChainCnt;
|
||||
OPAQUE16_LEN * (word32)ssl->buffers.certChainCnt;
|
||||
length += certChainSz;
|
||||
listSz += certChainSz;
|
||||
}
|
||||
|
@ -8559,7 +8559,7 @@ static int SendTls13Certificate(WOLFSSL* ssl)
|
|||
certChainSz = 0;
|
||||
}
|
||||
|
||||
payloadSz = length;
|
||||
payloadSz = (word32)length;
|
||||
|
||||
if (ssl->fragOffset != 0)
|
||||
length -= (ssl->fragOffset + headerSz);
|
||||
|
@ -8703,7 +8703,7 @@ static int SendTls13Certificate(WOLFSSL* ssl)
|
|||
{
|
||||
/* This message is always encrypted. */
|
||||
sendSz = BuildTls13Message(ssl, output, sendSz,
|
||||
output + RECORD_HEADER_SZ, i - RECORD_HEADER_SZ, handshake, 1,
|
||||
output + RECORD_HEADER_SZ, (int)(i - RECORD_HEADER_SZ), handshake, 1,
|
||||
0, 0);
|
||||
if (sendSz < 0)
|
||||
return sendSz;
|
||||
|
@ -8719,7 +8719,7 @@ static int SendTls13Certificate(WOLFSSL* ssl)
|
|||
}
|
||||
#endif
|
||||
|
||||
ssl->buffers.outputBuffer.length += sendSz;
|
||||
ssl->buffers.outputBuffer.length += (word32)sendSz;
|
||||
ssl->options.buildingMsg = 0;
|
||||
if (!ssl->options.groupMessages)
|
||||
ret = SendBuffered(ssl);
|
||||
|
@ -9150,7 +9150,7 @@ static int SendTls13CertificateVerify(WOLFSSL* ssl)
|
|||
#endif /* !NO_RSA */
|
||||
#ifdef HAVE_ECC
|
||||
if (ssl->hsType == DYNAMIC_TYPE_ECC) {
|
||||
args->sigLen = args->sendSz - args->idx - HASH_SIG_SIZE -
|
||||
args->sigLen = (word32)args->sendSz - args->idx - HASH_SIG_SIZE -
|
||||
VERIFY_HEADER;
|
||||
#if defined(WOLFSSL_SM2) && defined(WOLFSSL_SM3)
|
||||
if (ssl->buffers.keyType != sm2_sa_algo)
|
||||
|
@ -9555,7 +9555,7 @@ static int SendTls13CertificateVerify(WOLFSSL* ssl)
|
|||
}
|
||||
#endif
|
||||
|
||||
ssl->buffers.outputBuffer.length += args->sendSz;
|
||||
ssl->buffers.outputBuffer.length += (word32)args->sendSz;
|
||||
ssl->options.buildingMsg = 0;
|
||||
if (!ssl->options.groupMessages)
|
||||
ret = SendBuffered(ssl);
|
||||
|
@ -10846,7 +10846,7 @@ static int SendTls13Finished(WOLFSSL* ssl)
|
|||
input = output + Dtls13GetRlHeaderLength(ssl, 1);
|
||||
#endif /* WOLFSSL_DTLS13 */
|
||||
|
||||
AddTls13HandShakeHeader(input, (word32)finishedSz, 0, finishedSz, finished, ssl);
|
||||
AddTls13HandShakeHeader(input, (word32)finishedSz, 0, (word32)finishedSz, finished, ssl);
|
||||
|
||||
#if defined(WOLFSSL_RENESAS_TSIP_TLS)
|
||||
if (ssl->options.side == WOLFSSL_CLIENT_END) {
|
||||
|
@ -10931,7 +10931,7 @@ static int SendTls13Finished(WOLFSSL* ssl)
|
|||
}
|
||||
#endif
|
||||
|
||||
ssl->buffers.outputBuffer.length += sendSz;
|
||||
ssl->buffers.outputBuffer.length += (word32)sendSz;
|
||||
ssl->options.buildingMsg = 0;
|
||||
}
|
||||
|
||||
|
@ -11140,7 +11140,7 @@ static int SendTls13KeyUpdate(WOLFSSL* ssl)
|
|||
}
|
||||
#endif
|
||||
|
||||
ssl->buffers.outputBuffer.length += sendSz;
|
||||
ssl->buffers.outputBuffer.length += (word32)sendSz;
|
||||
|
||||
ret = SendBuffered(ssl);
|
||||
|
||||
|
|
26
tests/api.c
26
tests/api.c
|
@ -18620,7 +18620,7 @@ static int test_wc_Chacha_Process(void)
|
|||
ExpectIntEQ(wc_Chacha_Process(&enc, cipher, (byte*)input, (word32)inlen),
|
||||
0);
|
||||
ExpectIntEQ(wc_Chacha_Process(&dec, plain, cipher, (word32)inlen), 0);
|
||||
ExpectIntEQ(XMEMCMP(input, plain, (int)inlen), 0);
|
||||
ExpectIntEQ(XMEMCMP(input, plain, inlen), 0);
|
||||
|
||||
#if !defined(USE_INTEL_CHACHA_SPEEDUP) && !defined(WOLFSSL_ARMASM)
|
||||
/* test checking and using leftovers, currently just in C code */
|
||||
|
@ -18635,7 +18635,7 @@ static int test_wc_Chacha_Process(void)
|
|||
(word32)inlen - 2), 0);
|
||||
ExpectIntEQ(wc_Chacha_Process(&dec, cipher + (inlen - 2),
|
||||
(byte*)input + (inlen - 2), 2), 0);
|
||||
ExpectIntEQ(XMEMCMP(input, plain, (int)inlen), 0);
|
||||
ExpectIntEQ(XMEMCMP(input, plain, inlen), 0);
|
||||
|
||||
/* check edge cases with counter increment */
|
||||
{
|
||||
|
@ -20142,8 +20142,8 @@ static int test_wc_RsaPublicKeyDecodeRaw(void)
|
|||
RsaKey key;
|
||||
const byte n = 0x23;
|
||||
const byte e = 0x03;
|
||||
int nSz = sizeof(n);
|
||||
int eSz = sizeof(e);
|
||||
word32 nSz = sizeof(n);
|
||||
word32 eSz = sizeof(e);
|
||||
|
||||
ExpectIntEQ(wc_InitRsaKey(&key, HEAP_HINT), 0);
|
||||
ExpectIntEQ(wc_RsaPublicKeyDecodeRaw(&n, nSz, &e, eSz, &key), 0);
|
||||
|
@ -50065,7 +50065,7 @@ static int test_wc_PemToDer(void)
|
|||
ExpectIntEQ(load_file(ecc_private_key, &cert_buf, &cert_sz), 0);
|
||||
key_buf[0] = '\n';
|
||||
ExpectNotNull(XMEMCPY(key_buf + 1, cert_buf, cert_sz));
|
||||
ExpectIntNE((ret = wc_PemToDer(key_buf, cert_sz + 1, CERT_TYPE,
|
||||
ExpectIntNE((ret = wc_PemToDer(key_buf, (long int)cert_sz + 1, CERT_TYPE,
|
||||
&pDer, NULL, &info, &eccKey)), 0);
|
||||
|
||||
#ifdef OPENSSL_EXTRA
|
||||
|
@ -70516,7 +70516,7 @@ static int test_wc_ParseCert_Error(void)
|
|||
/* Test data */
|
||||
const struct testStruct {
|
||||
const byte* c;
|
||||
const int cSz;
|
||||
word32 cSz;
|
||||
const int expRet;
|
||||
} t[] = {
|
||||
{c0, sizeof(c0), WC_NO_ERR_TRACE(ASN_PARSE_E)}, /* Invalid bit-string length */
|
||||
|
@ -76326,7 +76326,7 @@ static int test_ForceZero(void)
|
|||
for (i = 0; i < sizeof(data); i++) {
|
||||
for (len = 1; len < sizeof(data) - i; len++) {
|
||||
for (j = 0; j < sizeof(data); j++)
|
||||
data[j] = j + 1;
|
||||
data[j] = ((unsigned char)j + 1);
|
||||
|
||||
ForceZero(data + i, len);
|
||||
|
||||
|
@ -81896,7 +81896,7 @@ static int load_ca_into_cm(WOLFSSL_CERT_MANAGER* cm, char* certA)
|
|||
if ((ret = wolfSSL_CertManagerLoadCA(cm, certA, 0)) != WOLFSSL_SUCCESS) {
|
||||
fprintf(stderr, "loading cert %s failed\n", certA);
|
||||
fprintf(stderr, "Error: (%d): %s\n", ret,
|
||||
wolfSSL_ERR_reason_error_string(ret));
|
||||
wolfSSL_ERR_reason_error_string((unsigned long)ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -81910,7 +81910,7 @@ static int verify_cert_with_cm(WOLFSSL_CERT_MANAGER* cm, char* certA)
|
|||
!= WOLFSSL_SUCCESS) {
|
||||
fprintf(stderr, "could not verify the cert: %s\n", certA);
|
||||
fprintf(stderr, "Error: (%d): %s\n", ret,
|
||||
wolfSSL_ERR_reason_error_string(ret));
|
||||
wolfSSL_ERR_reason_error_string((unsigned long)ret));
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
@ -83223,7 +83223,7 @@ static int error_test(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
errStr = wolfSSL_ERR_reason_error_string(i);
|
||||
errStr = wolfSSL_ERR_reason_error_string((unsigned long)i);
|
||||
|
||||
if (! this_missing) {
|
||||
ExpectIntNE(XSTRCMP(errStr, unknownStr), 0);
|
||||
|
@ -83271,10 +83271,10 @@ static int test_wolfSSL_ERR_strings(void)
|
|||
ExpectNotNull(err = ERR_lib_error_string(PEM_R_PROBLEMS_GETTING_PASSWORD));
|
||||
ExpectIntEQ(XSTRNCMP(err, err2, XSTRLEN(err2)), 0);
|
||||
#else
|
||||
ExpectNotNull(err = wolfSSL_ERR_reason_error_string(WC_NO_ERR_TRACE(UNSUPPORTED_SUITE)));
|
||||
ExpectNotNull(err = wolfSSL_ERR_reason_error_string(WC_NO_ERR_TRACE((unsigned long)UNSUPPORTED_SUITE)));
|
||||
ExpectIntEQ(XSTRNCMP(err, err1, XSTRLEN(err1)), 0);
|
||||
|
||||
ExpectNotNull(err = wolfSSL_ERR_func_error_string(WC_NO_ERR_TRACE(UNSUPPORTED_SUITE)));
|
||||
ExpectNotNull(err = wolfSSL_ERR_func_error_string(WC_NO_ERR_TRACE((unsigned long)UNSUPPORTED_SUITE)));
|
||||
ExpectIntEQ((*err == '\0'), 1);
|
||||
|
||||
/* The value -MIN_CODE_E+2 is PEM_R_PROBLEMS_GETTING_PASSWORD. */
|
||||
|
@ -87239,7 +87239,7 @@ static int test_short_session_id_ssl_ready(WOLFSSL* ssl)
|
|||
EXPECT_DECLS;
|
||||
WOLFSSL_SESSION *sess = NULL;
|
||||
/* Setup the session to avoid errors */
|
||||
ssl->session->timeout = -1;
|
||||
ssl->session->timeout = (word32)-1;
|
||||
ssl->session->side = WOLFSSL_CLIENT_END;
|
||||
#if defined(SESSION_CERTS) || (defined(WOLFSSL_TLS13) && \
|
||||
defined(HAVE_SESSION_TICKET))
|
||||
|
|
|
@ -215,7 +215,9 @@
|
|||
const byte* _x = (const byte*)(x); \
|
||||
const byte* _y = (const byte*)(y); \
|
||||
int _z = (int)(z); \
|
||||
int _w = ((_x) && (_y)) ? XMEMCMP(_x, _y, _z) : -1; \
|
||||
int _w = ((_x) && (_y))
|
||||
? XMEMCMP(_x, _y, (unsigned long)_z)
|
||||
: -1;
|
||||
Expect(_w op 0, ("%s " #op " %s for %s", #x, #y, #z), \
|
||||
("\"%p\" " #er " \"%p\" for \"%d\"", \
|
||||
(const void *)_x, (const void *)_y, _z)); \
|
||||
|
|
Loading…
Reference in New Issue