diff options
| author | Vicent Martà <vicent@github.com> | 2012-11-13 13:28:08 -0800 |
|---|---|---|
| committer | Vicent Martà <vicent@github.com> | 2012-11-13 13:28:08 -0800 |
| commit | 3741a37f5ee80d7475cdfedcd4de7d8ea64cf1e8 (patch) | |
| tree | 8861ec34c51061c59ed2daf945d2b7cf77456fed /src/hash/hash_openssl.h | |
| parent | 70572ff80b071aae5d6b398572e1aa0be45f6844 (diff) | |
| parent | 2a612fe3c31f2c386236ccb1483741835a5db318 (diff) | |
| download | libgit2-3741a37f5ee80d7475cdfedcd4de7d8ea64cf1e8.tar.gz | |
Merge pull request #1055 from ethomson/sha1_win32
Win32 CryptoAPI and CNG support for SHA1
Diffstat (limited to 'src/hash/hash_openssl.h')
| -rw-r--r-- | src/hash/hash_openssl.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/hash/hash_openssl.h b/src/hash/hash_openssl.h new file mode 100644 index 000000000..3ae49a732 --- /dev/null +++ b/src/hash/hash_openssl.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2009-2012 the libgit2 contributors + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifndef INCLUDE_hash_openssl_h__ +#define INCLUDE_hash_openssl_h__ + +#include "hash.h" + +#include <openssl/sha.h> + +struct git_hash_ctx { + SHA_CTX c; +}; + +#define git_hash_global_init() 0 +#define git_hash_global_shutdown() /* noop */ +#define git_hash_ctx_init(ctx) git_hash_init(ctx) +#define git_hash_ctx_cleanup(ctx) + +GIT_INLINE(int) git_hash_init(git_hash_ctx *ctx) +{ + assert(ctx); + SHA1_Init(&ctx->c); + return 0; +} + +GIT_INLINE(int) git_hash_update(git_hash_ctx *ctx, const void *data, size_t len) +{ + assert(ctx); + SHA1_Update(&ctx->c, data, len); + return 0; +} + +GIT_INLINE(int) git_hash_final(git_oid *out, git_hash_ctx *ctx) +{ + assert(ctx); + SHA1_Final(out->id, &ctx->c); + return 0; +} + +#endif /* INCLUDE_hash_openssl_h__ */ |
