]>
git.proxmox.com Git - libgit2.git/blob - src/hash/hash_collisiondetect.h
2 * Copyright (C) the libgit2 contributors. All rights reserved.
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.
8 #ifndef INCLUDE_hash_collisiondetect_h__
9 #define INCLUDE_hash_collisiondetect_h__
12 #include "sha1dc/sha1.h"
18 #define git_hash_global_init() 0
19 #define git_hash_ctx_init(ctx) git_hash_init(ctx)
20 #define git_hash_ctx_cleanup(ctx)
22 GIT_INLINE(int) git_hash_init(git_hash_ctx
*ctx
)
29 GIT_INLINE(int) git_hash_update(git_hash_ctx
*ctx
, const void *data
, size_t len
)
32 SHA1DCUpdate(&ctx
->c
, data
, len
);
36 GIT_INLINE(int) git_hash_final(git_oid
*out
, git_hash_ctx
*ctx
)
39 if (SHA1DCFinal(out
->id
, &ctx
->c
)) {
40 giterr_set(GITERR_SHA1
, "SHA1 collision attack detected");
47 #endif /* INCLUDE_hash_collisiondetect_h__ */