deps/libgit2/src/util/hash/collisiondetect.c

filter: Statementstmt 90.4% 19 / 21 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 79.3% 23 / 29 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« deps/libgit2/src/util/allocators/stdalloc.c ↑ Summary deps/libgit2/src/libgit2/diff_parse.c »
1 /*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
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.
6 */
7  
8 #include "collisiondetect.h"
9  
10 87 int git_hash_sha1_global_init(void)
11 {
12 87 return 0;
13 }
14  
15 1540 int git_hash_sha1_ctx_init(git_hash_sha1_ctx *ctx)
16 {
17 1540 return git_hash_sha1_init(ctx);
18 }
19  
20 1540 void git_hash_sha1_ctx_cleanup(git_hash_sha1_ctx *ctx)
21 {
22 1540 GIT_UNUSED(ctx);
23 1540 }
24  
25 1587 int git_hash_sha1_init(git_hash_sha1_ctx *ctx)
26 {
27 1587 ▶ GIT_ASSERT_ARG(ctx);
Branch: 1 branch
BranchTrueFalseTotal
GIT_ASSERT_ARG(ctx); 0 1587 1587
28 1587 SHA1DCInit(&ctx->c);
29 1587 return 0;
30 }
31  
32 3064 int git_hash_sha1_update(git_hash_sha1_ctx *ctx, const void *data, size_t len)
33 {
34 3064 ▶ GIT_ASSERT_ARG(ctx);
Branch: 1 branch
BranchTrueFalseTotal
GIT_ASSERT_ARG(ctx); 0 3064 3064
35 3064 SHA1DCUpdate(&ctx->c, data, len);
36 3064 return 0;
37 }
38  
39 1528 int git_hash_sha1_final(unsigned char *out, git_hash_sha1_ctx *ctx)
40 {
41 1528 ▶ GIT_ASSERT_ARG(ctx);
Branch: 1 branch
BranchTrueFalseTotal
GIT_ASSERT_ARG(ctx); 0 1528 1528
42 1528 ▶ if (SHA1DCFinal(out, &ctx->c)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SHA1DCFinal(out, &ctx->c)) { 0 1528 1528
43 0 git_error_set(GIT_ERROR_SHA, "SHA1 collision attack detected");
44 0 return -1;
45 }
46  
47 1528 return 0;
48 }
« deps/libgit2/src/util/allocators/stdalloc.c ↑ Summary deps/libgit2/src/libgit2/diff_parse.c »