Skip to content

Commit

Permalink
Merge pull request #6163 from ARMmbed/revert-5973-IOTSSL-1727-update-…
Browse files Browse the repository at this point in the history
…to-new-md-api

Revert "Update Mbed TLS HW acceleration partner code to new hashing API"
  • Loading branch information
cmonr committed Feb 22, 2018
2 parents c32b822 + 414b2d9 commit 56ec718
Show file tree
Hide file tree
Showing 21 changed files with 133 additions and 725 deletions.
61 changes: 0 additions & 61 deletions TESTS/mbedtls/multi/main.cpp
Expand Up @@ -23,67 +23,6 @@

#include "mbedtls/sha256.h"

/**
* \name SECTION: Compatibility code
*
* Depending on whether the alternative (hatdware accelerated) hashing
* functions are provided or not, different API should be used for hashing.
* \{
*/

#if defined(MBEDTLS_SHA256_ALT)

/**
* \brief This function starts a SHA-256 checksum calculation.
*
* \deprecated Superseded by mbedtls_sha256_starts_ret() in 2.7.0.
*
* \param ctx The SHA-256 context to initialize.
* \param is224 Determines which function to use.
* <ul><li>0: Use SHA-256.</li>
* <li>1: Use SHA-224.</li></ul>
*/
void mbedtls_sha256_starts( mbedtls_sha256_context *ctx,
int is224 )
{
mbedtls_sha256_starts_ret( ctx, is224 );
}

/**
* \brief This function feeds an input buffer into an ongoing
* SHA-256 checksum calculation.
*
* \deprecated Superseded by mbedtls_sha256_update_ret() in 2.7.0.
*
* \param ctx The SHA-256 context to initialize.
* \param input The buffer holding the data.
* \param ilen The length of the input data.
*/
void mbedtls_sha256_update( mbedtls_sha256_context *ctx,
const unsigned char *input,
size_t ilen )
{
mbedtls_sha256_update_ret( ctx, input, ilen );
}

/**
* \brief This function finishes the SHA-256 operation, and writes
* the result to the output buffer.
*
* \deprecated Superseded by mbedtls_sha256_finish_ret() in 2.7.0.
*
* \param ctx The SHA-256 context.
* \param output The SHA-224or SHA-256 checksum result.
*/
void mbedtls_sha256_finish( mbedtls_sha256_context *ctx,
unsigned char output[32] )
{
mbedtls_sha256_finish_ret( ctx, output );
}

#endif /* defined(MBEDTLS_SHA256_ALT) */

/* \} name SECTION: Compatibility code */

using namespace utest::v1;

Expand Down
Expand Up @@ -103,40 +103,37 @@ void mbedtls_sha1_clone(mbedtls_sha1_context *dst,
/*
* SHA-1 context setup
*/
int mbedtls_sha1_starts_ret(mbedtls_sha1_context *ctx)
void mbedtls_sha1_starts(mbedtls_sha1_context *ctx)
{
if (ctx->active_ctx == &ctx->hw_ctx) {
mbedtls_sha1_hw_starts(&ctx->hw_ctx);
} else if (ctx->active_ctx == &ctx->sw_ctx) {
mbedtls_sha1_sw_starts(&ctx->sw_ctx);
}
return 0;
}

/*
* SHA-1 process buffer
*/
int mbedtls_sha1_update_ret(mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen)
void mbedtls_sha1_update(mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen)
{
if (ctx->active_ctx == &ctx->hw_ctx) {
mbedtls_sha1_hw_update(&ctx->hw_ctx, input, ilen);
} else if (ctx->active_ctx == &ctx->sw_ctx) {
mbedtls_sha1_sw_update(&ctx->sw_ctx, input, ilen);
}
return 0;
}

/*
* SHA-1 final digest
*/
int mbedtls_sha1_finish_ret(mbedtls_sha1_context *ctx, unsigned char output[20])
void mbedtls_sha1_finish(mbedtls_sha1_context *ctx, unsigned char output[20])
{
if (ctx->active_ctx == &ctx->hw_ctx) {
mbedtls_sha1_hw_finish(&ctx->hw_ctx, output);
} else if (ctx->active_ctx == &ctx->sw_ctx) {
mbedtls_sha1_sw_finish(&ctx->sw_ctx, output);
}
return 0;
}

void mbedtls_sha1_process(mbedtls_sha1_context *ctx, const unsigned char data[64])
Expand Down
Expand Up @@ -66,31 +66,25 @@ void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
* \brief SHA-1 context setup
*
* \param ctx context to be initialized
*
* \return 0 if successful
*/
int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx );
void mbedtls_sha1_starts( mbedtls_sha1_context *ctx );

/**
* \brief SHA-1 process buffer
*
* \param ctx SHA-1 context
* \param input buffer holding the data
* \param ilen length of the input data
*
* \return 0 if successful
*/
int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen );
void mbedtls_sha1_update( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen );

/**
* \brief SHA-1 final digest
*
* \param ctx SHA-1 context
* \param output SHA-1 checksum result
*
* \return 0 if successful
*/
int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx, unsigned char output[20] );
void mbedtls_sha1_finish( mbedtls_sha1_context *ctx, unsigned char output[20] );

/* Internal use */
void mbedtls_sha1_process( mbedtls_sha1_context *ctx, const unsigned char data[64] );
Expand Down
Expand Up @@ -104,40 +104,37 @@ void mbedtls_sha256_clone(mbedtls_sha256_context *dst,
/*
* SHA-256 context setup
*/
int mbedtls_sha256_starts_ret(mbedtls_sha256_context *ctx, int is224)
void mbedtls_sha256_starts(mbedtls_sha256_context *ctx, int is224)
{
if (ctx->active_ctx == &ctx->hw_ctx) {
mbedtls_sha256_hw_starts(&ctx->hw_ctx, is224);
} else if (ctx->active_ctx == &ctx->sw_ctx) {
mbedtls_sha256_sw_starts(&ctx->sw_ctx, is224);
}
return 0;
}

/*
* SHA-256 process buffer
*/
int mbedtls_sha256_update_ret(mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen)
void mbedtls_sha256_update(mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen)
{
if (ctx->active_ctx == &ctx->hw_ctx) {
mbedtls_sha256_hw_update(&ctx->hw_ctx, input, ilen);
} else if (ctx->active_ctx == &ctx->sw_ctx) {
mbedtls_sha256_sw_update(&ctx->sw_ctx, input, ilen);
}
return 0;
}

/*
* SHA-256 final digest
*/
int mbedtls_sha256_finish_ret(mbedtls_sha256_context *ctx, unsigned char output[32])
void mbedtls_sha256_finish(mbedtls_sha256_context *ctx, unsigned char output[32])
{
if (ctx->active_ctx == &ctx->hw_ctx) {
mbedtls_sha256_hw_finish(&ctx->hw_ctx, output);
} else if (ctx->active_ctx == &ctx->sw_ctx) {
mbedtls_sha256_sw_finish(&ctx->sw_ctx, output);
}
return 0;
}

void mbedtls_sha256_process(mbedtls_sha256_context *ctx, const unsigned char data[64])
Expand Down
Expand Up @@ -67,32 +67,26 @@ void mbedtls_sha256_clone( mbedtls_sha256_context *dst,
*
* \param ctx context to be initialized
* \param is224 0 = use SHA256, 1 = use SHA224
*
* \return 0 if successful
*/
int mbedtls_sha256_starts_ret( mbedtls_sha256_context *ctx, int is224 );
void mbedtls_sha256_starts( mbedtls_sha256_context *ctx, int is224 );

/**
* \brief SHA-256 process buffer
*
* \param ctx SHA-256 context
* \param input buffer holding the data
* \param ilen length of the input data
*
* \return 0 if successful
*/
int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx, const unsigned char *input,
size_t ilen );
void mbedtls_sha256_update( mbedtls_sha256_context *ctx, const unsigned char *input,
size_t ilen );

/**
* \brief SHA-256 final digest
*
* \param ctx SHA-256 context
* \param output SHA-224/256 checksum result
*
* \return 0 if successful
*/
int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx, unsigned char output[32] );
void mbedtls_sha256_finish( mbedtls_sha256_context *ctx, unsigned char output[32] );

/* Internal use */
void mbedtls_sha256_process( mbedtls_sha256_context *ctx, const unsigned char data[64] );
Expand Down
Expand Up @@ -105,40 +105,37 @@ void mbedtls_sha512_clone(mbedtls_sha512_context *dst,
/*
* SHA-512 context setup
*/
int mbedtls_sha512_starts_ret(mbedtls_sha512_context *ctx, int is384)
void mbedtls_sha512_starts(mbedtls_sha512_context *ctx, int is384)
{
if (ctx->active_ctx == &ctx->hw_ctx) {
mbedtls_sha512_hw_starts(&ctx->hw_ctx, is384);
} else if (ctx->active_ctx == &ctx->sw_ctx) {
mbedtls_sha512_sw_starts(&ctx->sw_ctx, is384);
}
return 0;
}

/*
* SHA-512 process buffer
*/
int mbedtls_sha512_update_ret(mbedtls_sha512_context *ctx, const unsigned char *input, size_t ilen)
void mbedtls_sha512_update(mbedtls_sha512_context *ctx, const unsigned char *input, size_t ilen)
{
if (ctx->active_ctx == &ctx->hw_ctx) {
mbedtls_sha512_hw_update(&ctx->hw_ctx, input, ilen);
} else if (ctx->active_ctx == &ctx->sw_ctx) {
mbedtls_sha512_sw_update(&ctx->sw_ctx, input, ilen);
}
return 0;
}

/*
* SHA-512 final digest
*/
int mbedtls_sha512_finish_ret(mbedtls_sha512_context *ctx, unsigned char output[64])
void mbedtls_sha512_finish(mbedtls_sha512_context *ctx, unsigned char output[64])
{
if (ctx->active_ctx == &ctx->hw_ctx) {
mbedtls_sha512_hw_finish(&ctx->hw_ctx, output);
} else if (ctx->active_ctx == &ctx->sw_ctx) {
mbedtls_sha512_sw_finish(&ctx->sw_ctx, output);
}
return 0;
}

void mbedtls_sha512_process(mbedtls_sha512_context *ctx, const unsigned char data[128])
Expand Down
Expand Up @@ -67,32 +67,26 @@ void mbedtls_sha512_clone( mbedtls_sha512_context *dst,
*
* \param ctx context to be initialized
* \param is384 0 = use SHA512, 1 = use SHA384
*
* \return 0 if successful
*/
int mbedtls_sha512_starts_ret( mbedtls_sha512_context *ctx, int is384 );
void mbedtls_sha512_starts( mbedtls_sha512_context *ctx, int is384 );

/**
* \brief SHA-512 process buffer
*
* \param ctx SHA-512 context
* \param input buffer holding the data
* \param ilen length of the input data
*
* \return 0 if successful
*/
int mbedtls_sha512_update_ret( mbedtls_sha512_context *ctx, const unsigned char *input,
size_t ilen );
void mbedtls_sha512_update( mbedtls_sha512_context *ctx, const unsigned char *input,
size_t ilen );

/**
* \brief SHA-512 final digest
*
* \param ctx SHA-512 context
* \param output SHA-384/512 checksum result
*
* \return 0 if successful
*/
int mbedtls_sha512_finish_ret( mbedtls_sha512_context *ctx, unsigned char output[64] );
void mbedtls_sha512_finish( mbedtls_sha512_context *ctx, unsigned char output[64] );

/* Internal use */
void mbedtls_sha512_process( mbedtls_sha512_context *ctx, const unsigned char data[128] );
Expand Down
Expand Up @@ -103,40 +103,37 @@ void mbedtls_sha1_clone(mbedtls_sha1_context *dst,
/*
* SHA-1 context setup
*/
int mbedtls_sha1_starts_ret(mbedtls_sha1_context *ctx)
void mbedtls_sha1_starts(mbedtls_sha1_context *ctx)
{
if (ctx->active_ctx == &ctx->hw_ctx) {
mbedtls_sha1_hw_starts(&ctx->hw_ctx);
} else if (ctx->active_ctx == &ctx->sw_ctx) {
mbedtls_sha1_sw_starts(&ctx->sw_ctx);
}
return 0;
}

/*
* SHA-1 process buffer
*/
int mbedtls_sha1_update_ret(mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen)
void mbedtls_sha1_update(mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen)
{
if (ctx->active_ctx == &ctx->hw_ctx) {
mbedtls_sha1_hw_update(&ctx->hw_ctx, input, ilen);
} else if (ctx->active_ctx == &ctx->sw_ctx) {
mbedtls_sha1_sw_update(&ctx->sw_ctx, input, ilen);
}
return 0;
}

/*
* SHA-1 final digest
*/
int mbedtls_sha1_finish_ret(mbedtls_sha1_context *ctx, unsigned char output[20])
void mbedtls_sha1_finish(mbedtls_sha1_context *ctx, unsigned char output[20])
{
if (ctx->active_ctx == &ctx->hw_ctx) {
mbedtls_sha1_hw_finish(&ctx->hw_ctx, output);
} else if (ctx->active_ctx == &ctx->sw_ctx) {
mbedtls_sha1_sw_finish(&ctx->sw_ctx, output);
}
return 0;
}

void mbedtls_sha1_process(mbedtls_sha1_context *ctx, const unsigned char data[64])
Expand Down
Expand Up @@ -66,31 +66,25 @@ void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
* \brief SHA-1 context setup
*
* \param ctx context to be initialized
*
* \return 0 if successful
*/
int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx );
void mbedtls_sha1_starts( mbedtls_sha1_context *ctx );

/**
* \brief SHA-1 process buffer
*
* \param ctx SHA-1 context
* \param input buffer holding the data
* \param ilen length of the input data
*
* \return 0 if successful
*/
int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen );
void mbedtls_sha1_update( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen );

/**
* \brief SHA-1 final digest
*
* \param ctx SHA-1 context
* \param output SHA-1 checksum result
*
* \return 0 if successful
*/
int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx, unsigned char output[20] );
void mbedtls_sha1_finish( mbedtls_sha1_context *ctx, unsigned char output[20] );

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

0 comments on commit 56ec718

Please sign in to comment.