Skip to content

Commit

Permalink
SecurityPkg: Added SecurityPkg to CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Krichanov committed Nov 1, 2024
1 parent 020db62 commit 75247e4
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 39 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/build_common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ jobs:
SKIP_TESTS: 1
SKIP_PACKAGE: 1

- name: Build SecurityPkg
if: always()
run: ./efibuild.sh
env:
SELFPKG: SecurityPkg
ARCHS: IA32,X64
SKIP_TESTS: 1
SKIP_PACKAGE: 1

build-windows:
name: Windows VS2019
runs-on: windows-latest
Expand Down Expand Up @@ -249,6 +258,15 @@ jobs:
SKIP_TESTS: 1
SKIP_PACKAGE: 1

- name: Build SecurityPkg
if: always()
run: ./efibuild.sh
env:
SELFPKG: SecurityPkg
ARCHS: IA32,X64
SKIP_TESTS: 1
SKIP_PACKAGE: 1

build-linux-clangpdb:
name: Linux CLANGPDB
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -373,6 +391,18 @@ jobs:
SKIP_TESTS: 1
SKIP_PACKAGE: 1

- name: Build SecurityPkg
if: always()
run: docker compose run build-package
env:
SELFPKG: SecurityPkg
SELFPKG_DIR: SecurityPkg
TOOLCHAINS: CLANGPDB
ARCHS: IA32,X64
TARGETS: RELEASE,DEBUG,NOOPT
SKIP_TESTS: 1
SKIP_PACKAGE: 1

build-linux-clangdwarf:
name: Linux CLANGDWARF
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -497,6 +527,18 @@ jobs:
SKIP_TESTS: 1
SKIP_PACKAGE: 1

- name: Build SecurityPkg
if: always()
run: docker compose run build-package
env:
SELFPKG: SecurityPkg
SELFPKG_DIR: SecurityPkg
TOOLCHAINS: CLANGDWARF
ARCHS: IA32,X64
TARGETS: RELEASE,DEBUG,NOOPT
SKIP_TESTS: 1
SKIP_PACKAGE: 1

build-linux-gcc5:
name: Linux GCC
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -620,3 +662,15 @@ jobs:
TARGETS: RELEASE,DEBUG,NOOPT
SKIP_TESTS: 1
SKIP_PACKAGE: 1

- name: Build SecurityPkg
if: always()
run: docker compose run build-package
env:
SELFPKG: SecurityPkg
SELFPKG_DIR: SecurityPkg
TOOLCHAINS: GCC
ARCHS: IA32,X64
TARGETS: RELEASE,DEBUG,NOOPT
SKIP_TESTS: 1
SKIP_PACKAGE: 1
2 changes: 1 addition & 1 deletion STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
| $${\color{lightblue}RedfishPkg/}$$ |
| RedfishPkg.dsc | IA32 X64 ARM AARCH64 RISCV64 | DEBUG RELEASE NOOPT |||
| $${\color{lightblue}SecurityPkg/}$$ |
| SecurityPkg.dsc | IA32 X64 EBC ARM AARCH64 RISCV64 LOONGARCH64 | DEBUG RELEASE NOOPT | ||
| SecurityPkg.dsc | IA32 X64 EBC ARM AARCH64 RISCV64 LOONGARCH64 | DEBUG RELEASE NOOPT | GCC CLANGDWARF CLANGPDB VS2019 XCODE5 ||
| Test/SecurityPkgHostTest.dsc | IA32 X64 | NOOPT |||
| $${\color{lightblue}ShellPkg/}$$ |
| ShellPkg.dsc | IA32 X64 EBC ARM AARCH64 RISCV64 LOONGARCH64 | DEBUG RELEASE NOOPT |||
Expand Down
5 changes: 5 additions & 0 deletions SecurityPkg/DeviceSecurity/SpdmLib/SpdmCryptLib.inf
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,8 @@
BaseCryptLib
RngLib
MemLibWrapper

[BuildOptions]
CLANGPDB:*_*_*_CC_FLAGS = -Wno-non-literal-null-conversion
GCC:*_*_*_CC_FLAGS = -Wno-non-literal-null-conversion
XCODE:*_*_*_CC_FLAGS = -Wno-non-literal-null-conversion
12 changes: 6 additions & 6 deletions SecurityPkg/DeviceSecurity/SpdmSecurityLib/SpdmAuthentication.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ ExtendCertificate (

EventLog = NULL;
ZeroMem (&Parameter, sizeof (Parameter));
Parameter.location = SpdmDataLocationConnection;
Parameter.location = (libspdm_data_location_t)SpdmDataLocationConnection;
DataSize = sizeof (BaseHashAlgo);
Status = SpdmGetData (SpdmContext, SpdmDataBaseHashAlgo, &Parameter, &BaseHashAlgo, &DataSize);
Status = SpdmGetData (SpdmContext, (libspdm_data_type_t)SpdmDataBaseHashAlgo, &Parameter, &BaseHashAlgo, &DataSize);
ASSERT_EFI_ERROR (Status);

DeviceContextSize = GetDeviceMeasurementContextSize (SpdmDeviceContext);
Expand Down Expand Up @@ -520,9 +520,9 @@ DoDeviceCertificate (
SpdmContext = SpdmDeviceContext->SpdmContext;

ZeroMem (&Parameter, sizeof (Parameter));
Parameter.location = SpdmDataLocationConnection;
Parameter.location = (libspdm_data_location_t)SpdmDataLocationConnection;
DataSize = sizeof (CapabilityFlags);
SpdmReturn = SpdmGetData (SpdmContext, SpdmDataCapabilityFlags, &Parameter, &CapabilityFlags, &DataSize);
SpdmReturn = SpdmGetData (SpdmContext, (libspdm_data_type_t)SpdmDataCapabilityFlags, &Parameter, &CapabilityFlags, &DataSize);
if (LIBSPDM_STATUS_IS_ERROR (SpdmReturn)) {
SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_DEVICE_ERROR;
return EFI_DEVICE_ERROR;
Expand Down Expand Up @@ -641,9 +641,9 @@ DoDeviceAuthentication (
SpdmContext = SpdmDeviceContext->SpdmContext;

ZeroMem (&Parameter, sizeof (Parameter));
Parameter.location = SpdmDataLocationConnection;
Parameter.location = (libspdm_data_location_t)SpdmDataLocationConnection;
DataSize = sizeof (CapabilityFlags);
SpdmReturn = SpdmGetData (SpdmContext, SpdmDataCapabilityFlags, &Parameter, &CapabilityFlags, &DataSize);
SpdmReturn = SpdmGetData (SpdmContext, (libspdm_data_type_t)SpdmDataCapabilityFlags, &Parameter, &CapabilityFlags, &DataSize);
if (LIBSPDM_STATUS_IS_ERROR (SpdmReturn)) {
SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_DEVICE_ERROR;
return EFI_DEVICE_ERROR;
Expand Down
20 changes: 10 additions & 10 deletions SecurityPkg/DeviceSecurity/SpdmSecurityLib/SpdmConnectionInit.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ CreateSpdmDeviceContext (
DataSize = DbList->SignatureSize - sizeof (EFI_GUID);

ZeroMem (&Parameter, sizeof (Parameter));
Parameter.location = SpdmDataLocationLocal;
SpdmReturn = SpdmSetData (SpdmContext, SpdmDataPeerPublicRootCert, &Parameter, Data, DataSize);
Parameter.location = (libspdm_data_location_t)SpdmDataLocationLocal;
SpdmReturn = SpdmSetData (SpdmContext, (libspdm_data_type_t)SpdmDataPeerPublicRootCert, &Parameter, Data, DataSize);
if (LIBSPDM_STATUS_IS_ERROR (SpdmReturn)) {
if (SpdmReturn == LIBSPDM_STATUS_BUFFER_FULL) {
Status = RecordConnectionFailureStatus (
Expand All @@ -366,22 +366,22 @@ CreateSpdmDeviceContext (

Data8 = 0;
ZeroMem (&Parameter, sizeof (Parameter));
Parameter.location = SpdmDataLocationLocal;
SpdmReturn = SpdmSetData (SpdmContext, SpdmDataCapabilityCTExponent, &Parameter, &Data8, sizeof (Data8));
Parameter.location = (libspdm_data_location_t)SpdmDataLocationLocal;
SpdmReturn = SpdmSetData (SpdmContext, (libspdm_data_type_t)SpdmDataCapabilityCTExponent, &Parameter, &Data8, sizeof (Data8));
if (LIBSPDM_STATUS_IS_ERROR (SpdmReturn)) {
ASSERT (FALSE);
goto Error;
}

Data32 = 0;
SpdmReturn = SpdmSetData (SpdmContext, SpdmDataCapabilityFlags, &Parameter, &Data32, sizeof (Data32));
SpdmReturn = SpdmSetData (SpdmContext, (libspdm_data_type_t)SpdmDataCapabilityFlags, &Parameter, &Data32, sizeof (Data32));
if (LIBSPDM_STATUS_IS_ERROR (SpdmReturn)) {
ASSERT (FALSE);
goto Error;
}

Data8 = SPDM_MEASUREMENT_SPECIFICATION_DMTF;
SpdmReturn = SpdmSetData (SpdmContext, SpdmDataMeasurementSpec, &Parameter, &Data8, sizeof (Data8));
SpdmReturn = SpdmSetData (SpdmContext, (libspdm_data_type_t)SpdmDataMeasurementSpec, &Parameter, &Data8, sizeof (Data8));
if (LIBSPDM_STATUS_IS_ERROR (SpdmReturn)) {
ASSERT (FALSE);
goto Error;
Expand All @@ -398,7 +398,7 @@ CreateSpdmDeviceContext (
SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P521;
}

SpdmReturn = SpdmSetData (SpdmContext, SpdmDataBaseAsymAlgo, &Parameter, &Data32, sizeof (Data32));
SpdmReturn = SpdmSetData (SpdmContext, (libspdm_data_type_t)SpdmDataBaseAsymAlgo, &Parameter, &Data32, sizeof (Data32));
if (LIBSPDM_STATUS_IS_ERROR (SpdmReturn)) {
ASSERT (FALSE);
goto Error;
Expand All @@ -412,7 +412,7 @@ CreateSpdmDeviceContext (
SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_512;
}

SpdmReturn = SpdmSetData (SpdmContext, SpdmDataBaseHashAlgo, &Parameter, &Data32, sizeof (Data32));
SpdmReturn = SpdmSetData (SpdmContext, (libspdm_data_type_t)SpdmDataBaseHashAlgo, &Parameter, &Data32, sizeof (Data32));
if (LIBSPDM_STATUS_IS_ERROR (SpdmReturn)) {
ASSERT (FALSE);
goto Error;
Expand All @@ -433,9 +433,9 @@ CreateSpdmDeviceContext (
}

ZeroMem (&Parameter, sizeof (Parameter));
Parameter.location = SpdmDataLocationConnection;
Parameter.location = (libspdm_data_location_t)SpdmDataLocationConnection;
DataSize = sizeof (Data16);
SpdmReturn = SpdmGetData (SpdmContext, SpdmDataSpdmVersion, &Parameter, &Data16, &DataSize);
SpdmReturn = SpdmGetData (SpdmContext, (libspdm_data_type_t)SpdmDataSpdmVersion, &Parameter, &Data16, &DataSize);
if (LIBSPDM_STATUS_IS_ERROR (SpdmReturn)) {
DEBUG ((DEBUG_ERROR, "SpdmGetData - %p\n", SpdmReturn));
goto Error;
Expand Down
8 changes: 4 additions & 4 deletions SecurityPkg/DeviceSecurity/SpdmSecurityLib/SpdmMeasurement.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ ExtendMeasurement (

EventLog = NULL;
ZeroMem (&Parameter, sizeof (Parameter));
Parameter.location = SpdmDataLocationConnection;
Parameter.location = (libspdm_data_location_t)SpdmDataLocationConnection;
DataSize = sizeof (MeasurementHashAlgo);
Status = SpdmGetData (SpdmContext, SpdmDataMeasurementHashAlgo, &Parameter, &MeasurementHashAlgo, &DataSize);
Status = SpdmGetData (SpdmContext, (libspdm_data_type_t)SpdmDataMeasurementHashAlgo, &Parameter, &MeasurementHashAlgo, &DataSize);
ASSERT_EFI_ERROR (Status);

if (MeasurementRecord != NULL) {
Expand Down Expand Up @@ -531,9 +531,9 @@ DoDeviceMeasurement (
SpdmContext = SpdmDeviceContext->SpdmContext;

ZeroMem (&Parameter, sizeof (Parameter));
Parameter.location = SpdmDataLocationConnection;
Parameter.location = (libspdm_data_location_t)SpdmDataLocationConnection;
DataSize = sizeof (CapabilityFlags);
SpdmGetData (SpdmContext, SpdmDataCapabilityFlags, &Parameter, &CapabilityFlags, &DataSize);
SpdmGetData (SpdmContext, (libspdm_data_type_t)SpdmDataCapabilityFlags, &Parameter, &CapabilityFlags, &DataSize);

if ((CapabilityFlags & SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP_SIG) == 0) {
AuthState = TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_FAIL_NO_SIG;
Expand Down
37 changes: 19 additions & 18 deletions SecurityPkg/Library/HashLibTpm2/HashLibTpm2.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ Tpm2GetAlgoFromHashMask (
@retval EFI_SUCCESS Hash sequence start and HandleHandle returned.
@retval EFI_OUT_OF_RESOURCES No enough resource to start hash.
**/
BOOLEAN
EFI_STATUS
EFIAPI
HashStart (
OUT VOID **HashHandle
OUT HASH_HANDLE *HashHandle
)
{
TPMI_DH_OBJECT SequenceHandle;
Expand All @@ -72,12 +72,13 @@ HashStart (
AlgoId = Tpm2GetAlgoFromHashMask ();

Status = Tpm2HashSequenceStart (AlgoId, &SequenceHandle);
if (!EFI_ERROR (Status)) {
*HashHandle = (VOID *)(UINTN)SequenceHandle;
return TRUE;
if (EFI_ERROR (Status)) {
return Status;
}

return FALSE;
*HashHandle = (HASH_HANDLE)SequenceHandle;

return EFI_SUCCESS;
}

/**
Expand All @@ -89,11 +90,11 @@ HashStart (
@retval EFI_SUCCESS Hash sequence updated.
**/
BOOLEAN
EFI_STATUS
EFIAPI
HashUpdate (
IN VOID *HashHandle,
IN CONST VOID *DataToHash,
IN HASH_HANDLE HashHandle,
IN VOID *DataToHash,
IN UINTN DataToHashLen
)
{
Expand All @@ -108,9 +109,9 @@ HashUpdate (
CopyMem (HashBuffer.buffer, Buffer, sizeof (HashBuffer.buffer));
Buffer += sizeof (HashBuffer.buffer);

Status = Tpm2SequenceUpdate ((TPMI_DH_OBJECT)(UINTN)HashHandle, &HashBuffer);
Status = Tpm2SequenceUpdate ((TPMI_DH_OBJECT)HashHandle, &HashBuffer);
if (EFI_ERROR (Status)) {
return FALSE;
return Status;
}
}

Expand All @@ -119,12 +120,12 @@ HashUpdate (
//
HashBuffer.size = (UINT16)HashLen;
CopyMem (HashBuffer.buffer, Buffer, (UINTN)HashLen);
Status = Tpm2SequenceUpdate ((TPMI_DH_OBJECT)(UINTN)HashHandle, &HashBuffer);
Status = Tpm2SequenceUpdate ((TPMI_DH_OBJECT)HashHandle, &HashBuffer);
if (EFI_ERROR (Status)) {
return FALSE;
return Status;
}

return TRUE;
return EFI_SUCCESS;
}

/**
Expand All @@ -141,7 +142,7 @@ HashUpdate (
EFI_STATUS
EFIAPI
HashCompleteAndExtend (
IN VOID *HashHandle,
IN HASH_HANDLE HashHandle,
IN TPMI_DH_PCR PcrIndex,
IN VOID *DataToHash,
IN UINTN DataToHashLen,
Expand All @@ -163,7 +164,7 @@ HashCompleteAndExtend (
CopyMem (HashBuffer.buffer, Buffer, sizeof (HashBuffer.buffer));
Buffer += sizeof (HashBuffer.buffer);

Status = Tpm2SequenceUpdate ((TPMI_DH_OBJECT)(UINTN)HashHandle, &HashBuffer);
Status = Tpm2SequenceUpdate ((TPMI_DH_OBJECT)HashHandle, &HashBuffer);
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
Expand All @@ -181,13 +182,13 @@ HashCompleteAndExtend (
if (AlgoId == TPM_ALG_NULL) {
Status = Tpm2EventSequenceComplete (
PcrIndex,
(TPMI_DH_OBJECT)(UINTN)HashHandle,
(TPMI_DH_OBJECT)HashHandle,
&HashBuffer,
DigestList
);
} else {
Status = Tpm2SequenceComplete (
(TPMI_DH_OBJECT)(UINTN)HashHandle,
(TPMI_DH_OBJECT)HashHandle,
&HashBuffer,
&Result
);
Expand Down

0 comments on commit 75247e4

Please sign in to comment.