Skip to content

Commit 58c1c0c

Browse files
authored
Merge pull request #6499 from douzzer/20230612-windows-fixes
20230612-windows-fixes
2 parents 9ffa9fa + 03a6eed commit 58c1c0c

8 files changed

Lines changed: 52 additions & 34 deletions

File tree

wolfcrypt/src/aes.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5623,10 +5623,10 @@ static WC_INLINE void GMULT(byte *x, byte m[32][AES_BLOCK_SIZE])
56235623
a = (z8[1] >> 56) & 0xf;
56245624

56255625
/* Rotate z by 4-bits */
5626-
n3 = z8[1] & W64LIT(0xf0f0f0f0f0f0f0f0U);
5627-
n2 = z8[1] & W64LIT(0x0f0f0f0f0f0f0f0fU);
5628-
n1 = z8[0] & W64LIT(0xf0f0f0f0f0f0f0f0U);
5629-
n0 = z8[0] & W64LIT(0x0f0f0f0f0f0f0f0fU);
5626+
n3 = z8[1] & W64LIT(0xf0f0f0f0f0f0f0f0);
5627+
n2 = z8[1] & W64LIT(0x0f0f0f0f0f0f0f0f);
5628+
n1 = z8[0] & W64LIT(0xf0f0f0f0f0f0f0f0);
5629+
n0 = z8[0] & W64LIT(0x0f0f0f0f0f0f0f0f);
56305630
z8[1] = (n3 >> 4) | (n2 << 12) | (n0 >> 52);
56315631
z8[0] = (n1 >> 4) | (n0 << 12);
56325632

wolfcrypt/src/asn.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31485,6 +31485,7 @@ static void DataToHexString(const byte* input, word32 inSz, char* out)
3148531485
out[i * 2] = '\0';
3148631486
}
3148731487

31488+
#ifndef WOLFSSL_ECC_CURVE_STATIC
3148831489
/* Convert data to hex string and place in allocated buffer.
3148931490
*
3149031491
* Big-endian byte array is converted to big-endian hexadecimal string.
@@ -31519,6 +31520,7 @@ static int DataToHexStringAlloc(const byte* input, word32 inSz, char** out,
3151931520

3152031521
return ret;
3152131522
}
31523+
#endif /* WOLFSSL_ECC_CURVE_STATIC */
3152231524

3152331525
/* ASN.1 template for SpecifiedECDomain.
3152431526
* SEC 1 Ver. 2.0, C.2 - Syntax for Elliptic Curve Domain Parameters

wolfcrypt/src/blake2b.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848

4949
static const word64 blake2b_IV[8] =
5050
{
51-
W64LIT(0x6a09e667f3bcc908U), W64LIT(0xbb67ae8584caa73bU),
52-
W64LIT(0x3c6ef372fe94f82bU), W64LIT(0xa54ff53a5f1d36f1U),
53-
W64LIT(0x510e527fade682d1U), W64LIT(0x9b05688c2b3e6c1fU),
54-
W64LIT(0x1f83d9abfb41bd6bU), W64LIT(0x5be0cd19137e2179U)
51+
W64LIT(0x6a09e667f3bcc908), W64LIT(0xbb67ae8584caa73b),
52+
W64LIT(0x3c6ef372fe94f82b), W64LIT(0xa54ff53a5f1d36f1),
53+
W64LIT(0x510e527fade682d1), W64LIT(0x9b05688c2b3e6c1f),
54+
W64LIT(0x1f83d9abfb41bd6b), W64LIT(0x5be0cd19137e2179)
5555
};
5656

5757
static const byte blake2b_sigma[12][16] =
@@ -73,7 +73,7 @@ static const byte blake2b_sigma[12][16] =
7373

7474
static WC_INLINE int blake2b_set_lastnode( blake2b_state *S )
7575
{
76-
S->f[1] = ~W64LIT(0U);
76+
S->f[1] = ~W64LIT(0);
7777
return 0;
7878
}
7979

@@ -82,7 +82,7 @@ static WC_INLINE int blake2b_set_lastblock( blake2b_state *S )
8282
{
8383
if( S->last_node ) blake2b_set_lastnode( S );
8484

85-
S->f[0] = ~W64LIT(0U);
85+
S->f[0] = ~W64LIT(0);
8686
return 0;
8787
}
8888

wolfcrypt/src/ecc.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4311,6 +4311,14 @@ int wc_ecc_get_curve_id_from_oid(const byte* oid, word32 len)
43114311
}
43124312
#endif
43134313

4314+
#if !defined(HAVE_OID_ENCODING) && !defined(HAVE_OID_DECODING)
4315+
if (len == 0) {
4316+
/* SAKKE has zero oidSz and will otherwise match with len==0. */
4317+
WOLFSSL_MSG("zero oidSz");
4318+
return ECC_CURVE_INVALID;
4319+
}
4320+
#endif
4321+
43144322
for (curve_idx = 0; ecc_sets[curve_idx].size != 0; curve_idx++) {
43154323
#if defined(HAVE_OID_ENCODING) && !defined(HAVE_OID_DECODING)
43164324
decOidSz = (word32)sizeof(decOid);

wolfcrypt/src/siphash.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,15 @@ int wc_InitSipHash(SipHash* sipHash, const unsigned char* key,
165165
word64 k1 = GET_U64(key + 8);
166166

167167
/* Initialize state with key. */
168-
sipHash->v[0] = W64LIT(0x736f6d6570736575U);
168+
sipHash->v[0] = W64LIT(0x736f6d6570736575);
169169
if (outSz == SIPHASH_MAC_SIZE_8) {
170-
sipHash->v[1] = W64LIT(0x646f72616e646f6dU);
170+
sipHash->v[1] = W64LIT(0x646f72616e646f6d);
171171
}
172172
else {
173-
sipHash->v[1] = W64LIT(0x646f72616e646f83U);
173+
sipHash->v[1] = W64LIT(0x646f72616e646f83);
174174
}
175-
sipHash->v[2] = W64LIT(0x6c7967656e657261U);
176-
sipHash->v[3] = W64LIT(0x7465646279746573U);
175+
sipHash->v[2] = W64LIT(0x6c7967656e657261);
176+
sipHash->v[3] = W64LIT(0x7465646279746573);
177177

178178
sipHash->v[0] ^= k0;
179179
sipHash->v[1] ^= k1;

wolfcrypt/src/wc_port.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ int wc_ReadDirFirst(ReadDirCtx* ctx, const char* path, char** name)
615615
return BAD_PATH_ERROR;
616616

617617
XSTRNCPY(ctx->name, path, MAX_FILENAME_SZ - 3);
618-
XSTRNCPY(ctx->name + pathLen, "\\*", MAX_FILENAME_SZ - pathLen);
618+
XSTRNCPY(ctx->name + pathLen, "\\*", (size_t)(MAX_FILENAME_SZ - pathLen));
619619

620620
ctx->hFind = FindFirstFileA(ctx->name, &ctx->FindFileData);
621621
if (ctx->hFind == INVALID_HANDLE_VALUE) {
@@ -630,11 +630,11 @@ int wc_ReadDirFirst(ReadDirCtx* ctx, const char* path, char** name)
630630
if (pathLen + dnameLen + 2 > MAX_FILENAME_SZ) {
631631
return BAD_PATH_ERROR;
632632
}
633-
XSTRNCPY(ctx->name, path, pathLen + 1);
633+
XSTRNCPY(ctx->name, path, (size_t)pathLen + 1);
634634
ctx->name[pathLen] = '\\';
635635
XSTRNCPY(ctx->name + pathLen + 1,
636636
ctx->FindFileData.cFileName,
637-
MAX_FILENAME_SZ - pathLen - 1);
637+
(size_t)(MAX_FILENAME_SZ - pathLen - 1));
638638
if (name)
639639
*name = ctx->name;
640640
return 0;
@@ -783,11 +783,11 @@ int wc_ReadDirNext(ReadDirCtx* ctx, const char* path, char** name)
783783
if (pathLen + dnameLen + 2 > MAX_FILENAME_SZ) {
784784
return BAD_PATH_ERROR;
785785
}
786-
XSTRNCPY(ctx->name, path, pathLen + 1);
786+
XSTRNCPY(ctx->name, path, (size_t)pathLen + 1);
787787
ctx->name[pathLen] = '\\';
788788
XSTRNCPY(ctx->name + pathLen + 1,
789789
ctx->FindFileData.cFileName,
790-
MAX_FILENAME_SZ - pathLen - 1);
790+
(size_t)(MAX_FILENAME_SZ - pathLen - 1));
791791
if (name)
792792
*name = ctx->name;
793793
return 0;

wolfssl/wolfcrypt/ecc.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,14 @@ typedef struct ecc_set_type {
306306
typedef struct ecc_set_type {
307307
int size; /* The size of the curve in octets */
308308
int id; /* id of this curve */
309-
const char name[MAX_ECC_NAME]; /* name of this curve */
310-
const char prime[MAX_ECC_STRING]; /* prime that defines the field, curve is in (hex) */
311-
const char Af[MAX_ECC_STRING]; /* fields A param (hex) */
312-
const char Bf[MAX_ECC_STRING]; /* fields B param (hex) */
313-
const char order[MAX_ECC_STRING]; /* order of the curve (hex) */
314-
const char Gx[MAX_ECC_STRING]; /* x coordinate of the base point on curve (hex) */
315-
const char Gy[MAX_ECC_STRING]; /* y coordinate of the base point on curve (hex) */
316-
const ecc_oid_t oid[10];
309+
char name[MAX_ECC_NAME]; /* name of this curve */
310+
char prime[MAX_ECC_STRING]; /* prime that defines the field, curve is in (hex) */
311+
char Af[MAX_ECC_STRING]; /* fields A param (hex) */
312+
char Bf[MAX_ECC_STRING]; /* fields B param (hex) */
313+
char order[MAX_ECC_STRING]; /* order of the curve (hex) */
314+
char Gx[MAX_ECC_STRING]; /* x coordinate of the base point on curve (hex) */
315+
char Gy[MAX_ECC_STRING]; /* y coordinate of the base point on curve (hex) */
316+
ecc_oid_t oid[10];
317317
word32 oidSz;
318318
word32 oidSum; /* sum of encoded OID bytes */
319319
int cofactor;

wolfssl/wolfcrypt/types.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,37 +177,45 @@ decouple library dependencies with standard string, memory and so on.
177177
#if defined(_MSC_VER) || defined(__BCPLUSPLUS__)
178178
#define WORD64_AVAILABLE
179179
#define W64LIT(x) x##ui64
180+
#define SW64LIT(x) x##i64
180181
typedef __int64 sword64;
181182
typedef unsigned __int64 word64;
182183
#elif defined(__EMSCRIPTEN__)
183184
#define WORD64_AVAILABLE
184185
#define W64LIT(x) x##ull
186+
#define SW64LIT(x) x##ll
185187
typedef long long sword64;
186188
typedef unsigned long long word64;
187189
#elif defined(SIZEOF_LONG) && SIZEOF_LONG == 8
188190
#define WORD64_AVAILABLE
189191
#ifdef WOLF_C89
190-
#define W64LIT(x) x##L
192+
#define W64LIT(x) x##UL
193+
#define SW64LIT(x) x##L
191194
#else
192-
#define W64LIT(x) x##LL
195+
#define W64LIT(x) x##ULL
196+
#define SW64LIT(x) x##LL
193197
#endif
194198
typedef long sword64;
195199
typedef unsigned long word64;
196200
#elif defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG == 8
197201
#define WORD64_AVAILABLE
198202
#ifdef WOLF_C89
199-
#define W64LIT(x) x##L
203+
#define W64LIT(x) x##UL
204+
#define SW64LIT(x) x##L
200205
#else
201-
#define W64LIT(x) x##LL
206+
#define W64LIT(x) x##ULL
207+
#define SW64LIT(x) x##LL
202208
#endif
203209
typedef long long sword64;
204210
typedef unsigned long long word64;
205211
#elif defined(__SIZEOF_LONG_LONG__) && __SIZEOF_LONG_LONG__ == 8
206212
#define WORD64_AVAILABLE
207213
#ifdef WOLF_C89
208-
#define W64LIT(x) x##L
214+
#define W64LIT(x) x##UL
215+
#define SW64LIT(x) x##L
209216
#else
210-
#define W64LIT(x) x##LL
217+
#define W64LIT(x) x##ULL
218+
#define SW64LIT(x) x##LL
211219
#endif
212220
typedef long long sword64;
213221
typedef unsigned long long word64;

0 commit comments

Comments
 (0)