mirror of
https://github.com/vlang/v.git
synced 2025-09-14 06:52:36 +03:00
thirdparty,net.mbedtls: update mbedtls
to latest compatible version v3.3.0 (#21118)
This commit is contained in:
parent
cb402a3340
commit
64a336932c
156 changed files with 16293 additions and 4396 deletions
49
thirdparty/mbedtls/library/sha256.c
vendored
49
thirdparty/mbedtls/library/sha256.c
vendored
|
@ -32,17 +32,7 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(MBEDTLS_SELF_TEST)
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
#include "mbedtls/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define mbedtls_printf printf
|
||||
#define mbedtls_calloc calloc
|
||||
#define mbedtls_free free
|
||||
#endif /* MBEDTLS_PLATFORM_C */
|
||||
#endif /* MBEDTLS_SELF_TEST */
|
||||
|
||||
#if defined(__aarch64__)
|
||||
# if defined(MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT) || \
|
||||
|
@ -149,18 +139,12 @@ static int mbedtls_a64_crypto_sha256_determine_support( void )
|
|||
|
||||
#endif /* MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT */
|
||||
|
||||
#define SHA256_VALIDATE_RET(cond) \
|
||||
MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_SHA256_BAD_INPUT_DATA )
|
||||
#define SHA256_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE( cond )
|
||||
|
||||
#if !defined(MBEDTLS_SHA256_ALT)
|
||||
|
||||
#define SHA256_BLOCK_SIZE 64
|
||||
|
||||
void mbedtls_sha256_init( mbedtls_sha256_context *ctx )
|
||||
{
|
||||
SHA256_VALIDATE( ctx != NULL );
|
||||
|
||||
memset( ctx, 0, sizeof( mbedtls_sha256_context ) );
|
||||
}
|
||||
|
||||
|
@ -175,9 +159,6 @@ void mbedtls_sha256_free( mbedtls_sha256_context *ctx )
|
|||
void mbedtls_sha256_clone( mbedtls_sha256_context *dst,
|
||||
const mbedtls_sha256_context *src )
|
||||
{
|
||||
SHA256_VALIDATE( dst != NULL );
|
||||
SHA256_VALIDATE( src != NULL );
|
||||
|
||||
*dst = *src;
|
||||
}
|
||||
|
||||
|
@ -186,12 +167,12 @@ void mbedtls_sha256_clone( mbedtls_sha256_context *dst,
|
|||
*/
|
||||
int mbedtls_sha256_starts( mbedtls_sha256_context *ctx, int is224 )
|
||||
{
|
||||
SHA256_VALIDATE_RET( ctx != NULL );
|
||||
|
||||
#if defined(MBEDTLS_SHA224_C)
|
||||
SHA256_VALIDATE_RET( is224 == 0 || is224 == 1 );
|
||||
if( is224 != 0 && is224 != 1 )
|
||||
return MBEDTLS_ERR_SHA256_BAD_INPUT_DATA;
|
||||
#else
|
||||
SHA256_VALIDATE_RET( is224 == 0 );
|
||||
if( is224 != 0 )
|
||||
return MBEDTLS_ERR_SHA256_BAD_INPUT_DATA;
|
||||
#endif
|
||||
|
||||
ctx->total[0] = 0;
|
||||
|
@ -427,9 +408,6 @@ int mbedtls_internal_sha256_process_c( mbedtls_sha256_context *ctx,
|
|||
|
||||
unsigned int i;
|
||||
|
||||
SHA256_VALIDATE_RET( ctx != NULL );
|
||||
SHA256_VALIDATE_RET( (const unsigned char *)data != NULL );
|
||||
|
||||
for( i = 0; i < 8; i++ )
|
||||
local.A[i] = ctx->state[i];
|
||||
|
||||
|
@ -579,9 +557,6 @@ int mbedtls_sha256_update( mbedtls_sha256_context *ctx,
|
|||
size_t fill;
|
||||
uint32_t left;
|
||||
|
||||
SHA256_VALIDATE_RET( ctx != NULL );
|
||||
SHA256_VALIDATE_RET( ilen == 0 || input != NULL );
|
||||
|
||||
if( ilen == 0 )
|
||||
return( 0 );
|
||||
|
||||
|
@ -633,9 +608,6 @@ int mbedtls_sha256_finish( mbedtls_sha256_context *ctx,
|
|||
uint32_t used;
|
||||
uint32_t high, low;
|
||||
|
||||
SHA256_VALIDATE_RET( ctx != NULL );
|
||||
SHA256_VALIDATE_RET( (unsigned char *)output != NULL );
|
||||
|
||||
/*
|
||||
* Add padding: 0x80 then 0x00 until 8 bytes remain for the length
|
||||
*/
|
||||
|
@ -683,9 +655,11 @@ int mbedtls_sha256_finish( mbedtls_sha256_context *ctx,
|
|||
MBEDTLS_PUT_UINT32_BE( ctx->state[5], output, 20 );
|
||||
MBEDTLS_PUT_UINT32_BE( ctx->state[6], output, 24 );
|
||||
|
||||
int truncated = 0;
|
||||
#if defined(MBEDTLS_SHA224_C)
|
||||
if( ctx->is224 == 0 )
|
||||
truncated = ctx->is224;
|
||||
#endif
|
||||
if( !truncated )
|
||||
MBEDTLS_PUT_UINT32_BE( ctx->state[7], output, 28 );
|
||||
|
||||
return( 0 );
|
||||
|
@ -705,14 +679,13 @@ int mbedtls_sha256( const unsigned char *input,
|
|||
mbedtls_sha256_context ctx;
|
||||
|
||||
#if defined(MBEDTLS_SHA224_C)
|
||||
SHA256_VALIDATE_RET( is224 == 0 || is224 == 1 );
|
||||
if( is224 != 0 && is224 != 1 )
|
||||
return MBEDTLS_ERR_SHA256_BAD_INPUT_DATA;
|
||||
#else
|
||||
SHA256_VALIDATE_RET( is224 == 0 );
|
||||
if( is224 != 0 )
|
||||
return MBEDTLS_ERR_SHA256_BAD_INPUT_DATA;
|
||||
#endif
|
||||
|
||||
SHA256_VALIDATE_RET( ilen == 0 || input != NULL );
|
||||
SHA256_VALIDATE_RET( (unsigned char *)output != NULL );
|
||||
|
||||
mbedtls_sha256_init( &ctx );
|
||||
|
||||
if( ( ret = mbedtls_sha256_starts( &ctx, is224 ) ) != 0 )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue