4 #include "git-compat-util.h"
8 #elif defined(SHA1_APPLE)
9 #include <CommonCrypto/CommonDigest.h>
10 #elif defined(SHA1_OPENSSL)
11 #include <openssl/sha.h>
12 #elif defined(SHA1_DC)
13 #include "sha1dc_git.h"
15 #include "block-sha1/sha1.h"
19 * Note that these constants are suitable for indexing the hash_algos array and
20 * comparing against each other, but are otherwise arbitrary, so they should not
21 * be exposed to the user or serialized to disk. To know whether a
22 * git_hash_algo struct points to some usable hash function, test the format_id
23 * field for being non-zero. Use the name field for user-visible situations and
24 * the format_id field for fixed-length fields on disk.
26 /* An unknown hash function. */
27 #define GIT_HASH_UNKNOWN 0
29 #define GIT_HASH_SHA1 1
30 /* Number of algorithms supported (including unknown). */
31 #define GIT_HASH_NALGOS (GIT_HASH_SHA1 + 1)
33 typedef void (*git_hash_init_fn
)(void *ctx
);
34 typedef void (*git_hash_update_fn
)(void *ctx
, const void *in
, size_t len
);
35 typedef void (*git_hash_final_fn
)(unsigned char *hash
, void *ctx
);
37 struct git_hash_algo
{
39 * The name of the algorithm, as appears in the config file and in
44 /* A four-byte version identifier, used in pack indices. */
47 /* The size of a hash context (e.g. git_SHA_CTX). */
50 /* The length of the hash in binary. */
53 /* The length of the hash in hex characters. */
56 /* The hash initialization function. */
57 git_hash_init_fn init_fn
;
59 /* The hash update function. */
60 git_hash_update_fn update_fn
;
62 /* The hash finalization function. */
63 git_hash_final_fn final_fn
;
65 /* The OID of the empty tree. */
66 const struct object_id
*empty_tree
;
68 /* The OID of the empty blob. */
69 const struct object_id
*empty_blob
;
71 extern const struct git_hash_algo hash_algos
[GIT_HASH_NALGOS
];