Skip to content

Commit

Permalink
sys/hashes: inline functions in sha224/sha256
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterKietzmann committed Jun 10, 2020
1 parent 454d1fe commit f9c67e1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 34 deletions.
15 changes: 0 additions & 15 deletions sys/hashes/sha224.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,6 @@ void sha224_init(sha224_context_t *ctx)
ctx->state[7] = 0xBEFA4FA4;
}

/* Add bytes into the hash */
void sha224_update(sha224_context_t *ctx, const void *data, size_t len)
{
sha2xx_update(ctx, data, len);
}

/*
* SHA-224 finalization. Pads the input data, exports the hash value,
* and clears the context state.
*/
void sha224_final(sha224_context_t *ctx, void *dst)
{
sha2xx_final(ctx, dst, SHA224_DIGEST_LENGTH);
}

void *sha224(const void *data, size_t len, void *digest)
{
sha224_context_t c;
Expand Down
15 changes: 0 additions & 15 deletions sys/hashes/sha256.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,6 @@ void sha256_init(sha256_context_t *ctx)
ctx->state[7] = 0x5BE0CD19;
}

/* Add bytes into the hash */
void sha256_update(sha256_context_t *ctx, const void *data, size_t len)
{
sha2xx_update(ctx, data, len);
}

/*
* SHA-256 finalization. Pads the input data, exports the hash value,
* and clears the context state.
*/
void sha256_final(sha256_context_t *ctx, void *dst)
{
sha2xx_final(ctx, dst, SHA256_DIGEST_LENGTH);
}

void *sha256(const void *data, size_t len, void *digest)
{
sha256_context_t c;
Expand Down
10 changes: 8 additions & 2 deletions sys/include/hashes/sha224.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ void sha224_init(sha224_context_t *ctx);
* @param[in] data Input data
* @param[in] len Length of @p data
*/
void sha224_update(sha224_context_t *ctx, const void *data, size_t len);
static inline void sha224_update(sha224_context_t *ctx, const void *data, size_t len)
{
sha2xx_update(ctx, data, len);
}

/**
* @brief SHA-224 finalization. Pads the input data, exports the hash value,
Expand All @@ -97,7 +100,10 @@ void sha224_update(sha224_context_t *ctx, const void *data, size_t len);
* @param ctx sha224_context_t handle to use
* @param digest resulting digest, this is the hash of all the bytes
*/
void sha224_final(sha224_context_t *ctx, void *digest);
static inline void sha224_final(sha224_context_t *ctx, void *digest)
{
sha2xx_final(ctx, digest, SHA224_DIGEST_LENGTH);
}

/**
* @brief A wrapper function to simplify the generation of a hash, this is
Expand Down
10 changes: 8 additions & 2 deletions sys/include/hashes/sha256.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ void sha256_init(sha256_context_t *ctx);
* @param[in] data Input data
* @param[in] len Length of @p data
*/
void sha256_update(sha256_context_t *ctx, const void *data, size_t len);
static inline void sha256_update(sha256_context_t *ctx, const void *data, size_t len)
{
sha2xx_update(ctx, data, len);
}

/**
* @brief SHA-256 finalization. Pads the input data, exports the hash value,
Expand All @@ -115,7 +118,10 @@ void sha256_update(sha256_context_t *ctx, const void *data, size_t len);
* @param ctx sha256_context_t handle to use
* @param digest resulting digest, this is the hash of all the bytes
*/
void sha256_final(sha256_context_t *ctx, void *digest);
static inline void sha256_final(sha256_context_t *ctx, void *digest)
{
sha2xx_final(ctx, digest, SHA256_DIGEST_LENGTH);
}

/**
* @brief A wrapper function to simplify the generation of a hash, this is
Expand Down

0 comments on commit f9c67e1

Please sign in to comment.