]> git.proxmox.com Git - libgit2.git/blame - src/hash.h
New upstream version 1.4.3+dfsg.1
[libgit2.git] / src / hash.h
CommitLineData
007e0753 1/*
359fc2d2 2 * Copyright (C) the libgit2 contributors. All rights reserved.
bb742ede
VM
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.
007e0753 6 */
22a2d3d5 7
007e0753
RJ
8#ifndef INCLUDE_hash_h__
9#define INCLUDE_hash_h__
10
eae0bfdc
PP
11#include "common.h"
12
e579e0f7 13#include "hash/sha1.h"
007e0753 14
22a2d3d5
UG
15typedef struct {
16 void *data;
17 size_t len;
e579e0f7 18} git_str_vec;
007e0753 19
22a2d3d5 20typedef enum {
e579e0f7
MB
21 GIT_HASH_ALGORITHM_NONE = 0,
22 GIT_HASH_ALGORITHM_SHA1
23} git_hash_algorithm_t;
22a2d3d5
UG
24
25typedef struct git_hash_ctx {
26 union {
27 git_hash_sha1_ctx sha1;
c25aa7cd 28 } ctx;
e579e0f7 29 git_hash_algorithm_t algorithm;
22a2d3d5 30} git_hash_ctx;
d6fb0924 31
ac3d33df
JK
32int git_hash_global_init(void);
33
e579e0f7 34int git_hash_ctx_init(git_hash_ctx *ctx, git_hash_algorithm_t algorithm);
22a2d3d5 35void git_hash_ctx_cleanup(git_hash_ctx *ctx);
007e0753 36
8005c6d4 37int git_hash_init(git_hash_ctx *c);
d6fb0924 38int git_hash_update(git_hash_ctx *c, const void *data, size_t len);
e579e0f7
MB
39int git_hash_final(unsigned char *out, git_hash_ctx *c);
40
41int git_hash_buf(unsigned char *out, const void *data, size_t len, git_hash_algorithm_t algorithm);
42int git_hash_vec(unsigned char *out, git_str_vec *vec, size_t n, git_hash_algorithm_t algorithm);
007e0753 43
e579e0f7 44int git_hash_fmt(char *out, unsigned char *hash, size_t hash_len);
007e0753 45
eae0bfdc 46#endif