mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
Clang-format: fix some header files and remove them from whitelist
This commit is contained in:
parent
b751c59f43
commit
f7088f69ab
12 changed files with 161 additions and 169 deletions
|
@ -30,9 +30,8 @@ static inline std::string hex_encode(const char *data, unsigned int data_size)
|
|||
char buf2[3];
|
||||
buf2[2] = '\0';
|
||||
|
||||
for(unsigned int i = 0; i < data_size; i++)
|
||||
{
|
||||
unsigned char c = (unsigned char) data[i];
|
||||
for (unsigned int i = 0; i < data_size; i++) {
|
||||
unsigned char c = (unsigned char)data[i];
|
||||
buf2[0] = hex_chars[(c & 0xf0) >> 4];
|
||||
buf2[1] = hex_chars[c & 0x0f];
|
||||
ret.append(buf2);
|
||||
|
@ -43,16 +42,16 @@ static inline std::string hex_encode(const char *data, unsigned int data_size)
|
|||
|
||||
static inline std::string hex_encode(const std::string &data)
|
||||
{
|
||||
return hex_encode(data.c_str(), data.size());
|
||||
return hex_encode(data.c_str(), data.size());
|
||||
}
|
||||
|
||||
static inline bool hex_digit_decode(char hexdigit, unsigned char &value)
|
||||
{
|
||||
if(hexdigit >= '0' && hexdigit <= '9')
|
||||
if (hexdigit >= '0' && hexdigit <= '9')
|
||||
value = hexdigit - '0';
|
||||
else if(hexdigit >= 'A' && hexdigit <= 'F')
|
||||
else if (hexdigit >= 'A' && hexdigit <= 'F')
|
||||
value = hexdigit - 'A' + 10;
|
||||
else if(hexdigit >= 'a' && hexdigit <= 'f')
|
||||
else if (hexdigit >= 'a' && hexdigit <= 'f')
|
||||
value = hexdigit - 'a' + 10;
|
||||
else
|
||||
return false;
|
||||
|
|
|
@ -29,22 +29,23 @@ typedef unsigned int Uint32;
|
|||
|
||||
class SHA1
|
||||
{
|
||||
private:
|
||||
// fields
|
||||
Uint32 H0, H1, H2, H3, H4;
|
||||
unsigned char bytes[64];
|
||||
int unprocessedBytes;
|
||||
Uint32 size;
|
||||
void process();
|
||||
public:
|
||||
SHA1();
|
||||
~SHA1();
|
||||
void addBytes( const char* data, int num );
|
||||
unsigned char* getDigest();
|
||||
// utility methods
|
||||
static Uint32 lrot( Uint32 x, int bits );
|
||||
static void storeBigEndianUint32( unsigned char* byte, Uint32 num );
|
||||
static void hexPrinter( unsigned char* c, int l );
|
||||
private:
|
||||
// fields
|
||||
Uint32 H0, H1, H2, H3, H4;
|
||||
unsigned char bytes[64];
|
||||
int unprocessedBytes;
|
||||
Uint32 size;
|
||||
void process();
|
||||
|
||||
public:
|
||||
SHA1();
|
||||
~SHA1();
|
||||
void addBytes(const char *data, int num);
|
||||
unsigned char *getDigest();
|
||||
// utility methods
|
||||
static Uint32 lrot(Uint32 x, int bits);
|
||||
static void storeBigEndianUint32(unsigned char *byte, Uint32 num);
|
||||
static void hexPrinter(unsigned char *c, int l);
|
||||
};
|
||||
|
||||
#define SHA1_HEADER
|
||||
|
|
101
src/util/sha2.h
101
src/util/sha2.h
|
@ -57,21 +57,21 @@
|
|||
*/
|
||||
|
||||
#ifndef HEADER_SHA_H
|
||||
# define HEADER_SHA_H
|
||||
#define HEADER_SHA_H
|
||||
|
||||
# include <stddef.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_SHA1))
|
||||
# error SHA is disabled.
|
||||
# endif
|
||||
#if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_SHA1))
|
||||
#error SHA is disabled.
|
||||
#endif
|
||||
|
||||
# if defined(OPENSSL_FIPS)
|
||||
# define FIPS_SHA_SIZE_T size_t
|
||||
# endif
|
||||
#if defined(OPENSSL_FIPS)
|
||||
#define FIPS_SHA_SIZE_T size_t
|
||||
#endif
|
||||
|
||||
/*
|
||||
Compat stuff from OpenSSL land
|
||||
|
@ -79,11 +79,10 @@ extern "C" {
|
|||
|
||||
/* crypto.h */
|
||||
|
||||
# define fips_md_init(alg) fips_md_init_ctx(alg, alg)
|
||||
#define fips_md_init(alg) fips_md_init_ctx(alg, alg)
|
||||
|
||||
# define fips_md_init_ctx(alg, cx) \
|
||||
int alg##_Init(cx##_CTX *c)
|
||||
# define fips_cipher_abort(alg) while(0)
|
||||
#define fips_md_init_ctx(alg, cx) int alg##_Init(cx##_CTX *c)
|
||||
#define fips_cipher_abort(alg) while (0)
|
||||
|
||||
/*-
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
@ -92,47 +91,51 @@ extern "C" {
|
|||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
*/
|
||||
|
||||
# if defined(__LP32__)
|
||||
# define SHA_LONG unsigned long
|
||||
# elif defined(__ILP64__)
|
||||
# define SHA_LONG unsigned long
|
||||
# define SHA_LONG_LOG2 3
|
||||
# else
|
||||
# define SHA_LONG unsigned int
|
||||
# endif
|
||||
#if defined(__LP32__)
|
||||
#define SHA_LONG unsigned long
|
||||
#elif defined(__ILP64__)
|
||||
#define SHA_LONG unsigned long
|
||||
#define SHA_LONG_LOG2 3
|
||||
#else
|
||||
#define SHA_LONG unsigned int
|
||||
#endif
|
||||
|
||||
# define SHA_LBLOCK 16
|
||||
# define SHA_CBLOCK (SHA_LBLOCK*4)/* SHA treats input data as a
|
||||
* contiguous array of 32 bit wide
|
||||
* big-endian values. */
|
||||
# define SHA_LAST_BLOCK (SHA_CBLOCK-8)
|
||||
# define SHA_DIGEST_LENGTH 20
|
||||
#define SHA_LBLOCK 16
|
||||
#define SHA_CBLOCK \
|
||||
(SHA_LBLOCK * 4) /* SHA treats input data as a \
|
||||
* contiguous array of 32 bit wide \
|
||||
* big-endian values. */
|
||||
#define SHA_LAST_BLOCK (SHA_CBLOCK - 8)
|
||||
#define SHA_DIGEST_LENGTH 20
|
||||
|
||||
typedef struct SHAstate_st {
|
||||
SHA_LONG h0, h1, h2, h3, h4;
|
||||
SHA_LONG Nl, Nh;
|
||||
SHA_LONG data[SHA_LBLOCK];
|
||||
unsigned int num;
|
||||
typedef struct SHAstate_st
|
||||
{
|
||||
SHA_LONG h0, h1, h2, h3, h4;
|
||||
SHA_LONG Nl, Nh;
|
||||
SHA_LONG data[SHA_LBLOCK];
|
||||
unsigned int num;
|
||||
} SHA_CTX;
|
||||
|
||||
# define SHA256_CBLOCK (SHA_LBLOCK*4)/* SHA-256 treats input data as a
|
||||
* contiguous array of 32 bit wide
|
||||
* big-endian values. */
|
||||
# define SHA224_DIGEST_LENGTH 28
|
||||
# define SHA256_DIGEST_LENGTH 32
|
||||
#define SHA256_CBLOCK \
|
||||
(SHA_LBLOCK * 4) /* SHA-256 treats input data as a \
|
||||
* contiguous array of 32 bit wide \
|
||||
* big-endian values. */
|
||||
#define SHA224_DIGEST_LENGTH 28
|
||||
#define SHA256_DIGEST_LENGTH 32
|
||||
|
||||
typedef struct SHA256state_st {
|
||||
SHA_LONG h[8];
|
||||
SHA_LONG Nl, Nh;
|
||||
SHA_LONG data[SHA_LBLOCK];
|
||||
unsigned int num, md_len;
|
||||
typedef struct SHA256state_st
|
||||
{
|
||||
SHA_LONG h[8];
|
||||
SHA_LONG Nl, Nh;
|
||||
SHA_LONG data[SHA_LBLOCK];
|
||||
unsigned int num, md_len;
|
||||
} SHA256_CTX;
|
||||
|
||||
# ifndef OPENSSL_NO_SHA256
|
||||
# ifdef OPENSSL_FIPS
|
||||
#ifndef OPENSSL_NO_SHA256
|
||||
#ifdef OPENSSL_FIPS
|
||||
int private_SHA224_Init(SHA256_CTX *c);
|
||||
int private_SHA256_Init(SHA256_CTX *c);
|
||||
# endif
|
||||
#endif
|
||||
int SHA224_Init(SHA256_CTX *c);
|
||||
int SHA224_Update(SHA256_CTX *c, const void *data, size_t len);
|
||||
int SHA224_Final(unsigned char *md, SHA256_CTX *c);
|
||||
|
@ -142,12 +145,12 @@ int SHA256_Update(SHA256_CTX *c, const void *data, size_t len);
|
|||
int SHA256_Final(unsigned char *md, SHA256_CTX *c);
|
||||
unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md);
|
||||
void SHA256_Transform(SHA256_CTX *c, const unsigned char *data);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
# define SHA384_DIGEST_LENGTH 48
|
||||
# define SHA512_DIGEST_LENGTH 64
|
||||
#define SHA384_DIGEST_LENGTH 48
|
||||
#define SHA512_DIGEST_LENGTH 64
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue