2 * Copyright (C) the libgit2 contributors. All rights reserved.
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
8 #ifndef INCLUDE_hash_sha_h__
9 #define INCLUDE_hash_sha_h__
11 #include "git2_util.h"
13 typedef struct git_hash_sha1_ctx git_hash_sha1_ctx
;
14 typedef struct git_hash_sha256_ctx git_hash_sha256_ctx
;
16 #if defined(GIT_SHA1_COMMON_CRYPTO) || defined(GIT_SHA256_COMMON_CRYPTO)
17 # include "common_crypto.h"
20 #if defined(GIT_SHA1_OPENSSL) || defined(GIT_SHA256_OPENSSL)
24 #if defined(GIT_SHA1_WIN32) || defined(GIT_SHA256_WIN32)
28 #if defined(GIT_SHA1_MBEDTLS) || defined(GIT_SHA256_MBEDTLS)
32 #if defined(GIT_SHA1_COLLISIONDETECT)
33 # include "collisiondetect.h"
36 #if defined(GIT_SHA256_BUILTIN)
44 #define GIT_HASH_SHA1_SIZE 20
46 int git_hash_sha1_global_init(void);
48 int git_hash_sha1_ctx_init(git_hash_sha1_ctx
*ctx
);
49 void git_hash_sha1_ctx_cleanup(git_hash_sha1_ctx
*ctx
);
51 int git_hash_sha1_init(git_hash_sha1_ctx
*c
);
52 int git_hash_sha1_update(git_hash_sha1_ctx
*c
, const void *data
, size_t len
);
53 int git_hash_sha1_final(unsigned char *out
, git_hash_sha1_ctx
*c
);
59 #define GIT_HASH_SHA256_SIZE 32
61 int git_hash_sha256_global_init(void);
63 int git_hash_sha256_ctx_init(git_hash_sha256_ctx
*ctx
);
64 void git_hash_sha256_ctx_cleanup(git_hash_sha256_ctx
*ctx
);
66 int git_hash_sha256_init(git_hash_sha256_ctx
*c
);
67 int git_hash_sha256_update(git_hash_sha256_ctx
*c
, const void *data
, size_t len
);
68 int git_hash_sha256_final(unsigned char *out
, git_hash_sha256_ctx
*c
);