]> git.proxmox.com Git - libgit2.git/blame - src/util/hash.h
Merge https://salsa.debian.org/debian/libgit2 into proxmox/bullseye
[libgit2.git] / src / util / 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
ad5611d8 11#include "git2_util.h"
eae0bfdc 12
ad5611d8 13#include "hash/sha.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 21 GIT_HASH_ALGORITHM_NONE = 0,
ad5611d8
TR
22 GIT_HASH_ALGORITHM_SHA1,
23 GIT_HASH_ALGORITHM_SHA256
e579e0f7 24} git_hash_algorithm_t;
22a2d3d5
UG
25
26typedef struct git_hash_ctx {
27 union {
28 git_hash_sha1_ctx sha1;
ad5611d8 29 git_hash_sha256_ctx sha256;
c25aa7cd 30 } ctx;
e579e0f7 31 git_hash_algorithm_t algorithm;
22a2d3d5 32} git_hash_ctx;
d6fb0924 33
ac3d33df
JK
34int git_hash_global_init(void);
35
e579e0f7 36int git_hash_ctx_init(git_hash_ctx *ctx, git_hash_algorithm_t algorithm);
22a2d3d5 37void git_hash_ctx_cleanup(git_hash_ctx *ctx);
007e0753 38
8005c6d4 39int git_hash_init(git_hash_ctx *c);
d6fb0924 40int git_hash_update(git_hash_ctx *c, const void *data, size_t len);
e579e0f7
MB
41int git_hash_final(unsigned char *out, git_hash_ctx *c);
42
43int git_hash_buf(unsigned char *out, const void *data, size_t len, git_hash_algorithm_t algorithm);
44int git_hash_vec(unsigned char *out, git_str_vec *vec, size_t n, git_hash_algorithm_t algorithm);
007e0753 45
e579e0f7 46int git_hash_fmt(char *out, unsigned char *hash, size_t hash_len);
007e0753 47
eae0bfdc 48#endif