Skip to content

Commit 56ec718

Browse files
authored
Merge pull request #6163 from ARMmbed/revert-5973-IOTSSL-1727-update-to-new-md-api
Revert "Update Mbed TLS HW acceleration partner code to new hashing API"
2 parents c32b822 + 414b2d9 commit 56ec718

File tree

21 files changed

+133
-725
lines changed

21 files changed

+133
-725
lines changed

TESTS/mbedtls/multi/main.cpp

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -23,67 +23,6 @@
2323

2424
#include "mbedtls/sha256.h"
2525

26-
/**
27-
* \name SECTION: Compatibility code
28-
*
29-
* Depending on whether the alternative (hatdware accelerated) hashing
30-
* functions are provided or not, different API should be used for hashing.
31-
* \{
32-
*/
33-
34-
#if defined(MBEDTLS_SHA256_ALT)
35-
36-
/**
37-
* \brief This function starts a SHA-256 checksum calculation.
38-
*
39-
* \deprecated Superseded by mbedtls_sha256_starts_ret() in 2.7.0.
40-
*
41-
* \param ctx The SHA-256 context to initialize.
42-
* \param is224 Determines which function to use.
43-
* <ul><li>0: Use SHA-256.</li>
44-
* <li>1: Use SHA-224.</li></ul>
45-
*/
46-
void mbedtls_sha256_starts( mbedtls_sha256_context *ctx,
47-
int is224 )
48-
{
49-
mbedtls_sha256_starts_ret( ctx, is224 );
50-
}
51-
52-
/**
53-
* \brief This function feeds an input buffer into an ongoing
54-
* SHA-256 checksum calculation.
55-
*
56-
* \deprecated Superseded by mbedtls_sha256_update_ret() in 2.7.0.
57-
*
58-
* \param ctx The SHA-256 context to initialize.
59-
* \param input The buffer holding the data.
60-
* \param ilen The length of the input data.
61-
*/
62-
void mbedtls_sha256_update( mbedtls_sha256_context *ctx,
63-
const unsigned char *input,
64-
size_t ilen )
65-
{
66-
mbedtls_sha256_update_ret( ctx, input, ilen );
67-
}
68-
69-
/**
70-
* \brief This function finishes the SHA-256 operation, and writes
71-
* the result to the output buffer.
72-
*
73-
* \deprecated Superseded by mbedtls_sha256_finish_ret() in 2.7.0.
74-
*
75-
* \param ctx The SHA-256 context.
76-
* \param output The SHA-224or SHA-256 checksum result.
77-
*/
78-
void mbedtls_sha256_finish( mbedtls_sha256_context *ctx,
79-
unsigned char output[32] )
80-
{
81-
mbedtls_sha256_finish_ret( ctx, output );
82-
}
83-
84-
#endif /* defined(MBEDTLS_SHA256_ALT) */
85-
86-
/* \} name SECTION: Compatibility code */
8726

8827
using namespace utest::v1;
8928

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha1_alt.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,40 +103,37 @@ void mbedtls_sha1_clone(mbedtls_sha1_context *dst,
103103
/*
104104
* SHA-1 context setup
105105
*/
106-
int mbedtls_sha1_starts_ret(mbedtls_sha1_context *ctx)
106+
void mbedtls_sha1_starts(mbedtls_sha1_context *ctx)
107107
{
108108
if (ctx->active_ctx == &ctx->hw_ctx) {
109109
mbedtls_sha1_hw_starts(&ctx->hw_ctx);
110110
} else if (ctx->active_ctx == &ctx->sw_ctx) {
111111
mbedtls_sha1_sw_starts(&ctx->sw_ctx);
112112
}
113-
return 0;
114113
}
115114

116115
/*
117116
* SHA-1 process buffer
118117
*/
119-
int mbedtls_sha1_update_ret(mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen)
118+
void mbedtls_sha1_update(mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen)
120119
{
121120
if (ctx->active_ctx == &ctx->hw_ctx) {
122121
mbedtls_sha1_hw_update(&ctx->hw_ctx, input, ilen);
123122
} else if (ctx->active_ctx == &ctx->sw_ctx) {
124123
mbedtls_sha1_sw_update(&ctx->sw_ctx, input, ilen);
125124
}
126-
return 0;
127125
}
128126

129127
/*
130128
* SHA-1 final digest
131129
*/
132-
int mbedtls_sha1_finish_ret(mbedtls_sha1_context *ctx, unsigned char output[20])
130+
void mbedtls_sha1_finish(mbedtls_sha1_context *ctx, unsigned char output[20])
133131
{
134132
if (ctx->active_ctx == &ctx->hw_ctx) {
135133
mbedtls_sha1_hw_finish(&ctx->hw_ctx, output);
136134
} else if (ctx->active_ctx == &ctx->sw_ctx) {
137135
mbedtls_sha1_sw_finish(&ctx->sw_ctx, output);
138136
}
139-
return 0;
140137
}
141138

142139
void mbedtls_sha1_process(mbedtls_sha1_context *ctx, const unsigned char data[64])

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha1_alt.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,31 +66,25 @@ void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
6666
* \brief SHA-1 context setup
6767
*
6868
* \param ctx context to be initialized
69-
*
70-
* \return 0 if successful
7169
*/
72-
int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx );
70+
void mbedtls_sha1_starts( mbedtls_sha1_context *ctx );
7371

7472
/**
7573
* \brief SHA-1 process buffer
7674
*
7775
* \param ctx SHA-1 context
7876
* \param input buffer holding the data
7977
* \param ilen length of the input data
80-
*
81-
* \return 0 if successful
8278
*/
83-
int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen );
79+
void mbedtls_sha1_update( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen );
8480

8581
/**
8682
* \brief SHA-1 final digest
8783
*
8884
* \param ctx SHA-1 context
8985
* \param output SHA-1 checksum result
90-
*
91-
* \return 0 if successful
9286
*/
93-
int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx, unsigned char output[20] );
87+
void mbedtls_sha1_finish( mbedtls_sha1_context *ctx, unsigned char output[20] );
9488

9589
/* Internal use */
9690
void mbedtls_sha1_process( mbedtls_sha1_context *ctx, const unsigned char data[64] );

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha256_alt.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,40 +104,37 @@ void mbedtls_sha256_clone(mbedtls_sha256_context *dst,
104104
/*
105105
* SHA-256 context setup
106106
*/
107-
int mbedtls_sha256_starts_ret(mbedtls_sha256_context *ctx, int is224)
107+
void mbedtls_sha256_starts(mbedtls_sha256_context *ctx, int is224)
108108
{
109109
if (ctx->active_ctx == &ctx->hw_ctx) {
110110
mbedtls_sha256_hw_starts(&ctx->hw_ctx, is224);
111111
} else if (ctx->active_ctx == &ctx->sw_ctx) {
112112
mbedtls_sha256_sw_starts(&ctx->sw_ctx, is224);
113113
}
114-
return 0;
115114
}
116115

117116
/*
118117
* SHA-256 process buffer
119118
*/
120-
int mbedtls_sha256_update_ret(mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen)
119+
void mbedtls_sha256_update(mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen)
121120
{
122121
if (ctx->active_ctx == &ctx->hw_ctx) {
123122
mbedtls_sha256_hw_update(&ctx->hw_ctx, input, ilen);
124123
} else if (ctx->active_ctx == &ctx->sw_ctx) {
125124
mbedtls_sha256_sw_update(&ctx->sw_ctx, input, ilen);
126125
}
127-
return 0;
128126
}
129127

130128
/*
131129
* SHA-256 final digest
132130
*/
133-
int mbedtls_sha256_finish_ret(mbedtls_sha256_context *ctx, unsigned char output[32])
131+
void mbedtls_sha256_finish(mbedtls_sha256_context *ctx, unsigned char output[32])
134132
{
135133
if (ctx->active_ctx == &ctx->hw_ctx) {
136134
mbedtls_sha256_hw_finish(&ctx->hw_ctx, output);
137135
} else if (ctx->active_ctx == &ctx->sw_ctx) {
138136
mbedtls_sha256_sw_finish(&ctx->sw_ctx, output);
139137
}
140-
return 0;
141138
}
142139

143140
void mbedtls_sha256_process(mbedtls_sha256_context *ctx, const unsigned char data[64])

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha256_alt.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,32 +67,26 @@ void mbedtls_sha256_clone( mbedtls_sha256_context *dst,
6767
*
6868
* \param ctx context to be initialized
6969
* \param is224 0 = use SHA256, 1 = use SHA224
70-
*
71-
* \return 0 if successful
7270
*/
73-
int mbedtls_sha256_starts_ret( mbedtls_sha256_context *ctx, int is224 );
71+
void mbedtls_sha256_starts( mbedtls_sha256_context *ctx, int is224 );
7472

7573
/**
7674
* \brief SHA-256 process buffer
7775
*
7876
* \param ctx SHA-256 context
7977
* \param input buffer holding the data
8078
* \param ilen length of the input data
81-
*
82-
* \return 0 if successful
8379
*/
84-
int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx, const unsigned char *input,
85-
size_t ilen );
80+
void mbedtls_sha256_update( mbedtls_sha256_context *ctx, const unsigned char *input,
81+
size_t ilen );
8682

8783
/**
8884
* \brief SHA-256 final digest
8985
*
9086
* \param ctx SHA-256 context
9187
* \param output SHA-224/256 checksum result
92-
*
93-
* \return 0 if successful
9488
*/
95-
int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx, unsigned char output[32] );
89+
void mbedtls_sha256_finish( mbedtls_sha256_context *ctx, unsigned char output[32] );
9690

9791
/* Internal use */
9892
void mbedtls_sha256_process( mbedtls_sha256_context *ctx, const unsigned char data[64] );

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha512_alt.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,40 +105,37 @@ void mbedtls_sha512_clone(mbedtls_sha512_context *dst,
105105
/*
106106
* SHA-512 context setup
107107
*/
108-
int mbedtls_sha512_starts_ret(mbedtls_sha512_context *ctx, int is384)
108+
void mbedtls_sha512_starts(mbedtls_sha512_context *ctx, int is384)
109109
{
110110
if (ctx->active_ctx == &ctx->hw_ctx) {
111111
mbedtls_sha512_hw_starts(&ctx->hw_ctx, is384);
112112
} else if (ctx->active_ctx == &ctx->sw_ctx) {
113113
mbedtls_sha512_sw_starts(&ctx->sw_ctx, is384);
114114
}
115-
return 0;
116115
}
117116

118117
/*
119118
* SHA-512 process buffer
120119
*/
121-
int mbedtls_sha512_update_ret(mbedtls_sha512_context *ctx, const unsigned char *input, size_t ilen)
120+
void mbedtls_sha512_update(mbedtls_sha512_context *ctx, const unsigned char *input, size_t ilen)
122121
{
123122
if (ctx->active_ctx == &ctx->hw_ctx) {
124123
mbedtls_sha512_hw_update(&ctx->hw_ctx, input, ilen);
125124
} else if (ctx->active_ctx == &ctx->sw_ctx) {
126125
mbedtls_sha512_sw_update(&ctx->sw_ctx, input, ilen);
127126
}
128-
return 0;
129127
}
130128

131129
/*
132130
* SHA-512 final digest
133131
*/
134-
int mbedtls_sha512_finish_ret(mbedtls_sha512_context *ctx, unsigned char output[64])
132+
void mbedtls_sha512_finish(mbedtls_sha512_context *ctx, unsigned char output[64])
135133
{
136134
if (ctx->active_ctx == &ctx->hw_ctx) {
137135
mbedtls_sha512_hw_finish(&ctx->hw_ctx, output);
138136
} else if (ctx->active_ctx == &ctx->sw_ctx) {
139137
mbedtls_sha512_sw_finish(&ctx->sw_ctx, output);
140138
}
141-
return 0;
142139
}
143140

144141
void mbedtls_sha512_process(mbedtls_sha512_context *ctx, const unsigned char data[128])

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/sha/sha512_alt.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,32 +67,26 @@ void mbedtls_sha512_clone( mbedtls_sha512_context *dst,
6767
*
6868
* \param ctx context to be initialized
6969
* \param is384 0 = use SHA512, 1 = use SHA384
70-
*
71-
* \return 0 if successful
7270
*/
73-
int mbedtls_sha512_starts_ret( mbedtls_sha512_context *ctx, int is384 );
71+
void mbedtls_sha512_starts( mbedtls_sha512_context *ctx, int is384 );
7472

7573
/**
7674
* \brief SHA-512 process buffer
7775
*
7876
* \param ctx SHA-512 context
7977
* \param input buffer holding the data
8078
* \param ilen length of the input data
81-
*
82-
* \return 0 if successful
8379
*/
84-
int mbedtls_sha512_update_ret( mbedtls_sha512_context *ctx, const unsigned char *input,
85-
size_t ilen );
80+
void mbedtls_sha512_update( mbedtls_sha512_context *ctx, const unsigned char *input,
81+
size_t ilen );
8682

8783
/**
8884
* \brief SHA-512 final digest
8985
*
9086
* \param ctx SHA-512 context
9187
* \param output SHA-384/512 checksum result
92-
*
93-
* \return 0 if successful
9488
*/
95-
int mbedtls_sha512_finish_ret( mbedtls_sha512_context *ctx, unsigned char output[64] );
89+
void mbedtls_sha512_finish( mbedtls_sha512_context *ctx, unsigned char output[64] );
9690

9791
/* Internal use */
9892
void mbedtls_sha512_process( mbedtls_sha512_context *ctx, const unsigned char data[128] );

features/mbedtls/targets/TARGET_NUVOTON/TARGET_NUC472/sha/sha1_alt.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,40 +103,37 @@ void mbedtls_sha1_clone(mbedtls_sha1_context *dst,
103103
/*
104104
* SHA-1 context setup
105105
*/
106-
int mbedtls_sha1_starts_ret(mbedtls_sha1_context *ctx)
106+
void mbedtls_sha1_starts(mbedtls_sha1_context *ctx)
107107
{
108108
if (ctx->active_ctx == &ctx->hw_ctx) {
109109
mbedtls_sha1_hw_starts(&ctx->hw_ctx);
110110
} else if (ctx->active_ctx == &ctx->sw_ctx) {
111111
mbedtls_sha1_sw_starts(&ctx->sw_ctx);
112112
}
113-
return 0;
114113
}
115114

116115
/*
117116
* SHA-1 process buffer
118117
*/
119-
int mbedtls_sha1_update_ret(mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen)
118+
void mbedtls_sha1_update(mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen)
120119
{
121120
if (ctx->active_ctx == &ctx->hw_ctx) {
122121
mbedtls_sha1_hw_update(&ctx->hw_ctx, input, ilen);
123122
} else if (ctx->active_ctx == &ctx->sw_ctx) {
124123
mbedtls_sha1_sw_update(&ctx->sw_ctx, input, ilen);
125124
}
126-
return 0;
127125
}
128126

129127
/*
130128
* SHA-1 final digest
131129
*/
132-
int mbedtls_sha1_finish_ret(mbedtls_sha1_context *ctx, unsigned char output[20])
130+
void mbedtls_sha1_finish(mbedtls_sha1_context *ctx, unsigned char output[20])
133131
{
134132
if (ctx->active_ctx == &ctx->hw_ctx) {
135133
mbedtls_sha1_hw_finish(&ctx->hw_ctx, output);
136134
} else if (ctx->active_ctx == &ctx->sw_ctx) {
137135
mbedtls_sha1_sw_finish(&ctx->sw_ctx, output);
138136
}
139-
return 0;
140137
}
141138

142139
void mbedtls_sha1_process(mbedtls_sha1_context *ctx, const unsigned char data[64])

features/mbedtls/targets/TARGET_NUVOTON/TARGET_NUC472/sha/sha1_alt.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,31 +66,25 @@ void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
6666
* \brief SHA-1 context setup
6767
*
6868
* \param ctx context to be initialized
69-
*
70-
* \return 0 if successful
7169
*/
72-
int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx );
70+
void mbedtls_sha1_starts( mbedtls_sha1_context *ctx );
7371

7472
/**
7573
* \brief SHA-1 process buffer
7674
*
7775
* \param ctx SHA-1 context
7876
* \param input buffer holding the data
7977
* \param ilen length of the input data
80-
*
81-
* \return 0 if successful
8278
*/
83-
int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen );
79+
void mbedtls_sha1_update( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen );
8480

8581
/**
8682
* \brief SHA-1 final digest
8783
*
8884
* \param ctx SHA-1 context
8985
* \param output SHA-1 checksum result
90-
*
91-
* \return 0 if successful
9286
*/
93-
int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx, unsigned char output[20] );
87+
void mbedtls_sha1_finish( mbedtls_sha1_context *ctx, unsigned char output[20] );
9488

9589
/* Internal use */
9690
void mbedtls_sha1_process( mbedtls_sha1_context *ctx, const unsigned char data[64] );

0 commit comments

Comments
 (0)