Skip to content

Commit 2704dbd

Browse files
author
Andras Fekete
committed
Fix size_t conversion for OSX
1 parent f657fa8 commit 2704dbd

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

src/wp_digests.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ static int name##_final(CTX* ctx, unsigned char* out, size_t* outLen, \
583583
ok = 0; \
584584
} \
585585
if (ok) { \
586-
int rc = fin(&ctx->obj, out, ctx->outLen); \
586+
int rc = fin(&ctx->obj, out, (word32)ctx->outLen); \
587587
if (rc != 0) { \
588588
ok = 0; \
589589
} \

src/wp_ecx_exch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static int wp_x25519_derive(wp_EcxCtx* ctx, unsigned char* secret,
230230
}
231231
else if (ok) {
232232
int rc;
233-
word32 len = secSize;
233+
word32 len = (word32)secSize;
234234
int i;
235235

236236
rc = wc_curve25519_shared_secret(wp_ecx_get_key(ctx->key),
@@ -316,7 +316,7 @@ static int wp_x448_derive(wp_EcxCtx* ctx, unsigned char* secret,
316316
}
317317
else if (ok) {
318318
int rc;
319-
word32 len = secSize;
319+
word32 len = (word32)secSize;
320320

321321
rc = wc_curve448_shared_secret(wp_ecx_get_key(ctx->key),
322322
wp_ecx_get_key(ctx->peer), secret, &len);

src/wp_ecx_kmgmt.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ static int wp_ecx_set_params(wp_Ecx* ecx, const OSSL_PARAM params[])
404404
ok = 0;
405405
}
406406
if (ok && (data != NULL)) {
407-
int rc = (*ecx->data->importPub)(data, len, (void*)&ecx->key,
407+
int rc = (*ecx->data->importPub)(data, (word32)len, (void*)&ecx->key,
408408
ECX_LITTLE_ENDIAN);
409409
if (rc != 0) {
410410
ok = 0;
@@ -479,7 +479,7 @@ static int wp_ecx_get_params_enc_pub_key(wp_Ecx* ecx, OSSL_PARAM params[],
479479

480480
p = OSSL_PARAM_locate(params, key);
481481
if (p != NULL) {
482-
word32 outLen = p->return_size;
482+
word32 outLen = (word32)p->return_size;
483483

484484
if (p->data == NULL) {
485485
outLen = ecx->data->len;
@@ -513,7 +513,7 @@ static int wp_ecx_get_params_priv_key(wp_Ecx* ecx, OSSL_PARAM params[])
513513

514514
p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_PRIV_KEY);
515515
if (p != NULL) {
516-
word32 outLen = p->return_size;
516+
word32 outLen = (word32)p->return_size;
517517

518518
if (p->data == NULL) {
519519
outLen = ecx->data->len;
@@ -869,7 +869,7 @@ static int wp_ecx_import(wp_Ecx* ecx, int selection, const OSSL_PARAM params[])
869869
if (ok && (privData != NULL)) {
870870
ecx->unclamped[0] = privData[0];
871871
ecx->unclamped[1] = privData[len - 1];
872-
rc = (*ecx->data->importPriv)(privData, len, (void*)&ecx->key,
872+
rc = (*ecx->data->importPriv)(privData, (word32)len, (void*)&ecx->key,
873873
ECX_LITTLE_ENDIAN);
874874
if (rc != 0) {
875875
ok = 0;
@@ -886,7 +886,7 @@ static int wp_ecx_import(wp_Ecx* ecx, int selection, const OSSL_PARAM params[])
886886
ok = 0;
887887
}
888888
if (ok && (pubData != NULL)) {
889-
rc = (*ecx->data->importPub)(pubData, len, (void*)&ecx->key,
889+
rc = (*ecx->data->importPub)(pubData, (word32)len, (void*)&ecx->key,
890890
ECX_LITTLE_ENDIAN);
891891
if (rc != 0) {
892892
ok = 0;
@@ -2034,7 +2034,7 @@ static int wp_ecx_encode(wp_EcxEncDecCtx* ctx, OSSL_CORE_BIO *cBio,
20342034
keyLen = derLen;
20352035
}
20362036
else if (ok && (ctx->encoding == WP_FORMAT_PEM)) {
2037-
rc = wc_DerToPemEx(derData, derLen, NULL, 0, cipherInfo, pemType);
2037+
rc = wc_DerToPemEx(derData, (word32)derLen, NULL, 0, cipherInfo, pemType);
20382038
if (rc <= 0) {
20392039
ok = 0;
20402040
}
@@ -2046,7 +2046,7 @@ static int wp_ecx_encode(wp_EcxEncDecCtx* ctx, OSSL_CORE_BIO *cBio,
20462046
}
20472047
}
20482048
if (ok) {
2049-
rc = wc_DerToPemEx(derData, derLen, pemData, pemLen, cipherInfo,
2049+
rc = wc_DerToPemEx(derData, (word32)derLen, pemData, (word32)pemLen, cipherInfo,
20502050
pemType);
20512051
if (rc <= 0) {
20522052
ok = 0;
@@ -2058,7 +2058,7 @@ static int wp_ecx_encode(wp_EcxEncDecCtx* ctx, OSSL_CORE_BIO *cBio,
20582058
}
20592059
}
20602060
if (ok) {
2061-
rc = BIO_write(out, keyData, keyLen);
2061+
rc = BIO_write(out, keyData, (int)keyLen);
20622062
if (rc <= 0) {
20632063
ok = 0;
20642064
}

src/wp_ecx_sig.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ static int wp_ed25519_digest_sign(wp_EcxSigCtx *ctx, unsigned char *sig,
362362
if (sigSize == (size_t)-1) {
363363
sigSize = *sigLen;
364364
}
365-
len = sigSize;
365+
len = (word32)sigSize;
366366

367367
if (!ed25519->pubKeySet) {
368368
unsigned char pubKey[ED25519_PUB_KEY_SIZE];
@@ -379,7 +379,7 @@ static int wp_ed25519_digest_sign(wp_EcxSigCtx *ctx, unsigned char *sig,
379379
}
380380
}
381381
if (ok) {
382-
rc = wc_ed25519_sign_msg(tbs, tbsLen, sig, &len, ed25519);
382+
rc = wc_ed25519_sign_msg(tbs, (word32)tbsLen, sig, &len, ed25519);
383383
if (rc != 0) {
384384
ok = 0;
385385
}
@@ -434,8 +434,8 @@ static int wp_ed25519_digest_verify(wp_EcxSigCtx *ctx, unsigned char *sig,
434434
}
435435
if (ok) {
436436
int res;
437-
int rc = wc_ed25519_verify_msg(sig, sigLen, tbs, tbsLen, &res,
438-
wp_ecx_get_key(ctx->ecx));
437+
int rc = wc_ed25519_verify_msg(sig, (word32)sigLen, tbs, (word32)tbsLen,
438+
&res, wp_ecx_get_key(ctx->ecx));
439439
if (rc != 0) {
440440
ok = 0;
441441
}
@@ -504,7 +504,7 @@ static int wp_ed448_digest_sign(wp_EcxSigCtx *ctx, unsigned char *sig,
504504
if (sigSize == (size_t)-1) {
505505
sigSize = *sigLen;
506506
}
507-
len = sigSize;
507+
len = (word32)sigSize;
508508

509509
if (!ed448->pubKeySet) {
510510
unsigned char pubKey[ED448_PUB_KEY_SIZE];
@@ -521,7 +521,7 @@ static int wp_ed448_digest_sign(wp_EcxSigCtx *ctx, unsigned char *sig,
521521
}
522522
}
523523
if (ok) {
524-
rc = wc_ed448_sign_msg(tbs, tbsLen, sig, &len,
524+
rc = wc_ed448_sign_msg(tbs, (word32)tbsLen, sig, &len,
525525
(ed448_key*)wp_ecx_get_key(ctx->ecx), NULL, 0);
526526
if (rc != 0) {
527527
ok = 0;
@@ -582,8 +582,8 @@ static int wp_ed448_digest_verify(wp_EcxSigCtx *ctx, unsigned char *sig,
582582
}
583583
if (ok) {
584584
int res;
585-
int rc = wc_ed448_verify_msg(sig, sigLen, tbs, tbsLen, &res,
586-
wp_ecx_get_key(ctx->ecx), NULL, 0);
585+
int rc = wc_ed448_verify_msg(sig, (word32)sigLen, tbs, (word32)tbsLen,
586+
&res, wp_ecx_get_key(ctx->ecx), NULL, 0);
587587
if (rc != 0) {
588588
ok = 0;
589589
}

0 commit comments

Comments
 (0)