From 8bafde994223da25be680de04eaa584251945888 Mon Sep 17 00:00:00 2001 From: "Li, Fei1" Date: Sat, 8 Dec 2018 00:01:04 +0800 Subject: [PATCH] hv: use uint8_t replace "unsigned char" Since it's typedef in "include/lib/types.h" Tracked-On: #861 Signed-off-by: Li, Fei1 --- hypervisor/bsp/uefi/efi/boot.c | 2 +- hypervisor/include/arch/x86/guest/vm.h | 4 +- hypervisor/include/debug/profiling_internal.h | 2 +- hypervisor/lib/crypto/mbedtls/ChangeLog | 2 +- hypervisor/lib/crypto/mbedtls/hkdf.c | 30 ++++++------ hypervisor/lib/crypto/mbedtls/hkdf.h | 20 ++++---- hypervisor/lib/crypto/mbedtls/md.c | 46 +++++++++---------- hypervisor/lib/crypto/mbedtls/md.h | 28 +++++------ hypervisor/lib/crypto/mbedtls/md_internal.h | 10 ++-- hypervisor/lib/crypto/mbedtls/md_wrap.c | 10 ++-- hypervisor/lib/crypto/mbedtls/sha256.c | 18 ++++---- hypervisor/lib/crypto/mbedtls/sha256.h | 12 ++--- hypervisor/lib/memory.c | 6 +-- 13 files changed, 95 insertions(+), 95 deletions(-) diff --git a/hypervisor/bsp/uefi/efi/boot.c b/hypervisor/bsp/uefi/efi/boot.c index 4e741c781..a21ed30f7 100644 --- a/hypervisor/bsp/uefi/efi/boot.c +++ b/hypervisor/bsp/uefi/efi/boot.c @@ -280,7 +280,7 @@ out: static inline EFI_STATUS isspace(CHAR8 ch) { - return ((unsigned char)ch <= ' '); + return ((uint8_t)ch <= ' '); } /** diff --git a/hypervisor/include/arch/x86/guest/vm.h b/hypervisor/include/arch/x86/guest/vm.h index b7c822af0..367d0cfef 100644 --- a/hypervisor/include/arch/x86/guest/vm.h +++ b/hypervisor/include/arch/x86/guest/vm.h @@ -139,7 +139,7 @@ struct acrn_vm { uint16_t emul_mmio_regions; /* Number of 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; /* Secure World's snapshot @@ -174,7 +174,7 @@ struct vm_description { * will be the VM's BSP */ 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 */ /* Whether secure world is supported for current VM. */ bool sworld_supported; diff --git a/hypervisor/include/debug/profiling_internal.h b/hypervisor/include/debug/profiling_internal.h index 09d178f69..699f01b7e 100644 --- a/hypervisor/include/debug/profiling_internal.h +++ b/hypervisor/include/debug/profiling_internal.h @@ -108,7 +108,7 @@ struct profiling_vcpu_pcpu_map { struct profiling_vm_info { int32_t vm_id_num; - unsigned char guid[16]; + uint8_t guid[16]; char vm_name[16]; int32_t num_vcpus; struct profiling_vcpu_pcpu_map cpu_map[MAX_NR_VCPUS]; diff --git a/hypervisor/lib/crypto/mbedtls/ChangeLog b/hypervisor/lib/crypto/mbedtls/ChangeLog index bda3de8f5..9e46c9722 100644 --- a/hypervisor/lib/crypto/mbedtls/ChangeLog +++ b/hypervisor/lib/crypto/mbedtls/ChangeLog @@ -1266,7 +1266,7 @@ Semi-API changes (technically public, morally private) * Changed pk_info_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. - * 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 mode from des_context and des3_context diff --git a/hypervisor/lib/crypto/mbedtls/hkdf.c b/hypervisor/lib/crypto/mbedtls/hkdf.c index 35a61aa58..fc8caa3b6 100644 --- a/hypervisor/lib/crypto/mbedtls/hkdf.c +++ b/hypervisor/lib/crypto/mbedtls/hkdf.c @@ -21,13 +21,13 @@ #include "hkdf.h" -int mbedtls_hkdf( const mbedtls_md_info_t *md, const unsigned char *salt, - size_t salt_len, const unsigned char *ikm, size_t ikm_len, - const unsigned char *info, size_t info_len, - unsigned char *okm, size_t okm_len ) +int mbedtls_hkdf( const mbedtls_md_info_t *md, const uint8_t *salt, + size_t salt_len, const uint8_t *ikm, size_t ikm_len, + const uint8_t *info, size_t info_len, + uint8_t *okm, size_t okm_len ) { 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 ); @@ -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, - const unsigned char *salt, size_t salt_len, - const unsigned char *ikm, size_t ikm_len, - unsigned char *prk ) + const uint8_t *salt, size_t salt_len, + const uint8_t *ikm, size_t ikm_len, + uint8_t *prk ) { - unsigned char null_salt[MBEDTLS_MD_MAX_SIZE] = { '\0' }; + uint8_t null_salt[MBEDTLS_MD_MAX_SIZE] = { '\0' }; 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 ) ); } -int mbedtls_hkdf_expand( const mbedtls_md_info_t *md, const unsigned char *prk, - size_t prk_len, const unsigned char *info, - size_t info_len, unsigned char *okm, size_t okm_len ) +int mbedtls_hkdf_expand( const mbedtls_md_info_t *md, const uint8_t *prk, + size_t prk_len, const uint8_t *info, + size_t info_len, uint8_t *okm, size_t okm_len ) { size_t hash_len; 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; int ret = 0; mbedtls_md_context_t ctx; - unsigned char t[MBEDTLS_MD_MAX_SIZE]; + uint8_t t[MBEDTLS_MD_MAX_SIZE]; if( okm == NULL ) { @@ -99,7 +99,7 @@ int mbedtls_hkdf_expand( const mbedtls_md_info_t *md, const unsigned char *prk, if( info == NULL ) { - info = (const unsigned char *) ""; + info = (const uint8_t *) ""; 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++ ) { size_t num_to_copy; - unsigned char c = i & 0xff; + uint8_t c = i & 0xff; ret = mbedtls_md_hmac_starts( &ctx, prk, prk_len ); if( ret != 0 ) diff --git a/hypervisor/lib/crypto/mbedtls/hkdf.h b/hypervisor/lib/crypto/mbedtls/hkdf.h index ddaf200fe..a59edbc0f 100644 --- a/hypervisor/lib/crypto/mbedtls/hkdf.h +++ b/hypervisor/lib/crypto/mbedtls/hkdf.h @@ -60,10 +60,10 @@ * \return An MBEDTLS_ERR_MD_* error for errors returned from the underlying * MD layer. */ -int mbedtls_hkdf( const mbedtls_md_info_t *md, const unsigned char *salt, - size_t salt_len, const unsigned char *ikm, size_t ikm_len, - const unsigned char *info, size_t info_len, - unsigned char *okm, size_t okm_len ); +int mbedtls_hkdf( const mbedtls_md_info_t *md, const uint8_t *salt, + size_t salt_len, const uint8_t *ikm, size_t ikm_len, + const uint8_t *info, size_t info_len, + uint8_t *okm, size_t okm_len ); /** * \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. */ int mbedtls_hkdf_extract( const mbedtls_md_info_t *md, - const unsigned char *salt, size_t salt_len, - const unsigned char *ikm, size_t ikm_len, - unsigned char *prk ); + const uint8_t *salt, size_t salt_len, + const uint8_t *ikm, size_t ikm_len, + uint8_t *prk ); /** * \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 * MD layer. */ -int mbedtls_hkdf_expand( const mbedtls_md_info_t *md, const unsigned char *prk, - size_t prk_len, const unsigned char *info, - size_t info_len, unsigned char *okm, size_t okm_len ); +int mbedtls_hkdf_expand( const mbedtls_md_info_t *md, const uint8_t *prk, + size_t prk_len, const uint8_t *info, + size_t info_len, uint8_t *okm, size_t okm_len ); #endif /* hkdf.h */ diff --git a/hypervisor/lib/crypto/mbedtls/md.c b/hypervisor/lib/crypto/mbedtls/md.c index 4c6ed24fa..2b323a409 100644 --- a/hypervisor/lib/crypto/mbedtls/md.c +++ b/hypervisor/lib/crypto/mbedtls/md.c @@ -98,7 +98,7 @@ int mbedtls_md_starts( mbedtls_md_context_t *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 ) 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 ) ); } -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 ) 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 ) ); } -int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen, - unsigned char *output ) +int mbedtls_md( const mbedtls_md_info_t *md_info, const uint8_t *input, size_t ilen, + uint8_t *output ) { if( md_info == NULL ) 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 ) ); } -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; - unsigned char sum[MBEDTLS_MD_MAX_SIZE]; - unsigned char *ipad, *opad; + uint8_t sum[MBEDTLS_MD_MAX_SIZE]; + uint8_t *ipad, *opad; size_t i; 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; } - ipad = (unsigned char *) ctx->hmac_ctx; - opad = (unsigned char *) ctx->hmac_ctx + ctx->md_info->block_size; + ipad = (uint8_t *) ctx->hmac_ctx; + opad = (uint8_t *) ctx->hmac_ctx + ctx->md_info->block_size; memset( ipad, 0x36, ctx->md_info->block_size ); memset( opad, 0x5C, ctx->md_info->block_size ); for( i = 0; i < keylen; i++ ) { - ipad[i] = (unsigned char)( ipad[i] ^ key[i] ); - opad[i] = (unsigned char)( opad[i] ^ key[i] ); + ipad[i] = (uint8_t)( ipad[i] ^ key[i] ); + opad[i] = (uint8_t)( opad[i] ^ key[i] ); } if( ( ret = ctx->md_info->starts_func( ctx->md_ctx ) ) != 0 ) @@ -170,7 +170,7 @@ cleanup: 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 ) 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 ) ); } -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; - unsigned char tmp[MBEDTLS_MD_MAX_SIZE]; - unsigned char *opad; + uint8_t tmp[MBEDTLS_MD_MAX_SIZE]; + uint8_t *opad; if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL ) 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 ) 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 ret; - unsigned char *ipad; + uint8_t *ipad; if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL ) 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 ) 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, - const unsigned char *key, size_t keylen, - const unsigned char *input, size_t ilen, - unsigned char *output ) + const uint8_t *key, size_t keylen, + const uint8_t *input, size_t ilen, + uint8_t *output ) { mbedtls_md_context_t ctx; int ret; @@ -247,7 +247,7 @@ cleanup: 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 ) 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 ) ); } -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 ) return( 0 ); diff --git a/hypervisor/lib/crypto/mbedtls/md.h b/hypervisor/lib/crypto/mbedtls/md.h index c7c7ee150..883c57a17 100644 --- a/hypervisor/lib/crypto/mbedtls/md.h +++ b/hypervisor/lib/crypto/mbedtls/md.h @@ -62,13 +62,13 @@ typedef struct { const mbedtls_md_info_t *md_info; /** 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 * allocation. The hardcode value 128 is 2 times of block_size which * is 64 in md_wrap.c */ - unsigned char hmac_ctx[128]; + uint8_t hmac_ctx[128]; } 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. */ -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 @@ -212,7 +212,7 @@ int mbedtls_md_starts( mbedtls_md_context_t *ctx ); * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification * 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, @@ -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 * 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, @@ -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 * failure. */ -int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen, - unsigned char *output ); +int mbedtls_md( const mbedtls_md_info_t *md_info, const uint8_t *input, size_t ilen, + uint8_t *output ); /** * \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 * 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 ); /** @@ -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 * 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 ); /** @@ -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 * 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 @@ -357,11 +357,11 @@ int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx ); * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification * failure. */ -int mbedtls_md_hmac( const mbedtls_md_info_t *md_info, const unsigned char *key, size_t keylen, - const unsigned char *input, size_t ilen, - unsigned char *output ); +int mbedtls_md_hmac( const mbedtls_md_info_t *md_info, const uint8_t *key, size_t keylen, + const uint8_t *input, size_t ilen, + uint8_t *output ); /* 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 */ diff --git a/hypervisor/lib/crypto/mbedtls/md_internal.h b/hypervisor/lib/crypto/mbedtls/md_internal.h index 03a15328e..9f2053039 100644 --- a/hypervisor/lib/crypto/mbedtls/md_internal.h +++ b/hypervisor/lib/crypto/mbedtls/md_internal.h @@ -53,20 +53,20 @@ struct mbedtls_md_info_t int (*starts_func)( void *ctx ); /** 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 */ - int (*finish_func)( void *ctx, unsigned char *output ); + int (*finish_func)( void *ctx, uint8_t *output ); /** Generic digest function */ - int (*digest_func)( const unsigned char *input, size_t ilen, - unsigned char *output ); + int (*digest_func)( const uint8_t *input, size_t ilen, + uint8_t *output ); /** Clone state from a context */ void (*clone_func)( void *dst, const void *src ); /** 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; diff --git a/hypervisor/lib/crypto/mbedtls/md_wrap.c b/hypervisor/lib/crypto/mbedtls/md_wrap.c index 96c4d197e..0505e4bba 100644 --- a/hypervisor/lib/crypto/mbedtls/md_wrap.c +++ b/hypervisor/lib/crypto/mbedtls/md_wrap.c @@ -32,14 +32,14 @@ * 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 ) { return( mbedtls_sha256_update_ret( (mbedtls_sha256_context *) ctx, 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, output ) ); @@ -51,7 +51,7 @@ static void sha256_clone_wrap( void *dst, const void *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, data ) ); @@ -62,8 +62,8 @@ static int sha256_starts_wrap( void *ctx ) return( mbedtls_sha256_starts_ret( (mbedtls_sha256_context *) ctx, 0 ) ); } -static int sha256_wrap( const unsigned char *input, size_t ilen, - unsigned char *output ) +static int sha256_wrap( const uint8_t *input, size_t ilen, + uint8_t *output ) { return( mbedtls_sha256_ret( input, ilen, output, 0 ) ); } diff --git a/hypervisor/lib/crypto/mbedtls/sha256.c b/hypervisor/lib/crypto/mbedtls/sha256.c index 2f7032f30..f8bf4657a 100644 --- a/hypervisor/lib/crypto/mbedtls/sha256.c +++ b/hypervisor/lib/crypto/mbedtls/sha256.c @@ -44,10 +44,10 @@ do { \ #ifndef PUT_UINT32_BE #define PUT_UINT32_BE(n,b,i) \ do { \ - (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ - (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ - (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ - (b)[(i) + 3] = (unsigned char) ( (n) ); \ + (b)[(i) ] = (uint8_t) ( (n) >> 24 ); \ + (b)[(i) + 1] = (uint8_t) ( (n) >> 16 ); \ + (b)[(i) + 2] = (uint8_t) ( (n) >> 8 ); \ + (b)[(i) + 3] = (uint8_t) ( (n) ); \ } while( 0 ) #endif @@ -154,7 +154,7 @@ static const uint32_t K[] = } 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 A[8]; @@ -200,7 +200,7 @@ int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx, * SHA-256 process buffer */ int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx, - const unsigned char *input, + const uint8_t *input, size_t ilen ) { int ret; @@ -250,7 +250,7 @@ int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx, * SHA-256 final digest */ int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx, - unsigned char output[32] ) + uint8_t output[32] ) { int ret; uint32_t used; @@ -312,9 +312,9 @@ int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx, /* * output = SHA-256( input buffer ) */ -int mbedtls_sha256_ret( const unsigned char *input, +int mbedtls_sha256_ret( const uint8_t *input, size_t ilen, - unsigned char output[32], + uint8_t output[32], int is224 ) { int ret; diff --git a/hypervisor/lib/crypto/mbedtls/sha256.h b/hypervisor/lib/crypto/mbedtls/sha256.h index c2eb66ae0..a6f2662c8 100644 --- a/hypervisor/lib/crypto/mbedtls/sha256.h +++ b/hypervisor/lib/crypto/mbedtls/sha256.h @@ -42,7 +42,7 @@ typedef struct { uint32_t total[2]; /*!< The number of Bytes processed. */ 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: 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. */ int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx, - const unsigned char *input, + const uint8_t *input, size_t ilen ); /** @@ -107,7 +107,7 @@ int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx, * \return \c 0 on success. */ 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 @@ -120,7 +120,7 @@ int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx, * \return \c 0 on success. */ 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 @@ -138,9 +138,9 @@ int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx, * \param is224 Determines which function to use: * 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, - unsigned char output[32], + uint8_t output[32], int is224 ); #endif /* mbedtls_sha256.h */ diff --git a/hypervisor/lib/memory.c b/hypervisor/lib/memory.c index f13986230..ce6cac569 100644 --- a/hypervisor/lib/memory.c +++ b/hypervisor/lib/memory.c @@ -261,9 +261,9 @@ void free(const void *ptr) void *memchr(const void *void_s, int c, size_t n) { - unsigned char val = (unsigned char)c; - unsigned char *ptr = (unsigned char *)void_s; - unsigned char *end = ptr + n; + uint8_t val = (uint8_t)c; + uint8_t *ptr = (uint8_t *)void_s; + uint8_t *end = ptr + n; while (ptr < end) { if (*ptr == val) {