]> git.proxmox.com Git - libgit2.git/blob - src/hash.h
New upstream version 0.28.1+dfsg.1
[libgit2.git] / src / hash.h
1 /*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
3 *
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.
6 */
7 #ifndef INCLUDE_hash_h__
8 #define INCLUDE_hash_h__
9
10 #include "common.h"
11
12 #include "git2/oid.h"
13
14 typedef struct git_hash_prov git_hash_prov;
15 typedef struct git_hash_ctx git_hash_ctx;
16
17 int git_hash_ctx_init(git_hash_ctx *ctx);
18 void git_hash_ctx_cleanup(git_hash_ctx *ctx);
19
20 #if defined(GIT_SHA1_COLLISIONDETECT)
21 # include "hash/hash_collisiondetect.h"
22 #elif defined(GIT_SHA1_COMMON_CRYPTO)
23 # include "hash/hash_common_crypto.h"
24 #elif defined(GIT_SHA1_OPENSSL)
25 # include "hash/hash_openssl.h"
26 #elif defined(GIT_SHA1_WIN32)
27 # include "hash/hash_win32.h"
28 #elif defined(GIT_SHA1_MBEDTLS)
29 # include "hash/hash_mbedtls.h"
30 #else
31 # include "hash/hash_generic.h"
32 #endif
33
34 int git_hash_global_init(void);
35
36 typedef struct {
37 void *data;
38 size_t len;
39 } git_buf_vec;
40
41 int git_hash_init(git_hash_ctx *c);
42 int git_hash_update(git_hash_ctx *c, const void *data, size_t len);
43 int git_hash_final(git_oid *out, git_hash_ctx *c);
44
45 int git_hash_buf(git_oid *out, const void *data, size_t len);
46 int git_hash_vec(git_oid *out, git_buf_vec *vec, size_t n);
47
48 #endif