SEC: implement stackinit() functions to simplify initialization and composition of...
[bertos.git] / bertos / sec / mac / hmac.h
index c22a695b90b5330ac8b87acabeedffece54e0124..88de9fab135ebbd13bbfaffb4f789fd9ecaafa82 100644 (file)
@@ -40,6 +40,7 @@
 
 #include <sec/mac.h>
 #include <sec/hash.h>
+#include <alloca.h>
 
 typedef struct HMAC_Context
 {
@@ -50,6 +51,9 @@ typedef struct HMAC_Context
 
 void HMAC_init(HMAC_Context* hmac, Hash *h);
 
+#define HMAC_stackinit(...) \
+       ({ HMAC_Context *ctx = alloca(sizeof(HMAC_Context)); HMAC_init(ctx, ##__VA_ARGS__); &ctx->m; })
+
 int HMAC_testSetup(void);
 int HMAC_testRun(void);
 int HMAC_testTearDown(void);