Skip to content

Commit

Permalink
Style.
Browse files Browse the repository at this point in the history
Signed-off-by: Pol Henarejos <[email protected]>
  • Loading branch information
polhenarejos authored and lhuang04 committed Apr 2, 2024
1 parent b6cd31e commit 21460a8
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 223 deletions.
37 changes: 17 additions & 20 deletions include/mbedtls/sha3.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ extern "C" {
* It identifies the family (SHA3-256, SHA3-512, etc.)
*/

typedef enum
{
typedef enum {
MBEDTLS_SHA3_NONE = 0, /*!< Operation not defined. */
MBEDTLS_SHA3_224, /*!< SHA3-224 */
MBEDTLS_SHA3_256, /*!< SHA3-256 */
Expand All @@ -56,8 +55,7 @@ typedef enum
} mbedtls_sha3_id;

struct mbedtls_sha3_context;
typedef struct mbedtls_sha3_family_functions
{
typedef struct mbedtls_sha3_family_functions {
mbedtls_sha3_id id;

uint16_t r;
Expand Down Expand Up @@ -88,7 +86,7 @@ mbedtls_sha3_context;
*
* \param ctx The SHA-3 context to initialize. This must not be \c NULL.
*/
void mbedtls_sha3_init( mbedtls_sha3_context *ctx );
void mbedtls_sha3_init(mbedtls_sha3_context *ctx);

/**
* \brief This function clears a SHA-3 context.
Expand All @@ -97,16 +95,16 @@ void mbedtls_sha3_init( mbedtls_sha3_context *ctx );
* case this function returns immediately. If it is not \c NULL,
* it must point to an initialized SHA-3 context.
*/
void mbedtls_sha3_free( mbedtls_sha3_context *ctx );
void mbedtls_sha3_free(mbedtls_sha3_context *ctx);

/**
* \brief This function clones the state of a SHA-3 context.
*
* \param dst The destination context. This must be initialized.
* \param src The context to clone. This must be initialized.
*/
void mbedtls_sha3_clone( mbedtls_sha3_context *dst,
const mbedtls_sha3_context *src );
void mbedtls_sha3_clone(mbedtls_sha3_context *dst,
const mbedtls_sha3_context *src);

/**
* \brief This function starts a SHA-3 checksum
Expand All @@ -118,7 +116,7 @@ void mbedtls_sha3_clone( mbedtls_sha3_context *dst,
* \return \c 0 on success.
* \return A negative error code on failure.
*/
int mbedtls_sha3_starts( mbedtls_sha3_context *ctx, mbedtls_sha3_id id );
int mbedtls_sha3_starts(mbedtls_sha3_context *ctx, mbedtls_sha3_id id);

/**
* \brief This function feeds an input buffer into an ongoing
Expand All @@ -133,9 +131,9 @@ int mbedtls_sha3_starts( mbedtls_sha3_context *ctx, mbedtls_sha3_id id );
* \return \c 0 on success.
* \return A negative error code on failure.
*/
int mbedtls_sha3_update( mbedtls_sha3_context *ctx,
const uint8_t *input,
size_t ilen );
int mbedtls_sha3_update(mbedtls_sha3_context *ctx,
const uint8_t *input,
size_t ilen);

/**
* \brief This function finishes the SHA-3 operation, and writes
Expand All @@ -152,8 +150,8 @@ int mbedtls_sha3_update( mbedtls_sha3_context *ctx,
* \return \c 0 on success.
* \return A negative error code on failure.
*/
int mbedtls_sha3_finish( mbedtls_sha3_context *ctx,
uint8_t *output, size_t olen );
int mbedtls_sha3_finish(mbedtls_sha3_context *ctx,
uint8_t *output, size_t olen);

/**
* \brief This function calculates the SHA-3
Expand All @@ -178,10 +176,10 @@ int mbedtls_sha3_finish( mbedtls_sha3_context *ctx,
* \return \c 0 on success.
* \return A negative error code on failure.
*/
int mbedtls_sha3( mbedtls_sha3_id id, const uint8_t *input,
size_t ilen,
uint8_t *output,
size_t olen );
int mbedtls_sha3(mbedtls_sha3_id id, const uint8_t *input,
size_t ilen,
uint8_t *output,
size_t olen);

#if defined(MBEDTLS_SELF_TEST)
/**
Expand All @@ -191,12 +189,11 @@ int mbedtls_sha3( mbedtls_sha3_id id, const uint8_t *input,
*
* \return 0 if successful, or 1 if the test failed.
*/
int mbedtls_sha3_self_test( int verbose );
int mbedtls_sha3_self_test(int verbose);
#endif /* MBEDTLS_SELF_TEST */

#ifdef __cplusplus
}
#endif

#endif /* mbedtls_sha3.h */

36 changes: 18 additions & 18 deletions library/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,13 @@ const mbedtls_md_info_t *mbedtls_md_info_from_type(mbedtls_md_type_t md_type)
#endif
#if defined(MBEDTLS_SHA3_C)
case MBEDTLS_MD_SHA3_224:
return( &mbedtls_sha3_224_info );
return &mbedtls_sha3_224_info;
case MBEDTLS_MD_SHA3_256:
return( &mbedtls_sha3_256_info );
return &mbedtls_sha3_256_info;
case MBEDTLS_MD_SHA3_384:
return( &mbedtls_sha3_384_info );
return &mbedtls_sha3_384_info;
case MBEDTLS_MD_SHA3_512:
return( &mbedtls_sha3_512_info );
return &mbedtls_sha3_512_info;
#endif
default:
return NULL;
Expand Down Expand Up @@ -349,7 +349,7 @@ void mbedtls_md_free(mbedtls_md_context_t *ctx)
case MBEDTLS_MD_SHA3_256:
case MBEDTLS_MD_SHA3_384:
case MBEDTLS_MD_SHA3_512:
mbedtls_sha3_free( ctx->md_ctx );
mbedtls_sha3_free(ctx->md_ctx);
break;
#endif
default:
Expand Down Expand Up @@ -418,7 +418,7 @@ int mbedtls_md_clone(mbedtls_md_context_t *dst,
case MBEDTLS_MD_SHA3_256:
case MBEDTLS_MD_SHA3_384:
case MBEDTLS_MD_SHA3_512:
mbedtls_sha3_clone( dst->md_ctx, src->md_ctx );
mbedtls_sha3_clone(dst->md_ctx, src->md_ctx);
break;
#endif
default:
Expand Down Expand Up @@ -488,7 +488,7 @@ int mbedtls_md_setup(mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info
case MBEDTLS_MD_SHA3_256:
case MBEDTLS_MD_SHA3_384:
case MBEDTLS_MD_SHA3_512:
ALLOC( sha3 );
ALLOC(sha3);
break;
#endif
default:
Expand Down Expand Up @@ -544,13 +544,13 @@ int mbedtls_md_starts(mbedtls_md_context_t *ctx)
#endif
#if defined(MBEDTLS_SHA3_C)
case MBEDTLS_MD_SHA3_224:
return( mbedtls_sha3_starts( ctx->md_ctx, MBEDTLS_SHA3_224 ) );
return mbedtls_sha3_starts(ctx->md_ctx, MBEDTLS_SHA3_224);
case MBEDTLS_MD_SHA3_256:
return( mbedtls_sha3_starts( ctx->md_ctx, MBEDTLS_SHA3_256 ) );
return mbedtls_sha3_starts(ctx->md_ctx, MBEDTLS_SHA3_256);
case MBEDTLS_MD_SHA3_384:
return( mbedtls_sha3_starts( ctx->md_ctx, MBEDTLS_SHA3_384 ) );
return mbedtls_sha3_starts(ctx->md_ctx, MBEDTLS_SHA3_384);
case MBEDTLS_MD_SHA3_512:
return( mbedtls_sha3_starts( ctx->md_ctx, MBEDTLS_SHA3_512 ) );
return mbedtls_sha3_starts(ctx->md_ctx, MBEDTLS_SHA3_512);
#endif
default:
return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
Expand Down Expand Up @@ -597,7 +597,7 @@ int mbedtls_md_update(mbedtls_md_context_t *ctx, const unsigned char *input, siz
case MBEDTLS_MD_SHA3_256:
case MBEDTLS_MD_SHA3_384:
case MBEDTLS_MD_SHA3_512:
return( mbedtls_sha3_update( ctx->md_ctx, input, ilen ) );
return mbedtls_sha3_update(ctx->md_ctx, input, ilen);
#endif
default:
return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
Expand Down Expand Up @@ -644,7 +644,7 @@ int mbedtls_md_finish(mbedtls_md_context_t *ctx, unsigned char *output)
case MBEDTLS_MD_SHA3_256:
case MBEDTLS_MD_SHA3_384:
case MBEDTLS_MD_SHA3_512:
return( mbedtls_sha3_finish( ctx->md_ctx, output, ctx->md_info->size ) );
return mbedtls_sha3_finish(ctx->md_ctx, output, ctx->md_info->size);
#endif
default:
return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
Expand Down Expand Up @@ -689,13 +689,13 @@ int mbedtls_md(const mbedtls_md_info_t *md_info, const unsigned char *input, siz
#endif
#if defined(MBEDTLS_SHA3_C)
case MBEDTLS_MD_SHA3_224:
return( mbedtls_sha3( MBEDTLS_SHA3_224, input, ilen, output, md_info->size ) );
return mbedtls_sha3(MBEDTLS_SHA3_224, input, ilen, output, md_info->size);
case MBEDTLS_MD_SHA3_256:
return( mbedtls_sha3( MBEDTLS_SHA3_256, input, ilen, output, md_info->size ) );
return mbedtls_sha3(MBEDTLS_SHA3_256, input, ilen, output, md_info->size);
case MBEDTLS_MD_SHA3_384:
return( mbedtls_sha3( MBEDTLS_SHA3_384, input, ilen, output, md_info->size ) );
return mbedtls_sha3(MBEDTLS_SHA3_384, input, ilen, output, md_info->size);
case MBEDTLS_MD_SHA3_512:
return( mbedtls_sha3( MBEDTLS_SHA3_512, input, ilen, output, md_info->size ) );
return mbedtls_sha3(MBEDTLS_SHA3_512, input, ilen, output, md_info->size);
#endif
default:
return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
Expand Down Expand Up @@ -932,7 +932,7 @@ int mbedtls_md_process(mbedtls_md_context_t *ctx, const unsigned char *data)
case MBEDTLS_MD_SHA3_256:
case MBEDTLS_MD_SHA3_384:
case MBEDTLS_MD_SHA3_512:
return( 0 );
return 0;
#endif
default:
return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
Expand Down
Loading

0 comments on commit 21460a8

Please sign in to comment.