Skip to content

Commit 254ab05

Browse files
tgorollinuxwolf
tgorol
authored andcommitted
Fix compilation error on Windows in src/concatkdf.c (#75)
1 parent 425dfcf commit 254ab05

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/concatkdf.c

+14-1
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,25 @@
77

88
#include "include/concatkdf_int.h"
99

10+
11+
#ifdef _WIN32
12+
#include <Winsock2.h>
13+
#include <malloc.h>
14+
#else
1015
#include <arpa/inet.h>
16+
#include <alloca.h>
17+
#endif
1118
#include <openssl/evp.h>
1219
#include <string.h>
1320
#include <cjose/base64.h>
1421
#include <cjose/util.h>
1522

23+
#ifdef _WIN32
24+
#define STACK_ALLOC _alloca
25+
#else
26+
#define STACK_ALLOC alloca
27+
#endif
28+
1629
////////////////////////////////////////////////////////////////////////////////
1730
static uint8_t *_apply_uint32(const uint32_t value, uint8_t *buffer)
1831
{
@@ -139,7 +152,7 @@ uint8_t *cjose_concatkdf_derive(const size_t keylen,
139152
uint8_t counter[4];
140153
_apply_uint32(idx, counter);
141154

142-
uint8_t hash[hashlen];
155+
uint8_t* hash = STACK_ALLOC(hashlen * sizeof(uint8_t));
143156
if (1 != EVP_DigestInit_ex(ctx, dgst, NULL) ||
144157
1 != EVP_DigestUpdate(ctx, counter, sizeof(counter)) ||
145158
1 != EVP_DigestUpdate(ctx, ikm, ikmLen) ||

0 commit comments

Comments
 (0)