]>
git.proxmox.com Git - libgit2.git/blob - src/hash/sha1/common_crypto.c
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 #include "common_crypto.h"
10 #define CC_LONG_MAX ((CC_LONG)-1)
12 int git_hash_sha1_global_init(void)
17 int git_hash_sha1_ctx_init(git_hash_sha1_ctx
*ctx
)
19 return git_hash_sha1_init(ctx
);
22 void git_hash_sha1_ctx_cleanup(git_hash_sha1_ctx
*ctx
)
27 int git_hash_sha1_init(git_hash_sha1_ctx
*ctx
)
30 CC_SHA1_Init(&ctx
->c
);
34 int git_hash_sha1_update(git_hash_sha1_ctx
*ctx
, const void *_data
, size_t len
)
36 const unsigned char *data
= _data
;
41 CC_LONG chunk
= (len
> CC_LONG_MAX
) ? CC_LONG_MAX
: (CC_LONG
)len
;
43 CC_SHA1_Update(&ctx
->c
, data
, chunk
);
52 int git_hash_sha1_final(unsigned char *out
, git_hash_sha1_ctx
*ctx
)
55 CC_SHA1_Final(out
, &ctx
->c
);