]>
Commit | Line | Data |
---|---|---|
ac3d33df JK |
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 | ||
22a2d3d5 | 8 | #include "mbedtls.h" |
ac3d33df | 9 | |
22a2d3d5 UG |
10 | int git_hash_sha1_global_init(void) |
11 | { | |
12 | return 0; | |
13 | } | |
14 | ||
15 | int git_hash_sha1_ctx_init(git_hash_sha1_ctx *ctx) | |
16 | { | |
17 | return git_hash_sha1_init(ctx); | |
18 | } | |
19 | ||
20 | void git_hash_sha1_ctx_cleanup(git_hash_sha1_ctx *ctx) | |
ac3d33df | 21 | { |
c25aa7cd PP |
22 | if (ctx) |
23 | mbedtls_sha1_free(&ctx->c); | |
ac3d33df JK |
24 | } |
25 | ||
22a2d3d5 | 26 | int git_hash_sha1_init(git_hash_sha1_ctx *ctx) |
ac3d33df | 27 | { |
c25aa7cd PP |
28 | GIT_ASSERT_ARG(ctx); |
29 | mbedtls_sha1_init(&ctx->c); | |
30 | mbedtls_sha1_starts(&ctx->c); | |
31 | return 0; | |
ac3d33df JK |
32 | } |
33 | ||
22a2d3d5 | 34 | int git_hash_sha1_update(git_hash_sha1_ctx *ctx, const void *data, size_t len) |
ac3d33df | 35 | { |
c25aa7cd PP |
36 | GIT_ASSERT_ARG(ctx); |
37 | mbedtls_sha1_update(&ctx->c, data, len); | |
38 | return 0; | |
ac3d33df JK |
39 | } |
40 | ||
e579e0f7 | 41 | int git_hash_sha1_final(unsigned char *out, git_hash_sha1_ctx *ctx) |
ac3d33df | 42 | { |
c25aa7cd | 43 | GIT_ASSERT_ARG(ctx); |
e579e0f7 | 44 | mbedtls_sha1_finish(&ctx->c, out); |
c25aa7cd | 45 | return 0; |
ac3d33df | 46 | } |