sha.h 1.69 KB
Newer Older
1 2 3 4 5 6 7
/*
 * Copyright (C) the libgit2 contributors. All rights reserved.
 *
 * This file is part of libgit2, distributed under the GNU GPL v2 with
 * a Linking Exception. For full terms see the included COPYING file.
 */

8 9
#ifndef INCLUDE_hash_sha_h__
#define INCLUDE_hash_sha_h__
10

11
#include "git2_util.h"
12

13
typedef struct git_hash_sha1_ctx git_hash_sha1_ctx;
14
typedef struct git_hash_sha256_ctx git_hash_sha256_ctx;
15

16
#if defined(GIT_SHA1_COMMON_CRYPTO) || defined(GIT_SHA256_COMMON_CRYPTO)
17
# include "common_crypto.h"
18 19
#endif

20
#if defined(GIT_SHA1_OPENSSL) || defined(GIT_SHA256_OPENSSL)
21
# include "openssl.h"
22 23 24
#endif

#if defined(GIT_SHA1_WIN32) || defined(GIT_SHA256_WIN32)
25
# include "win32.h"
26 27 28
#endif

#if defined(GIT_SHA1_MBEDTLS) || defined(GIT_SHA256_MBEDTLS)
29
# include "mbedtls.h"
30 31 32
#endif

#if defined(GIT_SHA1_COLLISIONDETECT)
33
# include "collisiondetect.h"
34 35
#endif

36 37 38 39 40 41 42 43
#if defined(GIT_SHA256_BUILTIN)
# include "builtin.h"
#endif

/*
 * SHA1
 */

44 45
#define GIT_HASH_SHA1_SIZE 20

46 47
int git_hash_sha1_global_init(void);

48 49
int git_hash_sha1_ctx_init(git_hash_sha1_ctx *ctx);
void git_hash_sha1_ctx_cleanup(git_hash_sha1_ctx *ctx);
50

51 52
int git_hash_sha1_init(git_hash_sha1_ctx *c);
int git_hash_sha1_update(git_hash_sha1_ctx *c, const void *data, size_t len);
53
int git_hash_sha1_final(unsigned char *out, git_hash_sha1_ctx *c);
54

55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
/*
 * SHA256
 */

#define GIT_HASH_SHA256_SIZE 32

int git_hash_sha256_global_init(void);

int git_hash_sha256_ctx_init(git_hash_sha256_ctx *ctx);
void git_hash_sha256_ctx_cleanup(git_hash_sha256_ctx *ctx);

int git_hash_sha256_init(git_hash_sha256_ctx *c);
int git_hash_sha256_update(git_hash_sha256_ctx *c, const void *data, size_t len);
int git_hash_sha256_final(unsigned char *out, git_hash_sha256_ctx *c);

70
#endif