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

Go to the source code of this file.

Macros

#define UNIT_TEST_NAME   "DxeTpm2MeasureBootLibSanitizationTest"
 
#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 DxeTpm2MeasureBootLibUnitTestMain   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 DxeTpm2MeasureBootLibUnitTestMain (IN INT32 Argc, IN CHAR8 *Argv[])
 

Detailed Description

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

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

Definition in file DxeTpm2MeasureBootLibSanitizationTest.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 24 of file DxeTpm2MeasureBootLibSanitizationTest.c.

◆ DEFAULT_PRIMARY_TABLE_HEADER_REVISION

#define DEFAULT_PRIMARY_TABLE_HEADER_REVISION   0x00010000

Definition at line 23 of file DxeTpm2MeasureBootLibSanitizationTest.c.

◆ DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY

#define DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY   128

Definition at line 25 of file DxeTpm2MeasureBootLibSanitizationTest.c.

◆ DxeTpm2MeasureBootLibUnitTestMain

#define DxeTpm2MeasureBootLibUnitTestMain   main

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

Definition at line 327 of file DxeTpm2MeasureBootLibSanitizationTest.c.

◆ UNIT_TEST_NAME

#define UNIT_TEST_NAME   "DxeTpm2MeasureBootLibSanitizationTest"

Definition at line 20 of file DxeTpm2MeasureBootLibSanitizationTest.c.

◆ UNIT_TEST_VERSION

#define UNIT_TEST_VERSION   "1.0"

Definition at line 21 of file DxeTpm2MeasureBootLibSanitizationTest.c.

Function Documentation

◆ DxeTpm2MeasureBootLibUnitTestMain()

INT32 DxeTpm2MeasureBootLibUnitTestMain ( 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 339 of file DxeTpm2MeasureBootLibSanitizationTest.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 42 of file DxeTpm2MeasureBootLibSanitizationTest.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 when generating a 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 236 of file DxeTpm2MeasureBootLibSanitizationTest.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 127 of file DxeTpm2MeasureBootLibSanitizationTest.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 181 of file DxeTpm2MeasureBootLibSanitizationTest.c.

◆ UefiTestMain()

EFI_STATUS EFIAPI UefiTestMain ( VOID  )

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

Return values
UNIT_TEST_PASSEDThe test passed.
UNIT_TEST_ERROR_TEST_FAILEDThe test failed.
othersThe test failed.

Definition at line 282 of file DxeTpm2MeasureBootLibSanitizationTest.c.