clean-up
This commit is contained in:
10
src/sha256.c
10
src/sha256.c
@@ -113,7 +113,6 @@ static void sha256_compress(sha256_context *md, const uint8_t *buf)
|
||||
for (i = 0; i < 8; i++) {
|
||||
md->state[i] = md->state[i] + S[i];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void sha256_init(sha256_context *md)
|
||||
@@ -128,7 +127,6 @@ void sha256_init(sha256_context *md)
|
||||
md->state[5] = 0x9B05688CUL;
|
||||
md->state[6] = 0x1F83D9ABUL;
|
||||
md->state[7] = 0x5BE0CD19UL;
|
||||
return;
|
||||
}
|
||||
|
||||
void sha256_process(sha256_context *md, const uint8_t *in, size_t inlen)
|
||||
@@ -160,7 +158,6 @@ void sha256_process(sha256_context *md, const uint8_t *in, size_t inlen)
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void sha256_done(sha256_context *md, uint8_t *out)
|
||||
@@ -175,7 +172,7 @@ void sha256_done(sha256_context *md, uint8_t *out)
|
||||
md->length += md->curlen * 8;
|
||||
|
||||
/* append the '1' bit */
|
||||
md->buf[md->curlen++] = (unsigned char)0x80;
|
||||
md->buf[md->curlen++] = (uint8_t)0x80;
|
||||
|
||||
/* if the length is currently above 56 bytes we append zeros
|
||||
* then compress. Then we can fall back to padding zeros and length
|
||||
@@ -183,7 +180,7 @@ void sha256_done(sha256_context *md, uint8_t *out)
|
||||
*/
|
||||
if (md->curlen > 56) {
|
||||
while (md->curlen < 64) {
|
||||
md->buf[md->curlen++] = (unsigned char)0;
|
||||
md->buf[md->curlen++] = (uint8_t)0;
|
||||
}
|
||||
sha256_compress(md, md->buf);
|
||||
md->curlen = 0;
|
||||
@@ -191,7 +188,7 @@ void sha256_done(sha256_context *md, uint8_t *out)
|
||||
|
||||
/* pad upto 56 bytes of zeroes */
|
||||
while (md->curlen < 56) {
|
||||
md->buf[md->curlen++] = (unsigned char)0;
|
||||
md->buf[md->curlen++] = (uint8_t)0;
|
||||
}
|
||||
|
||||
/* store length */
|
||||
@@ -202,7 +199,6 @@ void sha256_done(sha256_context *md, uint8_t *out)
|
||||
for (i = 0; i < 8; i++) {
|
||||
STORE32H(md->state[i], out + (4 * i));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void sha256_hash(const uint8_t *data, size_t len, uint8_t *digest)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* public api for Thomas Pornin's BearSSL SHA-256 implementation */
|
||||
/* public api for LibTomCrypt SHA-256 implementation */
|
||||
|
||||
/** @file
|
||||
* SHA-256 hash API.
|
||||
|
||||
@@ -101,8 +101,6 @@ static void sha512_compress(sha512_context *md, const uint8_t *buf)
|
||||
for (i = 0; i < 8; i++) {
|
||||
md->state[i] = md->state[i] + S[i];
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void sha512_init(sha512_context *md)
|
||||
@@ -117,7 +115,6 @@ void sha512_init(sha512_context *md)
|
||||
md->state[5] = CONST64(0x9b05688c2b3e6c1f);
|
||||
md->state[6] = CONST64(0x1f83d9abfb41bd6b);
|
||||
md->state[7] = CONST64(0x5be0cd19137e2179);
|
||||
return;
|
||||
}
|
||||
|
||||
void sha512_process(sha512_context *md, const uint8_t *in, size_t inlen)
|
||||
@@ -149,7 +146,6 @@ void sha512_process(sha512_context *md, const uint8_t *in, size_t inlen)
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void sha512_done(sha512_context *md, uint8_t *out)
|
||||
@@ -194,7 +190,6 @@ void sha512_done(sha512_context *md, uint8_t *out)
|
||||
for (i = 0; i < 8; i++) {
|
||||
STORE64H(md->state[i], out + (8 * i));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void sha512_hash(const uint8_t *data, size_t len, uint8_t *digest)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* public api for Thomas Pornin's BearSSL SHA-512 implementation */
|
||||
/* public api for LibTomCrypt SHA-512 implementation */
|
||||
|
||||
/** @file
|
||||
* SHA-512 hash API.
|
||||
|
||||
@@ -14,7 +14,7 @@ int main()
|
||||
{
|
||||
static const struct {
|
||||
const char *msg;
|
||||
unsigned char hash[32];
|
||||
unsigned char hash[SHA256_DIGEST_SIZE];
|
||||
} tests[] = {
|
||||
{"abc",
|
||||
{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40,
|
||||
@@ -27,7 +27,7 @@ int main()
|
||||
};
|
||||
|
||||
int i;
|
||||
unsigned char tmp[32];
|
||||
unsigned char tmp[SHA256_DIGEST_SIZE];
|
||||
sha256_context md;
|
||||
|
||||
for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i++) {
|
||||
|
||||
Reference in New Issue
Block a user