SecurityPkg: add DeviceSecurity support
This patch implement the SpdmSecurityLib, which is the core of DeviceSecurity. And the SpdmSecurityLib include Device Authentication and Measurement. The other library is to support SpdmSecurityLib. Cc: Jiewen Yao <jiewen.yao@intel.com> Signed-off-by: Wenxing Hou <wenxing.hou@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
c3f615a1bd
commit
750d763623
@@ -0,0 +1,23 @@
|
||||
/** @file
|
||||
EDKII Device Security library for SPDM device.
|
||||
It follows the SPDM Specification.
|
||||
|
||||
Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef LIBSPDM_STDBOOL_ALT_H
|
||||
#define LIBSPDM_STDBOOL_ALT_H
|
||||
|
||||
typedef BOOLEAN bool;
|
||||
|
||||
#ifndef true
|
||||
#define true TRUE
|
||||
#endif
|
||||
|
||||
#ifndef false
|
||||
#define false FALSE
|
||||
#endif
|
||||
|
||||
#endif /* LIBSPDM_STDBOOL_ALT */
|
@@ -0,0 +1,16 @@
|
||||
/** @file
|
||||
EDKII Device Security library for SPDM device.
|
||||
It follows the SPDM Specification.
|
||||
|
||||
Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef LIBSPDM_STD_DEF_ALT_H
|
||||
#define LIBSPDM_STD_DEF_ALT_H
|
||||
|
||||
typedef UINTN size_t;
|
||||
#define offsetof(type, member) OFFSET_OF(type,member)
|
||||
|
||||
#endif /* LIBSPDM_STDDEF_ALT */
|
@@ -0,0 +1,25 @@
|
||||
/** @file
|
||||
EDKII Device Security library for SPDM device.
|
||||
It follows the SPDM Specification.
|
||||
|
||||
Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef LIBSPDM_STD_INT_ALT_H
|
||||
#define LIBSPDM_STD_INT_ALT_H
|
||||
|
||||
typedef UINT64 uint64_t;
|
||||
typedef INT64 int64_t;
|
||||
typedef UINT32 uint32_t;
|
||||
typedef INT32 int32_t;
|
||||
typedef UINT16 uint16_t;
|
||||
typedef INT16 int16_t;
|
||||
typedef UINT8 uint8_t;
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
#define SIZE_MAX MAX_UINTN
|
||||
#endif
|
||||
|
||||
#endif /* LIBSPDM_STDINT_ALT */
|
94
SecurityPkg/DeviceSecurity/SpdmLib/Include/hal/base.h
Normal file
94
SecurityPkg/DeviceSecurity/SpdmLib/Include/hal/base.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/** @file
|
||||
EDKII Device Security library for SPDM device.
|
||||
It follows the SPDM Specification.
|
||||
|
||||
Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef BASE_H
|
||||
#define BASE_H
|
||||
|
||||
#define LIBSPDM_STDINT_ALT "hal/LibspdmStdIntAlt.h"
|
||||
#define LIBSPDM_STDBOOL_ALT "hal/LibspdmStdBoolAlt.h"
|
||||
#define LIBSPDM_STDDEF_ALT "hal/LibspdmStdDefAlt.h"
|
||||
|
||||
#ifndef LIBSPDM_STDINT_ALT
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* LIBSPDM_OPENSSL_STDINT_WORKAROUND */
|
||||
|
||||
/* This is a workaround for OpenSSL compilation problems when used with <stdint.h>
|
||||
* on Windows platforms built with Visual Studio. Including <stdint.h> pulls in
|
||||
* <vcruntime.h>, which causes the type size_t to be defined. The size_t type
|
||||
* depends on if _WIN32 or _WIN64 is defined. The default if neither is defined
|
||||
* is the 32-bit version of size_t. */
|
||||
|
||||
/* Our OpenSSL compilation requires _WIN32 and _WIN64 to NOT be defined.
|
||||
* This will force the <vcruntime.h> to use the wrong 32-bit definition of size_t
|
||||
* if we are compiling as 64-bit. This 32-bit definition then does not agree with
|
||||
* the 64-bit definition defined in libspdm and generates compile errors. */
|
||||
|
||||
/* To workaround this issue, LIBSPDM_OPENSSL_STDINT_WORKAROUND was created
|
||||
* that is only defined for compilation via tha makefile of the OpenSSL library
|
||||
* portion of libspdm. */
|
||||
|
||||
/* This will lead to _WIN32 and _WIN64 to be NOT defined when reaching the OpenSSL
|
||||
* portions of a compilation unit (header files + c file), thus meeting the
|
||||
* no Win32/Win64 requirement for OpenSSL, but will still be defined when compiling
|
||||
* the <vcruntime.h> file in the compilation unit (and getting the right size_t). */
|
||||
|
||||
/* In the future libspdm intends to use the Windows native compilation flags and defines,
|
||||
* in place of the UEFI profile / personality. */
|
||||
|
||||
#ifdef LIBSPDM_OPENSSL_STDINT_WORKAROUND
|
||||
#undef _WIN32
|
||||
#undef _WIN64
|
||||
#endif
|
||||
|
||||
#else /* LIBSPDM_STDINT_ALT */
|
||||
#include LIBSPDM_STDINT_ALT
|
||||
#endif /* LIBSPDM_STDINT_ALT */
|
||||
|
||||
#ifndef LIBSPDM_STDBOOL_ALT
|
||||
#include <stdbool.h>
|
||||
#else
|
||||
#include LIBSPDM_STDBOOL_ALT
|
||||
#endif
|
||||
|
||||
#ifndef LIBSPDM_STDDEF_ALT
|
||||
#include <stddef.h>
|
||||
#else
|
||||
#include LIBSPDM_STDDEF_ALT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Return the minimum of two operands.
|
||||
*
|
||||
* This macro returns the minimal of two operand specified by a and b.
|
||||
* Both a and b must be the same numerical types, signed or unsigned.
|
||||
*
|
||||
* @param a The first operand with any numerical type.
|
||||
* @param b The second operand. It should be the same any numerical type with a.
|
||||
*
|
||||
* @return Minimum of two operands.
|
||||
*
|
||||
**/
|
||||
#define LIBSPDM_MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
/**
|
||||
* Return the number of elements in an array.
|
||||
*
|
||||
* @param array An object of array type. Array is only used as an argument to
|
||||
* the sizeof operator, therefore Array is never evaluated. The
|
||||
* caller is responsible for ensuring that Array's type is not
|
||||
* incomplete; that is, Array must have known constant size.
|
||||
*
|
||||
* @return The number of elements in Array. The result has type size_t.
|
||||
*
|
||||
**/
|
||||
#define LIBSPDM_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
|
||||
|
||||
#endif /* BASE_H */
|
@@ -0,0 +1,39 @@
|
||||
/** @file
|
||||
EDKII Device Security library for SPDM device.
|
||||
It follows the SPDM Specification.
|
||||
|
||||
Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
/** @file
|
||||
Provides services to print debug and assert messages to a debug output device.
|
||||
|
||||
The Debug library supports debug print and asserts based on a combination of macros and code.
|
||||
The debug library can be turned on and off so that the debug code does not increase the size of an image.
|
||||
|
||||
Note that a reserved macro named MDEPKG_NDEBUG is introduced for the intention
|
||||
of size reduction when compiler optimization is disabled. If MDEPKG_NDEBUG is
|
||||
defined, then debug and assert related macros wrapped by it are the NULL implementations.
|
||||
**/
|
||||
|
||||
#ifndef DEBUG_LIB_H
|
||||
#define DEBUG_LIB_H
|
||||
|
||||
#include <Library/DebugLib.h>
|
||||
|
||||
#define LIBSPDM_DEBUG_INFO DEBUG_INFO
|
||||
#define LIBSPDM_DEBUG_VERBOSE DEBUG_VERBOSE
|
||||
#define LIBSPDM_DEBUG_ERROR DEBUG_ERROR
|
||||
|
||||
#define LIBSPDM_DEBUG DEBUG
|
||||
#define LIBSPDM_ASSERT ASSERT
|
||||
#define LIBSPDM_ASSERT_RETURN_ERROR ASSERT_RETURN_ERROR
|
||||
|
||||
#define LIBSPDM_DEBUG_CODE_BEGIN DEBUG_CODE_BEGIN
|
||||
#define LIBSPDM_DEBUG_CODE_END DEBUG_CODE_END
|
||||
|
||||
#define LIBSPDM_DEBUG_CODE DEBUG_CODE
|
||||
|
||||
#endif /* DEBUG_LIB_H */
|
Reference in New Issue
Block a user