Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Wim Lewis
nettle
Commits
af89b978
Commit
af89b978
authored
Mar 26, 2010
by
Niels Möller
Browse files
(sha1_digest): Use _nettle_write_be32.
Rev: nettle/sha1.c:1.2
parent
e6dc6b62
Changes
1
Hide whitespace changes
Inline
Side-by-side
sha1.c
View file @
af89b978
...
...
@@ -47,6 +47,7 @@
#include
"sha.h"
#include
"macros.h"
#include
"nettle-write.h"
/* A block, treated as a sequence of 32-bit words. */
#define SHA1_DATA_LENGTH 16
...
...
@@ -164,42 +165,9 @@ sha1_digest(struct sha1_ctx *ctx,
unsigned
length
,
uint8_t
*
digest
)
{
unsigned
i
;
unsigned
words
;
unsigned
leftover
;
assert
(
length
<=
SHA1_DIGEST_SIZE
);
sha1_final
(
ctx
);
words
=
length
/
4
;
leftover
=
length
%
4
;
for
(
i
=
0
;
i
<
words
;
i
++
,
digest
+=
4
)
WRITE_UINT32
(
digest
,
ctx
->
digest
[
i
]);
if
(
leftover
)
{
uint32_t
word
;
unsigned
j
=
leftover
;
assert
(
i
<
_SHA1_DIGEST_LENGTH
);
word
=
ctx
->
digest
[
i
];
switch
(
leftover
)
{
default:
abort
();
case
3
:
digest
[
--
j
]
=
(
word
>>
8
)
&
0xff
;
/* Fall through */
case
2
:
digest
[
--
j
]
=
(
word
>>
16
)
&
0xff
;
/* Fall through */
case
1
:
digest
[
--
j
]
=
(
word
>>
24
)
&
0xff
;
}
}
_nettle_write_be32
(
length
,
digest
,
ctx
->
digest
);
sha1_init
(
ctx
);
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment