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/sha1/openssl.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 / sha1 / openssl.h` 57 lines ยท 1396 bytes Raw Blame History 1 /* wrappers for the EVP API of OpenSSL 3+ */ 2 #ifndef SHA1_OPENSSL_H 3 #define SHA1_OPENSSL_H 4 #include 5 6 struct openssl_SHA1_CTX { 7 EVP_MD_CTX *ectx; 8 }; 9 10 typedef struct openssl_SHA1_CTX openssl_SHA1_CTX; 11 12 static inline void openssl_SHA1_Init(struct openssl_SHA1_CTX *ctx) 13 { 14 const EVP_MD *type = EVP_sha1(); 15 16 ctx->ectx = EVP_MD_CTX_new(); 17 if (!ctx->ectx) 18 die("EVP_MD_CTX_new: out of memory"); 19 20 EVP_DigestInit_ex(ctx->ectx, type, NULL); 21 } 22 23 static inline void openssl_SHA1_Update(struct openssl_SHA1_CTX *ctx, 24 const void *data, 25 size_t len) 26 { 27 EVP_DigestUpdate(ctx->ectx, data, len); 28 } 29 30 static inline void openssl_SHA1_Final(unsigned char *digest, 31 struct openssl_SHA1_CTX *ctx) 32 { 33 EVP_DigestFinal_ex(ctx->ectx, digest, NULL); 34 EVP_MD_CTX_free(ctx->ectx); 35 } 36 37 static inline void openssl_SHA1_Clone(struct openssl_SHA1_CTX *dst, 38 const struct openssl_SHA1_CTX *src) 39 { 40 EVP_MD_CTX_copy_ex(dst->ectx, src->ectx); 41 } 42 43 static inline void openssl_SHA1_Discard(struct openssl_SHA1_CTX *ctx) 44 { 45 EVP_MD_CTX_free(ctx->ectx); 46 } 47 48 #ifndef platform_SHA_CTX 49 #define platform_SHA_CTX openssl_SHA1_CTX 50 #define platform_SHA1_Init openssl_SHA1_Init 51 #define platform_SHA1_Clone openssl_SHA1_Clone 52 #define platform_SHA1_Update openssl_SHA1_Update 53 #define platform_SHA1_Final openssl_SHA1_Final 54 #define platform_SHA1_Discard openssl_SHA1_Discard 55 #endif 56 57 #endif /* SHA1_OPENSSL_H */