diff --git a/sys/hashes/sha512_common.c b/sys/hashes/sha512_common.c index b205c1e746b2..b5480d824cf0 100644 --- a/sys/hashes/sha512_common.c +++ b/sys/hashes/sha512_common.c @@ -164,6 +164,8 @@ static const unsigned char PAD[128] = { /* Add padding and terminating bit-count. */ void sha512_common_pad(sha512_common_context_t *ctx) { + assert(ctx != NULL); + /* * Convert length to a vector of bytes -- we do this now rather * than later because the length will change after we pad. @@ -184,6 +186,8 @@ void sha512_common_pad(sha512_common_context_t *ctx) /* Add bytes into the hash */ void sha512_common_update(sha512_common_context_t *ctx, const void *data, size_t len) { + assert(ctx != NULL); + /* Number of bytes left in the buffer from previous updates */ uint8_t r = (ctx->count[1] >> 3) & 0x7f; /* Number of bytes free in the buffer from previous updates */ @@ -233,6 +237,8 @@ void sha512_common_update(sha512_common_context_t *ctx, const void *data, size_t */ void sha512_common_final(sha512_common_context_t *ctx, void *dst, size_t dig_len) { + assert(ctx != NULL); + /* Add padding */ sha512_common_pad(ctx); diff --git a/sys/include/hashes/sha512.h b/sys/include/hashes/sha512.h index f632904c9b29..4777b7eec9f3 100644 --- a/sys/include/hashes/sha512.h +++ b/sys/include/hashes/sha512.h @@ -49,14 +49,14 @@ typedef sha512_common_context_t sha512_context_t; /** * @brief SHA-512 initialization. Begins a SHA-512 operation. * - * @param ctx sha512_context_t handle to init + * @param ctx sha512_context_t handle to init, must not be NULL */ void sha512_init(sha512_context_t *ctx); /** * @brief Add bytes into the hash * - * @param ctx sha512_context_t handle to use + * @param ctx sha512_context_t handle to use, must not be NULL * @param[in] data Input data * @param[in] len Length of @p data */ @@ -69,7 +69,7 @@ static inline void sha512_update(sha512_context_t *ctx, const void *data, size_t * @brief SHA-512 finalization. Pads the input data, exports the hash value, * and clears the context state. * - * @param ctx sha512_context_t handle to use + * @param ctx sha512_context_t handle to use, must not be NULL * @param[out] digest pointer to resulting digest, this is the hash of all the bytes. * Length must be at least SHA512_DIGEST_LENGTH */ diff --git a/sys/include/hashes/sha512_common.h b/sys/include/hashes/sha512_common.h index d00e40843006..347b6cdfe38f 100644 --- a/sys/include/hashes/sha512_common.h +++ b/sys/include/hashes/sha512_common.h @@ -43,14 +43,14 @@ typedef struct { /** * @brief SHA-512 initialization. Begins a SHA-512 operation. * - * @param ctx sha512_common_context_t handle to init + * @param ctx sha512_common_context_t handle to init, must not be NULL */ void sha512_common_pad(sha512_common_context_t *ctx); /** * @brief Add bytes into the hash * - * @param ctx sha512_common_context_t handle to use + * @param ctx sha512_common_context_t handle to use, must not be NULL * @param[in] data Input data * @param[in] len Length of @p data */ @@ -60,7 +60,7 @@ void sha512_common_update(sha512_common_context_t *ctx, const void *data, size_t * @brief SHA-512 finalization. Pads the input data, exports the hash value, * and clears the context state. * - * @param ctx sha512_common_context_t handle to use + * @param ctx sha512_common_context_t handle to use, must not be NULL * @param[out] digest resulting digest, this is the hash of all the bytes * @param[in] dig_len Length of @p digest */