1 /*
2 	a custom hash must have a 512bit digest and implement:
3 
4 	struct ed25519_hash_context;
5 
6 	void ed25519_hash_init(ed25519_hash_context *ctx);
7 	void ed25519_hash_update(ed25519_hash_context *ctx, const uint8_t *in, size_t inlen);
8 	void ed25519_hash_final(ed25519_hash_context *ctx, uint8_t *hash);
9 	void ed25519_hash(uint8_t *hash, const uint8_t *in, size_t inlen);
10 */
11 #include <sodium/crypto_hash_sha512.h>
12 
13 typedef crypto_hash_sha512_state ed25519_hash_context;
14 
ed25519_hash_init(ed25519_hash_context * ctx)15 static inline void ed25519_hash_init(ed25519_hash_context *ctx)
16 {
17 	crypto_hash_sha512_init(ctx);
18 }
19 
ed25519_hash_update(ed25519_hash_context * ctx,const uint8_t * in,size_t inlen)20 static inline void ed25519_hash_update(ed25519_hash_context *ctx, const uint8_t *in, size_t inlen)
21 {
22 	crypto_hash_sha512_update(ctx,in,inlen);
23 }
24 
ed25519_hash_final(ed25519_hash_context * ctx,uint8_t * hash)25 static inline void ed25519_hash_final(ed25519_hash_context *ctx, uint8_t *hash)
26 {
27 	crypto_hash_sha512_final(ctx,hash);
28 }
29 
ed25519_hash(uint8_t * hash,const uint8_t * in,size_t inlen)30 static inline void ed25519_hash(uint8_t *hash, const uint8_t *in, size_t inlen)
31 {
32 	crypto_hash_sha512(hash,in,inlen);
33 }
34