Skip to content

Commit

Permalink
Fix compilation error on Windows in src/concatkdf.c (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgorol authored and linuxwolf committed Jun 21, 2018
1 parent 425dfcf commit 254ab05
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/concatkdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,25 @@

#include "include/concatkdf_int.h"


#ifdef _WIN32
#include <Winsock2.h>
#include <malloc.h>
#else
#include <arpa/inet.h>
#include <alloca.h>
#endif
#include <openssl/evp.h>
#include <string.h>
#include <cjose/base64.h>
#include <cjose/util.h>

#ifdef _WIN32
#define STACK_ALLOC _alloca
#else
#define STACK_ALLOC alloca
#endif

////////////////////////////////////////////////////////////////////////////////
static uint8_t *_apply_uint32(const uint32_t value, uint8_t *buffer)
{
Expand Down Expand Up @@ -139,7 +152,7 @@ uint8_t *cjose_concatkdf_derive(const size_t keylen,
uint8_t counter[4];
_apply_uint32(idx, counter);

uint8_t hash[hashlen];
uint8_t* hash = STACK_ALLOC(hashlen * sizeof(uint8_t));
if (1 != EVP_DigestInit_ex(ctx, dgst, NULL) ||
1 != EVP_DigestUpdate(ctx, counter, sizeof(counter)) ||
1 != EVP_DigestUpdate(ctx, ikm, ikmLen) ||
Expand Down

0 comments on commit 254ab05

Please sign in to comment.