mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2025-01-25 18:30:04 +00:00
SHA1: Code formatting
This commit is contained in:
parent
5015dceee0
commit
16e4e98ea0
25
lib/sha1.c
25
lib/sha1.c
@ -12,12 +12,12 @@
|
||||
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "lib/null.h"
|
||||
#include "lib/sha1.h"
|
||||
#include "lib/unaligned.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
void
|
||||
sha1_init(sha1_context *hd)
|
||||
{
|
||||
@ -54,7 +54,6 @@ transform(sha1_context *hd, const byte *data)
|
||||
x[i] = get_u32(data+4*i);
|
||||
#endif
|
||||
|
||||
|
||||
#define K1 0x5A827999L
|
||||
#define K2 0x6ED9EBA1L
|
||||
#define K3 0x8F1BBCDCL
|
||||
@ -64,19 +63,18 @@ transform(sha1_context *hd, const byte *data)
|
||||
#define F3(x,y,z) ( ( x & y ) | ( z & ( x | y ) ) )
|
||||
#define F4(x,y,z) ( x ^ y ^ z )
|
||||
|
||||
#define M(i) (tm = x[i&0x0f] ^ x[(i-14)&0x0f] ^ x[(i-8)&0x0f] ^ x[(i-3)&0x0f], (x[i&0x0f] = ROL(tm, 1)))
|
||||
|
||||
#define M(i) ( tm = x[i&0x0f] ^ x[(i-14)&0x0f] \
|
||||
^ x[(i-8)&0x0f] ^ x[(i-3)&0x0f] \
|
||||
, (x[i&0x0f] = ROL(tm, 1)) )
|
||||
/** Bitwise rotation of an unsigned int to the left **/
|
||||
#define ROL(x, bits) (((x) << (bits)) | ((uint)(x) >> (sizeof(uint)*8 - (bits))))
|
||||
|
||||
#define ROL(x, bits) (((x) << (bits)) | ((uint)(x) >> (sizeof(uint)*8 - (bits)))) /** Bitwise rotation of an unsigned int to the left **/
|
||||
|
||||
#define R(a,b,c,d,e,f,k,m) do { e += ROL( a, 5 ) \
|
||||
+ f( b, c, d ) \
|
||||
+ k \
|
||||
+ m; \
|
||||
#define R(a, b, c, d, e, f, k, m) \
|
||||
do \
|
||||
{ \
|
||||
e += ROL(a, 5) + f(b, c, d) + k + m; \
|
||||
b = ROL( b, 30 ); \
|
||||
} while(0)
|
||||
|
||||
R( a, b, c, d, e, F1, K1, x[ 0] );
|
||||
R( e, a, b, c, d, F1, K1, x[ 1] );
|
||||
R( d, e, a, b, c, F1, K1, x[ 2] );
|
||||
@ -166,7 +164,6 @@ transform(sha1_context *hd, const byte *data)
|
||||
hd->h4 += e;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Update the message digest with the contents
|
||||
* of INBUF with length INLEN.
|
||||
@ -204,7 +201,6 @@ sha1_update(sha1_context *hd, const byte *inbuf, uint inlen)
|
||||
hd->buf[hd->count++] = *inbuf++;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The routine final terminates the computation and
|
||||
* returns the digest.
|
||||
@ -212,7 +208,6 @@ sha1_update(sha1_context *hd, const byte *inbuf, uint inlen)
|
||||
* handle will the destroy the returned buffer.
|
||||
* Returns: 20 bytes representing the digest.
|
||||
*/
|
||||
|
||||
byte *
|
||||
sha1_final(sha1_context *hd)
|
||||
{
|
||||
|
@ -12,11 +12,11 @@
|
||||
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "lib/sha1.h"
|
||||
#include "lib/unaligned.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
void
|
||||
sha1_hmac_init(sha1_hmac_context *hd, const byte *key, uint keylen)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user