Tests: Update code for styling
Signed-off-by: Andreas Fuchs <andreas.fuchs@sit.fraunhofer.de>
diff --git a/test/integration/esys-clear.int.c b/test/integration/esys-clear.int.c
index ceb3f0f..fbebf69 100644
--- a/test/integration/esys-clear.int.c
+++ b/test/integration/esys-clear.int.c
@@ -77,17 +77,16 @@
ESYS_TR authHandle_handle = ESYS_TR_RH_PLATFORM;
- r = Esys_Clear(
- esys_context,
- authHandle_handle,
+ r = Esys_Clear(esys_context,
+ authHandle_handle,
#ifdef TEST_SESSION
- session,
+ session,
#else
- ESYS_TR_PASSWORD,
+ ESYS_TR_PASSWORD,
#endif
- ESYS_TR_NONE,
- ESYS_TR_NONE
- );
+ ESYS_TR_NONE,
+ ESYS_TR_NONE
+ );
goto_if_error(r, "Error: Clear", error);
#ifdef TEST_SESSION
@@ -97,6 +96,6 @@
return 0;
-error:
+ error:
return 1;
}
diff --git a/test/integration/esys-clockset.int.c b/test/integration/esys-clockset.int.c
index bcddb09..357d1cf 100644
--- a/test/integration/esys-clockset.int.c
+++ b/test/integration/esys-clockset.int.c
@@ -33,7 +33,6 @@
#include <signal.h>
#include <stdint.h>
#include <gcrypt.h>
-
#include <sapi/tpm20.h>
#define LOGMODULE test
#include "log/log.h"
@@ -69,7 +68,8 @@
r = Esys_StartAuthSession(esys_context, ESYS_TR_NONE, ESYS_TR_NONE,
ESYS_TR_NONE, ESYS_TR_NONE, ESYS_TR_NONE,
&nonceCaller,
- TPM2_SE_HMAC, &symmetric, TPM2_ALG_SHA1, &session,
+ TPM2_SE_HMAC, &symmetric, TPM2_ALG_SHA1,
+ &session,
&nonceTpm);
goto_if_error(r, "Error: During initialization of session", error);
@@ -78,18 +78,17 @@
ESYS_TR auth_handle = ESYS_TR_RH_OWNER;
UINT64 newTime = 0xffffff;
- r = Esys_ClockSet (
- esys_context,
- auth_handle,
+ r = Esys_ClockSet(esys_context,
+ auth_handle,
#ifdef TEST_SESSION
- session,
+ session,
#else
- ESYS_TR_PASSWORD,
+ ESYS_TR_PASSWORD,
#endif
- ESYS_TR_NONE,
- ESYS_TR_NONE,
- newTime
- );
+ ESYS_TR_NONE,
+ ESYS_TR_NONE,
+ newTime
+ );
goto_if_error(r, "Error: ClockSet", error);
#ifdef TEST_SESSION
@@ -99,6 +98,6 @@
return 0;
-error:
+ error:
return 1;
}
diff --git a/test/integration/esys-create-fail.int.c b/test/integration/esys-create-fail.int.c
index 455d2dc..991fa13 100644
--- a/test/integration/esys-create-fail.int.c
+++ b/test/integration/esys-create-fail.int.c
@@ -41,9 +41,9 @@
#include "esys_types.h"
#include "esys_iutil.h"
-#define goto_error_if_not_failed(rc,msg,label) \
- if (rc == TSS2_RC_SUCCESS) { \
- LOG_ERROR("Error %s (%x) in Line %i: \n", msg, __LINE__, rc); \
+#define goto_error_if_not_failed(rc,msg,label) \
+ if (rc == TSS2_RC_SUCCESS) { \
+ LOG_ERROR("Error %s (%x) in Line %i: \n", msg, __LINE__, rc); \
goto label; }
/*
@@ -58,24 +58,24 @@
{
uint32_t r = 0;
- TPM2B_AUTH authValuePrimary = {
+ TPM2B_AUTH authValuePrimary = {
.size = 5,
.buffer = {1, 2, 3, 4, 5}
};
- TPM2B_SENSITIVE_CREATE inSensitivePrimary = {
- .size = 4,
- .sensitive = {
- .userAuth = {
- .size = 0,
- .buffer = {0 },
- },
- .data = {
- .size = 0,
- .buffer = {0},
- },
- },
- };
+ TPM2B_SENSITIVE_CREATE inSensitivePrimary = {
+ .size = 4,
+ .sensitive = {
+ .userAuth = {
+ .size = 0,
+ .buffer = {0 },
+ },
+ .data = {
+ .size = 0,
+ .buffer = {0},
+ },
+ },
+ };
inSensitivePrimary.sensitive.userAuth = authValuePrimary;
@@ -189,7 +189,7 @@
goto_if_error(r, "Error Esys GetResourceObject", error);
LOG_INFO("Created Primary with handle 0x%08x...",
- primaryHandle_node->rsrc.handle);
+ primaryHandle_node->rsrc.handle);
r = Esys_TR_SetAuth(esys_context, primaryHandle_handle, &authValuePrimary);
goto_if_error(r, "Error: TR_SetAuth", error);
@@ -210,17 +210,22 @@
&outPrivate2,
&outPublic2,
&creationData2, &creationHash2, &creationTicket2);
- goto_error_if_not_failed(r, "Error esys create did not fail with NULL parameters",
- error);
+ goto_error_if_not_failed(r, "Error esys create did not fail with NULL parameters",
+ error);
r = Esys_Create_finish(NULL,
- &outPrivate2,
- &outPublic2,
- &creationData2, &creationHash2, &creationTicket2);
- goto_error_if_not_failed(r, "Error esys create finish wiht NULL context did not fail",
- error);
+ &outPrivate2,
+ &outPublic2,
+ &creationData2, &creationHash2, &creationTicket2);
- return 0;
+ goto_error_if_not_failed(
+ r, "Error esys create finish wiht NULL context did not fail",
+ error);
+
+ r = Esys_FlushContext(esys_context, primaryHandle_handle);
+ goto_if_error(r, "Error during FlushContext", error);
+
+ return 0;
error:
return 1;
diff --git a/test/integration/esys-create-password-auth.int.c b/test/integration/esys-create-password-auth.int.c
index 2a3cf6e..9f22d2c 100644
--- a/test/integration/esys-create-password-auth.int.c
+++ b/test/integration/esys-create-password-auth.int.c
@@ -42,7 +42,8 @@
#include "esys_iutil.h"
/*
- * This test is intended to test password authentication.
+ * This test is intended to test password authentication for the ESAPI command
+ * Create.
* We start by creating a primary key (Esys_CreatePrimary).
* Based in the primary a second key with an password define in the sensitive
* area will be created.
@@ -174,7 +175,8 @@
TPMT_TK_CREATION *creationTicket;
r = Esys_CreatePrimary(esys_context, ESYS_TR_RH_OWNER, ESYS_TR_PASSWORD,
- ESYS_TR_NONE, ESYS_TR_NONE, &inSensitivePrimary, &inPublic,
+ ESYS_TR_NONE, ESYS_TR_NONE,
+ &inSensitivePrimary, &inPublic,
&outsideInfo, &creationPCR, &primaryHandle_handle,
&outPublic, &creationData, &creationHash,
&creationTicket);
diff --git a/test/integration/esys-make-credential.int.c b/test/integration/esys-make-credential.int.c
index 1ee8370..2df8c2a 100644
--- a/test/integration/esys-make-credential.int.c
+++ b/test/integration/esys-make-credential.int.c
@@ -44,10 +44,11 @@
/*
* This test is intended to test the function Esys_MakeCredential
* We start by creating a primary key (Esys_CreatePrimary).
- * Based in the primary a second key.
+ * Based in the primary a second key will be created.
* The public part of the key will be loaded by the function
* Esys_LoadExternal. A credential will be encrypted with this
- * key with the command Esys_MakeCredential.
+ * key with the command Esys_MakeCredential. The credential
+ * will be activated with Esys_ActivateCredential.
*/
int
@@ -98,7 +99,7 @@
TPM2_SE_HMAC, &symmetric, TPM2_ALG_SHA1, &session2,
&nonceTpm);
- goto_if_error(r, "Error: During initialization of session", error);
+ goto_if_error(r, "Error: During initialization of session", error);
r = esys_GetResourceObject(esys_context, session2,
&session2_node);
@@ -130,45 +131,6 @@
inSensitivePrimary.sensitive.userAuth = authValuePrimary;
-#ifdef TEST_ECC
- TPM2B_PUBLIC inPublic = {
- .size = 0,
- .publicArea = {
- .type = TPM2_ALG_ECC,
- .nameAlg = TPM2_ALG_SHA256,
- .objectAttributes = (TPMA_OBJECT_USERWITHAUTH |
- TPMA_OBJECT_RESTRICTED |
- TPMA_OBJECT_SIGN_ENCRYPT |
- TPMA_OBJECT_FIXEDTPM |
- TPMA_OBJECT_FIXEDPARENT |
- TPMA_OBJECT_SENSITIVEDATAORIGIN),
- .authPolicy = {
- .size = 0,
- },
- .parameters.eccDetail = {
- .symmetric = {
- .algorithm = TPM2_ALG_NULL,
- .keyBits.aes = 128,
- .mode.aes = TPM2_ALG_ECB,
- },
- .scheme = {
- .scheme = TPM2_ALG_ECDSA,
- .details = {
- .ecdsa = {.hashAlg = TPM2_ALG_SHA256}},
- },
- .curveID = TPM2_ECC_NIST_P256,
- .kdf = {
- .scheme = TPM2_ALG_NULL,
- .details = {}}
- },
- .unique.ecc = {
- .x = {.size = 0,.buffer = {}},
- .y = {.size = 0,.buffer = {}},
- },
- },
- };
- LOG_INFO("\nECC key will be created.");
-#else
TPM2B_PUBLIC inPublic = {
.size = 0,
.publicArea = {
@@ -201,7 +163,6 @@
},
};
LOG_INFO("\nRSA key will be created.");
-#endif // TEST_ECC
TPM2B_DATA outsideInfo = {
.size = 0,
@@ -347,15 +308,14 @@
TPM2B_NAME *primaryKeyName;
TPM2B_NAME *primaryKeyQualifiedName;
- r = Esys_ReadPublic(
- esys_context,
- primaryHandle_handle,
- ESYS_TR_NONE,
- ESYS_TR_NONE,
- ESYS_TR_NONE,
- &primaryKeyPublic,
- &primaryKeyName,
- &primaryKeyQualifiedName);
+ r = Esys_ReadPublic(esys_context,
+ primaryHandle_handle,
+ ESYS_TR_NONE,
+ ESYS_TR_NONE,
+ ESYS_TR_NONE,
+ &primaryKeyPublic,
+ &primaryKeyName,
+ &primaryKeyQualifiedName);
goto_if_error(r, "Error esys read public", error);
@@ -367,17 +327,16 @@
TPM2B_ID_OBJECT *credentialBlob;
TPM2B_ENCRYPTED_SECRET *secret;
- r = Esys_MakeCredential(
- esys_context,
- loadedKeyHandle,
- ESYS_TR_NONE,
- ESYS_TR_NONE,
- ESYS_TR_NONE,
- &credential,
- primaryKeyName,
- &credentialBlob,
- &secret
- );
+ r = Esys_MakeCredential(esys_context,
+ loadedKeyHandle,
+ ESYS_TR_NONE,
+ ESYS_TR_NONE,
+ ESYS_TR_NONE,
+ &credential,
+ primaryKeyName,
+ &credentialBlob,
+ &secret
+ );
goto_if_error(r, "Error: MakeCredential", error);
r = Esys_FlushContext(esys_context, loadedKeyHandle);
@@ -385,16 +344,15 @@
TPM2B_DIGEST *certInfo;
- r = Esys_Load(
- esys_context,
- primaryHandle_handle,
+ r = Esys_Load(esys_context,
+ primaryHandle_handle,
#ifdef TEST_SESSION
- session,
+ session,
#else
- ESYS_TR_PASSWORD,
+ ESYS_TR_PASSWORD,
#endif
- ESYS_TR_NONE,
- ESYS_TR_NONE, outPrivate2, outPublic2, &loadedKeyHandle);
+ ESYS_TR_NONE,
+ ESYS_TR_NONE, outPrivate2, outPublic2, &loadedKeyHandle);
goto_if_error(r, "Error esys load ", error);
LOG_INFO("\nSecond Key loaded.");
@@ -402,26 +360,25 @@
r = Esys_TR_SetAuth(esys_context, loadedKeyHandle, &authKey2);
goto_if_error(r, "Error: TR_SetAuth", error);
- r = Esys_ActivateCredential(
- esys_context,
- primaryHandle_handle,
- loadedKeyHandle,
+ r = Esys_ActivateCredential(esys_context,
+ primaryHandle_handle,
+ loadedKeyHandle,
#ifdef TEST_SESSION
- session,
+ session,
#else
- ESYS_TR_PASSWORD,
+ ESYS_TR_PASSWORD,
#endif
#ifdef TEST_SESSION
- session2,
+ session2,
#else
- ESYS_TR_PASSWORD,
+ ESYS_TR_PASSWORD,
#endif
- ESYS_TR_NONE,
- credentialBlob,
- secret,
- &certInfo
- );
+ ESYS_TR_NONE,
+ credentialBlob,
+ secret,
+ &certInfo
+ );
goto_if_error(r, "Error: ActivateCredential", error);
return 0;