Improve SHA-1 documentation

This commit is contained in:
Hanno Becker 2018-12-18 11:11:18 +00:00
parent c523e011e0
commit 5359ca8a54

View File

@ -80,7 +80,7 @@ mbedtls_sha1_context;
* stronger message digests instead. * stronger message digests instead.
* *
* \param ctx The SHA-1 context to initialize. * \param ctx The SHA-1 context to initialize.
* Must not be \c NULL. * This must not be \c NULL.
* *
*/ */
void mbedtls_sha1_init( mbedtls_sha1_context *ctx ); void mbedtls_sha1_init( mbedtls_sha1_context *ctx );
@ -92,7 +92,10 @@ void mbedtls_sha1_init( mbedtls_sha1_context *ctx );
* constitutes a security risk. We recommend considering * constitutes a security risk. We recommend considering
* stronger message digests instead. * stronger message digests instead.
* *
* \param ctx The SHA-1 context to clear. * \param ctx The SHA-1 context to clear. This may be \c NULL,
* in which case this function does nothing. If it is
* not \c NULL, it must point to an initialized
* SHA-1 context.
* *
*/ */
void mbedtls_sha1_free( mbedtls_sha1_context *ctx ); void mbedtls_sha1_free( mbedtls_sha1_context *ctx );
@ -104,10 +107,8 @@ void mbedtls_sha1_free( mbedtls_sha1_context *ctx );
* constitutes a security risk. We recommend considering * constitutes a security risk. We recommend considering
* stronger message digests instead. * stronger message digests instead.
* *
* \param dst The SHA-1 context to clone to. * \param dst The SHA-1 context to clone to. This must be initialized.
* Must not be \c NULL. * \param src The SHA-1 context to clone from. This must be initialized.
* \param src The SHA-1 context to clone from.
* Must not be \c NULL.
* *
*/ */
void mbedtls_sha1_clone( mbedtls_sha1_context *dst, void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
@ -120,10 +121,10 @@ void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
* constitutes a security risk. We recommend considering * constitutes a security risk. We recommend considering
* stronger message digests instead. * stronger message digests instead.
* *
* \param ctx The SHA-1 context to initialize. * \param ctx The SHA-1 context to initialize. This must be initialized.
* Must not be \c NULL.
* *
* \return \c 0 on success. * \return \c 0 on success.
* \return A negative error code on failure.
* *
*/ */
int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx ); int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx );
@ -136,13 +137,15 @@ int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx );
* constitutes a security risk. We recommend considering * constitutes a security risk. We recommend considering
* stronger message digests instead. * stronger message digests instead.
* *
* \param ctx The SHA-1 context. * \param ctx The SHA-1 context. This must be initialized
* Must not be \c NULL. * and have a hash operation started.
* \param input The buffer holding the input data. * \param input The buffer holding the input data.
* Must not be \c NULL if \p ilen is greater than 0. * This must be a readable buffer of length \p ilen Bytes.
* \param ilen The length of the input data. * It may be \c NULL if \p ilen is zero.
* \param ilen The length of the input data \p input in Bytes.
* *
* \return \c 0 on success. * \return \c 0 on success.
* \return A negative error code on failure.
*/ */
int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx, int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx,
const unsigned char *input, const unsigned char *input,
@ -156,12 +159,14 @@ int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx,
* constitutes a security risk. We recommend considering * constitutes a security risk. We recommend considering
* stronger message digests instead. * stronger message digests instead.
* *
* \param ctx The SHA-1 context. * \param ctx The SHA-1 context to use. This must be initialized and
* Must not be \c NULL. * have a hash operation started.
* \param output The SHA-1 checksum result. * This must not be \c NULL.
* Must not be \c NULL. * \param output The SHA-1 checksum result. This must be a writable
* buffer of length \c 20 Bytes.
* *
* \return \c 0 on success. * \return \c 0 on success.
* \return A negative error code on failure.
*/ */
int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx, int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx,
unsigned char output[20] ); unsigned char output[20] );
@ -173,12 +178,13 @@ int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx,
* constitutes a security risk. We recommend considering * constitutes a security risk. We recommend considering
* stronger message digests instead. * stronger message digests instead.
* *
* \param ctx The SHA-1 context. * \param ctx The SHA-1 context to use. This must be initialized and
* Must not be \c NULL. * have a hash operation started.
* \param data The data block being processed. * \param data The data block being processed. This must be a
* Must not be \c NULL. * readable buffer of length \c 64 Bytes.
* *
* \return \c 0 on success. * \return \c 0 on success.
* \return A negative error code on failure.
* *
*/ */
int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx, int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx,
@ -199,8 +205,7 @@ int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx,
* *
* \deprecated Superseded by mbedtls_sha1_starts_ret() in 2.7.0. * \deprecated Superseded by mbedtls_sha1_starts_ret() in 2.7.0.
* *
* \param ctx The SHA-1 context to initialize. * \param ctx The SHA-1 context to initialize. This must be initialized.
* Must not be \c NULL.
* *
*/ */
MBEDTLS_DEPRECATED void mbedtls_sha1_starts( mbedtls_sha1_context *ctx ); MBEDTLS_DEPRECATED void mbedtls_sha1_starts( mbedtls_sha1_context *ctx );
@ -215,11 +220,12 @@ MBEDTLS_DEPRECATED void mbedtls_sha1_starts( mbedtls_sha1_context *ctx );
* *
* \deprecated Superseded by mbedtls_sha1_update_ret() in 2.7.0. * \deprecated Superseded by mbedtls_sha1_update_ret() in 2.7.0.
* *
* \param ctx The SHA-1 context. * \param ctx The SHA-1 context. THis must be initialized and
* Must not be \c NULL. * have a hash operation started.
* \param input The buffer holding the input data. * \param input The buffer holding the input data.
* Must not be \c NULL if \p ilen is greater than 0. * This must be a readable buffer of length \p ilen Bytes.
* \param ilen The length of the input data. * It may be \c NULL if \p ilen is zero.
* \param ilen The length of the input data \p input in Bytes.
* *
*/ */
MBEDTLS_DEPRECATED void mbedtls_sha1_update( mbedtls_sha1_context *ctx, MBEDTLS_DEPRECATED void mbedtls_sha1_update( mbedtls_sha1_context *ctx,
@ -236,11 +242,10 @@ MBEDTLS_DEPRECATED void mbedtls_sha1_update( mbedtls_sha1_context *ctx,
* *
* \deprecated Superseded by mbedtls_sha1_finish_ret() in 2.7.0. * \deprecated Superseded by mbedtls_sha1_finish_ret() in 2.7.0.
* *
* \param ctx The SHA-1 context. * \param ctx The SHA-1 context. This must be initialized and
* Must not be \c NULL. * have a hash operation started.
* \param output The SHA-1 checksum result. * \param output The SHA-1 checksum result.
* Must not be \c NULL. * This must be a writable buffer of length \c 20 Bytes.
*
*/ */
MBEDTLS_DEPRECATED void mbedtls_sha1_finish( mbedtls_sha1_context *ctx, MBEDTLS_DEPRECATED void mbedtls_sha1_finish( mbedtls_sha1_context *ctx,
unsigned char output[20] ); unsigned char output[20] );
@ -254,10 +259,10 @@ MBEDTLS_DEPRECATED void mbedtls_sha1_finish( mbedtls_sha1_context *ctx,
* *
* \deprecated Superseded by mbedtls_internal_sha1_process() in 2.7.0. * \deprecated Superseded by mbedtls_internal_sha1_process() in 2.7.0.
* *
* \param ctx The SHA-1 context. * \param ctx The SHA-1 context. This must be initialized and
* Must not be \c NULL. * have a hash operation started.
* \param data The data block being processed. * \param data The data block being processed.
* Must not be \c NULL. * This must be a readable buffer of length \c 64 bytes.
* *
*/ */
MBEDTLS_DEPRECATED void mbedtls_sha1_process( mbedtls_sha1_context *ctx, MBEDTLS_DEPRECATED void mbedtls_sha1_process( mbedtls_sha1_context *ctx,
@ -280,12 +285,14 @@ MBEDTLS_DEPRECATED void mbedtls_sha1_process( mbedtls_sha1_context *ctx,
* stronger message digests instead. * stronger message digests instead.
* *
* \param input The buffer holding the input data. * \param input The buffer holding the input data.
* Must not be \c NULL if \p ilen is greater than 0. * This must be a readable buffer of length \p ilen Bytes.
* \param ilen The length of the input data. * It may be \c NULL if \p ilen is zero.
* \param ilen The length of the input data \p input in Bytes.
* \param output The SHA-1 checksum result. * \param output The SHA-1 checksum result.
* Must not be \c NULL. * This must be a writable buffer of length \c 20 Bytes.
* *
* \return \c 0 on success. * \return \c 0 on success.
* \return A negative error code on failure.
* *
*/ */
int mbedtls_sha1_ret( const unsigned char *input, int mbedtls_sha1_ret( const unsigned char *input,
@ -314,10 +321,11 @@ int mbedtls_sha1_ret( const unsigned char *input,
* \deprecated Superseded by mbedtls_sha1_ret() in 2.7.0 * \deprecated Superseded by mbedtls_sha1_ret() in 2.7.0
* *
* \param input The buffer holding the input data. * \param input The buffer holding the input data.
* Must not be \c NULL if \p ilen is greater than 0. * This must be a readable buffer of length \p ilen Bytes.
* \param ilen The length of the input data. * It may be \c NULL if \p ilen is zero.
* \param output The SHA-1 checksum result. * \param ilen The length of the input data \p input in Bytes.
* Must not be \c NULL. * \param output The SHA-1 checksum result. This must be a writable
* buffer of size \c 20 Bytes.
* *
*/ */
MBEDTLS_DEPRECATED void mbedtls_sha1( const unsigned char *input, MBEDTLS_DEPRECATED void mbedtls_sha1( const unsigned char *input,