diff --git a/CHANGELOG.md b/CHANGELOG.md index 9536613..28946c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## [4.3.0] + +### Fixed + - Windows: process access denied on open + - UEFI: Add driver logic for fixed clients + +### Added + - Windows: add resource + - cmake: add 32 bit release preset + - add getters for maxMsgLen and prtocolVer + ## [4.2.1] ### Fixed diff --git a/CMakeLists.txt b/CMakeLists.txt index ebd5380..714478a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,15 +15,15 @@ option(CONSOLE_OUTPUT "Push debug and error output to console (instead of syslog include(GNUInstallDirs) +set(LICENSE Apache) +include(version.cmake) + if(WIN32) include(win32.cmake) else(WIN32) include(linux.cmake) endif(WIN32) -set(LICENSE Apache) -include(version.cmake) - set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER include/metee.h) set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${TEE_VERSION_STRING}) set_target_properties( diff --git a/CMakePresets.json b/CMakePresets.json index b243ce1..52d0a1a 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -68,6 +68,16 @@ "BUILD_SHARED_LIBS": "NO" } }, + { + "name": "Release32", + "displayName": "Windows x86 Release", + "description": "Build x86 Release, VS2019", + "inherits": "base32", + "binaryDir": "${sourceDir}/Release", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, { "name": "Release64", "displayName": "Windows x86-64 Release", @@ -107,6 +117,11 @@ "configurePreset": "Release32Static", "configuration": "Release" }, + { + "name": "Release32", + "configurePreset": "Release32", + "configuration": "Release" + }, { "name": "Release64", "configurePreset": "Release64", diff --git a/VERSION b/VERSION index fae6e3d..8089590 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.2.1 +4.3.0 diff --git a/include/metee.h b/include/metee.h index d8243e1..43bea22 100644 --- a/include/metee.h +++ b/include/metee.h @@ -331,6 +331,22 @@ uint32_t TEEAPI TeeGetLogLevel(IN const PTEEHANDLE handle); */ TEESTATUS TEEAPI TeeSetLogCallback(IN const PTEEHANDLE handle, TeeLogCallback log_callback); +/*! Retrieve client maximum message length (MTU) + * + * \param handle The handle of the session. + * \return client maximum message length. + * If client never connected, will return zero. + */ +uint32_t TEEAPI TeeGetMaxMsgLen(IN const PTEEHANDLE handle); + +/*! Retrieve client protocol version + * + * \param handle The handle of the session. + * \return client protocol version. + * If client never connected, will return zero. + */ +uint8_t TEEAPI TeeGetProtocolVer(IN const PTEEHANDLE handle); + #ifdef __cplusplus } #endif diff --git a/samples/metee_basic.c b/samples/metee_basic.c index 2a4b091..358051e 100644 --- a/samples/metee_basic.c +++ b/samples/metee_basic.c @@ -96,6 +96,12 @@ int main(int argc, char* argv[]) goto out; } + if (TeeGetMaxMsgLen(&handle) == 0) + { + fprintf(stderr, "Client reported zero MTU. Aborting.\n"); + goto out; + } + /* Write */ req.header.data = 0; /* Reset */ req.header.GroupId = 0xFF; /* MKHI */ @@ -115,14 +121,14 @@ int main(int argc, char* argv[]) } /* Read */ - read_buf = (uint8_t*)malloc(handle.maxMsgLen); + read_buf = (uint8_t*)malloc(TeeGetMaxMsgLen(&handle)); if (!read_buf) { fprintf(stderr, "malloc failed\n"); status = TEE_INTERNAL_ERROR; goto out; } - status = TeeRead(&handle, read_buf, handle.maxMsgLen, &written, MKHI_TIMEOUT); + status = TeeRead(&handle, read_buf, TeeGetMaxMsgLen(&handle), &written, MKHI_TIMEOUT); if (!TEE_IS_SUCCESS(status)) { fprintf(stderr, "TeeWrite failed with status = %u\n", status); goto out; diff --git a/samples/metee_connect.c b/samples/metee_connect.c index f9b3eac..6a1c72f 100644 --- a/samples/metee_connect.c +++ b/samples/metee_connect.c @@ -41,7 +41,12 @@ static int work(struct params *p) if (status != TEE_SUCCESS) goto out; - rsz = cl.maxMsgLen; + rsz = TeeGetMaxMsgLen(&cl); + if (rsz == 0) + { + fprintf(stderr, "client reproted zero MTU.\n"); + goto out; + } buf = (unsigned char *)malloc(rsz); if (buf == NULL) goto out; diff --git a/samples/metee_gsc.c b/samples/metee_gsc.c index 84964bd..2dfaa4b 100644 --- a/samples/metee_gsc.c +++ b/samples/metee_gsc.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* - * Copyright (C) 2020-2023 Intel Corporation + * Copyright (C) 2020-2024 Intel Corporation */ #include #include @@ -158,7 +158,13 @@ static uint32_t mk_host_if_call(struct mk_host_if *acmd, struct gsc_fwu_heci_response *msg_hdr; int count = 0; - in_buf_sz = (unsigned int)acmd->mei_cl.maxMsgLen; + in_buf_sz = TeeGetMaxMsgLen(&acmd->mei_cl); + if (in_buf_sz == 0) + { + if (acmd->verbose) + fprintf(stderr, "mkhif: client reproted zero MTU.\n"); + return GSC_FWU_STATUS_FAILURE; + } *read_buf = (uint8_t *)malloc(in_buf_sz); if (*read_buf == NULL) return GSC_FWU_STATUS_FAILURE; diff --git a/samples/metee_mkhi.c b/samples/metee_mkhi.c index 586a515..dd15a16 100644 --- a/samples/metee_mkhi.c +++ b/samples/metee_mkhi.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* - * Copyright (C) 2012-2023 Intel Corporation + * Copyright (C) 2012-2024 Intel Corporation */ #include #include @@ -235,7 +235,13 @@ static uint32_t mk_host_if_call(struct mk_host_if *acmd, struct mk_host_if_msg *msg_hdr; int count = 0; - in_buf_sz = (unsigned int)acmd->mei_cl.maxMsgLen; + in_buf_sz = TeeGetMaxMsgLen(&acmd->mei_cl); + if (in_buf_sz == 0) + { + if (acmd->verbose) + fprintf(stderr, "mkhif: client reproted zero MTU.\n"); + return MKHI_STATUS_INTERNAL_ERROR; + } *read_buf = (uint8_t *)malloc(in_buf_sz); if (*read_buf == NULL) return MKHI_STATUS_SDK_RESOURCES; diff --git a/src/Windows/metee.rc.in b/src/Windows/metee.rc.in new file mode 100644 index 0000000..630ca5d --- /dev/null +++ b/src/Windows/metee.rc.in @@ -0,0 +1,102 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* + * Copyright (C) 2024 Intel Corporation + */ +// Microsoft Visual C++ generated resource script. +// + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @TEE_VERSION_COMM@ + PRODUCTVERSION @TEE_VERSION_COMM@ + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "Intel Corporation" + VALUE "FileDescription", "Intel(R) CSME/GSC HECI Interface Library" + VALUE "FileVersion", "@TEE_VERSION_STRING@" + VALUE "InternalName", "MeTee" + VALUE "LegalCopyright", "Copyright (c) 2014-2024, Intel Corporation." + VALUE "OriginalFilename", "metee.dll" + VALUE "ProductName", "Intel(R) CSME/GSC HECI Interface Library" + VALUE "ProductVersion", "@TEE_VERSION_STRING@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/src/Windows/metee_win.c b/src/Windows/metee_win.c index 75d74fd..90324f4 100644 --- a/src/Windows/metee_win.c +++ b/src/Windows/metee_win.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* - * Copyright (C) 2014-2023 Intel Corporation + * Copyright (C) 2014-2024 Intel Corporation */ #include #include @@ -27,10 +27,19 @@ static TEESTATUS __CreateFile(PTEEHANDLE handle, const char *devicePath, PHANDLE if (*deviceHandle == INVALID_HANDLE_VALUE) { DWORD err = GetLastError(); ERRPRINT(handle, "Error in CreateFile, error: %lu\n", err); - if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND) + switch (err) + { + case ERROR_FILE_NOT_FOUND: + case ERROR_PATH_NOT_FOUND: status = TEE_DEVICE_NOT_FOUND; - else + break; + case ERROR_ACCESS_DENIED: + status = TEE_PERMISSION_DENIED; + break; + default: status = TEE_DEVICE_NOT_READY; + break; + } } else { status = TEE_SUCCESS; @@ -667,3 +676,19 @@ TEESTATUS TEEAPI TeeSetLogCallback(IN const PTEEHANDLE handle, TeeLogCallback lo FUNC_EXIT(handle, status); return status; } + +uint32_t TEEAPI TeeGetMaxMsgLen(IN const PTEEHANDLE handle) +{ + if (NULL == handle) { + return 0; + } + return (uint32_t)handle->maxMsgLen; +} + +uint8_t TEEAPI TeeGetProtocolVer(IN const PTEEHANDLE handle) +{ + if (NULL == handle) { + return 0; + } + return handle->protcolVer; +} diff --git a/src/linux/metee_linux.c b/src/linux/metee_linux.c index 7a78793..6ef4a44 100644 --- a/src/linux/metee_linux.c +++ b/src/linux/metee_linux.c @@ -579,3 +579,19 @@ TEESTATUS TEEAPI TeeSetLogCallback(IN const PTEEHANDLE handle, TeeLogCallback lo FUNC_EXIT(handle, status); return status; } + +uint32_t TEEAPI TeeGetMaxMsgLen(IN const PTEEHANDLE handle) +{ + if (!handle) { + return 0; + } + return (uint32_t)handle->maxMsgLen; +} + +uint8_t TEEAPI TeeGetProtocolVer(IN const PTEEHANDLE handle) +{ + if (!handle) { + return 0; + } + return handle->protcolVer; +} \ No newline at end of file diff --git a/src/uefi/heci_efi.c b/src/uefi/heci_efi.c index 3b15fd9..1df445a 100644 --- a/src/uefi/heci_efi.c +++ b/src/uefi/heci_efi.c @@ -285,6 +285,13 @@ HeciUninitialize( DBGPRINT(Handle->TeeHandle, "####Heci Uninitialize ####\n"); + lib = GetHeciLibrary(&Handle->Hw.Bdf); + if (lib != NULL) + { + DBGPRINT(Handle->TeeHandle, "Release Host Client Id: %d\n", client->HostClientId); + lib->State.HostClientIds[client->HostClientId] = 0; + } + if (client->properties.FixedAddress != 0) { DBGPRINT(Handle->TeeHandle, "######CONNECTION CLOSED SUCCESSFULLY######: Fixed client\n"); @@ -299,13 +306,6 @@ HeciUninitialize( disconnectMsg.MEAddress = client->properties.Address; disconnectMsg.HostAddress = client->HostClientId; - lib = GetHeciLibrary(&Handle->Hw.Bdf); - if (lib != NULL) - { - DBGPRINT(Handle->TeeHandle, "Release Host Client Id: %d\n", client->HostClientId); - lib->State.HostClientIds[client->HostClientId] = 0; - } - DBGPRINT(Handle->TeeHandle, "####Prior to Heci-SendMsg: Command: %02X, Host Client Id: %d, FW Client Id: %d\n", disconnectMsg.Command, disconnectMsg.HostAddress, disconnectMsg.MEAddress); status = heciSendMsg(Handle, (UINT32 *)&disconnectMsg, (UINT32)sizeof(disconnectMsg), (UINT8)BIOS_FIXED_HOST_ADDR, (UINT8)HECI_HBM_MSG_ADDR); @@ -443,6 +443,8 @@ HeciDeviceEnumerateClients( HBM_CLIENT_PROP_MSG propMsg; HBM_CLIENT_PROP_MSG_REPLY propMsgReply; UINT32 msgReplyLen = 0; + + FUNC_ENTRY(Handle->TeeHandle); if (HeciLib->State.IsValid) { @@ -644,17 +646,6 @@ HeciConnectClient( goto End; } - if (lib->State.Clients[ind].ClientProperties.FixedAddress != 0) - { - client->properties = lib->State.Clients[ind].ClientProperties; - client->properties.Address = lib->State.Clients[ind].ClientProperties.FixedAddress; - //client->properties.IsFixed = 1; - client->connected = TRUE; - DBGPRINT(Handle->TeeHandle, "######CONNECTION SETUP SUCCESSFULLY######\n"); - status = EFI_SUCCESS; - goto End; - } - /* find first available Host Client Id */ for (host_client_id=1; host_client_idState.Clients[ind].ClientProperties.FixedAddress != 0) + { + DBGPRINT(Handle->TeeHandle, "######Fixed client######\n"); + client->properties.Address = lib->State.Clients[ind].ClientProperties.FixedAddress; + status = EFI_SUCCESS; + goto Connected; + } + /* Now try to connect to the heci interface. */ SetMem(&connectMsg, sizeof(connectMsg), 0x0); @@ -719,6 +718,8 @@ HeciConnectClient( { goto End; } + +Connected: lib->State.HostClientIds[host_client_id] = 1; client->properties = lib->State.Clients[ind].ClientProperties; client->connected = TRUE; diff --git a/src/uefi/metee_efi.c b/src/uefi/metee_efi.c index cc04884..d23b0b8 100644 --- a/src/uefi/metee_efi.c +++ b/src/uefi/metee_efi.c @@ -693,4 +693,22 @@ TEESTATUS TEEAPI TeeSetLogCallback(IN const PTEEHANDLE handle, TeeLogCallback lo Cleanup: FUNC_EXIT(handle, status); return status; +} + +uint32_t TEEAPI TeeGetMaxMsgLen(IN const PTEEHANDLE handle) +{ + if (NULL == handle) + { + return 0; + } + return (uint32_t)handle->maxMsgLen; +} + +uint8_t TEEAPI TeeGetProtocolVer(IN const PTEEHANDLE handle) +{ + if (NULL == handle) + { + return 0; + } + return handle->protcolVer; } \ No newline at end of file diff --git a/tests/metee_test.cpp b/tests/metee_test.cpp index 9074d8a..39a2910 100644 --- a/tests/metee_test.cpp +++ b/tests/metee_test.cpp @@ -125,11 +125,11 @@ TEST_P(MeTeeDataNTEST, PROD_MKHI_SimpleGetVersion) std::vector MaxResponse; GEN_GET_FW_VERSION_ACK* pResponseMessage; //max length for this client is 2048 - MaxResponse.resize(_handle.maxMsgLen*sizeof(char)); + MaxResponse.resize(TeeGetMaxMsgLen(&_handle) * sizeof(char)); ASSERT_EQ(SUCCESS, TeeWrite(&_handle, &MkhiRequest, sizeof(GEN_GET_FW_VERSION), &NumberOfBytes, 0)); ASSERT_EQ(sizeof(GEN_GET_FW_VERSION), NumberOfBytes); - ASSERT_EQ(SUCCESS, TeeRead(&_handle, &MaxResponse[0], _handle.maxMsgLen, &NumberOfBytes, 0)); + ASSERT_EQ(SUCCESS, TeeRead(&_handle, &MaxResponse[0], TeeGetMaxMsgLen(&_handle), &NumberOfBytes, 0)); pResponseMessage = (GEN_GET_FW_VERSION_ACK*)(&MaxResponse[0]); ASSERT_EQ(SUCCESS, pResponseMessage->Header.Fields.Result); @@ -137,6 +137,16 @@ TEST_P(MeTeeDataNTEST, PROD_MKHI_SimpleGetVersion) EXPECT_NE(0, pResponseMessage->Data.FWVersion.CodeBuildNo); } +TEST_P(MeTeeDataNTEST, PROD_MKHI_GetMaxMsgLen) +{ + ASSERT_NE(0, TeeGetMaxMsgLen(&_handle)); +} + +TEST_P(MeTeeDataNTEST, PROD_MKHI_GetProtocolVer) +{ + TeeGetProtocolVer(&_handle); +} + /* Check too big timeouts on read and write */ @@ -196,6 +206,17 @@ TEST_P(MeTeeOpenTEST, PROD_MKHI_SetLogCallback) ERRPRINT(&_handle, "NotReal"); TeeSetLogLevel(&_handle, prev_log_level); } + +TEST_P(MeTeeOpenTEST, PROD_MKHI_GetMaxMsgLen) +{ + ASSERT_EQ(0, TeeGetMaxMsgLen(&_handle)); +} + +TEST_P(MeTeeOpenTEST, PROD_MKHI_GetProtocolVer) +{ + ASSERT_EQ(0, TeeGetProtocolVer(&_handle)); +} + /* * Blocking read from side thread cancelled by disconnect from the main thread */ @@ -207,8 +228,8 @@ TEST_P(MeTeeDataNTEST, PROD_MKHI_InterruptRead) thr = std::thread([Handle]() { std::vector MaxResponse; size_t NumberOfBytes = 0; - MaxResponse.resize(Handle.maxMsgLen * sizeof(char)); - EXPECT_EQ(TEE_UNABLE_TO_COMPLETE_OPERATION, TeeRead((PTEEHANDLE) &Handle, &MaxResponse[0], Handle.maxMsgLen, &NumberOfBytes, 0)); + MaxResponse.resize(TeeGetMaxMsgLen((PTEEHANDLE) &Handle) * sizeof(char)); + EXPECT_EQ(TEE_UNABLE_TO_COMPLETE_OPERATION, TeeRead((PTEEHANDLE) &Handle, &MaxResponse[0], TeeGetMaxMsgLen((PTEEHANDLE)&Handle), &NumberOfBytes, 0)); }); thr.detach(); std::this_thread::sleep_for(std::chrono::seconds(1)); @@ -240,11 +261,11 @@ TEST_P(MeTee1000OpenTEST, PROD_MKHI_1000HandlesGetVersion) ASSERT_EQ(SUCCESS, ConnectRetry(&Handle)); - MaxResponse.resize(Handle.maxMsgLen*sizeof(char)); + MaxResponse.resize(TeeGetMaxMsgLen(&Handle) * sizeof(char)); ASSERT_EQ(SUCCESS, TeeWrite(&Handle, &MkhiRequest, sizeof(GEN_GET_FW_VERSION), &NumberOfBytes, 1000)); ASSERT_EQ(sizeof(GEN_GET_FW_VERSION), NumberOfBytes); - ASSERT_EQ(SUCCESS, TeeRead(&Handle, &MaxResponse[0], Handle.maxMsgLen, &NumberOfBytes, 1000)); + ASSERT_EQ(SUCCESS, TeeRead(&Handle, &MaxResponse[0], TeeGetMaxMsgLen(&Handle), &NumberOfBytes, 1000)); pResponseMessage = (GEN_GET_FW_VERSION_ACK*)(&MaxResponse[0]); ASSERT_EQ(SUCCESS, pResponseMessage->Header.Fields.Result); @@ -269,12 +290,12 @@ TEST_P(MeTeeDataNTEST, PROD_MKHI_SimpleGetVersionStress) std::vector MaxResponse; GEN_GET_FW_VERSION_ACK* pResponseMessage; //max length for this client is 2048 - MaxResponse.resize(_handle.maxMsgLen * sizeof(char)); + MaxResponse.resize(TeeGetMaxMsgLen(&_handle) * sizeof(char)); for (unsigned int i = 0; i < 1000; i++) { ASSERT_EQ(SUCCESS, TeeWrite(&_handle, &MkhiRequest, sizeof(GEN_GET_FW_VERSION), &NumberOfBytes, 0)); ASSERT_EQ(sizeof(GEN_GET_FW_VERSION), NumberOfBytes); - ASSERT_EQ(SUCCESS, TeeRead(&_handle, &MaxResponse[0], _handle.maxMsgLen, &NumberOfBytes, 0)); + ASSERT_EQ(SUCCESS, TeeRead(&_handle, &MaxResponse[0], TeeGetMaxMsgLen(&_handle), &NumberOfBytes, 0)); pResponseMessage = (GEN_GET_FW_VERSION_ACK*)(&MaxResponse[0]); ASSERT_EQ(SUCCESS, pResponseMessage->Header.Fields.Result); @@ -306,10 +327,10 @@ TEST_P(MeTeeDataNTEST, PROD_MKHI_SimpleGetVersionNULLReturn) std::vector MaxResponse; GEN_GET_FW_VERSION_ACK* pResponseMessage; //max length for this client is 2048 - MaxResponse.resize(_handle.maxMsgLen*sizeof(char)); + MaxResponse.resize(TeeGetMaxMsgLen(&_handle) * sizeof(char)); ASSERT_EQ(SUCCESS, TeeWrite(&_handle, &MkhiRequest, sizeof(GEN_GET_FW_VERSION), NULL, 0)); - ASSERT_EQ(SUCCESS, TeeRead(&_handle, &MaxResponse[0], _handle.maxMsgLen, NULL, 0)); + ASSERT_EQ(SUCCESS, TeeRead(&_handle, &MaxResponse[0], TeeGetMaxMsgLen(&_handle), NULL, 0)); pResponseMessage = (GEN_GET_FW_VERSION_ACK*)(&MaxResponse[0]); ASSERT_EQ(SUCCESS, pResponseMessage->Header.Fields.Result); @@ -328,9 +349,9 @@ TEST_P(MeTeeDataNTEST, PROD_MKHI_TimeoutGetVersion) size_t NumberOfBytes = 0; std::vector MaxResponse; - MaxResponse.resize(_handle.maxMsgLen*sizeof(char)); + MaxResponse.resize(TeeGetMaxMsgLen(&_handle) * sizeof(char)); - EXPECT_EQ(TEE_TIMEOUT, TeeRead(&_handle, &MaxResponse[0], _handle.maxMsgLen, &NumberOfBytes, 1000)); + EXPECT_EQ(TEE_TIMEOUT, TeeRead(&_handle, &MaxResponse[0], TeeGetMaxMsgLen(&_handle), &NumberOfBytes, 1000)); } /* @@ -510,7 +531,7 @@ TEST_P(MeTeeDataNTEST, PROD_N_TestFWUZeroBufferSizeWrite) TEST_P(MeTeeDataNTEST, PROD_N_TestFWUBiggerThenMtuWrite) { size_t numOfBytes = 0; - std::vector buf(_handle.maxMsgLen + 10); + std::vector buf(TeeGetMaxMsgLen(&_handle) + 10); ASSERT_EQ(TEE_INTERNAL_ERROR, TeeWrite(&_handle, &buf[0], buf.size(), &numOfBytes, 0)); } @@ -547,11 +568,11 @@ TEST_P(MeTeeFDTEST, PROD_MKHI_SimpleGetVersion) ASSERT_EQ(SUCCESS, ConnectRetry(&Handle)); - MaxResponse.resize(Handle.maxMsgLen*sizeof(char)); + MaxResponse.resize(TeeGetMaxMsgLen(&Handle) * sizeof(char)); ASSERT_EQ(SUCCESS, TeeWrite(&Handle, &MkhiRequest, sizeof(GEN_GET_FW_VERSION), &NumberOfBytes, 0)); ASSERT_EQ(sizeof(GEN_GET_FW_VERSION), NumberOfBytes); - ASSERT_EQ(SUCCESS, TeeRead(&Handle, &MaxResponse[0], Handle.maxMsgLen, &NumberOfBytes, 0)); + ASSERT_EQ(SUCCESS, TeeRead(&Handle, &MaxResponse[0], TeeGetMaxMsgLen(&Handle), &NumberOfBytes, 0)); pResponseMessage = (GEN_GET_FW_VERSION_ACK*)(&MaxResponse[0]); ASSERT_EQ(SUCCESS, pResponseMessage->Header.Fields.Result); diff --git a/version.cmake b/version.cmake index 5932197..f03d8ba 100644 --- a/version.cmake +++ b/version.cmake @@ -1,5 +1,5 @@ # SPDX-License-Identifier: Apache-2.0 -# Copyright (C) 2014-2019 Intel Corporation +# Copyright (C) 2014-2024 Intel Corporation file(READ VERSION VER_FILE) string(STRIP "${VER_FILE}" VER_FILE) @@ -9,3 +9,5 @@ list(GET VER_LIST 1 TEE_VERSION_MINOR) list(GET VER_LIST 2 TEE_VERSION_PATCH) set(TEE_VERSION_STRING ${TEE_VERSION_MAJOR}.${TEE_VERSION_MINOR}.${TEE_VERSION_PATCH}) +set(TEE_VERSION_COMM + ${TEE_VERSION_MAJOR},${TEE_VERSION_MINOR},${TEE_VERSION_PATCH},0) \ No newline at end of file diff --git a/win32.cmake b/win32.cmake index 4bd24df..598aebe 100644 --- a/win32.cmake +++ b/win32.cmake @@ -8,6 +8,7 @@ endif() set(TEE_SOURCES src/Windows/metee_win.c src/Windows/metee_winhelpers.c + ${PROJECT_BINARY_DIR}/metee.rc ) add_library(${PROJECT_NAME} ${TEE_SOURCES}) @@ -22,6 +23,11 @@ if(NOT CONSOLE_OUTPUT) target_compile_definitions(${PROJECT_NAME} PRIVATE -DSYSLOG) endif() +configure_file ( + "${PROJECT_SOURCE_DIR}/src/Windows/metee.rc.in" + "${PROJECT_BINARY_DIR}/metee.rc" +) + # Secure compile flags target_compile_options(${PROJECT_NAME} PRIVATE /GS /sdl)