Skip to content

Commit 7822fa8

Browse files
Ron EldorRon Eldor
authored andcommitted
Style fixes
1. Change camelcase variables to Mbed OS style. 2. Remove functions declarations from the `_alt` header, since they are now added from the module header regardless whether an alternative implementation exists. 3. Remove the `extern "c"` declaration from the `_alt` headers. 4. Remove redundant extra lines.
1 parent c0108b1 commit 7822fa8

File tree

4 files changed

+6
-204
lines changed

4 files changed

+6
-204
lines changed

features/cryptocell/FEATURE_CRYPTOCELL310/sha1_alt.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
void mbedtls_sha1_init( mbedtls_sha1_context *ctx )
2626
{
2727
memset( ctx, 0, sizeof( mbedtls_sha1_context ) );
28-
2928
}
3029

3130
void mbedtls_sha1_free( mbedtls_sha1_context *ctx )
@@ -64,10 +63,10 @@ int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx,
6463
int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx,
6564
unsigned char output[20] )
6665
{
67-
CRYSError_t CrysErr = CRYS_OK;
66+
CRYSError_t crys_err = CRYS_OK;
6867
CRYS_HASH_Result_t crys_result = {0};
69-
CrysErr = CRYS_HASH_Finish( &ctx->crys_hash_ctx, crys_result );
70-
if( CrysErr == CRYS_OK )
68+
crys_err = CRYS_HASH_Finish( &ctx->crys_hash_ctx, crys_result );
69+
if( crys_err == CRYS_OK )
7170
{
7271
memcpy( output, crys_result, 20 );
7372
return ( 0 );

features/cryptocell/FEATURE_CRYPTOCELL310/sha1_alt.h

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222
#define __SHA1_ALT__
2323
#if defined(MBEDTLS_SHA1_ALT)
2424
#include "crys_hash.h"
25-
#ifdef __cplusplus
26-
extern "C" {
27-
#endif
28-
2925

3026
/**
3127
* \brief SHA-1 context structure
@@ -35,114 +31,6 @@ typedef struct
3531
CRYS_HASHUserContext_t crys_hash_ctx;
3632
} mbedtls_sha1_context;
3733

38-
/**
39-
* \brief This function initializes a SHA-1 context.
40-
*
41-
* \param ctx The SHA-1 context to initialize.
42-
*
43-
* \warning SHA-1 is considered a weak message digest and its use
44-
* constitutes a security risk. We recommend considering
45-
* stronger message digests instead.
46-
*
47-
*/
48-
void mbedtls_sha1_init( mbedtls_sha1_context *ctx );
49-
50-
/**
51-
* \brief This function clears a SHA-1 context.
52-
*
53-
* \param ctx The SHA-1 context to clear.
54-
*
55-
* \warning SHA-1 is considered a weak message digest and its use
56-
* constitutes a security risk. We recommend considering
57-
* stronger message digests instead.
58-
*
59-
*/
60-
void mbedtls_sha1_free( mbedtls_sha1_context *ctx );
61-
62-
/**
63-
* \brief This function clones the state of a SHA-1 context.
64-
*
65-
* \param dst The destination context.
66-
* \param src The context to clone.
67-
*
68-
* \warning SHA-1 is considered a weak message digest and its use
69-
* constitutes a security risk. We recommend considering
70-
* stronger message digests instead.
71-
*
72-
*/
73-
void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
74-
const mbedtls_sha1_context *src );
75-
76-
/**
77-
* \brief This function starts a SHA-1 checksum calculation.
78-
*
79-
* \param ctx The context to initialize.
80-
*
81-
* \return \c 0 if successful
82-
*
83-
* \warning SHA-1 is considered a weak message digest and its use
84-
* constitutes a security risk. We recommend considering
85-
* stronger message digests instead.
86-
*
87-
*/
88-
int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx );
89-
90-
/**
91-
* \brief This function feeds an input buffer into an ongoing SHA-1
92-
* checksum calculation.
93-
*
94-
* \param ctx The SHA-1 context.
95-
* \param input The buffer holding the input data.
96-
* \param ilen The length of the input data.
97-
*
98-
* \return \c 0 if successful
99-
*
100-
* \warning SHA-1 is considered a weak message digest and its use
101-
* constitutes a security risk. We recommend considering
102-
* stronger message digests instead.
103-
*
104-
*/
105-
int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx,
106-
const unsigned char *input,
107-
size_t ilen );
108-
109-
/**
110-
* \brief This function finishes the SHA-1 operation, and writes
111-
* the result to the output buffer.
112-
*
113-
* \param ctx The SHA-1 context.
114-
* \param output The SHA-1 checksum result.
115-
*
116-
* \return \c 0 if successful
117-
*
118-
* \warning SHA-1 is considered a weak message digest and its use
119-
* constitutes a security risk. We recommend considering
120-
* stronger message digests instead.
121-
*
122-
*/
123-
int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx,
124-
unsigned char output[20] );
125-
126-
/**
127-
* \brief SHA-1 process data block (internal use only)
128-
*
129-
* \param ctx SHA-1 context
130-
* \param data The data block being processed.
131-
*
132-
* \return \c 0 if successful
133-
*
134-
* \warning SHA-1 is considered a weak message digest and its use
135-
* constitutes a security risk. We recommend considering
136-
* stronger message digests instead.
137-
*
138-
*/
139-
int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx,
140-
const unsigned char data[64] );
141-
142-
#ifdef __cplusplus
143-
}
144-
#endif
145-
14634
#endif //MBEDTLS_SHA1_ALT
14735
#endif //__SHA1_ALT__
14836

features/cryptocell/FEATURE_CRYPTOCELL310/sha256_alt.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
void mbedtls_sha256_init( mbedtls_sha256_context *ctx )
2626
{
2727
memset( ctx, 0, sizeof( mbedtls_sha256_context ) );
28-
2928
}
3029

3130
void mbedtls_sha256_free( mbedtls_sha256_context *ctx )
@@ -71,10 +70,10 @@ int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx,
7170
int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx,
7271
unsigned char output[32] )
7372
{
74-
CRYSError_t CrysErr = CRYS_OK;
73+
CRYSError_t crys_err = CRYS_OK;
7574
CRYS_HASH_Result_t crys_result = {0};
76-
CrysErr = CRYS_HASH_Finish( &ctx->crys_hash_ctx, crys_result );
77-
if( CrysErr == CRYS_OK )
75+
crys_err = CRYS_HASH_Finish( &ctx->crys_hash_ctx, crys_result );
76+
if( crys_err == CRYS_OK )
7877
{
7978
memcpy( output, crys_result, 32 );
8079
return ( 0 );

features/cryptocell/FEATURE_CRYPTOCELL310/sha256_alt.h

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
#if defined(MBEDTLS_SHA256_ALT)
2525

2626
#include "crys_hash.h"
27-
#ifdef __cplusplus
28-
extern "C" {
29-
#endif
30-
3127

3228
/**
3329
* \brief SHA-256 context structure
@@ -37,85 +33,5 @@ typedef struct
3733
CRYS_HASHUserContext_t crys_hash_ctx;
3834
} mbedtls_sha256_context;
3935

40-
41-
/**
42-
* \brief This function initializes a SHA-256 context.
43-
*
44-
* \param ctx The SHA-256 context to initialize.
45-
*/
46-
void mbedtls_sha256_init( mbedtls_sha256_context *ctx );
47-
48-
/**
49-
* \brief This function clears a SHA-256 context.
50-
*
51-
* \param ctx The SHA-256 context to clear.
52-
*/
53-
void mbedtls_sha256_free( mbedtls_sha256_context *ctx );
54-
55-
/**
56-
* \brief This function clones the state of a SHA-256 context.
57-
*
58-
* \param dst The destination context.
59-
* \param src The context to clone.
60-
*/
61-
void mbedtls_sha256_clone( mbedtls_sha256_context *dst,
62-
const mbedtls_sha256_context *src );
63-
64-
/**
65-
* \brief This function starts a SHA-224 or SHA-256 checksum
66-
* calculation.
67-
*
68-
* \param ctx The context to initialize.
69-
* \param is224 Determines which function to use.
70-
* <ul><li>0: Use SHA-256.</li>
71-
* <li>1: Use SHA-224.</li></ul>
72-
*
73-
* \return \c 0 on success.
74-
*/
75-
int mbedtls_sha256_starts_ret( mbedtls_sha256_context *ctx, int is224 );
76-
77-
/**
78-
* \brief This function feeds an input buffer into an ongoing
79-
* SHA-256 checksum calculation.
80-
*
81-
* \param ctx SHA-256 context
82-
* \param input buffer holding the data
83-
* \param ilen length of the input data
84-
*
85-
* \return \c 0 on success.
86-
*/
87-
int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx,
88-
const unsigned char *input,
89-
size_t ilen );
90-
91-
/**
92-
* \brief This function finishes the SHA-256 operation, and writes
93-
* the result to the output buffer.
94-
*
95-
* \param ctx The SHA-256 context.
96-
* \param output The SHA-224 or SHA-256 checksum result.
97-
*
98-
* \return \c 0 on success.
99-
*/
100-
int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx,
101-
unsigned char output[32] );
102-
103-
/**
104-
* \brief This function processes a single data block within
105-
* the ongoing SHA-256 computation. This function is for
106-
* internal use only.
107-
*
108-
* \param ctx The SHA-256 context.
109-
* \param data The buffer holding one block of data.
110-
*
111-
* \return \c 0 on success.
112-
*/
113-
int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx,
114-
const unsigned char data[64] );
115-
116-
#ifdef __cplusplus
117-
}
118-
#endif
119-
12036
#endif // MBEDTLS_SHA256_ALT__
12137
#endif //__SHA256_ALT__

0 commit comments

Comments
 (0)