From 254ab05e04cc32d866712bea838990eb4011cbf5 Mon Sep 17 00:00:00 2001 From: tgorol Date: Thu, 21 Jun 2018 17:34:20 +0100 Subject: [PATCH] Fix compilation error on Windows in src/concatkdf.c (#75) --- src/concatkdf.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/concatkdf.c b/src/concatkdf.c index 65c4976..ec064ab 100644 --- a/src/concatkdf.c +++ b/src/concatkdf.c @@ -7,12 +7,25 @@ #include "include/concatkdf_int.h" + +#ifdef _WIN32 +#include +#include +#else #include +#include +#endif #include #include #include #include +#ifdef _WIN32 +#define STACK_ALLOC _alloca +#else +#define STACK_ALLOC alloca +#endif + //////////////////////////////////////////////////////////////////////////////// static uint8_t *_apply_uint32(const uint32_t value, uint8_t *buffer) { @@ -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) ||