Skip to content

Commit d370d58

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.
1 parent 4ebd812 commit d370d58

File tree

4 files changed

+6
-202
lines changed

4 files changed

+6
-202
lines changed

features/cryptocell/FEATURE_CRYPTOCELL310/sha1_alt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx,
7676
int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx,
7777
unsigned char output[20] )
7878
{
79-
CRYSError_t CrysErr = CRYS_OK;
79+
CRYSError_t crys_err = CRYS_OK;
8080
CRYS_HASH_Result_t crys_result = {0};
81-
CrysErr = CRYS_HASH_Finish( &ctx->crys_hash_ctx, crys_result );
82-
if( CrysErr == CRYS_OK )
81+
crys_err = CRYS_HASH_Finish( &ctx->crys_hash_ctx, crys_result );
82+
if( crys_err == CRYS_OK )
8383
{
8484
memcpy( output, crys_result, 20 );
8585
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
@@ -36,114 +32,6 @@ typedef struct
3632
int is_cc_initiated;
3733
} mbedtls_sha1_context;
3834

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

features/cryptocell/FEATURE_CRYPTOCELL310/sha256_alt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx,
9696
int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx,
9797
unsigned char output[32] )
9898
{
99-
CRYSError_t CrysErr = CRYS_OK;
99+
CRYSError_t crys_err = CRYS_OK;
100100
CRYS_HASH_Result_t crys_result = {0};
101-
CrysErr = CRYS_HASH_Finish( &ctx->crys_hash_ctx, crys_result );
102-
if( CrysErr == CRYS_OK )
101+
crys_err = CRYS_HASH_Finish( &ctx->crys_hash_ctx, crys_result );
102+
if( crys_err == CRYS_OK )
103103
{
104104
memcpy( output, crys_result, 32 );
105105
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
@@ -38,85 +34,5 @@ typedef struct
3834
int is_cc_initiated;
3935
} mbedtls_sha256_context;
4036

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

0 commit comments

Comments
 (0)