| Current Path : /usr/include/ |
| Current File : //usr/include/liblsapi-sha1.h |
/* public api for steve reid's public domain SHA-1 implementation */
/* this file is in the public domain */
#ifndef __SHA1_H
#define __SHA1_H
/* SHA1_DIGEST_SIZE must always be visible regardless of OpenSSL. */
#define SHA1_DIGEST_SIZE 20
/*
* When OpenSSL headers are already present, their SHA1_Init/Update/Final
* declarations take precedence. Redeclaring with incompatible signatures
* causes compile errors in consumers (e.g. nginx) that include both
* lscapi.h and OpenSSL. Use OpenSSL's SHA_CTX as an alias so internal
* callers that hold a SHA1_CTX* still work.
*
* Guard macros differ by OpenSSL version:
* OpenSSL 1.1.x -> HEADER_SHA_H
* OpenSSL 3.x -> OPENSSL_SHA_H
*/
#if !defined(OPENSSL_SHA_H) && !defined(HEADER_SHA_H)
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
uint32_t state[5];
uint32_t count[2];
uint8_t buffer[64];
} SHA1_CTX;
void SHA1_Init(SHA1_CTX* context);
void SHA1_Update(SHA1_CTX* context, const uint8_t* data, const size_t len);
void SHA1_Final(SHA1_CTX* context, uint8_t digest[SHA1_DIGEST_SIZE]);
#ifdef __cplusplus
}
#endif
#else /* OpenSSL sha.h already included */
/* openssl/sha.h is already loaded; avoid redeclaring SHA1_* with
* incompatible types. Alias SHA1_CTX to OpenSSL's SHA_CTX so any
* code holding a pointer to SHA1_CTX still compiles. */
#include <openssl/sha.h>
typedef SHA_CTX SHA1_CTX;
#endif /* !OPENSSL_SHA_H && !HEADER_SHA_H */
#endif /* __SHA1_H */