hash.h 1.22 KB
Newer Older
1
/*
Edward Thomson committed
2
 * Copyright (C) the libgit2 contributors. All rights reserved.
Vicent Marti committed
3 4 5
 *
 * This file is part of libgit2, distributed under the GNU GPL v2 with
 * a Linking Exception. For full terms see the included COPYING file.
6 7 8 9
 */
#ifndef INCLUDE_hash_h__
#define INCLUDE_hash_h__

10 11
#include "common.h"

12
#include "git2/oid.h"
13

14
typedef struct git_hash_prov git_hash_prov;
15 16
typedef struct git_hash_ctx git_hash_ctx;

17 18 19
int git_hash_ctx_init(git_hash_ctx *ctx);
void git_hash_ctx_cleanup(git_hash_ctx *ctx);

20 21 22
#if defined(GIT_SHA1_COLLISIONDETECT)
# include "hash/hash_collisiondetect.h"
#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 29
#elif defined(GIT_SHA1_MBEDTLS)
# include "hash/hash_mbedtls.h"
30 31 32 33
#else
# include "hash/hash_generic.h"
#endif

34 35
int git_hash_global_init(void);

36 37 38 39 40
typedef struct {
	void *data;
	size_t len;
} git_buf_vec;

41
int git_hash_init(git_hash_ctx *c);
42 43
int git_hash_update(git_hash_ctx *c, const void *data, size_t len);
int git_hash_final(git_oid *out, git_hash_ctx *c);
44

45 46
int git_hash_buf(git_oid *out, const void *data, size_t len);
int git_hash_vec(git_oid *out, git_buf_vec *vec, size_t n);
47

48
#endif