SEC: implement stackinit() functions to simplify initialization and composition of...
[bertos.git] / bertos / sec / hash / sha1.h
index 734779ab3e048524b62a86cd72b5b9762b7aefe3..eff7fa70df8fb9da8e95efb93c13c181a369306c 100644 (file)
@@ -41,6 +41,7 @@
 
 #include <cfg/compiler.h>
 #include <sec/hash.h>
+#include <alloca.h>
 
 /**
  * Context for SHA1 computation.
@@ -54,6 +55,9 @@ typedef struct {
 
 void SHA1_init(SHA1_Context *context);
 
+#define SHA1_stackinit(...) \
+       ({ SHA1_Context *ctx = alloca(sizeof(SHA1_Context)); SHA1_init(ctx, ##__VA_ARGS__); &ctx->h; })
+
 int SHA1_testSetup(void);
 int SHA1_testRun(void);
 int SHA1_testTearDown(void);