aboutsummaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
2019-03-18deheader: remove double #include’d headersДилян Палаузов
and fix unbalanced #ifdef .. #endif Found by http://www.catb.org/~esr/deheader/ . Signed-Off-By: Дилян Палаузов <git-dpa@aegee.org>
2019-03-15Tests: esys+sys encrypt / decrypt session flags propagationAndreas Fuchs
Adding a test for command decrypt and response encrypt session flags that are set in Esys are actually propagated to the TPM command's session flags, if the command allows this. Using TPM2_CreatePrimary as a candidate. Signed-off-by: Andreas Fuchs <andreas.fuchs@sit.fraunhofer.de>
2019-03-14test: Test marshaling TPM2B_PUBLIC RSA key with optional unique dataBryon Nevis
Signed-off-by: Bryon Nevis <bryon.nevis@intel.com>
2019-03-07test: Restore output of Check* macros in tpmclient.Philip Tricca
Using strlen on an uninitialized character array means the old behavior of this macro is undefined. "Most compilers" initialize this memory to '\0' however and the behavior is as if the ErrorHandler function were passed a character array with length 0. This causes the ErrorHandler to write no data to the array and no output to be displayed. The array size is constant and this patch moves its definition to a macro. Signed-off-by: Philip Tricca <philip.b.tricca@intel.com>
2019-03-05test: Remove use of 'sysapi_util.h' from integration tests.Philip Tricca
These tests don't test any of the code from the sysapi_util module. The only use was to get the size of a structure defined there but this is exposed through the tss2-sys API directly. Inclusion of this header is largely an artifact of this code having been liberated from the legacy `tpmclient` test. Signed-off-by: Philip Tricca <philip.b.tricca@intel.com>
2019-03-01test: fix string to 'char *' conversionTadeusz Struk
Fix warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings] In test/fuzz/main-sapi.cpp:37 .socket_address = HOSTNAME_DEFAULT, Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
2019-02-28Tests: Fix valgrind errorsAndreas Fuchs
Fix memcheckd error on reading unitialized memory during make check-valgrind. Signed-off-by: Andreas Fuchs <andreas.fuchs@sit.fraunhofer.de>
2019-02-27test: fuzz: Generate libfuzzer and OSS Fuzz testsJohn Andersen
* Added python script gen_fuzz.py which reads include/tss2/tss2_sys.h and generates a fuzz target for all _Prepare and _Complete calls. It also generates Makefile-fuzz-generated.am for building each fuzz test. * Modified Makefile-fuzz.am to include Makefile-fuzz-generated.am * Added test/fuzz/main-sapi.cpp which defines a libfuzzer target used to fuzz SAPI calls. Signed-off-by: John Andersen <john.s.andersen@intel.com>
2019-02-27test: fuzz: Added fuzzing TCTIJohn Andersen
* Created a test/fuzz/tcti/ directory which contains a TCTI to be used for fuzz testing. * Added ifdefs to sapi helpers and test-options in integration tests to enable static linking to a single TCTI. * Added configure.ac options to build fuzzing TCTI. * Added Makefile-fuzz.am used to build fuzzing TCTI. Signed-off-by: John Andersen <john.s.andersen@intel.com>
2019-02-25test: add tests that covers auto unset session enc/dec flagsTadeusz Struk
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
2019-02-20test: cleanup hmac and hash contextsPeter Huewe
If we do not clean up the 'invalid' contexts valgrind complains about memory leaks - also tests often serve as reference code. Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
2019-02-19Add missing free on handles returned by Esys_GetPollHandlesPeter Huewe
Esys_GetPollHandles returns callee-allocated handles in *handles which must be freed on exit. Even if this is only in a test case, we should free it as someone might use it as a reference code. Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
2019-02-19test: update tpmclient test Tss2_Sys_GetEncryptParam for bad sequenceTadeusz Struk
Update tpmclient test Tss2_Sys_GetEncryptParam for bad sequence case After the order of checks in Tss2_Sys_GetEncryptParam was changed. Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
2019-02-12test: esys: free tcti_innerTadeusz Struk
Don't leak tcti_innner pointer. Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
2019-01-30test: esys: fix leaks found by coverity scanTadeusz Struk
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
2019-01-09ESYS: Fix passing of NULL pointers for auth values.Juergen Repp
* In some cases in ESAPI a NULL pointer was dereferenced when NULL was passed as auth value. * When a special handling for the auth value is required by ESAPI, in these cases the size of the stored auth value will be set to zero. * The integration tests are modified to cover these cases. Signed-off-by: Juergen Repp <Juergen.Repp@sit.fraunhofer.de>
2019-01-08test: esys: Add test for Esys_TR_SetAuth with NULL authTadeusz Struk
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
2019-01-07test: remove a work around for clang static analysis warningTadeusz Struk
The issue is fixed in 2.1.0 version of uthash. Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
2018-12-14tests: fix scan-build warnings with Clang 7.0.0Jonas Witschel
- Fix "uninitialized value" warning for sessionAttributes in esys-create-session-auth.int.c. - Supress "division by zero" warnings for HASH_ADD_INT in uthash.h, reported upstream as https://github.com/troydhanson/uthash/issues/166. Signed-off-by: Jonas Witschel <diabonas@gmx.de>
2018-12-13MU: Fix marshaling of TPM2Bs with sub types.Juergen Repp
* The offset was not computed correctly if a NULL buffer was passed. The TSS MU spec states: If the 'buffer' parameter is NULL the implementation shall not write any marshaled data but the 'offset' parameter shall be updated as as though it had. * The unnecessary test of NULL buffer and not NULL offset was removed and the corresponding unit test was adapted. * Also a unit test which compares the result of NULL buffer and not NULL buffer marshaling was added. Signed-off-by: Juergen Repp <Juergen.Repp@sit.fraunhofer.de>
2018-12-13test: fix overflow warningWilliam Roberts
gcc with -Wstrict-overflow=5 produces the following error: ../test/integration/sapi-session-util.c: In function ‘gen_session_key.part.0.constprop.1’: ../test/integration/sapi-session-util.c:580:40: error: assuming signed overflow does not occur when changing X +- C1 cmp C2 to X cmp C1 +- C2 [-Werror=strict-overflow] if (iv->size > sizeof (iv->buffer) || ^ cc1: all warnings being treated as errors This is due to type promotion of addition where anything smaller than int (UINT16) is promoted to int, which is signed addition and thus can have a signed overflow issue. Signed-off-by: William Roberts <william.c.roberts@intel.com>
2018-11-27tcti: add support for partial readsTadeusz Struk
This enables partial reads in tcti-device. The feature has dependecy on the same being enable in the driver so it is disabled by default. It can be enabled by a new configure time option --enable-tcti-partial-reads=yes By enabling this the Tss_ExecuteFinish function will call Tss2_Tcti_Receive() twice. First with a NULL receive buffer, which will cause the TCTI device to read only 10 bytes response header, and return the actuall response size. Then the second call to Tss2_Tcti_Receive() will read the remaining of the response. NOTE: If this feature is not enabled in the driver then the first read will cause the response by dropped after the first read and the subsequent read will cause the connection to be closed and an IO error returned. Fixes: #1102 The driver support for partial reads has been added with commit: 8f82ffbc5b0b5e9a4546a2c8ab3366758ef76c62 Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
2018-11-14 ESYS TEST: Split the test policy-regression-opt into three test cases.Juergen Repp
* The original test did check optional policy commands. Since it cannot be expected that the three optional commands are all implemented on a physical TPM the test case was split. * If the related command is not implemented only this test case will be skipped. * Also the related doxygen files are updated. Signed-off-by: Juergen Repp <Juergen.Repp@sit.fraunhofer.de>
2018-10-25test: fix tpm2b unit tests failing on big endianTadeusz Struk
tpm2b unit test fails on big endian machines Fixes: #1171 Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
2018-10-18util: Move several auxiliary macros from esys module to utilities.Juergen Repp
* The macros will also be used in the FAPI implementation. Thus they were removed from the esys package. * The macros could also be used in the sys module to improve logging. Signed-off-by: Juergen Repp <Juergen.Repp@sit.fraunhofer.de>
2018-09-30test: Add integration test for StirRandomPeter Huewe
Add a simple test for StirRandom to increase code coverage. It does only check whether the command itself works and returns success for suitable input data. Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
2018-09-14esys: Capitalize esys_free to Esys_FreeTadeusz Struk
This makes it consistent with the rest of the ESYS API. Fixes: #1141 Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
2018-09-14ESYS: Fix default value for config string for loading libtss2-tcti-default.Juergen Repp
* The config string was set to "" in the ESYS default table. The value now is set to NULL. If config string is NULL the used TCTI module will use the default value instead of "" * The corresponding fake routines in the unit test were adapted to accept a null pointer for config parameter. * This fix allows changing of the default library without recompiling, which was not possible before. Signed-off-by: Juergen Repp <Juergen.Repp@sit.fraunhofer.de>
2018-09-12ESYS: Fix leak of dlopen handleAndreas Fuchs
The handle of dlopen used to leak. Save this handle and dlclose on Esys_Finish(). Signed-off-by: Andreas Fuchs <andreas.fuchs@sit.fraunhofer.de>
2018-08-24test: add unit tests for the polling interfaceTadeusz Struk
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
2018-08-24tcti-device: enable nonblocking mode on tcti-deviceTadeusz Struk
Enable non-blocking mode on tcti-device. This new feature requires the TPM driver to support asynchronous mode of operation. (As of kernel v3.18 the driver doesn't support it) It is therefor configure time enabled by a new flag called enable-tcti-device-async (off by default) There are two places where the new flag changes the behavior: 1. In tcti_device_get_poll_handles(), where if the flag is enabled, the function will populate handles with the tcti_dev->fd, set num_handles to 1, and return TSS2_RC_SUCCESS. If the flag is not enabled the function returns TSS2_TCTI_RC_NOT_IMPLEMENTED. 2. In tcti_device_receive(), where if the flag is not enabled the only acceptable timeout value is TSS2_TCTI_TIMEOUT_BLOCK, to enforce synchronous mode. If the flag is enabled the valid timeout values are: -1 to block forever, 0 for nonblocking, and any positive value as the actual timeout value in milliseconds. The device interface will always be open in non-blocking mode as the flag is ignored by the driver and invoking poll() currently always returns with the POLLIN flag set. When this feature will be supported by the driver and the enable-tcti-device-async flag is not enabled the behavior doesn't change because it it enforced to be synchronous in tcti_device_get_poll_handles(), but if the flag is enabled it will enable the asynchronous behavior of the tcti-device module. Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
2018-08-23ESYS: Add unit test for crypto backends.Juergen Repp
Several error cases of the crypto backends, which are not covered by the integration tests, are tested. Signed-off-by: Juergen Repp <Juergen.Repp@sit.fraunhofer.de>
2018-08-21common.h: drop TSS2_DRIVER_RC_LAYERWilliam Roberts
This is not mentioned anywhere in Section 3.4 of the spec: - https://trustedcomputinggroup.org/wp-content/uploads/TSS_Overview_Common_Structures_Version-0.9_Revision-03_Review_030918.pdf Thus remove it. Signed-off-by: William Roberts <william.c.roberts@intel.com>
2018-08-02ESYS TEST: Added tests for Esys_HMAC and Esys_Hash and minor fixes.Juergen Repp
* The two new integration tests were added to the mandatory tests. * The test clockset was moved from optional to mandatory tests. * Doxygen comments were updated. * Also some minor formatting fixes were added. Signed-off-by: Juergen Repp <Juergen.Repp@sit.fraunhofer.de>
2018-07-30TEST ESYS: Fixed test clockset.Juergen Repp
The wrong field of the structure TIME_INFO was used to determine the current clock. Signed-off-by: Juergen Repp <Juergen.Repp@sit.fraunhofer.de>
2018-07-30TEST ESYS: Enable tests for physical TPM.Juergen Repp
* To enable tests with a physical TPM the configure options: --with-ptpm=[device] --with-ptpmtests=[test cases] were added. To compile the integration tests --enable-integration has to be used. The test cases are a comma separated list of: mandatory, optional and destructive. The default is mandatory. To avoid parallel usage of the TPM the tests should be executed with: make check-ptpm or with: make check -j 1. The compiled integration tests for a simulator test can be used for tests with a physical TPM without re-compilation. * A second int_log compiler script was added to execute these tests. * Split policy regression tests into two parts. Optional commands are moved to the test policy-regression-opt. * The test policy-ticket will return success if the PolicyTicket command is not available, but all other commands in this tests were successful. * Exponent 0 will be used in the ESAPI integration tests. Exponent 65537 for RSA keys is optional in TPM spec while exponent is mandatory: A TPM compatible with this specification and supporting RSA shall support two primes and an exponent of zero. Support for other values is optional. (Spec Part2 12.2.3.5 TPMS_RSA_PARMS). * The check whether optional commands are available are adapted for the usage with a resource manager TPM. Signed-off-by: Juergen Repp <Juergen.Repp@sit.fraunhofer.de>
2018-07-16TEST ESYS: Doxygen documentation added to integration tests.Juergen Repp
* The standard test function test_invoke_esapi calls a test case specific function. For this function the old test case documentation is converted into doxygen format. * A cross reference to used ESAPI commands is added. * Possible compiler defines to generate different test cases are listed. Signed-off-by: Juergen Repp <Juergen.Repp@sit.fraunhofer.de>
2018-07-10TEST ESYS: Fix wrong check of bad authorization.Juergen Repp
The usage of the mask to get the return code was fixed. Signed-off-by: Juergen Repp <juergen.repp@sit.fraunhofer.de>
2018-07-10TEST ESYS: Fix digest comparison in policy regression test.Juergen Repp
* If the digest comparison fails the test did return 0 because only the return code of the last ESAPI call was checked to determine the result. * The test was also adapted to the cleanup scheme of the other esys tests.
2018-07-05test: use defined return value for skipped testsTadeusz Struk
Use defined value for skipped tests. Fixes: #1024 Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
2018-07-02TEST ESAPI: Improve some tests for usage with physical TPMJuergen Repp
* Test clockset: the clock rate was reset to the old value after the test. * Test ecdh-keygen: reasonable parameter were used. * Test hierarchy-control: Esys_CreatePrimary instead of Esys_ClockSet is used to check whether owner hierarchy is disabled. For Esys_ClockSet platform authorization might be needed. * Test policy_ticket: Test was improved: TPM nonce with an expiration of ten years was used to compute the digest to be signed for the command Esys_PolicySigned. Signed-off-by: Juergen Repp <Juergen.Repp@sit.fraunhofer.de>
2018-06-29test: Undefine NV space and make sure the cleanup is called in any caseRicardo Schwarzmeier
The defined NV space must be cleaned up, even if the test fails at some point. Some possibly unsupported commands are not being checked for yet. Checking the RC for TPM2_RC_COMMAND_CODE in the exit label detects all cases. Signed-off-by: Ricardo Schwarzmeier <Ricardo.Schwarzmeier@infineon.com>
2018-06-25TEST ESYS: Fix error handling.Juergen Repp
* Cleanup for TPM objects added in error cases. * Added initialization for esys handles with ESYS_TR_NONE to check whether object was allocated before cleanup. * Moved Handle declarations to the beginning of the file to avoid usage of uninitialized variables in cleanup. * Check for optional commands added to skip the test. * Check for platform authorization added to skip the test if authorization is not possible. Signed-off-by: Juergen Repp <Juergen.Repp@sit.fraunhofer.de>
2018-06-25ESYS TEST: Fix checking of esys return values.Juergen Repp
* Return values of optional commands are checked to skip this tests if the commands are not available. * Return values of commands with platform authorization are checked to skip this tests if platform hierarchy is disabled * Only EXIT_SUCCESS (0), EXIT_FAILURE (1), or EXIT_SKIP(77) will be returned by the test function. Erroneously return codes of esys commands were returned before. Signed-off-by: Juergen Repp <Juergen.Repp@sit.fraunhofer.de>
2018-06-25TEST ESYS: Changed nvHandle_handle to nvHandleJuergen Repp
Despective name was changed in nv tests. Signed-off-by: Juergen Repp <Juergen.Repp@sit.fraunhofer.de>
2018-06-13TEST ESYS: Switch from ECB to CFB mode.Juergen Repp
The PC client TPM profile only requires CFB mode for TPMs. ECB mode is denoted as 'should not'. This patch changes occurences of ECB mode to CFB mode in ESYS tests. Signed-off-by: Juergen Repp <Juergen.Repp@sit.fraunhofer.de>
2018-06-13Fixed wrong indentationjoholl
2018-06-13Replace tabs by spacesjoholl
2018-06-12Convert to SPDX-License-IndentifiersPeter Huewe
Instead of adding the same 'boilerplate' license text, we can use the much more concise SPDX Short License Identifiers. Only the standard BSD-2 clause text has been replaced. See spdx.org for more details. Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
2018-06-12Remove trailing whitespacesjoholl