projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
*** empty log message ***
[gnulib.git]
/
lib
/
sha.c
diff --git
a/lib/sha.c
b/lib/sha.c
index
f6969a6
..
a75b8cf
100644
(file)
--- a/
lib/sha.c
+++ b/
lib/sha.c
@@
-1,7
+1,7
@@
/* sha.c - Functions to compute the SHA1 hash (message-digest) of files
or blocks of memory. Complies to the NIST specification FIPS-180-1.
/* sha.c - Functions to compute the SHA1 hash (message-digest) of files
or blocks of memory. Complies to the NIST specification FIPS-180-1.
- Copyright (C) 2000 Scott G. Miller
+ Copyright (C) 2000
, 2001
Scott G. Miller
Credits:
Robert Klep <robert@ilse.nl> -- Expansion function fix
Credits:
Robert Klep <robert@ilse.nl> -- Expansion function fix
@@
-24,6
+24,7
@@
#include "md5.h"
#include "sha.h"
#include "md5.h"
#include "sha.h"
+#include "unlocked-io.h"
/*
Not-swap is a macro that does an endian swap on architectures that are
/*
Not-swap is a macro that does an endian swap on architectures that are
@@
-241,7
+242,8
@@
sha_process_bytes (const void *buffer, size_t len, struct sha_ctx *ctx)
#define F4(B,C,D) (B ^ C ^ D)
/* Process LEN bytes of BUFFER, accumulating context into CTX.
#define F4(B,C,D) (B ^ C ^ D)
/* Process LEN bytes of BUFFER, accumulating context into CTX.
- It is assumed that LEN % 64 == 0. */
+ It is assumed that LEN % 64 == 0.
+ Most of this code comes from GnuPG's cipher/sha1.c. */
void
sha_process_block (const void *buffer, size_t len, struct sha_ctx *ctx)
void
sha_process_block (const void *buffer, size_t len, struct sha_ctx *ctx)
@@
-249,7
+251,7
@@
sha_process_block (const void *buffer, size_t len, struct sha_ctx *ctx)
const md5_uint32 *words = buffer;
size_t nwords = len / sizeof (md5_uint32);
const md5_uint32 *endp = words + nwords;
const md5_uint32 *words = buffer;
size_t nwords = len / sizeof (md5_uint32);
const md5_uint32 *endp = words + nwords;
- md5_uint32 x[
80
];
+ md5_uint32 x[
16
];
md5_uint32 a = ctx->A;
md5_uint32 b = ctx->B;
md5_uint32 c = ctx->C;
md5_uint32 a = ctx->A;
md5_uint32 b = ctx->B;
md5_uint32 c = ctx->C;
@@
-265,7
+267,7
@@
sha_process_block (const void *buffer, size_t len, struct sha_ctx *ctx)
#define M(I) ( tm = x[I&0x0f] ^ x[(I-14)&0x0f] \
^ x[(I-8)&0x0f] ^ x[(I-3)&0x0f] \
#define M(I) ( tm = x[I&0x0f] ^ x[(I-14)&0x0f] \
^ x[(I-8)&0x0f] ^ x[(I-3)&0x0f] \
- , (x[I&0x0f] =
(tm << 1) | (tm >> 3
1)) )
+ , (x[I&0x0f] =
rol(tm,
1)) )
#define R(A,B,C,D,E,F,K,M) do { E += rol( A, 5 ) \
+ F( B, C, D ) \
#define R(A,B,C,D,E,F,K,M) do { E += rol( A, 5 ) \
+ F( B, C, D ) \
@@
-278,6
+280,7
@@
sha_process_block (const void *buffer, size_t len, struct sha_ctx *ctx)
{
md5_uint32 tm;
int t;
{
md5_uint32 tm;
int t;
+ /* FIXME: see sha1.c for a better implementation. */
for (t = 0; t < 16; t++)
{
x[t] = NOTSWAP (*words);
for (t = 0; t < 16; t++)
{
x[t] = NOTSWAP (*words);