TianoCore EDK2 master
Loading...
Searching...
No Matches
DxeTpmMeasureBootLibSanitizationTest.c File Reference

Go to the source code of this file.

Macros

#define UNIT_TEST_NAME   "DxeTpmMeasureBootLibSanitizationTest"
 
#define UNIT_TEST_VERSION   "1.0"
 
#define DEFAULT_PRIMARY_TABLE_HEADER_REVISION   0x00010000
 
#define DEFAULT_PRIMARY_TABLE_HEADER_NUMBER_OF_PARTITION_ENTRIES   1
 
#define DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY   128
 
#define DxeTpmMeasureBootLibUnitTestMain   main
 

Functions

UNIT_TEST_STATUS EFIAPI TestSanitizeEfiPartitionTableHeader (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestSanitizePrimaryHeaderAllocationSize (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestSanitizePrimaryHeaderGptEventSize (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestSanitizePeImageEventSize (IN UNIT_TEST_CONTEXT Context)
 
EFI_STATUS EFIAPI UefiTestMain (VOID)
 
INT32 DxeTpmMeasureBootLibUnitTestMain (IN INT32 Argc, IN CHAR8 *Argv[])
 

Detailed Description

This file includes the unit test cases for the DxeTpmMeasureBootLibSanitizationTest.c.

Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file DxeTpmMeasureBootLibSanitizationTest.c.

Macro Definition Documentation

◆ DEFAULT_PRIMARY_TABLE_HEADER_NUMBER_OF_PARTITION_ENTRIES

#define DEFAULT_PRIMARY_TABLE_HEADER_NUMBER_OF_PARTITION_ENTRIES   1

Definition at line 23 of file DxeTpmMeasureBootLibSanitizationTest.c.

◆ DEFAULT_PRIMARY_TABLE_HEADER_REVISION

#define DEFAULT_PRIMARY_TABLE_HEADER_REVISION   0x00010000

Definition at line 22 of file DxeTpmMeasureBootLibSanitizationTest.c.

◆ DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY

#define DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY   128

Definition at line 24 of file DxeTpmMeasureBootLibSanitizationTest.c.

◆ DxeTpmMeasureBootLibUnitTestMain

#define DxeTpmMeasureBootLibUnitTestMain   main

Avoid ECC error for function name that starts with lower case letter

Definition at line 369 of file DxeTpmMeasureBootLibSanitizationTest.c.

◆ UNIT_TEST_NAME

#define UNIT_TEST_NAME   "DxeTpmMeasureBootLibSanitizationTest"

Definition at line 19 of file DxeTpmMeasureBootLibSanitizationTest.c.

◆ UNIT_TEST_VERSION

#define UNIT_TEST_VERSION   "1.0"

Definition at line 20 of file DxeTpmMeasureBootLibSanitizationTest.c.

Function Documentation

◆ DxeTpmMeasureBootLibUnitTestMain()

INT32 DxeTpmMeasureBootLibUnitTestMain ( IN INT32  Argc,
IN CHAR8 *  Argv[] 
)

Standard POSIX C entry point for host based unit test execution.

Parameters
[in]ArgcNumber of arguments
[in]ArgvArray of pointers to arguments
Return values
0Success
otherError

Definition at line 381 of file DxeTpmMeasureBootLibSanitizationTest.c.

◆ TestSanitizeEfiPartitionTableHeader()

UNIT_TEST_STATUS EFIAPI TestSanitizeEfiPartitionTableHeader ( IN UNIT_TEST_CONTEXT  Context)

This function tests the SanitizeEfiPartitionTableHeader function. It's intent is to test that a malicious EFI_PARTITION_TABLE_HEADER structure will not cause undefined or unexpected behavior.

In general the TPM should still be able to measure the data, but be the header should be sanitized to prevent any unexpected behavior.

Parameters
[in]ContextThe unit test context.
Return values
UNIT_TEST_PASSEDThe test passed.
UNIT_TEST_ERROR_TEST_FAILEDThe test failed.

Definition at line 41 of file DxeTpmMeasureBootLibSanitizationTest.c.

◆ TestSanitizePeImageEventSize()

UNIT_TEST_STATUS EFIAPI TestSanitizePeImageEventSize ( IN UNIT_TEST_CONTEXT  Context)

This function tests the SanitizePeImageEventSize function. It's intent is to test that the untrusted input from a file path for an EFI_IMAGE_LOAD_EVENT structure will not cause an overflow when calculating the event size when allocating space.

Parameters
[in]ContextThe unit test context.
Return values
UNIT_TEST_PASSEDThe test passed.
UNIT_TEST_ERROR_TEST_FAILEDThe test failed.

Definition at line 235 of file DxeTpmMeasureBootLibSanitizationTest.c.

◆ TestSanitizePrimaryHeaderAllocationSize()

UNIT_TEST_STATUS EFIAPI TestSanitizePrimaryHeaderAllocationSize ( IN UNIT_TEST_CONTEXT  Context)

This function tests the SanitizePrimaryHeaderAllocationSize function. It's intent is to test that the untrusted input from a EFI_PARTITION_TABLE_HEADER structure will not cause an overflow when calculating the allocation size.

Parameters
[in]ContextThe unit test context.
Return values
UNIT_TEST_PASSEDThe test passed.
UNIT_TEST_ERROR_TEST_FAILEDThe test failed.

Definition at line 126 of file DxeTpmMeasureBootLibSanitizationTest.c.

◆ TestSanitizePrimaryHeaderGptEventSize()

UNIT_TEST_STATUS EFIAPI TestSanitizePrimaryHeaderGptEventSize ( IN UNIT_TEST_CONTEXT  Context)

This function tests the SanitizePrimaryHeaderGptEventSize function. It's intent is to test that the untrusted input from a EFI_GPT_DATA structure will not cause an overflow when calculating the event size.

Parameters
[in]ContextThe unit test context.
Return values
UNIT_TEST_PASSEDThe test passed.
UNIT_TEST_ERROR_TEST_FAILEDThe test failed.

Definition at line 180 of file DxeTpmMeasureBootLibSanitizationTest.c.

◆ UefiTestMain()

EFI_STATUS EFIAPI UefiTestMain ( VOID  )

This function acts as the entry point for the unit tests.

Parameters
argc- The number of command line arguments
argv- The command line arguments
Returns
int - The status of the test

Definition at line 324 of file DxeTpmMeasureBootLibSanitizationTest.c.