1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-26 16:18:22 +00:00

reorder parameters of hash_final methods

This commit is contained in:
Pavol Rusnak 2016-04-26 11:50:04 +02:00
parent c01be339f5
commit ed6debf8c4
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
6 changed files with 16 additions and 16 deletions

View File

@ -14,5 +14,5 @@
#define ed25519_hash_context SHA512_CTX
#define ed25519_hash_init(ctx) sha512_Init(ctx)
#define ed25519_hash_update(ctx, in, inlen) sha512_Update((ctx), (in), (inlen))
#define ed25519_hash_final(ctx, hash) sha512_Final((hash), (ctx))
#define ed25519_hash_final(ctx, hash) sha512_Final((ctx), (hash))
#define ed25519_hash(hash, in, inlen) sha512_Raw((in), (inlen), (hash))

8
hmac.c
View File

@ -48,12 +48,12 @@ void hmac_sha256(const uint8_t *key, const uint32_t keylen, const uint8_t *msg,
sha256_Init(&ctx);
sha256_Update(&ctx, i_key_pad, SHA256_BLOCK_LENGTH);
sha256_Update(&ctx, msg, msglen);
sha256_Final(buf, &ctx);
sha256_Final(&ctx, buf);
sha256_Init(&ctx);
sha256_Update(&ctx, o_key_pad, SHA256_BLOCK_LENGTH);
sha256_Update(&ctx, buf, SHA256_DIGEST_LENGTH);
sha256_Final(hmac, &ctx);
sha256_Final(&ctx, hmac);
MEMSET_BZERO(buf, sizeof(buf));
MEMSET_BZERO(o_key_pad, sizeof(o_key_pad));
MEMSET_BZERO(i_key_pad, sizeof(i_key_pad));
@ -80,12 +80,12 @@ void hmac_sha512(const uint8_t *key, const uint32_t keylen, const uint8_t *msg,
sha512_Init(&ctx);
sha512_Update(&ctx, i_key_pad, SHA512_BLOCK_LENGTH);
sha512_Update(&ctx, msg, msglen);
sha512_Final(buf, &ctx);
sha512_Final(&ctx, buf);
sha512_Init(&ctx);
sha512_Update(&ctx, o_key_pad, SHA512_BLOCK_LENGTH);
sha512_Update(&ctx, buf, SHA512_DIGEST_LENGTH);
sha512_Final(hmac, &ctx);
sha512_Final(&ctx, hmac);
MEMSET_BZERO(buf, sizeof(buf));
MEMSET_BZERO(o_key_pad, sizeof(o_key_pad));

View File

@ -301,7 +301,7 @@ static const uint8_t ripemd160_padding[64] =
/*
* RIPEMD-160 final digest
*/
void ripemd160_Final( uint8_t output[20], RIPEMD160_CTX *ctx )
void ripemd160_Final( RIPEMD160_CTX *ctx, uint8_t output[20] )
{
uint32_t last, padn;
uint32_t high, low;
@ -335,5 +335,5 @@ void ripemd160(const uint8_t *msg, uint32_t msg_len, uint8_t hash[20])
RIPEMD160_CTX ctx;
ripemd160_Init( &ctx );
ripemd160_Update( &ctx, msg, msg_len );
ripemd160_Final( hash, &ctx );
ripemd160_Final( &ctx, hash );
}

View File

@ -11,7 +11,7 @@ typedef struct _RIPEMD160_CTX {
void ripemd160_Init(RIPEMD160_CTX *ctx);
void ripemd160_Update(RIPEMD160_CTX *ctx, const uint8_t *input, uint32_t ilen);
void ripemd160_Final(uint8_t output[20], RIPEMD160_CTX *ctx);
void ripemd160_Final(RIPEMD160_CTX *ctx, uint8_t output[20]);
void ripemd160(const uint8_t *msg, uint32_t msg_len, uint8_t hash[20]);
#endif

12
sha2.c
View File

@ -505,7 +505,7 @@ void sha256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) {
usedspace = freespace = 0;
}
void sha256_Final(sha2_byte digest[], SHA256_CTX* context) {
void sha256_Final(SHA256_CTX* context, sha2_byte digest[]) {
sha2_word32 *d = (sha2_word32*)digest;
unsigned int usedspace;
@ -571,7 +571,7 @@ char *sha256_End(SHA256_CTX* context, char buffer[]) {
int i;
if (buffer != (char*)0) {
sha256_Final(digest, context);
sha256_Final(context, digest);
for (i = 0; i < SHA256_DIGEST_LENGTH; i++) {
*buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
@ -590,7 +590,7 @@ void sha256_Raw(const sha2_byte* data, size_t len, uint8_t digest[SHA256_DIGEST_
SHA256_CTX context;
sha256_Init(&context);
sha256_Update(&context, data, len);
sha256_Final(digest, &context);
sha256_Final(&context, digest);
}
char* sha256_Data(const sha2_byte* data, size_t len, char digest[SHA256_DIGEST_STRING_LENGTH]) {
@ -870,7 +870,7 @@ void sha512_Last(SHA512_CTX* context) {
sha512_Transform(context, (sha2_word64*)context->buffer);
}
void sha512_Final(sha2_byte digest[], SHA512_CTX* context) {
void sha512_Final(SHA512_CTX* context, sha2_byte digest[]) {
sha2_word64 *d = (sha2_word64*)digest;
/* If no digest buffer is passed, we don't bother doing this: */
@ -901,7 +901,7 @@ char *sha512_End(SHA512_CTX* context, char buffer[]) {
int i;
if (buffer != (char*)0) {
sha512_Final(digest, context);
sha512_Final(context, digest);
for (i = 0; i < SHA512_DIGEST_LENGTH; i++) {
*buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
@ -920,7 +920,7 @@ void sha512_Raw(const sha2_byte* data, size_t len, uint8_t digest[SHA512_DIGEST_
SHA512_CTX context;
sha512_Init(&context);
sha512_Update(&context, data, len);
sha512_Final(digest, &context);
sha512_Final(&context, digest);
}
char* sha512_Data(const sha2_byte* data, size_t len, char digest[SHA512_DIGEST_STRING_LENGTH]) {

4
sha2.h
View File

@ -54,14 +54,14 @@ typedef struct _SHA512_CTX {
void sha256_Init(SHA256_CTX *);
void sha256_Update(SHA256_CTX*, const uint8_t*, size_t);
void sha256_Final(uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*);
void sha256_Final(SHA256_CTX*, uint8_t[SHA256_DIGEST_LENGTH]);
char* sha256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]);
void sha256_Raw(const uint8_t*, size_t, uint8_t[SHA256_DIGEST_LENGTH]);
char* sha256_Data(const uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]);
void sha512_Init(SHA512_CTX*);
void sha512_Update(SHA512_CTX*, const uint8_t*, size_t);
void sha512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
void sha512_Final(SHA512_CTX*, uint8_t[SHA512_DIGEST_LENGTH]);
char* sha512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]);
void sha512_Raw(const uint8_t*, size_t, uint8_t[SHA512_DIGEST_LENGTH]);
char* sha512_Data(const uint8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]);