CLang-Format pass
Also reduce the travis load since most of it is on github now.
diff --git a/.travis.yml b/.travis.yml
index 588ee63..68cecb2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,5 @@
language: c
compiler:
- - clang
- gcc
sudo: false
env:
@@ -14,17 +13,8 @@
COVERALLS="-DCOSE_C_COVERALLS_SEND=ON -DCOSE_C_INCLUDE_COUNTERSIGN=ON"
- USE_CONTEXT=OFF USE_EMBEDTLS=ON
COVERALLS="-DCOSE_C_COVERALLS_SEND=ON -DCOSE_C_INCLUDE_COUNTERSIGN=ON"
- - CMAKE_OPTIONS="-DCOSE_C_INCLUDE_ENCRYPT=ON -DCOSE_C_INCLUDE_ENCRYPT0=OFF -DCOSE_C_INCLUDE_MAC0=OFF -DCOSE_C_INCLUDE_MAC=OFF -DCOSE_C_INCLUDE_SIGN=OFF -DCOSE_C_INCLUDE_SIGN1=OFF"
- - CMAKE_OPTIONS="-DCOSE_C_INCLUDE_ENCRYPT=OFF -DCOSE_C_INCLUDE_ENCRYPT0=ON -DCOSE_C_INCLUDE_MAC0=OFF -DCOSE_C_INCLUDE_MAC=OFF -DCOSE_C_INCLUDE_SIGN=OFF -DCOSE_C_INCLUDE_SIGN1=OFF"
- - CMAKE_OPTIONS="-DCOSE_C_INCLUDE_ENCRYPT=OFF -DCOSE_C_INCLUDE_ENCRYPT0=OFF -DCOSE_C_INCLUDE_MAC0=ON -DCOSE_C_INCLUDE_MAC=OFF -DCOSE_C_INCLUDE_SIGN=OFF -DCOSE_C_INCLUDE_SIGN1=OFF"
- - CMAKE_OPTIONS="-DCOSE_C_INCLUDE_ENCRYPT=OFF -DCOSE_C_INCLUDE_ENCRYPT0=OFF -DCOSE_C_INCLUDE_MAC0=OFF -DCOSE_C_INCLUDE_MAC=ON -DCOSE_C_INCLUDE_SIGN=OFF -DCOSE_C_INCLUDE_SIGN1=OFF"
- - CMAKE_OPTIONS="-DCOSE_C_INCLUDE_ENCRYPT=OFF -DCOSE_C_INCLUDE_ENCRYPT0=OFF -DCOSE_C_INCLUDE_MAC0=OFF -DCOSE_C_INCLUDE_MAC=OFF -DCOSE_C_INCLUDE_SIGN=ON -DCOSE_C_INCLUDE_SIGN1=OFF"
- - CMAKE_OPTIONS="-DCOSE_C_INCLUDE_ENCRYPT=OFF -DCOSE_C_INCLUDE_ENCRYPT0=OFF -DCOSE_C_INCLUDE_MAC0=OFF -DCOSE_C_INCLUDE_MAC=OFF -DCOSE_C_INCLUDE_SIGN=OFF -DCOSE_C_INCLUDE_SIGN1=ON"
-
-matrix:
- exclude:
- - compiler: clang
- env: USE_CONTEXT=OFF
+ - USE_CONTEXT=ON USE_EMBEDTLS=ON
+ COVERALLS="-DCOSE_C_COVERALLS_SEND=ON -DCOSE_C_INCLUDE_COUNTERSIGN=ON"
addons:
apt:
@@ -33,8 +23,6 @@
- llvm-toolchain-precise-3.8
- george-edison55-precise-backports
packages:
- # - libssl-dev
- # - libssl1.1
- cmake
- cmake-data
diff --git a/src/CounterSign.c b/src/CounterSign.c
index 643b213..bd6a2a8 100644
--- a/src/CounterSign.c
+++ b/src/CounterSign.c
@@ -115,7 +115,7 @@
}
_COSE_RemoveFromList(&CountersignRoot, &p->m_signer.m_message);
-
+
fRet = _COSE_CounterSign_Free(p);
errorReturn:
@@ -142,7 +142,6 @@
return false;
}
-
#if 0
I Don't remember why I wrote this and if I don't need it any more.
Keep for a little while and then delete
diff --git a/src/Encrypt.c b/src/Encrypt.c
index 2da3b01..5be2f27 100644
--- a/src/Encrypt.c
+++ b/src/Encrypt.c
@@ -363,8 +363,8 @@
break;
}
else if (pRecipX->m_encrypt.m_recipientFirst != NULL) {
- if (_COSE_Recipient_decrypt(
- pRecipX, pRecip, alg, cbitKey, pbKeyNew, &errorLocal)) {
+ if (_COSE_Recipient_decrypt(pRecipX, pRecip, alg, cbitKey,
+ pbKeyNew, &errorLocal)) {
break;
}
}
@@ -991,7 +991,6 @@
pRecip->m_encrypt.m_message.m_cbor, &cbor_error),
cbor_error);
-
return true;
errorReturn:
diff --git a/src/MacMessage.c b/src/MacMessage.c
index b3e030d..62287da 100644
--- a/src/MacMessage.c
+++ b/src/MacMessage.c
@@ -635,7 +635,7 @@
if (perr == NULL) {
perr = &error;
}
-
+
COSE_MacMessage *pcose = (COSE_MacMessage *)h;
COSE_RecipientInfo *pRecip = (COSE_RecipientInfo *)hRecip;
diff --git a/src/Recipient.c b/src/Recipient.c
index df43e42..fd5d208 100644
--- a/src/Recipient.c
+++ b/src/Recipient.c
@@ -474,14 +474,14 @@
CHECK_CONDITION(pbKeyX != NULL, COSE_ERR_OUT_OF_MEMORY);
cose_errback error = {COSE_ERR_NONE};
int errorFound = false;
-
+
for (pRecip2 = pcose->m_recipientFirst; pRecip2 != NULL;
pRecip2 = pRecip->m_recipientNext) {
if (_COSE_Recipient_decrypt(
pRecip2, NULL, alg, cbitKeyX, pbKeyX, &error)) {
break;
}
- if (error.err == COSE_ERR_NO_COMPRESSED_POINTS ||
+ if (error.err == COSE_ERR_NO_COMPRESSED_POINTS ||
error.err == COSE_ERR_UNKNOWN_ALGORITHM) {
errorFound = error.err;
}
diff --git a/src/mbedtls.c b/src/mbedtls.c
index d1f7fb9..3b48981 100644
--- a/src/mbedtls.c
+++ b/src/mbedtls.c
@@ -194,7 +194,6 @@
}
#endif
-
#ifdef USE_AES_GCM
bool AES_GCM_Decrypt(COSE_Enveloped *pcose,
const byte *pbKey,
@@ -392,8 +391,6 @@
}
#endif
-
-
#if defined(USE_HKDF_SHA2)
bool HKDF_Extract(COSE *pcose,
const byte *pbKey,
@@ -501,7 +498,7 @@
}
if (mbedtls_hkdf_expand(
- pmd, pbPRK, cbPRK, pbInfo, cbInfo, pbOutput, cbOutput) != 0) {
+ pmd, pbPRK, cbPRK, pbInfo, cbInfo, pbOutput, cbOutput) != 0) {
goto errorReturn;
}
@@ -509,7 +506,6 @@
}
#endif
-
#ifdef USE_HMAC
bool HMAC_Create(COSE_MacMessage *pcose,
int HSize,
@@ -694,7 +690,7 @@
}
CHECK_CONDITION(mbedtls_ecp_group_load(&keypair->grp, groupId) == 0,
COSE_ERR_INVALID_PARAMETER);
- cbGroup = (int) (keypair->grp.nbits + 7) / 8;
+ cbGroup = (int)(keypair->grp.nbits + 7) / 8;
p = cn_cbor_mapget_int(pKey, COSE_Key_EC_X);
CHECK_CONDITION(
@@ -747,7 +743,6 @@
return false;
}
-
bool ECDSA_Sign(COSE *pSigner,
int index,
const cn_cbor *pKey,
@@ -1103,7 +1098,7 @@
CBOR_CONTEXT_COMMA cose_errback *perr)
{
UNUSED(pRecipient);
-
+
int cbGroup = 0;
int cbsecret = 0;
byte *pbsecret = NULL;
diff --git a/test/CounterSign_test.c b/test/CounterSign_test.c
index 252f692..c1b02f5 100644
--- a/test/CounterSign_test.c
+++ b/test/CounterSign_test.c
@@ -23,7 +23,7 @@
byte rgb[10];
cn_cbor *cn = cn_cbor_int_create(5, CBOR_CONTEXT_PARAM_COMMA NULL);
-
+
hCounterSign = COSE_CounterSign_Init(CBOR_CONTEXT_PARAM_COMMA NULL);
hBadHandle = (HCOSE_COUNTERSIGN)COSE_CALLOC(1, sizeof(COSE), context);
#if INCLUDE_SIGN1
@@ -59,7 +59,8 @@
COSE_ERR_INVALID_PARAMETER, CFails++);
#if INCLUDE_SIGN1
- CHECK_FAILURE(COSE_Sign1_add_countersignature(hSign1, hBadHandle, &cose_error),
+ CHECK_FAILURE(
+ COSE_Sign1_add_countersignature(hSign1, hBadHandle, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
((COSE_CounterSign *)hCounterSign)->m_next = (COSE_CounterSign *)hBadHandle;
CHECK_FAILURE(
@@ -72,7 +73,7 @@
CHECK_FAILURE(COSE_Sign1_get_countersignature(hSign1, 3, &cose_error),
COSE_ERR_INVALID_PARAMETER, CFails++);
#endif
-
+
CHECK_FAILURE(
COSE_CounterSign_SetExternal(hNULL, rgb, sizeof(rgb), &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
@@ -80,13 +81,12 @@
COSE_CounterSign_SetExternal(hBadHandle, rgb, sizeof(rgb), &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
COSE_CounterSign_SetExternal(hCounterSign, rgb, sizeof(rgb), &cose_error);
-
-
+
CHECK_RETURN(!COSE_CounterSign_Free(hBadHandle), false, CFails++);
COSE_CounterSign_Free(hCounterSign);
#if INCLUDE_SIGN1
COSE_Sign1_Free(hSign1);
-#endif
+#endif
}
#endif
diff --git a/test/encrypt.c b/test/encrypt.c
index 8eb6baf..c451310 100644
--- a/test/encrypt.c
+++ b/test/encrypt.c
@@ -151,7 +151,8 @@
fRet = !fFailBody;
}
else {
- if (cose_err.err == COSE_ERR_NO_COMPRESSED_POINTS || cose_err.err == COSE_ERR_UNKNOWN_ALGORITHM) {
+ if (cose_err.err == COSE_ERR_NO_COMPRESSED_POINTS ||
+ cose_err.err == COSE_ERR_UNKNOWN_ALGORITHM) {
fRet = false;
fNoSupport = true;
}
@@ -617,7 +618,7 @@
if (hEncObj != NULL) {
COSE_Enveloped_Free(hEncObj);
}
-
+
CFails += 1;
return 0;
}
@@ -934,7 +935,6 @@
}
#endif
-
exitHere:
if (hEnc != NULL) {
COSE_Encrypt_Free(hEnc);
@@ -1100,7 +1100,7 @@
if (hEncObj != NULL) {
COSE_Encrypt_Free(hEncObj);
}
-
+
CFails += 1;
return 1;
}
diff --git a/test/mac_test.c b/test/mac_test.c
index 03a3ae6..45a98c3 100644
--- a/test/mac_test.c
+++ b/test/mac_test.c
@@ -127,7 +127,8 @@
}
}
else {
- if (error.err == COSE_ERR_NO_COMPRESSED_POINTS || error.err == COSE_ERR_UNKNOWN_ALGORITHM) {
+ if (error.err == COSE_ERR_NO_COMPRESSED_POINTS ||
+ error.err == COSE_ERR_UNKNOWN_ALGORITHM) {
fAlgNoSupport = true;
returnCode = 0;
}
@@ -322,7 +323,7 @@
{
int iRecipient = 0;
HCOSE_RECIPIENT hRecip = NULL;
-
+
//
// We don't run this for all control sequences - skip those marked fail.
//
@@ -776,7 +777,6 @@
}
#endif
-
if (fFailBody) {
if (!fFail) {
fFail = true;
@@ -785,12 +785,12 @@
fFail = false;
}
}
-
+
exitHere:
if (hMAC != NULL) {
COSE_Mac0_Free(hMAC);
}
-
+
if (fFail) {
CFails += 1;
}
diff --git a/test/sign.c b/test/sign.c
index f6ac539..8f2fb9e 100644
--- a/test/sign.c
+++ b/test/sign.c
@@ -141,7 +141,7 @@
for (int counterNo = 0; counterNo < count; counterNo++) {
bool noSignAlg = false;
- h = COSE_Signer_get_countersignature(hSigner, counterNo, 0);
+ h = COSE_Signer_get_countersignature(hSigner, counterNo, 0);
if (h == NULL) {
fFail = true;
continue;
@@ -292,7 +292,7 @@
if (hSig != NULL) {
COSE_Sign_Free(hSig);
}
-
+
CFails += 1;
return 0;
}
@@ -309,7 +309,7 @@
{
int iSigner;
HCOSE_SIGNER hSigner = NULL;
-
+
//
// We don't run this for all control sequences - skip those marked fail.
//
@@ -479,7 +479,7 @@
if (hSigner != NULL) {
COSE_Signer_Free(hSigner);
}
-
+
CFails += 1;
return 1;
}
@@ -729,7 +729,6 @@
}
#endif
-
if (fFailBody) {
if (!fFail) {
fFail = true;