]>
Commit | Line | Data |
---|---|---|
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 |
15 | typedef struct { |
16 | void *data; | |
17 | size_t len; | |
e579e0f7 | 18 | } git_str_vec; |
007e0753 | 19 | |
22a2d3d5 | 20 | typedef enum { |
e579e0f7 MB |
21 | GIT_HASH_ALGORITHM_NONE = 0, |
22 | GIT_HASH_ALGORITHM_SHA1 | |
23 | } git_hash_algorithm_t; | |
22a2d3d5 UG |
24 | |
25 | typedef 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 |
32 | int git_hash_global_init(void); |
33 | ||
e579e0f7 | 34 | int git_hash_ctx_init(git_hash_ctx *ctx, git_hash_algorithm_t algorithm); |
22a2d3d5 | 35 | void git_hash_ctx_cleanup(git_hash_ctx *ctx); |
007e0753 | 36 | |
8005c6d4 | 37 | int git_hash_init(git_hash_ctx *c); |
d6fb0924 | 38 | int git_hash_update(git_hash_ctx *c, const void *data, size_t len); |
e579e0f7 MB |
39 | int git_hash_final(unsigned char *out, git_hash_ctx *c); |
40 | ||
41 | int git_hash_buf(unsigned char *out, const void *data, size_t len, git_hash_algorithm_t algorithm); | |
42 | int git_hash_vec(unsigned char *out, git_str_vec *vec, size_t n, git_hash_algorithm_t algorithm); | |
007e0753 | 43 | |
e579e0f7 | 44 | int git_hash_fmt(char *out, unsigned char *hash, size_t hash_len); |
007e0753 | 45 | |
eae0bfdc | 46 | #endif |