3 * @copyright Public domain.
8 #ifndef __DECAF_SHA512_H__
9 #define __DECAF_SHA512_H__
12 #include <sys/types.h>
13 #include <stdlib.h> /* for NULL */
15 #include <decaf/common.h>
22 typedef struct decaf_sha512_ctx_s {
25 uint64_t bytes_processed;
26 } decaf_sha512_ctx_s, decaf_sha512_ctx_t[1];
28 void decaf_sha512_init(decaf_sha512_ctx_t ctx) DECAF_NONNULL DECAF_API_VIS;
29 void decaf_sha512_update(decaf_sha512_ctx_t ctx, const uint8_t *message, size_t length) DECAF_NONNULL DECAF_API_VIS;
30 void decaf_sha512_final(decaf_sha512_ctx_t ctx, uint8_t *out, size_t length) DECAF_NONNULL DECAF_API_VIS;
32 static inline void decaf_sha512_destroy(decaf_sha512_ctx_t ctx) {
33 decaf_bzero(ctx,sizeof(*ctx));
36 static inline void decaf_sha512_hash(
39 const uint8_t *message,
42 decaf_sha512_ctx_t ctx;
43 decaf_sha512_init(ctx);
44 decaf_sha512_update(ctx,message,message_len);
45 decaf_sha512_final(ctx,output,output_len);
46 decaf_sha512_destroy(ctx);
53 #endif /* __DECAF_SHA512_H__ */