]> git.proxmox.com Git - libgit2.git/blame - src/hash/sha1/mbedtls.c
New upstream version 1.1.0+dfsg.1
[libgit2.git] / src / hash / sha1 / mbedtls.c
CommitLineData
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
10int git_hash_sha1_global_init(void)
11{
12 return 0;
13}
14
15int git_hash_sha1_ctx_init(git_hash_sha1_ctx *ctx)
16{
17 return git_hash_sha1_init(ctx);
18}
19
20void git_hash_sha1_ctx_cleanup(git_hash_sha1_ctx *ctx)
ac3d33df
JK
21{
22 assert(ctx);
23 mbedtls_sha1_free(&ctx->c);
24}
25
22a2d3d5 26int git_hash_sha1_init(git_hash_sha1_ctx *ctx)
ac3d33df
JK
27{
28 assert(ctx);
29 mbedtls_sha1_init(&ctx->c);
30 mbedtls_sha1_starts(&ctx->c);
31 return 0;
32}
33
22a2d3d5 34int git_hash_sha1_update(git_hash_sha1_ctx *ctx, const void *data, size_t len)
ac3d33df
JK
35{
36 assert(ctx);
37 mbedtls_sha1_update(&ctx->c, data, len);
38 return 0;
39}
40
22a2d3d5 41int git_hash_sha1_final(git_oid *out, git_hash_sha1_ctx *ctx)
ac3d33df
JK
42{
43 assert(ctx);
44 mbedtls_sha1_finish(&ctx->c, out->id);
45 return 0;
46}