Git 2.21-rc0
[git.git] / sha256 / gcrypt.h
blob09bd8bb20062ae6047a9680162cc761ad7ca8531
1 #ifndef SHA256_GCRYPT_H
2 #define SHA256_GCRYPT_H
4 #include <gcrypt.h>
6 #define SHA256_DIGEST_SIZE 32
8 typedef gcry_md_hd_t gcrypt_SHA256_CTX;
10 inline void gcrypt_SHA256_Init(gcrypt_SHA256_CTX *ctx)
12 gcry_md_open(ctx, GCRY_MD_SHA256, 0);
15 inline void gcrypt_SHA256_Update(gcrypt_SHA256_CTX *ctx, const void *data, size_t len)
17 gcry_md_write(*ctx, data, len);
20 inline void gcrypt_SHA256_Final(unsigned char *digest, gcrypt_SHA256_CTX *ctx)
22 memcpy(digest, gcry_md_read(*ctx, GCRY_MD_SHA256), SHA256_DIGEST_SIZE);
25 #define platform_SHA256_CTX gcrypt_SHA256_CTX
26 #define platform_SHA256_Init gcrypt_SHA256_Init
27 #define platform_SHA256_Update gcrypt_SHA256_Update
28 #define platform_SHA256_Final gcrypt_SHA256_Final
30 #endif