mirror of
https://github.com/vlang/v.git
synced 2025-09-15 07:22:27 +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
47
thirdparty/mbedtls/library/sha512.c
vendored
47
thirdparty/mbedtls/library/sha512.c
vendored
|
@ -38,17 +38,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_SHA512_USE_A64_CRYPTO_IF_PRESENT) || \
|
||||
|
@ -164,10 +154,6 @@ static int mbedtls_a64_crypto_sha512_determine_support( void )
|
|||
|
||||
#endif /* MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT */
|
||||
|
||||
#define SHA512_VALIDATE_RET(cond) \
|
||||
MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_SHA512_BAD_INPUT_DATA )
|
||||
#define SHA512_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE( cond )
|
||||
|
||||
#if !defined(MBEDTLS_SHA512_ALT)
|
||||
|
||||
#define SHA512_BLOCK_SIZE 128
|
||||
|
@ -183,8 +169,6 @@ static void sha512_put_uint64_be( uint64_t n, unsigned char *b, uint8_t i )
|
|||
|
||||
void mbedtls_sha512_init( mbedtls_sha512_context *ctx )
|
||||
{
|
||||
SHA512_VALIDATE( ctx != NULL );
|
||||
|
||||
memset( ctx, 0, sizeof( mbedtls_sha512_context ) );
|
||||
}
|
||||
|
||||
|
@ -199,9 +183,6 @@ void mbedtls_sha512_free( mbedtls_sha512_context *ctx )
|
|||
void mbedtls_sha512_clone( mbedtls_sha512_context *dst,
|
||||
const mbedtls_sha512_context *src )
|
||||
{
|
||||
SHA512_VALIDATE( dst != NULL );
|
||||
SHA512_VALIDATE( src != NULL );
|
||||
|
||||
*dst = *src;
|
||||
}
|
||||
|
||||
|
@ -210,11 +191,12 @@ void mbedtls_sha512_clone( mbedtls_sha512_context *dst,
|
|||
*/
|
||||
int mbedtls_sha512_starts( mbedtls_sha512_context *ctx, int is384 )
|
||||
{
|
||||
SHA512_VALIDATE_RET( ctx != NULL );
|
||||
#if defined(MBEDTLS_SHA384_C)
|
||||
SHA512_VALIDATE_RET( is384 == 0 || is384 == 1 );
|
||||
if( is384 != 0 && is384 != 1 )
|
||||
return MBEDTLS_ERR_SHA512_BAD_INPUT_DATA;
|
||||
#else
|
||||
SHA512_VALIDATE_RET( is384 == 0 );
|
||||
if( is384 != 0 )
|
||||
return MBEDTLS_ERR_SHA512_BAD_INPUT_DATA;
|
||||
#endif
|
||||
|
||||
ctx->total[0] = 0;
|
||||
|
@ -569,9 +551,6 @@ int mbedtls_internal_sha512_process_c( mbedtls_sha512_context *ctx,
|
|||
uint64_t A[8];
|
||||
} local;
|
||||
|
||||
SHA512_VALIDATE_RET( ctx != NULL );
|
||||
SHA512_VALIDATE_RET( (const unsigned char *)data != NULL );
|
||||
|
||||
#define SHR(x,n) ((x) >> (n))
|
||||
#define ROTR(x,n) (SHR((x),(n)) | ((x) << (64 - (n))))
|
||||
|
||||
|
@ -735,9 +714,6 @@ int mbedtls_sha512_update( mbedtls_sha512_context *ctx,
|
|||
size_t fill;
|
||||
unsigned int left;
|
||||
|
||||
SHA512_VALIDATE_RET( ctx != NULL );
|
||||
SHA512_VALIDATE_RET( ilen == 0 || input != NULL );
|
||||
|
||||
if( ilen == 0 )
|
||||
return( 0 );
|
||||
|
||||
|
@ -788,9 +764,6 @@ int mbedtls_sha512_finish( mbedtls_sha512_context *ctx,
|
|||
unsigned used;
|
||||
uint64_t high, low;
|
||||
|
||||
SHA512_VALIDATE_RET( ctx != NULL );
|
||||
SHA512_VALIDATE_RET( (unsigned char *)output != NULL );
|
||||
|
||||
/*
|
||||
* Add padding: 0x80 then 0x00 until 16 bytes remain for the length
|
||||
*/
|
||||
|
@ -837,9 +810,11 @@ int mbedtls_sha512_finish( mbedtls_sha512_context *ctx,
|
|||
sha512_put_uint64_be( ctx->state[4], output, 32 );
|
||||
sha512_put_uint64_be( ctx->state[5], output, 40 );
|
||||
|
||||
int truncated = 0;
|
||||
#if defined(MBEDTLS_SHA384_C)
|
||||
if( ctx->is384 == 0 )
|
||||
truncated = ctx->is384;
|
||||
#endif
|
||||
if( !truncated )
|
||||
{
|
||||
sha512_put_uint64_be( ctx->state[6], output, 48 );
|
||||
sha512_put_uint64_be( ctx->state[7], output, 56 );
|
||||
|
@ -862,12 +837,12 @@ int mbedtls_sha512( const unsigned char *input,
|
|||
mbedtls_sha512_context ctx;
|
||||
|
||||
#if defined(MBEDTLS_SHA384_C)
|
||||
SHA512_VALIDATE_RET( is384 == 0 || is384 == 1 );
|
||||
if( is384 != 0 && is384 != 1 )
|
||||
return MBEDTLS_ERR_SHA512_BAD_INPUT_DATA;
|
||||
#else
|
||||
SHA512_VALIDATE_RET( is384 == 0 );
|
||||
if( is384 != 0 )
|
||||
return MBEDTLS_ERR_SHA512_BAD_INPUT_DATA;
|
||||
#endif
|
||||
SHA512_VALIDATE_RET( ilen == 0 || input != NULL );
|
||||
SHA512_VALIDATE_RET( (unsigned char *)output != NULL );
|
||||
|
||||
mbedtls_sha512_init( &ctx );
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue