mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-01-04 15:14:27 +00:00
HV: wrap and enable hkdf_sha256 key derivation based on mbedtls
Derive multiple seeds to support multiple guest VMs Signed-off-by: Chen, Gang G <gang.g.chen@intel.com>
This commit is contained in:
@@ -168,7 +168,7 @@ int mbedtls_hkdf_expand( const mbedtls_md_info_t *md, const unsigned char *prk,
|
||||
}
|
||||
|
||||
num_to_copy = i != n ? hash_len : okm_len - where;
|
||||
memcpy( okm + where, t, num_to_copy );
|
||||
memcpy_s( okm + where, num_to_copy, t, num_to_copy );
|
||||
where += hash_len;
|
||||
t_len = hash_len;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||
*/
|
||||
|
||||
#include <hypervisor.h>
|
||||
#include "md.h"
|
||||
#include "md_internal.h"
|
||||
|
||||
|
||||
@@ -28,12 +28,14 @@
|
||||
#ifndef MBEDTLS_MD_H
|
||||
#define MBEDTLS_MD_H
|
||||
|
||||
#include <rtl.h>
|
||||
#define MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE -0x5080 /**< The selected feature is not available. */
|
||||
#define MBEDTLS_ERR_MD_BAD_INPUT_DATA -0x5100 /**< Bad input parameters to function. */
|
||||
#define MBEDTLS_ERR_MD_ALLOC_FAILED -0x5180 /**< Failed to allocate memory. */
|
||||
#define MBEDTLS_ERR_MD_FILE_IO_ERROR -0x5200 /**< Opening or reading of file failed. */
|
||||
#define MBEDTLS_ERR_MD_HW_ACCEL_FAILED -0x5280 /**< MD hardware accelerator failed. */
|
||||
|
||||
#define mbedtls_platform_zeroize(buf, len) memset(buf, 0, len)
|
||||
#define mbedtls_calloc calloc
|
||||
#define mbedtls_free free
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||
*/
|
||||
|
||||
#include <hypervisor.h>
|
||||
#include "md_internal.h"
|
||||
#include "sha256.h"
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx,
|
||||
|
||||
if( left && ilen >= fill )
|
||||
{
|
||||
memcpy( (void *) (ctx->buffer + left), input, fill );
|
||||
memcpy_s( (void *) (ctx->buffer + left), fill, input, fill );
|
||||
|
||||
if( ( ret = mbedtls_internal_sha256_process( ctx, ctx->buffer ) ) != 0 )
|
||||
return( ret );
|
||||
@@ -241,7 +241,7 @@ int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx,
|
||||
}
|
||||
|
||||
if( ilen > 0 )
|
||||
memcpy( (void *) (ctx->buffer + left), input, ilen );
|
||||
memcpy_s( (void *) (ctx->buffer + left), ilen, input, ilen );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#ifndef MBEDTLS_SHA256_H
|
||||
#define MBEDTLS_SHA256_H
|
||||
|
||||
#include <types.h>
|
||||
#define MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED -0x0037 /**< SHA-256 hardware accelerator failed */
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user