Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/sha256/gcrypt.h # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / sha256 / gcrypt.h` 46 lines ยท 1188 bytes Raw Blame History 1 #ifndef SHA256_GCRYPT_H 2 #define SHA256_GCRYPT_H 3 4 #include 5 6 #define SHA256_DIGEST_SIZE 32 7 8 typedef gcry_md_hd_t gcrypt_SHA256_CTX; 9 10 static inline void gcrypt_SHA256_Init(gcrypt_SHA256_CTX *ctx) 11 { 12 gcry_error_t err = gcry_md_open(ctx, GCRY_MD_SHA256, 0); 13 if (err) 14 die("gcry_md_open: %s", gcry_strerror(err)); 15 } 16 17 static inline void gcrypt_SHA256_Update(gcrypt_SHA256_CTX *ctx, const void *data, size_t len) 18 { 19 gcry_md_write(*ctx, data, len); 20 } 21 22 static inline void gcrypt_SHA256_Final(unsigned char *digest, gcrypt_SHA256_CTX *ctx) 23 { 24 memcpy(digest, gcry_md_read(*ctx, GCRY_MD_SHA256), SHA256_DIGEST_SIZE); 25 gcry_md_close(*ctx); 26 } 27 28 static inline void gcrypt_SHA256_Clone(gcrypt_SHA256_CTX *dst, const gcrypt_SHA256_CTX *src) 29 { 30 gcry_md_close(*dst); 31 gcry_md_copy(dst, *src); 32 } 33 34 static inline void gcrypt_SHA256_Discard(gcrypt_SHA256_CTX *ctx) 35 { 36 gcry_md_close(*ctx); 37 } 38 39 #define platform_SHA256_CTX gcrypt_SHA256_CTX 40 #define platform_SHA256_Init gcrypt_SHA256_Init 41 #define platform_SHA256_Clone gcrypt_SHA256_Clone 42 #define platform_SHA256_Update gcrypt_SHA256_Update 43 #define platform_SHA256_Final gcrypt_SHA256_Final 44 #define platform_SHA256_Discard gcrypt_SHA256_Discard 45 46 #endif