Fix indentation and some whitespace issues.
This commit is contained in:
parent
07108117ce
commit
4b42518813
1 changed files with 68 additions and 68 deletions
|
|
@ -168,7 +168,7 @@ int sha512_init(sha512_context * md) {
|
||||||
@param inlen The length of the data (octets)
|
@param inlen The length of the data (octets)
|
||||||
@return 0 if successful
|
@return 0 if successful
|
||||||
*/
|
*/
|
||||||
int sha512_update (sha512_context * md, const unsigned char *in, size_t inlen)
|
int sha512_update(sha512_context *md, const unsigned char *in, size_t inlen)
|
||||||
{
|
{
|
||||||
size_t n;
|
size_t n;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
@ -215,22 +215,22 @@ int sha512_update (sha512_context * md, const unsigned char *in, size_t inlen)
|
||||||
@param out [out] The destination of the hash (64 bytes)
|
@param out [out] The destination of the hash (64 bytes)
|
||||||
@return 0 if successful
|
@return 0 if successful
|
||||||
*/
|
*/
|
||||||
int sha512_final(sha512_context * md, unsigned char *out)
|
int sha512_final(sha512_context * md, unsigned char *out)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (md == NULL) return 1;
|
if (md == NULL) return 1;
|
||||||
if (out == NULL) return 1;
|
if (out == NULL) return 1;
|
||||||
|
|
||||||
if (md->curlen >= sizeof(md->buf)) {
|
if (md->curlen >= sizeof(md->buf)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* increase the length of the message */
|
/* increase the length of the message */
|
||||||
md->length += md->curlen * UINT64_C(8);
|
md->length += md->curlen * UINT64_C(8);
|
||||||
|
|
||||||
/* append the '1' bit */
|
/* append the '1' bit */
|
||||||
md->buf[md->curlen++] = (unsigned char)0x80;
|
md->buf[md->curlen++] = (unsigned char)0x80;
|
||||||
|
|
||||||
/* if the length is currently above 112 bytes we append zeros
|
/* if the length is currently above 112 bytes we append zeros
|
||||||
* then compress. Then we can fall back to padding zeros and length
|
* then compress. Then we can fall back to padding zeros and length
|
||||||
|
|
@ -248,20 +248,20 @@ int sha512_update (sha512_context * md, const unsigned char *in, size_t inlen)
|
||||||
* note: that from 112 to 120 is the 64 MSB of the length. We assume that you won't hash
|
* note: that from 112 to 120 is the 64 MSB of the length. We assume that you won't hash
|
||||||
* > 2^64 bits of data... :-)
|
* > 2^64 bits of data... :-)
|
||||||
*/
|
*/
|
||||||
while (md->curlen < 120) {
|
while (md->curlen < 120) {
|
||||||
md->buf[md->curlen++] = (unsigned char)0;
|
md->buf[md->curlen++] = (unsigned char)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* store length */
|
/* store length */
|
||||||
STORE64H(md->length, md->buf+120);
|
STORE64H(md->length, md->buf+120);
|
||||||
sha512_compress(md, md->buf);
|
sha512_compress(md, md->buf);
|
||||||
|
|
||||||
/* copy output */
|
/* copy output */
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
STORE64H(md->state[i], out+(8*i));
|
STORE64H(md->state[i], out+(8*i));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sha512(const unsigned char *message, size_t message_len, unsigned char *out)
|
int sha512(const unsigned char *message, size_t message_len, unsigned char *out)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue