mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 23:38:50 +03:00
0938fe19a3
Summary: cdatapack depends on clib, so let's move it to lib/ outside of fb-hgext. None of the consumers of these files were changed. They will be changed as they are moved into the main part of the repo. Test Plan: hg purge --all && make local && cd tests && ./run-tests.py -S -j 48 Reviewers: mitrandir, #mercurial Reviewed By: mitrandir Differential Revision: https://phabricator.intern.facebook.com/D6677197 Signature: 6677197:1515447873:399fb3e7beb5cc1ad8db18f42b359ffbfbeb21f2
63 lines
1.4 KiB
C
63 lines
1.4 KiB
C
// Copyright (c) 2017-present, Facebook, Inc.
|
|
// All Rights Reserved.
|
|
//
|
|
// This software may be used and distributed according to the terms of the
|
|
// GNU General Public License version 2 or any later version.
|
|
|
|
// sha1.h - wrapper functions around the underlying SHA-1 implementation.
|
|
//
|
|
// no-check-code
|
|
#ifndef FBHGEXT_CLIB_SHA1_H
|
|
#define FBHGEXT_CLIB_SHA1_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#ifdef SHA1_USE_SHA1DC
|
|
#include <stdlib.h>
|
|
#include <sha1dc/sha1.h>
|
|
|
|
typedef SHA1_CTX fbhg_sha1_ctx_t;
|
|
|
|
static inline int fbhg_sha1_init(fbhg_sha1_ctx_t* ctx) {
|
|
SHA1DCInit(ctx);
|
|
SHA1DCSetSafeHash(ctx, 0);
|
|
SHA1DCSetUseDetectColl(ctx, 0);
|
|
return 0;
|
|
}
|
|
|
|
static inline int
|
|
fbhg_sha1_update(fbhg_sha1_ctx_t* ctx, const void* data, unsigned long length) {
|
|
SHA1DCUpdate(ctx, (const char*)data, length);
|
|
return 0;
|
|
}
|
|
|
|
static inline int fbhg_sha1_final(unsigned char* md, fbhg_sha1_ctx_t* ctx) {
|
|
return SHA1DCFinal(md, ctx);
|
|
}
|
|
#else
|
|
#include <openssl/sha.h>
|
|
|
|
typedef SHA_CTX fbhg_sha1_ctx_t;
|
|
|
|
static inline int fbhg_sha1_init(fbhg_sha1_ctx_t* ctx) {
|
|
return SHA1_Init(ctx);
|
|
}
|
|
|
|
static inline int
|
|
fbhg_sha1_update(fbhg_sha1_ctx_t* ctx, const void* data, unsigned long length) {
|
|
return SHA1_Update(ctx, data, length);
|
|
}
|
|
|
|
static inline int fbhg_sha1_final(unsigned char* md, fbhg_sha1_ctx_t* ctx) {
|
|
return SHA1_Final(md, ctx);
|
|
}
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
} /* extern C */
|
|
#endif
|
|
|
|
#endif /* FBHGEXT_CLIB_SHA1_H */
|