mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 12:21:22 -05:00
crypto: lib/sha256 - improve function prototypes
Follow best practices by changing the length parameters to size_t and explicitly specifying the length of the output digest arrays. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
@@ -100,9 +100,9 @@ static inline void sha256_init(struct sha256_state *sctx)
|
||||
sctx->state[7] = SHA256_H7;
|
||||
sctx->count = 0;
|
||||
}
|
||||
void sha256_update(struct sha256_state *sctx, const u8 *data, unsigned int len);
|
||||
void sha256_final(struct sha256_state *sctx, u8 *out);
|
||||
void sha256(const u8 *data, unsigned int len, u8 *out);
|
||||
void sha256_update(struct sha256_state *sctx, const u8 *data, size_t len);
|
||||
void sha256_final(struct sha256_state *sctx, u8 out[SHA256_DIGEST_SIZE]);
|
||||
void sha256(const u8 *data, size_t len, u8 out[SHA256_DIGEST_SIZE]);
|
||||
|
||||
static inline void sha224_init(struct sha256_state *sctx)
|
||||
{
|
||||
@@ -117,6 +117,6 @@ static inline void sha224_init(struct sha256_state *sctx)
|
||||
sctx->count = 0;
|
||||
}
|
||||
/* Simply use sha256_update as it is equivalent to sha224_update. */
|
||||
void sha224_final(struct sha256_state *sctx, u8 *out);
|
||||
void sha224_final(struct sha256_state *sctx, u8 out[SHA224_DIGEST_SIZE]);
|
||||
|
||||
#endif /* _CRYPTO_SHA2_H */
|
||||
|
||||
@@ -70,7 +70,7 @@ static inline void __sha256_update(struct sha256_state *sctx, const u8 *data,
|
||||
memcpy(&sctx->buf[partial], data, len);
|
||||
}
|
||||
|
||||
void sha256_update(struct sha256_state *sctx, const u8 *data, unsigned int len)
|
||||
void sha256_update(struct sha256_state *sctx, const u8 *data, size_t len)
|
||||
{
|
||||
__sha256_update(sctx, data, len, false);
|
||||
}
|
||||
@@ -101,19 +101,19 @@ static inline void __sha256_final(struct sha256_state *sctx, u8 *out,
|
||||
memzero_explicit(sctx, sizeof(*sctx));
|
||||
}
|
||||
|
||||
void sha256_final(struct sha256_state *sctx, u8 *out)
|
||||
void sha256_final(struct sha256_state *sctx, u8 out[SHA256_DIGEST_SIZE])
|
||||
{
|
||||
__sha256_final(sctx, out, SHA256_DIGEST_SIZE, false);
|
||||
}
|
||||
EXPORT_SYMBOL(sha256_final);
|
||||
|
||||
void sha224_final(struct sha256_state *sctx, u8 *out)
|
||||
void sha224_final(struct sha256_state *sctx, u8 out[SHA224_DIGEST_SIZE])
|
||||
{
|
||||
__sha256_final(sctx, out, SHA224_DIGEST_SIZE, false);
|
||||
}
|
||||
EXPORT_SYMBOL(sha224_final);
|
||||
|
||||
void sha256(const u8 *data, unsigned int len, u8 *out)
|
||||
void sha256(const u8 *data, size_t len, u8 out[SHA256_DIGEST_SIZE])
|
||||
{
|
||||
struct sha256_state sctx;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user