hv: use uint8_t replace "unsigned char"

Since it's typedef in "include/lib/types.h"

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
Li, Fei1 2018-12-08 00:01:04 +08:00 committed by wenlingz
parent a1435f332b
commit 8bafde9942
13 changed files with 95 additions and 95 deletions

View File

@ -280,7 +280,7 @@ out:
static inline EFI_STATUS isspace(CHAR8 ch) static inline EFI_STATUS isspace(CHAR8 ch)
{ {
return ((unsigned char)ch <= ' '); return ((uint8_t)ch <= ' ');
} }
/** /**

View File

@ -139,7 +139,7 @@ struct acrn_vm {
uint16_t emul_mmio_regions; /* Number of emulated mmio regions */ uint16_t emul_mmio_regions; /* Number of emulated mmio regions */
struct mem_io_node emul_mmio[CONFIG_MAX_EMULATED_MMIO_REGIONS]; struct mem_io_node emul_mmio[CONFIG_MAX_EMULATED_MMIO_REGIONS];
unsigned char GUID[16]; uint8_t GUID[16];
struct secure_world_control sworld_control; struct secure_world_control sworld_control;
/* Secure World's snapshot /* Secure World's snapshot
@ -174,7 +174,7 @@ struct vm_description {
* will be the VM's BSP * will be the VM's BSP
*/ */
uint16_t *vm_pcpu_ids; uint16_t *vm_pcpu_ids;
unsigned char GUID[16]; /* GUID of the vm will be created */ uint8_t GUID[16]; /* GUID of the vm will be created */
uint16_t vm_hw_num_cores; /* Number of virtual cores */ uint16_t vm_hw_num_cores; /* Number of virtual cores */
/* Whether secure world is supported for current VM. */ /* Whether secure world is supported for current VM. */
bool sworld_supported; bool sworld_supported;

View File

@ -108,7 +108,7 @@ struct profiling_vcpu_pcpu_map {
struct profiling_vm_info { struct profiling_vm_info {
int32_t vm_id_num; int32_t vm_id_num;
unsigned char guid[16]; uint8_t guid[16];
char vm_name[16]; char vm_name[16];
int32_t num_vcpus; int32_t num_vcpus;
struct profiling_vcpu_pcpu_map cpu_map[MAX_NR_VCPUS]; struct profiling_vcpu_pcpu_map cpu_map[MAX_NR_VCPUS];

View File

@ -1266,7 +1266,7 @@ Semi-API changes (technically public, morally private)
* Changed pk_info_t into an opaque structure. * Changed pk_info_t into an opaque structure.
* Changed cipher_base_t into an opaque structure. * Changed cipher_base_t into an opaque structure.
* Removed sig_oid2 and rename sig_oid1 to sig_oid in x509_crt and x509_crl. * Removed sig_oid2 and rename sig_oid1 to sig_oid in x509_crt and x509_crl.
* x509_crt.key_usage changed from unsigned char to unsigned int. * x509_crt.key_usage changed from uint8_t to unsigned int.
* Removed r and s from ecdsa_context * Removed r and s from ecdsa_context
* Removed mode from des_context and des3_context * Removed mode from des_context and des3_context

View File

@ -21,13 +21,13 @@
#include "hkdf.h" #include "hkdf.h"
int mbedtls_hkdf( const mbedtls_md_info_t *md, const unsigned char *salt, int mbedtls_hkdf( const mbedtls_md_info_t *md, const uint8_t *salt,
size_t salt_len, const unsigned char *ikm, size_t ikm_len, size_t salt_len, const uint8_t *ikm, size_t ikm_len,
const unsigned char *info, size_t info_len, const uint8_t *info, size_t info_len,
unsigned char *okm, size_t okm_len ) uint8_t *okm, size_t okm_len )
{ {
int ret; int ret;
unsigned char prk[MBEDTLS_MD_MAX_SIZE]; uint8_t prk[MBEDTLS_MD_MAX_SIZE];
ret = mbedtls_hkdf_extract( md, salt, salt_len, ikm, ikm_len, prk ); ret = mbedtls_hkdf_extract( md, salt, salt_len, ikm, ikm_len, prk );
@ -43,11 +43,11 @@ int mbedtls_hkdf( const mbedtls_md_info_t *md, const unsigned char *salt,
} }
int mbedtls_hkdf_extract( const mbedtls_md_info_t *md, int mbedtls_hkdf_extract( const mbedtls_md_info_t *md,
const unsigned char *salt, size_t salt_len, const uint8_t *salt, size_t salt_len,
const unsigned char *ikm, size_t ikm_len, const uint8_t *ikm, size_t ikm_len,
unsigned char *prk ) uint8_t *prk )
{ {
unsigned char null_salt[MBEDTLS_MD_MAX_SIZE] = { '\0' }; uint8_t null_salt[MBEDTLS_MD_MAX_SIZE] = { '\0' };
if( salt == NULL ) if( salt == NULL )
{ {
@ -72,9 +72,9 @@ int mbedtls_hkdf_extract( const mbedtls_md_info_t *md,
return( mbedtls_md_hmac( md, salt, salt_len, ikm, ikm_len, prk ) ); return( mbedtls_md_hmac( md, salt, salt_len, ikm, ikm_len, prk ) );
} }
int mbedtls_hkdf_expand( const mbedtls_md_info_t *md, const unsigned char *prk, int mbedtls_hkdf_expand( const mbedtls_md_info_t *md, const uint8_t *prk,
size_t prk_len, const unsigned char *info, size_t prk_len, const uint8_t *info,
size_t info_len, unsigned char *okm, size_t okm_len ) size_t info_len, uint8_t *okm, size_t okm_len )
{ {
size_t hash_len; size_t hash_len;
size_t where = 0; size_t where = 0;
@ -83,7 +83,7 @@ int mbedtls_hkdf_expand( const mbedtls_md_info_t *md, const unsigned char *prk,
size_t i; size_t i;
int ret = 0; int ret = 0;
mbedtls_md_context_t ctx; mbedtls_md_context_t ctx;
unsigned char t[MBEDTLS_MD_MAX_SIZE]; uint8_t t[MBEDTLS_MD_MAX_SIZE];
if( okm == NULL ) if( okm == NULL )
{ {
@ -99,7 +99,7 @@ int mbedtls_hkdf_expand( const mbedtls_md_info_t *md, const unsigned char *prk,
if( info == NULL ) if( info == NULL )
{ {
info = (const unsigned char *) ""; info = (const uint8_t *) "";
info_len = 0; info_len = 0;
} }
@ -133,7 +133,7 @@ int mbedtls_hkdf_expand( const mbedtls_md_info_t *md, const unsigned char *prk,
for( i = 1; i <= n; i++ ) for( i = 1; i <= n; i++ )
{ {
size_t num_to_copy; size_t num_to_copy;
unsigned char c = i & 0xff; uint8_t c = i & 0xff;
ret = mbedtls_md_hmac_starts( &ctx, prk, prk_len ); ret = mbedtls_md_hmac_starts( &ctx, prk, prk_len );
if( ret != 0 ) if( ret != 0 )

View File

@ -60,10 +60,10 @@
* \return An MBEDTLS_ERR_MD_* error for errors returned from the underlying * \return An MBEDTLS_ERR_MD_* error for errors returned from the underlying
* MD layer. * MD layer.
*/ */
int mbedtls_hkdf( const mbedtls_md_info_t *md, const unsigned char *salt, int mbedtls_hkdf( const mbedtls_md_info_t *md, const uint8_t *salt,
size_t salt_len, const unsigned char *ikm, size_t ikm_len, size_t salt_len, const uint8_t *ikm, size_t ikm_len,
const unsigned char *info, size_t info_len, const uint8_t *info, size_t info_len,
unsigned char *okm, size_t okm_len ); uint8_t *okm, size_t okm_len );
/** /**
* \brief Take the input keying material \p ikm and extract from it a * \brief Take the input keying material \p ikm and extract from it a
@ -85,9 +85,9 @@ int mbedtls_hkdf( const mbedtls_md_info_t *md, const unsigned char *salt,
* MD layer. * MD layer.
*/ */
int mbedtls_hkdf_extract( const mbedtls_md_info_t *md, int mbedtls_hkdf_extract( const mbedtls_md_info_t *md,
const unsigned char *salt, size_t salt_len, const uint8_t *salt, size_t salt_len,
const unsigned char *ikm, size_t ikm_len, const uint8_t *ikm, size_t ikm_len,
unsigned char *prk ); uint8_t *prk );
/** /**
* \brief Expand the supplied \p prk into several additional pseudorandom * \brief Expand the supplied \p prk into several additional pseudorandom
@ -110,8 +110,8 @@ int mbedtls_hkdf_extract( const mbedtls_md_info_t *md,
* \return An MBEDTLS_ERR_MD_* error for errors returned from the underlying * \return An MBEDTLS_ERR_MD_* error for errors returned from the underlying
* MD layer. * MD layer.
*/ */
int mbedtls_hkdf_expand( const mbedtls_md_info_t *md, const unsigned char *prk, int mbedtls_hkdf_expand( const mbedtls_md_info_t *md, const uint8_t *prk,
size_t prk_len, const unsigned char *info, size_t prk_len, const uint8_t *info,
size_t info_len, unsigned char *okm, size_t okm_len ); size_t info_len, uint8_t *okm, size_t okm_len );
#endif /* hkdf.h */ #endif /* hkdf.h */

View File

@ -98,7 +98,7 @@ int mbedtls_md_starts( mbedtls_md_context_t *ctx )
return( ctx->md_info->starts_func( ctx->md_ctx ) ); return( ctx->md_info->starts_func( ctx->md_ctx ) );
} }
int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen ) int mbedtls_md_update( mbedtls_md_context_t *ctx, const uint8_t *input, size_t ilen )
{ {
if( ctx == NULL || ctx->md_info == NULL ) if( ctx == NULL || ctx->md_info == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
@ -106,7 +106,7 @@ int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, si
return( ctx->md_info->update_func( ctx->md_ctx, input, ilen ) ); return( ctx->md_info->update_func( ctx->md_ctx, input, ilen ) );
} }
int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output ) int mbedtls_md_finish( mbedtls_md_context_t *ctx, uint8_t *output )
{ {
if( ctx == NULL || ctx->md_info == NULL ) if( ctx == NULL || ctx->md_info == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
@ -114,8 +114,8 @@ int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output )
return( ctx->md_info->finish_func( ctx->md_ctx, output ) ); return( ctx->md_info->finish_func( ctx->md_ctx, output ) );
} }
int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen, int mbedtls_md( const mbedtls_md_info_t *md_info, const uint8_t *input, size_t ilen,
unsigned char *output ) uint8_t *output )
{ {
if( md_info == NULL ) if( md_info == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
@ -123,11 +123,11 @@ int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, si
return( md_info->digest_func( input, ilen, output ) ); return( md_info->digest_func( input, ilen, output ) );
} }
int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key, size_t keylen ) int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const uint8_t *key, size_t keylen )
{ {
int ret; int ret;
unsigned char sum[MBEDTLS_MD_MAX_SIZE]; uint8_t sum[MBEDTLS_MD_MAX_SIZE];
unsigned char *ipad, *opad; uint8_t *ipad, *opad;
size_t i; size_t i;
if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL ) if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL )
@ -146,16 +146,16 @@ int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key,
key = sum; key = sum;
} }
ipad = (unsigned char *) ctx->hmac_ctx; ipad = (uint8_t *) ctx->hmac_ctx;
opad = (unsigned char *) ctx->hmac_ctx + ctx->md_info->block_size; opad = (uint8_t *) ctx->hmac_ctx + ctx->md_info->block_size;
memset( ipad, 0x36, ctx->md_info->block_size ); memset( ipad, 0x36, ctx->md_info->block_size );
memset( opad, 0x5C, ctx->md_info->block_size ); memset( opad, 0x5C, ctx->md_info->block_size );
for( i = 0; i < keylen; i++ ) for( i = 0; i < keylen; i++ )
{ {
ipad[i] = (unsigned char)( ipad[i] ^ key[i] ); ipad[i] = (uint8_t)( ipad[i] ^ key[i] );
opad[i] = (unsigned char)( opad[i] ^ key[i] ); opad[i] = (uint8_t)( opad[i] ^ key[i] );
} }
if( ( ret = ctx->md_info->starts_func( ctx->md_ctx ) ) != 0 ) if( ( ret = ctx->md_info->starts_func( ctx->md_ctx ) ) != 0 )
@ -170,7 +170,7 @@ cleanup:
return( ret ); return( ret );
} }
int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen ) int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const uint8_t *input, size_t ilen )
{ {
if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL ) if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
@ -178,16 +178,16 @@ int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *inpu
return( ctx->md_info->update_func( ctx->md_ctx, input, ilen ) ); return( ctx->md_info->update_func( ctx->md_ctx, input, ilen ) );
} }
int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output ) int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, uint8_t *output )
{ {
int ret; int ret;
unsigned char tmp[MBEDTLS_MD_MAX_SIZE]; uint8_t tmp[MBEDTLS_MD_MAX_SIZE];
unsigned char *opad; uint8_t *opad;
if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL ) if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
opad = (unsigned char *) ctx->hmac_ctx + ctx->md_info->block_size; opad = (uint8_t *) ctx->hmac_ctx + ctx->md_info->block_size;
if( ( ret = ctx->md_info->finish_func( ctx->md_ctx, tmp ) ) != 0 ) if( ( ret = ctx->md_info->finish_func( ctx->md_ctx, tmp ) ) != 0 )
return( ret ); return( ret );
@ -205,12 +205,12 @@ int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output )
int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx ) int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx )
{ {
int ret; int ret;
unsigned char *ipad; uint8_t *ipad;
if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL ) if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
ipad = (unsigned char *) ctx->hmac_ctx; ipad = (uint8_t *) ctx->hmac_ctx;
if( ( ret = ctx->md_info->starts_func( ctx->md_ctx ) ) != 0 ) if( ( ret = ctx->md_info->starts_func( ctx->md_ctx ) ) != 0 )
return( ret ); return( ret );
@ -219,9 +219,9 @@ int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx )
} }
int mbedtls_md_hmac( const mbedtls_md_info_t *md_info, int mbedtls_md_hmac( const mbedtls_md_info_t *md_info,
const unsigned char *key, size_t keylen, const uint8_t *key, size_t keylen,
const unsigned char *input, size_t ilen, const uint8_t *input, size_t ilen,
unsigned char *output ) uint8_t *output )
{ {
mbedtls_md_context_t ctx; mbedtls_md_context_t ctx;
int ret; int ret;
@ -247,7 +247,7 @@ cleanup:
return( ret ); return( ret );
} }
int mbedtls_md_process( mbedtls_md_context_t *ctx, const unsigned char *data ) int mbedtls_md_process( mbedtls_md_context_t *ctx, const uint8_t *data )
{ {
if( ctx == NULL || ctx->md_info == NULL ) if( ctx == NULL || ctx->md_info == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
@ -255,7 +255,7 @@ int mbedtls_md_process( mbedtls_md_context_t *ctx, const unsigned char *data )
return( ctx->md_info->process_func( ctx->md_ctx, data ) ); return( ctx->md_info->process_func( ctx->md_ctx, data ) );
} }
unsigned char mbedtls_md_get_size( const mbedtls_md_info_t *md_info ) uint8_t mbedtls_md_get_size( const mbedtls_md_info_t *md_info )
{ {
if( md_info == NULL ) if( md_info == NULL )
return( 0 ); return( 0 );

View File

@ -62,13 +62,13 @@ typedef struct {
const mbedtls_md_info_t *md_info; const mbedtls_md_info_t *md_info;
/** The digest-specific context. */ /** The digest-specific context. */
unsigned char md_ctx[sizeof( mbedtls_sha256_context )]; uint8_t md_ctx[sizeof( mbedtls_sha256_context )];
/** The HMAC part of the context. Use array here to avoid dynamic memory /** The HMAC part of the context. Use array here to avoid dynamic memory
* allocation. The hardcode value 128 is 2 times of block_size which * allocation. The hardcode value 128 is 2 times of block_size which
* is 64 in md_wrap.c * is 64 in md_wrap.c
*/ */
unsigned char hmac_ctx[128]; uint8_t hmac_ctx[128];
} mbedtls_md_context_t; } mbedtls_md_context_t;
/** /**
@ -168,7 +168,7 @@ int mbedtls_md_clone( mbedtls_md_context_t *dst,
* *
* \return The size of the message-digest output in Bytes. * \return The size of the message-digest output in Bytes.
*/ */
unsigned char mbedtls_md_get_size( const mbedtls_md_info_t *md_info ); uint8_t mbedtls_md_get_size( const mbedtls_md_info_t *md_info );
/** /**
* \brief This function extracts the message-digest type from the * \brief This function extracts the message-digest type from the
@ -212,7 +212,7 @@ int mbedtls_md_starts( mbedtls_md_context_t *ctx );
* \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification
* failure. * failure.
*/ */
int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen ); int mbedtls_md_update( mbedtls_md_context_t *ctx, const uint8_t *input, size_t ilen );
/** /**
* \brief This function finishes the digest operation, * \brief This function finishes the digest operation,
@ -232,7 +232,7 @@ int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, si
* \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification
* failure. * failure.
*/ */
int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output ); int mbedtls_md_finish( mbedtls_md_context_t *ctx, uint8_t *output );
/** /**
* \brief This function calculates the message-digest of a buffer, * \brief This function calculates the message-digest of a buffer,
@ -252,8 +252,8 @@ int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output );
* \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification
* failure. * failure.
*/ */
int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen, int mbedtls_md( const mbedtls_md_info_t *md_info, const uint8_t *input, size_t ilen,
unsigned char *output ); uint8_t *output );
/** /**
* \brief This function sets the HMAC key and prepares to * \brief This function sets the HMAC key and prepares to
@ -273,7 +273,7 @@ int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, si
* \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification
* failure. * failure.
*/ */
int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key, int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const uint8_t *key,
size_t keylen ); size_t keylen );
/** /**
@ -295,7 +295,7 @@ int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key,
* \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification
* failure. * failure.
*/ */
int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *input, int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const uint8_t *input,
size_t ilen ); size_t ilen );
/** /**
@ -316,7 +316,7 @@ int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *inpu
* \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification
* failure. * failure.
*/ */
int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output); int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, uint8_t *output);
/** /**
* \brief This function prepares to authenticate a new message with * \brief This function prepares to authenticate a new message with
@ -357,11 +357,11 @@ int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx );
* \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification
* failure. * failure.
*/ */
int mbedtls_md_hmac( const mbedtls_md_info_t *md_info, const unsigned char *key, size_t keylen, int mbedtls_md_hmac( const mbedtls_md_info_t *md_info, const uint8_t *key, size_t keylen,
const unsigned char *input, size_t ilen, const uint8_t *input, size_t ilen,
unsigned char *output ); uint8_t *output );
/* Internal use */ /* Internal use */
int mbedtls_md_process( mbedtls_md_context_t *ctx, const unsigned char *data ); int mbedtls_md_process( mbedtls_md_context_t *ctx, const uint8_t *data );
#endif /* MBEDTLS_MD_H */ #endif /* MBEDTLS_MD_H */

View File

@ -53,20 +53,20 @@ struct mbedtls_md_info_t
int (*starts_func)( void *ctx ); int (*starts_func)( void *ctx );
/** Digest update function */ /** Digest update function */
int (*update_func)( void *ctx, const unsigned char *input, size_t ilen ); int (*update_func)( void *ctx, const uint8_t *input, size_t ilen );
/** Digest finalisation function */ /** Digest finalisation function */
int (*finish_func)( void *ctx, unsigned char *output ); int (*finish_func)( void *ctx, uint8_t *output );
/** Generic digest function */ /** Generic digest function */
int (*digest_func)( const unsigned char *input, size_t ilen, int (*digest_func)( const uint8_t *input, size_t ilen,
unsigned char *output ); uint8_t *output );
/** Clone state from a context */ /** Clone state from a context */
void (*clone_func)( void *dst, const void *src ); void (*clone_func)( void *dst, const void *src );
/** Internal use only */ /** Internal use only */
int (*process_func)( void *ctx, const unsigned char *input ); int (*process_func)( void *ctx, const uint8_t *input );
}; };
extern const mbedtls_md_info_t mbedtls_sha256_info; extern const mbedtls_md_info_t mbedtls_sha256_info;

View File

@ -32,14 +32,14 @@
* Wrappers for generic message digests * Wrappers for generic message digests
*/ */
static int sha256_update_wrap( void *ctx, const unsigned char *input, static int sha256_update_wrap( void *ctx, const uint8_t *input,
size_t ilen ) size_t ilen )
{ {
return( mbedtls_sha256_update_ret( (mbedtls_sha256_context *) ctx, return( mbedtls_sha256_update_ret( (mbedtls_sha256_context *) ctx,
input, ilen ) ); input, ilen ) );
} }
static int sha256_finish_wrap( void *ctx, unsigned char *output ) static int sha256_finish_wrap( void *ctx, uint8_t *output )
{ {
return( mbedtls_sha256_finish_ret( (mbedtls_sha256_context *) ctx, return( mbedtls_sha256_finish_ret( (mbedtls_sha256_context *) ctx,
output ) ); output ) );
@ -51,7 +51,7 @@ static void sha256_clone_wrap( void *dst, const void *src )
(const mbedtls_sha256_context *) src ); (const mbedtls_sha256_context *) src );
} }
static int sha256_process_wrap( void *ctx, const unsigned char *data ) static int sha256_process_wrap( void *ctx, const uint8_t *data )
{ {
return( mbedtls_internal_sha256_process( (mbedtls_sha256_context *) ctx, return( mbedtls_internal_sha256_process( (mbedtls_sha256_context *) ctx,
data ) ); data ) );
@ -62,8 +62,8 @@ static int sha256_starts_wrap( void *ctx )
return( mbedtls_sha256_starts_ret( (mbedtls_sha256_context *) ctx, 0 ) ); return( mbedtls_sha256_starts_ret( (mbedtls_sha256_context *) ctx, 0 ) );
} }
static int sha256_wrap( const unsigned char *input, size_t ilen, static int sha256_wrap( const uint8_t *input, size_t ilen,
unsigned char *output ) uint8_t *output )
{ {
return( mbedtls_sha256_ret( input, ilen, output, 0 ) ); return( mbedtls_sha256_ret( input, ilen, output, 0 ) );
} }

View File

@ -44,10 +44,10 @@ do { \
#ifndef PUT_UINT32_BE #ifndef PUT_UINT32_BE
#define PUT_UINT32_BE(n,b,i) \ #define PUT_UINT32_BE(n,b,i) \
do { \ do { \
(b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ (b)[(i) ] = (uint8_t) ( (n) >> 24 ); \
(b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ (b)[(i) + 1] = (uint8_t) ( (n) >> 16 ); \
(b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ (b)[(i) + 2] = (uint8_t) ( (n) >> 8 ); \
(b)[(i) + 3] = (unsigned char) ( (n) ); \ (b)[(i) + 3] = (uint8_t) ( (n) ); \
} while( 0 ) } while( 0 )
#endif #endif
@ -154,7 +154,7 @@ static const uint32_t K[] =
} }
int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx, int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx,
const unsigned char data[64] ) const uint8_t data[64] )
{ {
uint32_t temp1, temp2, W[64]; uint32_t temp1, temp2, W[64];
uint32_t A[8]; uint32_t A[8];
@ -200,7 +200,7 @@ int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx,
* SHA-256 process buffer * SHA-256 process buffer
*/ */
int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx, int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx,
const unsigned char *input, const uint8_t *input,
size_t ilen ) size_t ilen )
{ {
int ret; int ret;
@ -250,7 +250,7 @@ int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx,
* SHA-256 final digest * SHA-256 final digest
*/ */
int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx, int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx,
unsigned char output[32] ) uint8_t output[32] )
{ {
int ret; int ret;
uint32_t used; uint32_t used;
@ -312,9 +312,9 @@ int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx,
/* /*
* output = SHA-256( input buffer ) * output = SHA-256( input buffer )
*/ */
int mbedtls_sha256_ret( const unsigned char *input, int mbedtls_sha256_ret( const uint8_t *input,
size_t ilen, size_t ilen,
unsigned char output[32], uint8_t output[32],
int is224 ) int is224 )
{ {
int ret; int ret;

View File

@ -42,7 +42,7 @@ typedef struct
{ {
uint32_t total[2]; /*!< The number of Bytes processed. */ uint32_t total[2]; /*!< The number of Bytes processed. */
uint32_t state[8]; /*!< The intermediate digest state. */ uint32_t state[8]; /*!< The intermediate digest state. */
unsigned char buffer[64]; /*!< The data block being processed. */ uint8_t buffer[64]; /*!< The data block being processed. */
int is224; /*!< Determines which function to use: int is224; /*!< Determines which function to use:
0: Use SHA-256, or 1: Use SHA-224. */ 0: Use SHA-256, or 1: Use SHA-224. */
} }
@ -94,7 +94,7 @@ int mbedtls_sha256_starts_ret( mbedtls_sha256_context *ctx, int is224 );
* \return \c 0 on success. * \return \c 0 on success.
*/ */
int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx, int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx,
const unsigned char *input, const uint8_t *input,
size_t ilen ); size_t ilen );
/** /**
@ -107,7 +107,7 @@ int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx,
* \return \c 0 on success. * \return \c 0 on success.
*/ */
int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx, int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx,
unsigned char output[32] ); uint8_t output[32] );
/** /**
* \brief This function processes a single data block within * \brief This function processes a single data block within
@ -120,7 +120,7 @@ int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx,
* \return \c 0 on success. * \return \c 0 on success.
*/ */
int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx, int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx,
const unsigned char data[64] ); const uint8_t data[64] );
/** /**
* \brief This function calculates the SHA-224 or SHA-256 * \brief This function calculates the SHA-224 or SHA-256
@ -138,9 +138,9 @@ int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx,
* \param is224 Determines which function to use: * \param is224 Determines which function to use:
* 0: Use SHA-256, or 1: Use SHA-224. * 0: Use SHA-256, or 1: Use SHA-224.
*/ */
int mbedtls_sha256_ret( const unsigned char *input, int mbedtls_sha256_ret( const uint8_t *input,
size_t ilen, size_t ilen,
unsigned char output[32], uint8_t output[32],
int is224 ); int is224 );
#endif /* mbedtls_sha256.h */ #endif /* mbedtls_sha256.h */

View File

@ -261,9 +261,9 @@ void free(const void *ptr)
void *memchr(const void *void_s, int c, size_t n) void *memchr(const void *void_s, int c, size_t n)
{ {
unsigned char val = (unsigned char)c; uint8_t val = (uint8_t)c;
unsigned char *ptr = (unsigned char *)void_s; uint8_t *ptr = (uint8_t *)void_s;
unsigned char *end = ptr + n; uint8_t *end = ptr + n;
while (ptr < end) { while (ptr < end) {
if (*ptr == val) { if (*ptr == val) {