summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2022-06-01 12:40:24 +0000
committerLaurent Bercot <ska@appnovation.com>2022-06-01 12:40:24 +0000
commite0c38ba95a293b747acee203ead11933a44a4c59 (patch)
tree7845c14e7c908c4bf15d898077309a12738a4961 /src/include
parente88276fdec7b3b94ec939f5eb1c8def004ee3878 (diff)
downloadskalibs-e0c38ba95a293b747acee203ead11933a44a4c59.tar.xz
Add blake2s implementation to stdcrypto
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/skalibs/blake2s.h32
-rw-r--r--src/include/skalibs/stdcrypto.h1
2 files changed, 33 insertions, 0 deletions
diff --git a/src/include/skalibs/blake2s.h b/src/include/skalibs/blake2s.h
new file mode 100644
index 0000000..1da386d
--- /dev/null
+++ b/src/include/skalibs/blake2s.h
@@ -0,0 +1,32 @@
+ /* ISC license. */
+
+#ifndef SKALIBS_BLAKE2S_H
+#define SKALIBS_BLAKE2S_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+typedef struct blake2s_ctx_s blake2s_ctx, *blake2s_ctx_ref ;
+struct blake2s_ctx_s
+{
+ size_t buflen ;
+ size_t outlen ;
+ uint32_t h[8] ;
+ uint32_t t[2] ;
+ uint32_t f[2] ;
+ char buf[64] ;
+} ;
+
+#define BLAKE2S_INIT(outlen) { \
+ .buflen = 0, \
+ .outlen = outlen, \
+ .h = { 0x6A09E667UL ^ (0x01010000 | outlen), 0xBB67AE85UL, 0x3C6EF372UL, 0xA54FF53AUL, 0x510E527FUL, 0x9B05688CUL, 0x1F83D9ABUL, 0x5BE0CD19UL }, \
+ .t = { 0, 0 }, \
+ .f = { 0, 0 }, \
+ .buf = { 0 } }
+
+extern void blake2s_init (blake2s_ctx *, size_t) ; /* outlen <= 32 */
+extern void blake2s_update (blake2s_ctx *, char const *, size_t) ;
+extern void blake2s_final (blake2s_ctx *, char *) ; /* outlen chars */
+
+#endif
diff --git a/src/include/skalibs/stdcrypto.h b/src/include/skalibs/stdcrypto.h
index c04407b..a74c451 100644
--- a/src/include/skalibs/stdcrypto.h
+++ b/src/include/skalibs/stdcrypto.h
@@ -6,5 +6,6 @@
#include <skalibs/sha1.h>
#include <skalibs/sha256.h>
#include <skalibs/sha512.h>
+#include <skalibs/blake2s.h>
#endif