Blame src/hash/hash_common_crypto.h
|
Packit Service |
20376f |
/*
|
|
Packit Service |
20376f |
* Copyright (C) the libgit2 contributors. All rights reserved.
|
|
Packit Service |
20376f |
*
|
|
Packit Service |
20376f |
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
|
Packit Service |
20376f |
* a Linking Exception. For full terms see the included COPYING file.
|
|
Packit Service |
20376f |
*/
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
#ifndef INCLUDE_hash_common_crypto_h__
|
|
Packit Service |
20376f |
#define INCLUDE_hash_common_crypto_h__
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
#include "hash.h"
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
#include <CommonCrypto/CommonDigest.h>
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
struct git_hash_ctx {
|
|
Packit Service |
20376f |
CC_SHA1_CTX c;
|
|
Packit Service |
20376f |
};
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
#define git_hash_global_init() 0
|
|
Packit Service |
20376f |
#define git_hash_ctx_init(ctx) git_hash_init(ctx)
|
|
Packit Service |
20376f |
#define git_hash_ctx_cleanup(ctx)
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
GIT_INLINE(int) git_hash_init(git_hash_ctx *ctx)
|
|
Packit Service |
20376f |
{
|
|
Packit Service |
20376f |
assert(ctx);
|
|
Packit Service |
20376f |
CC_SHA1_Init(&ctx->c);
|
|
Packit Service |
20376f |
return 0;
|
|
Packit Service |
20376f |
}
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
GIT_INLINE(int) git_hash_update(git_hash_ctx *ctx, const void *data, size_t len)
|
|
Packit Service |
20376f |
{
|
|
Packit Service |
20376f |
assert(ctx);
|
|
Packit Service |
20376f |
CC_SHA1_Update(&ctx->c, data, len);
|
|
Packit Service |
20376f |
return 0;
|
|
Packit Service |
20376f |
}
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
GIT_INLINE(int) git_hash_final(git_oid *out, git_hash_ctx *ctx)
|
|
Packit Service |
20376f |
{
|
|
Packit Service |
20376f |
assert(ctx);
|
|
Packit Service |
20376f |
CC_SHA1_Final(out->id, &ctx->c);
|
|
Packit Service |
20376f |
return 0;
|
|
Packit Service |
20376f |
}
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
#endif /* INCLUDE_hash_common_crypto_h__ */
|