From 17a0035a1c312a69769a6373b8d137b2cbe8592c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Tvrd=C3=ADk?= Date: Tue, 28 Apr 2015 09:08:43 +0200 Subject: [PATCH] SHA: Fixing small bugs and code style Thanks to Ondrej Zajicek --- lib/sha1.h | 12 ++++++------ lib/sha256.h | 8 ++++---- lib/sha256_hmac.h | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/sha1.h b/lib/sha1.h index cb2a5f14..78023b72 100644 --- a/lib/sha1.h +++ b/lib/sha1.h @@ -12,8 +12,8 @@ * Can be freely distributed and used under the terms of the GNU GPL. */ -#ifndef _BIRD_SHA1_H -#define _BIRD_SHA1_H +#ifndef _BIRD_SHA1_H_ +#define _BIRD_SHA1_H_ #include "sysdep/config.h" @@ -79,8 +79,8 @@ void sha1_hmac_init(sha1_hmac_context *hd, const byte *key, uint keylen); /** In void sha1_hmac_update(sha1_hmac_context *hd, const byte *data, uint datalen); /** Hash another @datalen bytes of data. See sha1_update(). */ byte *sha1_hmac_final(sha1_hmac_context *hd); /** Terminate the HMAC and return a pointer to the allocated hash. See sha1_final(). */ -#define SHA1_SIZE 20 /** Size of the SHA1 hash in its binary representation **/ -#define SHA1_HEX_SIZE 41 /** Buffer length for a string containing SHA1 in hexadecimal format. **/ -#define SHA1_BLOCK_SIZE 64 /** SHA1 splits input to blocks of this size. **/ +#define SHA1_SIZE 20 /** Size of the SHA1 hash in its binary representation **/ +#define SHA1_HEX_SIZE 41 /** Buffer length for a string containing SHA1 in hexadecimal format. **/ +#define SHA1_BLOCK_SIZE 64 /** SHA1 splits input to blocks of this size. **/ -#endif +#endif /* _BIRD_SHA1_H_ */ diff --git a/lib/sha256.h b/lib/sha256.h index 622f7603..266c66ca 100644 --- a/lib/sha256.h +++ b/lib/sha256.h @@ -9,8 +9,8 @@ * Can be freely distributed and used under the terms of the GNU GPL. */ -#ifndef _BIRD_SHA256_H -#define _BIRD_SHA256_H +#ifndef _BIRD_SHA256_H_ +#define _BIRD_SHA256_H_ #define SHA256_SIZE 32 #define SHA256_HEX_SIZE 65 @@ -28,7 +28,7 @@ typedef struct { typedef sha256_context sha224_context; void sha256_init(sha256_context *ctx); -void sha256_init(sha224_context *ctx); +void sha224_init(sha224_context *ctx); void sha256_update(sha256_context *ctx, const byte *in_buf, size_t in_len); void sha224_update(sha224_context *ctx, const byte *in_buf, size_t in_len) @@ -42,4 +42,4 @@ byte* sha224_final(sha224_context *ctx) return sha256_final(ctx); } -#endif +#endif /* _BIRD_SHA256_H_ */ diff --git a/lib/sha256_hmac.h b/lib/sha256_hmac.h index 72d1797a..cc90357e 100644 --- a/lib/sha256_hmac.h +++ b/lib/sha256_hmac.h @@ -9,8 +9,8 @@ * Can be freely distributed and used under the terms of the GNU GPL. */ -#ifndef SHA256_HMAC_H -#define SHA256_HMAC_H +#ifndef _BIRD_SHA256_HMAC_H_ +#define _BIRD_SHA256_HMAC_H_ #define SHA256_SIZE 32 #define SHA256_HEX_SIZE 65 @@ -34,4 +34,4 @@ void sha256_hmac_init(sha256_hmac_context *ctx, const void *key, size_t keylen); void sha256_hmac_update(sha256_hmac_context *ctx, const void *buf, size_t buflen); const byte *sha256_hmac_final(sha256_hmac_context *ctx); -#endif /* SHA256_HMAC_H */ +#endif /* _BIRD_SHA256_HMAC_H_ */