Skip to content

Commit 12768cd

Browse files
author
Andras Fekete
committed
Fix conversion tls13.c
1 parent bf92797 commit 12768cd

1 file changed

Lines changed: 36 additions & 36 deletions

File tree

src/tls13.c

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ static int DeriveKeyMsg(WOLFSSL* ssl, byte* output, int outputLen,
315315
case sha256_mac:
316316
ret = wc_InitSha256_ex(&digest.sha256, ssl->heap, ssl->devId);
317317
if (ret == 0) {
318-
ret = wc_Sha256Update(&digest.sha256, msg, msgLen);
318+
ret = wc_Sha256Update(&digest.sha256, msg, (word32)msgLen);
319319
if (ret == 0)
320320
ret = wc_Sha256Final(&digest.sha256, hash);
321321
wc_Sha256Free(&digest.sha256);
@@ -328,7 +328,7 @@ static int DeriveKeyMsg(WOLFSSL* ssl, byte* output, int outputLen,
328328
case sha384_mac:
329329
ret = wc_InitSha384_ex(&digest.sha384, ssl->heap, ssl->devId);
330330
if (ret == 0) {
331-
ret = wc_Sha384Update(&digest.sha384, msg, msgLen);
331+
ret = wc_Sha384Update(&digest.sha384, msg, (word32)msgLen);
332332
if (ret == 0)
333333
ret = wc_Sha384Final(&digest.sha384, hash);
334334
wc_Sha384Free(&digest.sha384);
@@ -341,7 +341,7 @@ static int DeriveKeyMsg(WOLFSSL* ssl, byte* output, int outputLen,
341341
case sha512_mac:
342342
ret = wc_InitSha512_ex(&digest.sha512, ssl->heap, ssl->devId);
343343
if (ret == 0) {
344-
ret = wc_Sha512Update(&digest.sha512, msg, msgLen);
344+
ret = wc_Sha512Update(&digest.sha512, msg, (word32)msgLen);
345345
if (ret == 0)
346346
ret = wc_Sha512Final(&digest.sha512, hash);
347347
wc_Sha512Free(&digest.sha512);
@@ -354,7 +354,7 @@ static int DeriveKeyMsg(WOLFSSL* ssl, byte* output, int outputLen,
354354
case sm3_mac:
355355
ret = wc_InitSm3(&digest.sm3, ssl->heap, ssl->devId);
356356
if (ret == 0) {
357-
ret = wc_Sm3Update(&digest.sm3, msg, msgLen);
357+
ret = wc_Sm3Update(&digest.sm3, msg, (word32)msgLen);
358358
if (ret == 0)
359359
ret = wc_Sm3Final(&digest.sm3, hash);
360360
wc_Sm3Free(&digest.sm3);
@@ -392,9 +392,9 @@ static int DeriveKeyMsg(WOLFSSL* ssl, byte* output, int outputLen,
392392
return VERSION_ERROR;
393393
}
394394
if (outputLen == -1)
395-
outputLen = hashSz;
395+
outputLen = (int)hashSz;
396396

397-
ret = Tls13HKDFExpandLabel(ssl, output, outputLen, secret, hashSz,
397+
ret = Tls13HKDFExpandLabel(ssl, output, (word32)outputLen, secret, hashSz,
398398
protocol, protocolLen, label, labelLen,
399399
hash, hashSz, digestAlg);
400400
return ret;
@@ -481,7 +481,7 @@ int Tls13DeriveKey(WOLFSSL* ssl, byte* output, int outputLen,
481481
#endif /* WOLFSSL_DTLS13 */
482482

483483
if (outputLen == -1) {
484-
outputLen = hashSz;
484+
outputLen = (int)hashSz;
485485
}
486486
if (includeMsgs) {
487487
hashOutSz = hashSz;
@@ -496,7 +496,7 @@ int Tls13DeriveKey(WOLFSSL* ssl, byte* output, int outputLen,
496496
}
497497

498498
PRIVATE_KEY_UNLOCK();
499-
ret = Tls13HKDFExpandKeyLabel(ssl, output, outputLen, secret, hashSz,
499+
ret = Tls13HKDFExpandKeyLabel(ssl, output, (word32)outputLen, secret, hashSz,
500500
protocol, protocolLen, label, labelLen,
501501
hash, hashOutSz, digestAlg, side);
502502
PRIVATE_KEY_LOCK();
@@ -973,7 +973,7 @@ int Tls13_Exporter(WOLFSSL* ssl, unsigned char *out, size_t outLen,
973973
{
974974
int ret;
975975
enum wc_HashType hashType = WC_HASH_TYPE_NONE;
976-
int hashLen = 0;
976+
word32 hashLen = 0;
977977
byte hashOut[WC_MAX_DIGEST_SIZE];
978978
const byte* emptyHash = NULL;
979979
byte firstExpand[WC_MAX_DIGEST_SIZE];
@@ -1124,7 +1124,7 @@ static int Tls13_HKDF_Extract(WOLFSSL *ssl, byte* prk, const byte* salt,
11241124
void *cb_ctx = ssl->HkdfExtractCtx;
11251125
CallbackHKDFExtract cb = ssl->ctx->HkdfExtractCb;
11261126
if (cb != NULL) {
1127-
ret = cb(prk, salt, saltLen, ikm, ikmLen, digest, cb_ctx);
1127+
ret = cb(prk, salt, (word32)saltLen, ikm, (word32)ikmLen, digest, cb_ctx);
11281128
}
11291129
else
11301130
#endif
@@ -1137,7 +1137,7 @@ static int Tls13_HKDF_Extract(WOLFSSL *ssl, byte* prk, const byte* salt,
11371137
{
11381138
#if !defined(HAVE_FIPS) || \
11391139
(defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,3))
1140-
ret = wc_Tls13_HKDF_Extract_ex(prk, salt, saltLen, ikm, ikmLen, digest,
1140+
ret = wc_Tls13_HKDF_Extract_ex(prk, salt, (word32)saltLen, ikm, (word32)ikmLen, digest,
11411141
ssl->heap, ssl->devId);
11421142
#else
11431143
ret = wc_Tls13_HKDF_Extract(prk, salt, saltLen, ikm, ikmLen, digest);
@@ -1167,7 +1167,7 @@ int DeriveEarlySecret(WOLFSSL* ssl)
11671167
PRIVATE_KEY_UNLOCK();
11681168
#if defined(HAVE_SESSION_TICKET) || !defined(NO_PSK)
11691169
ret = Tls13_HKDF_Extract(ssl, ssl->arrays->secret, NULL, 0,
1170-
ssl->arrays->psk_key, ssl->arrays->psk_keySz,
1170+
ssl->arrays->psk_key, (int)ssl->arrays->psk_keySz,
11711171
mac2hash(ssl->specs.mac_algorithm));
11721172
#else
11731173
ret = Tls13_HKDF_Extract(ssl, ssl->arrays->secret, NULL, 0,
@@ -1210,7 +1210,7 @@ int DeriveHandshakeSecret(WOLFSSL* ssl)
12101210
PRIVATE_KEY_UNLOCK();
12111211
ret = Tls13_HKDF_Extract(ssl, ssl->arrays->preMasterSecret,
12121212
key, ssl->specs.hash_size,
1213-
ssl->arrays->preMasterSecret, ssl->arrays->preMasterSz,
1213+
ssl->arrays->preMasterSecret, (int)ssl->arrays->preMasterSz,
12141214
mac2hash(ssl->specs.mac_algorithm));
12151215
PRIVATE_KEY_LOCK();
12161216

@@ -1416,7 +1416,7 @@ static int BuildTls13HandshakeHmac(WOLFSSL* ssl, byte* key, byte* hash,
14161416
if (ret == 0) {
14171417
ret = wc_HmacSetKey(verifyHmac, hashType, key, ssl->specs.hash_size);
14181418
if (ret == 0)
1419-
ret = wc_HmacUpdate(verifyHmac, hash, hashSz);
1419+
ret = wc_HmacUpdate(verifyHmac, hash, (word32)hashSz);
14201420
if (ret == 0)
14211421
ret = wc_HmacFinal(verifyHmac, hash);
14221422
wc_HmacFree(verifyHmac);
@@ -1432,7 +1432,7 @@ static int BuildTls13HandshakeHmac(WOLFSSL* ssl, byte* key, byte* hash,
14321432
#endif
14331433

14341434
if (pHashSz)
1435-
*pHashSz = hashSz;
1435+
*pHashSz = (word32)hashSz;
14361436

14371437
return ret;
14381438
}
@@ -1633,7 +1633,7 @@ int DeriveTls13Keys(WOLFSSL* ssl, int secret, int side, int store)
16331633
#endif /* WOLFSSL_DTLS13 */
16341634

16351635
end:
1636-
ForceZero(key_dig, i);
1636+
ForceZero(key_dig, (word32)i);
16371637
#ifdef WOLFSSL_SMALL_STACK
16381638
XFREE(key_dig, ssl->heap, DYNAMIC_TYPE_DIGEST);
16391639
#elif defined(WOLFSSL_CHECK_MEM_ZERO)
@@ -3273,7 +3273,7 @@ int BuildTls13Message(WOLFSSL* ssl, byte* output, int outSz, const byte* input,
32733273
args->headerSz = Dtls13GetRlHeaderLength(ssl, 1);
32743274
#endif /* WOLFSSL_DTLS13 */
32753275

3276-
args->sz = args->headerSz + inSz;
3276+
args->sz = args->headerSz + (word32)inSz;
32773277
args->idx = args->headerSz;
32783278

32793279
#ifdef WOLFSSL_ASYNC_CRYPT
@@ -3303,7 +3303,7 @@ int BuildTls13Message(WOLFSSL* ssl, byte* output, int outSz, const byte* input,
33033303
args->sz += ssl->specs.aead_mac_size;
33043304

33053305
if (sizeOnly)
3306-
return args->sz;
3306+
return (int)args->sz;
33073307

33083308
if (args->sz > (word32)outSz) {
33093309
WOLFSSL_MSG("Oops, want to write past output buffer size");
@@ -3328,8 +3328,8 @@ int BuildTls13Message(WOLFSSL* ssl, byte* output, int outSz, const byte* input,
33283328

33293329
/* TLS v1.3 can do in place encryption. */
33303330
if (input != output + args->idx)
3331-
XMEMCPY(output + args->idx, input, inSz);
3332-
args->idx += inSz;
3331+
XMEMCPY(output + args->idx, input, (size_t)inSz);
3332+
args->idx += (word32)inSz;
33333333

33343334
ssl->options.buildMsgState = BUILD_MSG_HASH;
33353335
}
@@ -3338,7 +3338,7 @@ int BuildTls13Message(WOLFSSL* ssl, byte* output, int outSz, const byte* input,
33383338
case BUILD_MSG_HASH:
33393339
{
33403340
if (hashOutput) {
3341-
ret = HashOutput(ssl, output, args->headerSz + inSz, 0);
3341+
ret = HashOutput(ssl, output, (int)args->headerSz + inSz, 0);
33423342
if (ret != 0)
33433343
goto exit_buildmsg;
33443344
}
@@ -3357,8 +3357,8 @@ int BuildTls13Message(WOLFSSL* ssl, byte* output, int outSz, const byte* input,
33573357
/* QUIC does not use encryption of the TLS Record Layer.
33583358
* Return the original length + added headers
33593359
* and restore it in the record header. */
3360-
AddTls13RecordHeader(output, inSz, type, ssl);
3361-
ret = args->headerSz + inSz;
3360+
AddTls13RecordHeader(output, (word32)inSz, (byte)type, ssl);
3361+
ret = (int)args->headerSz + inSz;
33623362
goto exit_buildmsg;
33633363
}
33643364
#endif
@@ -3368,7 +3368,7 @@ int BuildTls13Message(WOLFSSL* ssl, byte* output, int outSz, const byte* input,
33683368
byte* mac = output + args->idx;
33693369
output += args->headerSz;
33703370

3371-
ret = ssl->ctx->MacEncryptCb(ssl, mac, output, inSz, type, 0,
3371+
ret = ssl->ctx->MacEncryptCb(ssl, mac, output, (unsigned int)inSz, (byte)type, 0,
33723372
output, output, args->size, ssl->MacEncryptCtx);
33733373
}
33743374
else
@@ -3416,7 +3416,7 @@ int BuildTls13Message(WOLFSSL* ssl, byte* output, int outSz, const byte* input,
34163416

34173417
/* return sz on success */
34183418
if (ret == 0) {
3419-
ret = args->sz;
3419+
ret = (int)args->sz;
34203420
}
34213421
else {
34223422
WOLFSSL_ERROR_VERBOSE(ret);
@@ -4023,7 +4023,7 @@ static int WritePSKBinders(WOLFSSL* ssl, byte* output, word32 idx)
40234023
idx - Dtls13GetRlHeaderLength(ssl, 0));
40244024
else
40254025
#endif /* WOLFSSL_DTLS13 */
4026-
ret = HashOutput(ssl, output, idx, 0);
4026+
ret = HashOutput(ssl, output, (int)idx, 0);
40274027

40284028
if (ret != 0)
40294029
return ret;
@@ -4171,7 +4171,7 @@ static int EchHashHelloInner(WOLFSSL* ssl, WOLFSSL_ECH* ech)
41714171
/* hash the body */
41724172
if (ret == 0) {
41734173
ret = HashRaw(ssl, ech->innerClientHello,
4174-
ech->innerClientHelloLen - ech->paddingLen - ech->hpke->Nt);
4174+
(int)(ech->innerClientHelloLen - ech->paddingLen - ech->hpke->Nt));
41754175
}
41764176

41774177
/* swap hsHashes back */
@@ -4423,7 +4423,7 @@ int SendTls13ClientHello(WOLFSSL* ssl)
44234423

44244424
/* set the type to inner */
44254425
args->ech->type = ECH_TYPE_INNER;
4426-
args->preXLength = args->length;
4426+
args->preXLength = (int)args->length;
44274427

44284428
/* get size for inner */
44294429
ret = TLSX_GetRequestSize(ssl, client_hello, &args->length);
@@ -4434,10 +4434,10 @@ int SendTls13ClientHello(WOLFSSL* ssl)
44344434
args->ech->type = 0;
44354435
/* set innerClientHelloLen to ClientHelloInner + padding + tag */
44364436
args->ech->paddingLen = 31 - ((args->length - 1) % 32);
4437-
args->ech->innerClientHelloLen = args->length +
4438-
args->ech->paddingLen + args->ech->hpke->Nt;
4437+
args->ech->innerClientHelloLen = (word16)(args->length +
4438+
args->ech->paddingLen + args->ech->hpke->Nt);
44394439
/* set the length back to before we computed ClientHelloInner size */
4440-
args->length = args->preXLength;
4440+
args->length = (word32)args->preXLength;
44414441
}
44424442
#endif
44434443

@@ -4474,7 +4474,7 @@ int SendTls13ClientHello(WOLFSSL* ssl)
44744474
}
44754475

44764476
/* Total message size. */
4477-
args->sendSz = args->length + HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ;
4477+
args->sendSz = (int)(args->length + HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ);
44784478

44794479
#ifdef WOLFSSL_DTLS13
44804480
if (ssl->options.dtls)
@@ -4514,7 +4514,7 @@ int SendTls13ClientHello(WOLFSSL* ssl)
45144514
XMEMCPY(args->output + args->idx, ssl->arrays->clientRandom, RAN_LEN);
45154515

45164516
#if defined(HAVE_ECH)
4517-
args->clientRandomOffset = args->idx;
4517+
args->clientRandomOffset = (int)args->idx;
45184518
#endif
45194519

45204520
args->idx += RAN_LEN;
@@ -4623,7 +4623,7 @@ int SendTls13ClientHello(WOLFSSL* ssl)
46234623
if (ssl->options.useEch == 1) {
46244624
ret = TLSX_FinalizeEch(args->ech,
46254625
args->output + RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ,
4626-
args->sendSz - (RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ));
4626+
(word32)(args->sendSz - (RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ)));
46274627

46284628
if (ret != 0)
46294629
return ret;
@@ -4657,7 +4657,7 @@ int SendTls13ClientHello(WOLFSSL* ssl)
46574657

46584658
/* compute the outer hash */
46594659
if (ret == 0)
4660-
ret = HashOutput(ssl, args->output, args->idx, 0);
4660+
ret = HashOutput(ssl, args->output, (int)args->idx, 0);
46614661
}
46624662
}
46634663
if (ret != 0)
@@ -4684,7 +4684,7 @@ int SendTls13ClientHello(WOLFSSL* ssl)
46844684
}
46854685
#endif /* WOLFSSL_DTLS13 */
46864686

4687-
ssl->buffers.outputBuffer.length += args->sendSz;
4687+
ssl->buffers.outputBuffer.length += (word32)args->sendSz;
46884688

46894689
/* Advance state and proceed */
46904690
ssl->options.asyncState = TLS_ASYNC_END;

0 commit comments

Comments
 (0)