hash.h 1.16 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
int git_hash_global_init(void);
18 19 20
int git_hash_ctx_init(git_hash_ctx *ctx);
void git_hash_ctx_cleanup(git_hash_ctx *ctx);

21 22 23
#if defined(GIT_SHA1_COLLISIONDETECT)
# include "hash/hash_collisiondetect.h"
#elif defined(GIT_SHA1_COMMON_CRYPTO)
24
# include "hash/hash_common_crypto.h"
25
#elif defined(GIT_SHA1_OPENSSL)
26
# include "hash/hash_openssl.h"
27
#elif defined(GIT_SHA1_WIN32)
28 29 30 31 32
# include "hash/hash_win32.h"
#else
# include "hash/hash_generic.h"
#endif

33 34 35 36 37
typedef struct {
	void *data;
	size_t len;
} git_buf_vec;

38
int git_hash_init(git_hash_ctx *c);
39 40
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);
41

42 43
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);
44

45
#endif