0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-10-18 09:58:43 +00:00

SHA1: Use get_u32 and put_u32

This commit is contained in:
Pavel Tvrdík 2015-04-23 11:27:36 +02:00
parent dd78aae55c
commit 24ff638db2
2 changed files with 6 additions and 8 deletions

View File

@ -49,11 +49,9 @@ transform(sha1_context *hd, const byte *data)
#ifdef CPU_BIG_ENDIAN
memcpy(x, data, 64);
#else
{
int i;
for (i=0; i<16; i++)
x[i] = htonl(*((u32*)(data+4*i)));
}
int i;
for (i = 0; i < 16; i++)
x[i] = get_u32(data+4*i);
#endif
@ -263,7 +261,7 @@ sha1_final(sha1_context *hd)
transform(hd, hd->buf);
p = (u32*) hd->buf;
#define X(a) do { *(p++) = ntohl(hd->h##a); } while(0)
#define X(a) do { put_u32(p, hd->h##a); p++; } while(0)
X(0);
X(1);
X(2);

View File

@ -21,7 +21,7 @@
#include <netinet/in.h>
static inline u16
get_u16(void *p)
get_u16(const void *p)
{
u16 x;
memcpy(&x, p, 2);
@ -29,7 +29,7 @@ get_u16(void *p)
}
static inline u32
get_u32(void *p)
get_u32(const void *p)
{
u32 x;
memcpy(&x, p, 4);