Forgot to do the formatting. (#119)
diff --git a/src/Cose.cpp b/src/Cose.cpp
index 50f5c75..1eec83b 100644
--- a/src/Cose.cpp
+++ b/src/Cose.cpp
@@ -214,13 +214,12 @@
}
#endif
- #if INCLUDE_COUNTERSIGNATURE1
+#if INCLUDE_COUNTERSIGNATURE1
if (pcose->m_counterSign1 != NULL) {
COSE_CounterSign1_Free((HCOSE_COUNTERSIGN1)pcose->m_counterSign1);
}
#endif
}
-
HCOSE COSE_Decode(const byte *rgbData,
size_t cbData,
@@ -235,14 +234,13 @@
if (false) {
errorReturn:
CN_CBOR_FREE(cbor, context);
- return nullptr;
+ return nullptr;
}
CHECK_CONDITION(
(rgbData != nullptr) && (ptype != nullptr), COSE_ERR_INVALID_PARAMETER);
- cbor =
- cn_cbor_decode(rgbData, cbData, CBOR_CONTEXT_PARAM_COMMA & cbor_err);
+ cbor = cn_cbor_decode(rgbData, cbData, CBOR_CONTEXT_PARAM_COMMA & cbor_err);
CHECK_CONDITION_CBOR(cbor != nullptr, cbor_err);
if (cbor->type == CN_CBOR_TAG) {
@@ -275,7 +273,7 @@
#else
FAIL_CONDITION(COSE_ERR_UNSUPPORTED_COSE_TYPE);
#endif
- break;
+ break;
case COSE_sign_object:
#if INCLUDE_SIGN
@@ -383,7 +381,8 @@
perr->err = COSE_ERR_NONE;
}
- if ((cose->m_protectedMap != nullptr) && ((flags & COSE_PROTECT_ONLY) != 0)) {
+ if ((cose->m_protectedMap != nullptr) &&
+ ((flags & COSE_PROTECT_ONLY) != 0)) {
p = cn_cbor_mapget_int(cose->m_protectedMap, key);
if (p != nullptr) {
return p;
@@ -420,7 +419,8 @@
perror->err = COSE_ERR_NONE;
}
- if ((pcose->m_protectedMap != nullptr) && ((flags & COSE_PROTECT_ONLY) != 0)) {
+ if ((pcose->m_protectedMap != nullptr) &&
+ ((flags & COSE_PROTECT_ONLY) != 0)) {
p = cn_cbor_mapget_string(pcose->m_protectedMap, key);
if (p != nullptr) {
return p;
@@ -509,8 +509,9 @@
pbProtected = (byte *)COSE_CALLOC(cbProtected, 1, context);
CHECK_CONDITION(pbProtected != nullptr, COSE_ERR_OUT_OF_MEMORY);
- CHECK_CONDITION(cn_cbor_encoder_write(pbProtected, 0, cbProtected,
- pMessage->m_protectedMap) == static_cast<ssize_t>(cbProtected),
+ CHECK_CONDITION(
+ cn_cbor_encoder_write(pbProtected, 0, cbProtected,
+ pMessage->m_protectedMap) == static_cast<ssize_t>(cbProtected),
COSE_ERR_CBOR);
}
else {
@@ -577,7 +578,8 @@
return false;
}
- for (const COSE *walk = rootNode; walk != nullptr; walk = walk->m_handleList) {
+ for (const COSE *walk = rootNode; walk != nullptr;
+ walk = walk->m_handleList) {
if (walk == thisMsg) {
return true;
}
diff --git a/src/CoseKey.cpp b/src/CoseKey.cpp
index 6663945..717af12 100644
--- a/src/CoseKey.cpp
+++ b/src/CoseKey.cpp
@@ -23,7 +23,7 @@
bool IsValidKeyHandle(HCOSE_KEY h)
{
- COSE_KEY *p = (COSE_KEY*)h;
+ COSE_KEY *p = (COSE_KEY *)h;
if (KeysRoot == nullptr) {
return false;
}
@@ -31,7 +31,8 @@
return false;
}
- for (const COSE_KEY *walk = KeysRoot; walk != nullptr; walk = walk->m_nextKey) {
+ for (const COSE_KEY *walk = KeysRoot; walk != nullptr;
+ walk = walk->m_nextKey) {
if (walk == p) {
return true;
}
@@ -82,7 +83,8 @@
if (KeysRoot == p) {
KeysRoot = p->m_nextKey;
- p->m_nextKey = nullptr;;
+ p->m_nextKey = nullptr;
+ ;
}
else {
for (COSE_KEY *walk = KeysRoot; walk->m_nextKey != nullptr;
diff --git a/src/CounterSign.cpp b/src/CounterSign.cpp
index dbef207..4270398 100644
--- a/src/CounterSign.cpp
+++ b/src/CounterSign.cpp
@@ -234,9 +234,9 @@
#ifdef USE_CBOR_CONTEXT
cn_cbor_context* context = nullptr;
#endif
-
+
CHECK_CONDITION(pkey != nullptr, COSE_ERR_INVALID_PARAMETER);
- coseKey = COSE_KEY_FromCbor((cn_cbor*) pkey, CBOR_CONTEXT_PARAM_COMMA perr);
+ coseKey = COSE_KEY_FromCbor((cn_cbor*)pkey, CBOR_CONTEXT_PARAM_COMMA perr);
CHECK_CONDITION(coseKey != nullptr, COSE_ERR_OUT_OF_MEMORY);
fRet = COSE_CounterSign_SetKey2(h, coseKey, perr);
@@ -258,9 +258,9 @@
CHECK_CONDITION(IsValidCounterSignHandle(hSigner), COSE_ERR_INVALID_HANDLE);
CHECK_CONDITION(IsValidKeyHandle(hKey), COSE_ERR_INVALID_HANDLE);
-
+
if (pSigner->m_signer.m_pkey != nullptr) {
- COSE_KEY_Free((HCOSE_KEY) pSigner->m_signer.m_pkey);
+ COSE_KEY_Free((HCOSE_KEY)pSigner->m_signer.m_pkey);
}
pSigner->m_signer.m_pkey = pKey;
@@ -376,8 +376,8 @@
cn_cbor_array_create(CBOR_CONTEXT_PARAM_COMMA & cn_error);
CHECK_CONDITION_CBOR(cn_counterSign, cn_error);
- for (pCountersign = baseMessage->m_counterSigners; pCountersign != nullptr;
- pCountersign = pCountersign->m_next) {
+ for (pCountersign = baseMessage->m_counterSigners;
+ pCountersign != nullptr; pCountersign = pCountersign->m_next) {
cn_cbor* cn = COSE_get_cbor((HCOSE)pCountersign);
CHECK_CONDITION_CBOR(
cn_cbor_array_append(cn_counterSign, cn, &cn_error), cn_error);
@@ -482,7 +482,8 @@
const cn_cbor* cnProtected =
_COSE_arrayget_int(&pSigner->m_message, INDEX_PROTECTED);
- CHECK_CONDITION(cnProtected != nullptr && cnProtected->type == CN_CBOR_BYTES,
+ CHECK_CONDITION(
+ cnProtected != nullptr && cnProtected->type == CN_CBOR_BYTES,
COSE_ERR_INVALID_PARAMETER);
bool f = _COSE_Signer_validate(&pCountersign->m_signer, cnContent,
@@ -552,7 +553,8 @@
const cn_cbor* cnProtected =
_COSE_arrayget_int(&pSignMsg->m_message, INDEX_PROTECTED);
- CHECK_CONDITION(cnProtected != nullptr && cnProtected->type == CN_CBOR_BYTES,
+ CHECK_CONDITION(
+ cnProtected != nullptr && cnProtected->type == CN_CBOR_BYTES,
COSE_ERR_INVALID_PARAMETER);
bool f = _COSE_Signer_validate(&pCountersign->m_signer, cnContent,
@@ -624,7 +626,8 @@
const cn_cbor* cnProtected =
_COSE_arrayget_int(&pSignMsg->m_message, INDEX_PROTECTED);
- CHECK_CONDITION(cnProtected != nullptr && cnProtected->type == CN_CBOR_BYTES,
+ CHECK_CONDITION(
+ cnProtected != nullptr && cnProtected->type == CN_CBOR_BYTES,
COSE_ERR_INVALID_PARAMETER);
bool f = _COSE_Signer_validate(&pCountersign->m_signer, cnContent,
@@ -695,7 +698,8 @@
const cn_cbor* cnProtected =
_COSE_arrayget_int(&pSignMsg->m_message, INDEX_PROTECTED);
- CHECK_CONDITION(cnProtected != nullptr && cnProtected->type == CN_CBOR_BYTES,
+ CHECK_CONDITION(
+ cnProtected != nullptr && cnProtected->type == CN_CBOR_BYTES,
COSE_ERR_INVALID_PARAMETER);
bool f = _COSE_Signer_validate(&pCountersign->m_signer, cnContent,
@@ -768,7 +772,8 @@
const cn_cbor* cnProtected =
_COSE_arrayget_int(&pSignMsg->m_encrypt.m_message, INDEX_PROTECTED);
- CHECK_CONDITION(cnProtected != nullptr && cnProtected->type == CN_CBOR_BYTES,
+ CHECK_CONDITION(
+ cnProtected != nullptr && cnProtected->type == CN_CBOR_BYTES,
COSE_ERR_INVALID_PARAMETER);
bool f = _COSE_Signer_validate(&pCountersign->m_signer, cnContent,
@@ -840,7 +845,8 @@
const cn_cbor* cnProtected =
_COSE_arrayget_int(&pSignMsg->m_message, INDEX_PROTECTED);
- CHECK_CONDITION(cnProtected != nullptr && cnProtected->type == CN_CBOR_BYTES,
+ CHECK_CONDITION(
+ cnProtected != nullptr && cnProtected->type == CN_CBOR_BYTES,
COSE_ERR_INVALID_PARAMETER);
bool f = _COSE_Signer_validate(&pCountersign->m_signer, cnContent,
@@ -912,7 +918,8 @@
const cn_cbor* cnProtected =
_COSE_arrayget_int(&pSignMsg->m_message, INDEX_PROTECTED);
- CHECK_CONDITION(cnProtected != nullptr && cnProtected->type == CN_CBOR_BYTES,
+ CHECK_CONDITION(
+ cnProtected != nullptr && cnProtected->type == CN_CBOR_BYTES,
COSE_ERR_INVALID_PARAMETER);
bool f = _COSE_Signer_validate(&pCountersign->m_signer, cnContent,
@@ -984,7 +991,8 @@
const cn_cbor* cnProtected =
_COSE_arrayget_int(&pSignMsg->m_message, INDEX_PROTECTED);
- CHECK_CONDITION(cnProtected != nullptr && cnProtected->type == CN_CBOR_BYTES,
+ CHECK_CONDITION(
+ cnProtected != nullptr && cnProtected->type == CN_CBOR_BYTES,
COSE_ERR_INVALID_PARAMETER);
bool f = _COSE_Signer_validate(&pCountersign->m_signer, cnContent,
diff --git a/src/CounterSign1.cpp b/src/CounterSign1.cpp
index 3def09c..a8eb5b3 100644
--- a/src/CounterSign1.cpp
+++ b/src/CounterSign1.cpp
@@ -58,7 +58,7 @@
if (cn2 != nullptr) {
CN_CBOR_FREE(cn2, context);
}
- return nullptr;
+ return nullptr;
}
CHECK_CONDITION(cbor->type == CN_CBOR_BYTES, COSE_ERR_INVALID_PARAMETER);
@@ -66,17 +66,20 @@
newBody = cn_cbor_array_create(CBOR_CONTEXT_PARAM_COMMA & cborError);
CHECK_CONDITION_CBOR(newBody != NULL, cborError);
- cn2 = cn_cbor_data_create(nullptr, 0, CBOR_CONTEXT_PARAM_COMMA &cborError); // protected = bstr
+ cn2 = cn_cbor_data_create(
+ nullptr, 0, CBOR_CONTEXT_PARAM_COMMA & cborError); // protected = bstr
CHECK_CONDITION_CBOR(cn2 != NULL, cborError);
CHECK_CONDITION_CBOR(
cn_cbor_array_append(newBody, cn2, &cborError), cborError);
- cn2 = cn_cbor_map_create(CBOR_CONTEXT_PARAM_COMMA &cborError); // unprotected = map
+ cn2 = cn_cbor_map_create(
+ CBOR_CONTEXT_PARAM_COMMA & cborError); // unprotected = map
CHECK_CONDITION_CBOR(cn2 != NULL, cborError);
CHECK_CONDITION_CBOR(
cn_cbor_array_append(newBody, cn2, &cborError), cborError);
- cn2 = cn_cbor_clone(cbor, CBOR_CONTEXT_PARAM_COMMA &cborError); // signature = bstr
+ cn2 = cn_cbor_clone(
+ cbor, CBOR_CONTEXT_PARAM_COMMA & cborError); // signature = bstr
CHECK_CONDITION_CBOR(
cn_cbor_array_append(newBody, cn2, &cborError), cborError);
cn2 = nullptr;
@@ -86,7 +89,7 @@
1, sizeof(COSE_CounterSign1), context);
CHECK_CONDITION(pobj != NULL, COSE_ERR_OUT_OF_MEMORY);
}
-
+
if (!_COSE_SignerInfo_Init_From_Object(
newBody, &pobj->m_signer, CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
@@ -388,7 +391,7 @@
if (cn3 != nullptr) {
CN_CBOR_FREE(cn3, context);
}
- return fRet;
+ return fRet;
}
cn_cbor* pSignature = _COSE_arrayget_int(baseMessage, INDEX_SIGNATURE);
@@ -408,7 +411,8 @@
sigValue = (byte*)COSE_CALLOC(cn->length, 1, context);
CHECK_CONDITION(sigValue != NULL, COSE_ERR_OUT_OF_MEMORY);
memcpy(sigValue, cn->v.bytes, cn->length);
- cn3 = cn_cbor_data_create2(sigValue, cn->length, 0, CBOR_CONTEXT_PARAM_COMMA &cborerr);
+ cn3 = cn_cbor_data_create2(
+ sigValue, cn->length, 0, CBOR_CONTEXT_PARAM_COMMA & cborerr);
CHECK_CONDITION_CBOR(cn3 != NULL, cborerr);
sigValue = nullptr;
diff --git a/src/Encrypt.cpp b/src/Encrypt.cpp
index 4105af1..37f74bf 100644
--- a/src/Encrypt.cpp
+++ b/src/Encrypt.cpp
@@ -183,7 +183,8 @@
if (p->pbContent != nullptr) {
COSE_FREE((void *)p->pbContent, &p->m_message.m_allocContext);
}
- // if (p->pbIV != nullptr) COSE_FREE(p->pbIV, &p->m_message.m_allocContext);
+ // if (p->pbIV != nullptr) COSE_FREE(p->pbIV,
+ //&p->m_message.m_allocContext);
for (pRecipient1 = p->m_recipientFirst; pRecipient1 != nullptr;
pRecipient1 = pRecipient2) {
@@ -345,7 +346,8 @@
// Allocate the key if we have not already done so
if (pbKeyNew == nullptr) {
- pbKeyNew = static_cast<byte*>(COSE_CALLOC(cbitKey / 8, 1, context));
+ pbKeyNew =
+ static_cast<byte *>(COSE_CALLOC(cbitKey / 8, 1, context));
CHECK_CONDITION(pbKeyNew != nullptr, COSE_ERR_OUT_OF_MEMORY);
pbKey = pbKeyNew;
}
@@ -528,7 +530,8 @@
COSE_Enveloped *pcose = (COSE_Enveloped *)h;
CHECK_CONDITION(IsValidEnvelopedHandle(h), COSE_ERR_INVALID_HANDLE);
- CHECK_CONDITION(pcose->m_recipientFirst != nullptr, COSE_ERR_INVALID_HANDLE);
+ CHECK_CONDITION(
+ pcose->m_recipientFirst != nullptr, COSE_ERR_INVALID_HANDLE);
return _COSE_Enveloped_encrypt(pcose, nullptr, 0, "Encrypt", perr);
@@ -1041,8 +1044,8 @@
pItem = _COSE_arrayget_int(pMessage, INDEX_PROTECTED);
CHECK_CONDITION(pItem != nullptr, COSE_ERR_INVALID_PARAMETER);
if ((pItem->length == 1) && (pItem->v.bytes[0] == 0xa0)) {
- ptmp =
- cn_cbor_data_create(nullptr, 0, CBOR_CONTEXT_PARAM_COMMA & cbor_error);
+ ptmp = cn_cbor_data_create(
+ nullptr, 0, CBOR_CONTEXT_PARAM_COMMA & cbor_error);
}
else {
ptmp = cn_cbor_data_create(pItem->v.bytes, (int)pItem->length,
diff --git a/src/Encrypt0.cpp b/src/Encrypt0.cpp
index 32f312b..3c12466 100644
--- a/src/Encrypt0.cpp
+++ b/src/Encrypt0.cpp
@@ -50,7 +50,7 @@
{
if (false) {
errorReturn:
- return nullptr;
+ return nullptr;
}
CHECK_CONDITION(flags == COSE_INIT_FLAGS_NONE, COSE_ERR_INVALID_PARAMETER);
diff --git a/src/MacMessage.cpp b/src/MacMessage.cpp
index db2a758..5b9cb05 100644
--- a/src/MacMessage.cpp
+++ b/src/MacMessage.cpp
@@ -306,7 +306,8 @@
COSE_ERR_INVALID_PARAMETER);
if ((pcn->length == 1) && (pcn->v.bytes[0] == 0xa0)) {
- ptmp = cn_cbor_data_create(nullptr, 0, CBOR_CONTEXT_PARAM_COMMA nullptr);
+ ptmp =
+ cn_cbor_data_create(nullptr, 0, CBOR_CONTEXT_PARAM_COMMA nullptr);
}
else {
ptmp = cn_cbor_data_create(
@@ -314,7 +315,8 @@
}
CHECK_CONDITION(ptmp != nullptr, COSE_ERR_CBOR);
- CHECK_CONDITION(cn_cbor_array_append(pAuthData, ptmp, nullptr), COSE_ERR_CBOR);
+ CHECK_CONDITION(
+ cn_cbor_array_append(pAuthData, ptmp, nullptr), COSE_ERR_CBOR);
ptmp = nullptr;
// Add the external bytes
@@ -763,7 +765,8 @@
}
else {
if (pbKeyNew == nullptr) {
- pbKeyNew = static_cast<byte*>(COSE_CALLOC(cbitKey / 8, 1, context));
+ pbKeyNew =
+ static_cast<byte *>(COSE_CALLOC(cbitKey / 8, 1, context));
CHECK_CONDITION(pbKeyNew != nullptr, COSE_ERR_OUT_OF_MEMORY);
pbKey = pbKeyNew;
}
diff --git a/src/Recipient.cpp b/src/Recipient.cpp
index 871d1f6..2682079 100644
--- a/src/Recipient.cpp
+++ b/src/Recipient.cpp
@@ -50,7 +50,7 @@
{
if (false) {
errorReturn:
- return nullptr;
+ return nullptr;
}
CHECK_CONDITION(flags == COSE_INIT_FLAGS_NONE, COSE_ERR_INVALID_PARAMETER);
@@ -153,10 +153,10 @@
_COSE_Enveloped_Release(&pRecipient->m_encrypt);
if (pRecipient->m_pkey != nullptr) {
- COSE_KEY_Free((HCOSE_KEY) pRecipient->m_pkey);
+ COSE_KEY_Free((HCOSE_KEY)pRecipient->m_pkey);
}
if (pRecipient->m_pkeyStatic != nullptr) {
- COSE_KEY_Free((HCOSE_KEY) pRecipient->m_pkeyStatic);
+ COSE_KEY_Free((HCOSE_KEY)pRecipient->m_pkeyStatic);
}
COSE_FREE(pRecipient, &pRecipient->m_encrypt.m_message.m_allocContext);
@@ -242,17 +242,18 @@
cn_cbor_errback cborError;
cn_cbor *pdup = pkeyMessage->m_cborKey;
if (pKeyPrivate == nullptr) {
- pkeyMessage->m_cborKey = nullptr;
+ pkeyMessage->m_cborKey = nullptr;
}
else {
- pdup = cn_cbor_clone(pkeyMessage->m_cborKey, CBOR_CONTEXT_PARAM_COMMA &cborError);
+ pdup = cn_cbor_clone(pkeyMessage->m_cborKey,
+ CBOR_CONTEXT_PARAM_COMMA & cborError);
CHECK_CONDITION_CBOR(pdup != nullptr, cborError);
}
if (pKeyPrivate == nullptr) {
COSE_KEY_Free((HCOSE_KEY)pkeyMessage);
}
- if (!_COSE_map_put(pCose, COSE_Header_ECDH_EPHEMERAL,
- pdup, COSE_UNPROTECT_ONLY, perr)) {
+ if (!_COSE_map_put(pCose, COSE_Header_ECDH_EPHEMERAL, pdup,
+ COSE_UNPROTECT_ONLY, perr)) {
CN_CBOR_FREE(pdup, context);
goto errorReturn;
}
@@ -411,7 +412,8 @@
switch (alg) {
case COSE_Algorithm_Direct:
- CHECK_CONDITION(pRecip->m_pkey != nullptr, COSE_ERR_INVALID_PARAMETER);
+ CHECK_CONDITION(
+ pRecip->m_pkey != nullptr, COSE_ERR_INVALID_PARAMETER);
cn = cn_cbor_mapget_int(pRecip->m_pkey->m_cborKey, -1);
CHECK_CONDITION((cn != nullptr) && (cn->type == CN_CBOR_BYTES),
COSE_ERR_INVALID_PARAMETER);
@@ -517,7 +519,7 @@
if (pcose->m_recipientFirst != nullptr) {
// If there is a recipient - ask it for the key
CHECK_CONDITION(cbitKeyX != 0, COSE_ERR_INVALID_PARAMETER);
- pbKeyX = (byte*) COSE_CALLOC(cbitKeyX / 8, 1, context);
+ pbKeyX = (byte *)COSE_CALLOC(cbitKeyX / 8, 1, context);
CHECK_CONDITION(pbKeyX != nullptr, COSE_ERR_OUT_OF_MEMORY);
cose_errback error = {COSE_ERR_NONE};
cose_error errorFound = COSE_ERR_NONE;
@@ -548,7 +550,7 @@
#ifdef USE_AES_KW_128
case COSE_Algorithm_AES_KW_128:
if (pbKeyX != nullptr) {
- size_t x = (int) (cbitKeyOut / 8);
+ size_t x = (int)(cbitKeyOut / 8);
if (!AES_KW_Decrypt((COSE_Enveloped *)pcose, pbKeyX, cbitKeyX,
cnBody->v.bytes, cnBody->length, pbKeyOut, &x, perr)) {
goto errorReturn;
@@ -627,8 +629,7 @@
case COSE_Algorithm_Direct_HKDF_HMAC_SHA_256:
if (!HKDF_X(&pcose->m_message, true, false, false, false, algIn,
pRecip->m_pkey, pRecip->m_pkeyStatic, pbKeyOut, cbitKeyOut,
- 256,
- CBOR_CONTEXT_PARAM_COMMA perr)) {
+ 256, CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
break;
@@ -638,8 +639,7 @@
case COSE_Algorithm_Direct_HKDF_HMAC_SHA_512:
if (!HKDF_X(&pcose->m_message, true, false, false, false, algIn,
pRecip->m_pkey, pRecip->m_pkeyStatic, pbKeyOut, cbitKeyOut,
- 512,
- CBOR_CONTEXT_PARAM_COMMA perr)) {
+ 512, CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
break;
@@ -649,8 +649,7 @@
case COSE_Algorithm_Direct_HKDF_AES_128:
if (!HKDF_X(&pcose->m_message, false, false, false, false, algIn,
pRecip->m_pkey, pRecip->m_pkeyStatic, pbKeyOut, cbitKeyOut,
- 128,
- CBOR_CONTEXT_PARAM_COMMA perr)) {
+ 128, CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
break;
@@ -659,8 +658,7 @@
#ifdef USE_Direct_HKDF_AES_256
case COSE_Algorithm_Direct_HKDF_AES_256:
if (!HKDF_X(&pcose->m_message, false, false, false, false, algIn,
- pRecip->m_pkey, nullptr, pbKeyOut, cbitKeyOut,
- 256,
+ pRecip->m_pkey, nullptr, pbKeyOut, cbitKeyOut, 256,
CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
@@ -680,8 +678,7 @@
#ifdef USE_ECDH_ES_HKDF_512
case COSE_Algorithm_ECDH_ES_HKDF_512:
if (!HKDF_X(&pcose->m_message, true, true, false, false, algIn,
- pRecip->m_pkey, nullptr, pbKeyOut, cbitKeyOut,
- 512,
+ pRecip->m_pkey, nullptr, pbKeyOut, cbitKeyOut, 512,
CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
@@ -692,8 +689,7 @@
case COSE_Algorithm_ECDH_SS_HKDF_256:
if (!HKDF_X(&pcose->m_message, true, true, true, false, algIn,
pRecip->m_pkey, pRecip->m_pkeyStatic, pbKeyOut, cbitKeyOut,
- 256,
- CBOR_CONTEXT_PARAM_COMMA perr)) {
+ 256, CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
break;
@@ -703,8 +699,7 @@
case COSE_Algorithm_ECDH_SS_HKDF_512:
if (!HKDF_X(&pcose->m_message, true, true, true, false, algIn,
pRecip->m_pkey, pRecip->m_pkeyStatic, pbKeyOut, cbitKeyOut,
- 512,
- CBOR_CONTEXT_PARAM_COMMA perr)) {
+ 512, CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
break;
@@ -713,8 +708,7 @@
#ifdef USE_ECDH_ES_A128KW
case COSE_Algorithm_ECDH_ES_A128KW:
if (!HKDF_X(&pcose->m_message, true, true, false, false,
- COSE_Algorithm_AES_KW_128, pRecip->m_pkey,
- nullptr, rgbKey,
+ COSE_Algorithm_AES_KW_128, pRecip->m_pkey, nullptr, rgbKey,
128, 256, CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
@@ -730,8 +724,7 @@
#ifdef USE_ECDH_ES_A192KW
case COSE_Algorithm_ECDH_ES_A192KW:
if (!HKDF_X(&pcose->m_message, true, true, false, false,
- COSE_Algorithm_AES_KW_192, pRecip->m_pkey,
- nullptr, rgbKey,
+ COSE_Algorithm_AES_KW_192, pRecip->m_pkey, nullptr, rgbKey,
192, 256, CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
@@ -747,8 +740,7 @@
#ifdef USE_ECDH_ES_A256KW
case COSE_Algorithm_ECDH_ES_A256KW:
if (!HKDF_X(&pcose->m_message, true, true, false, false,
- COSE_Algorithm_AES_KW_256, pRecip->m_pkey,
- nullptr, rgbKey,
+ COSE_Algorithm_AES_KW_256, pRecip->m_pkey, nullptr, rgbKey,
256, 256, CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
@@ -764,8 +756,9 @@
#ifdef USE_ECDH_SS_A128KW
case COSE_Algorithm_ECDH_SS_A128KW:
if (!HKDF_X(&pcose->m_message, true, true, true, false,
- COSE_Algorithm_AES_KW_128, pRecip->m_pkey, pRecip->m_pkeyStatic, rgbKey,
- 128, 256, CBOR_CONTEXT_PARAM_COMMA perr)) {
+ COSE_Algorithm_AES_KW_128, pRecip->m_pkey,
+ pRecip->m_pkeyStatic, rgbKey, 128, 256,
+ CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
@@ -781,8 +774,8 @@
case COSE_Algorithm_ECDH_SS_A192KW:
if (!HKDF_X(&pcose->m_message, true, true, true, false,
COSE_Algorithm_AES_KW_192, pRecip->m_pkey,
- pRecip->m_pkeyStatic, rgbKey,
- 192, 256, CBOR_CONTEXT_PARAM_COMMA perr)) {
+ pRecip->m_pkeyStatic, rgbKey, 192, 256,
+ CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
@@ -798,8 +791,8 @@
case COSE_Algorithm_ECDH_SS_A256KW:
if (!HKDF_X(&pcose->m_message, true, true, true, false,
COSE_Algorithm_AES_KW_256, pRecip->m_pkey,
- pRecip->m_pkeyStatic, rgbKey,
- 256, 256, CBOR_CONTEXT_PARAM_COMMA perr)) {
+ pRecip->m_pkeyStatic, rgbKey, 256, 256,
+ CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
@@ -1061,7 +1054,8 @@
#ifdef USE_AES_KW_128
case COSE_Algorithm_AES_KW_128:
if (pRecipient->m_pkey != nullptr) {
- cn_cbor *pK = cn_cbor_mapget_int(pRecipient->m_pkey->m_cborKey, -1);
+ cn_cbor *pK =
+ cn_cbor_mapget_int(pRecipient->m_pkey->m_cborKey, -1);
CHECK_CONDITION(pK != nullptr, COSE_ERR_INVALID_PARAMETER);
if (!AES_KW_Encrypt(pRecipient, pK->v.bytes,
(int)pK->length * 8, pbContent, (int)cbContent, perr)) {
@@ -1080,7 +1074,8 @@
#ifdef USE_AES_KW_192
case COSE_Algorithm_AES_KW_192:
if (pRecipient->m_pkey != nullptr) {
- cn_cbor *pK = cn_cbor_mapget_int(pRecipient->m_pkey->m_cborKey, -1);
+ cn_cbor *pK =
+ cn_cbor_mapget_int(pRecipient->m_pkey->m_cborKey, -1);
CHECK_CONDITION(pK != nullptr, COSE_ERR_INVALID_PARAMETER);
if (!AES_KW_Encrypt(pRecipient, pK->v.bytes,
(int)pK->length * 8, pbContent, (int)cbContent, perr)) {
@@ -1099,7 +1094,8 @@
#ifdef USE_AES_KW_256
case COSE_Algorithm_AES_KW_256:
if (pRecipient->m_pkey != nullptr) {
- cn_cbor *pK = cn_cbor_mapget_int(pRecipient->m_pkey->m_cborKey, -1);
+ cn_cbor *pK =
+ cn_cbor_mapget_int(pRecipient->m_pkey->m_cborKey, -1);
CHECK_CONDITION(pK != nullptr, COSE_ERR_INVALID_PARAMETER);
if (!AES_KW_Encrypt(pRecipient, pK->v.bytes,
(int)pK->length * 8, pbContent, (int)cbContent, perr)) {
@@ -1118,8 +1114,9 @@
#ifdef USE_ECDH_ES_A128KW
case COSE_Algorithm_ECDH_ES_A128KW:
if (!HKDF_X(&pRecipient->m_encrypt.m_message, true, true, false,
- true, COSE_Algorithm_AES_KW_128, nullptr, pRecipient->m_pkey,
- rgbKey, 128, 256, CBOR_CONTEXT_PARAM_COMMA perr)) {
+ true, COSE_Algorithm_AES_KW_128, nullptr,
+ pRecipient->m_pkey, rgbKey, 128, 256,
+ CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
if (!AES_KW_Encrypt(
@@ -1132,8 +1129,9 @@
#ifdef USE_ECDH_ES_A192KW
case COSE_Algorithm_ECDH_ES_A192KW:
if (!HKDF_X(&pRecipient->m_encrypt.m_message, true, true, false,
- true, COSE_Algorithm_AES_KW_192, nullptr, pRecipient->m_pkey,
- rgbKey, 192, 256, CBOR_CONTEXT_PARAM_COMMA perr)) {
+ true, COSE_Algorithm_AES_KW_192, nullptr,
+ pRecipient->m_pkey, rgbKey, 192, 256,
+ CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
if (!AES_KW_Encrypt(
@@ -1146,8 +1144,9 @@
#ifdef USE_ECDH_ES_A256KW
case COSE_Algorithm_ECDH_ES_A256KW:
if (!HKDF_X(&pRecipient->m_encrypt.m_message, true, true, false,
- true, COSE_Algorithm_AES_KW_256, nullptr, pRecipient->m_pkey,
- rgbKey, 256, 256, CBOR_CONTEXT_PARAM_COMMA perr)) {
+ true, COSE_Algorithm_AES_KW_256, nullptr,
+ pRecipient->m_pkey, rgbKey, 256, 256,
+ CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
if (!AES_KW_Encrypt(
@@ -1215,8 +1214,8 @@
#if INCLUDE_COUNTERSIGNATURE
if (pRecipient->m_encrypt.m_message.m_counterSigners != nullptr) {
- if (!_COSE_CounterSign_Sign(
- &pRecipient->m_encrypt.m_message, CBOR_CONTEXT_PARAM_COMMA perr)) {
+ if (!_COSE_CounterSign_Sign(&pRecipient->m_encrypt.m_message,
+ CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
}
@@ -1224,14 +1223,13 @@
#if INCLUDE_COUNTERSIGNATURE1
if (pRecipient->m_encrypt.m_message.m_counterSign1 != NULL) {
- if (!_COSE_CounterSign1_Sign(
- &pRecipient->m_encrypt.m_message, CBOR_CONTEXT_PARAM_COMMA perr)) {
+ if (!_COSE_CounterSign1_Sign(&pRecipient->m_encrypt.m_message,
+ CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
}
#endif
-
// Figure out the clean up
fRet = true;
@@ -1262,7 +1260,7 @@
_COSE_encode_protected(&pRecipient->m_encrypt.m_message, perr);
- pb = (byte*) COSE_CALLOC(cbitKeySize / 8, 1, context);
+ pb = (byte *)COSE_CALLOC(cbitKeySize / 8, 1, context);
CHECK_CONDITION(pb != nullptr, COSE_ERR_OUT_OF_MEMORY);
switch (alg) {
@@ -1280,8 +1278,8 @@
#ifdef USE_Direct_HKDF_HMAC_SHA_256
case COSE_Algorithm_Direct_HKDF_HMAC_SHA_256:
if (!HKDF_X(&pRecipient->m_encrypt.m_message, true, false, false,
- true, algIn, pRecipient->m_pkey, nullptr, pb, cbitKeySize, 256,
- CBOR_CONTEXT_PARAM_COMMA perr)) {
+ true, algIn, pRecipient->m_pkey, nullptr, pb, cbitKeySize,
+ 256, CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
break;
@@ -1290,8 +1288,8 @@
#ifdef USE_Direct_HKDF_HMAC_SHA_512
case COSE_Algorithm_Direct_HKDF_HMAC_SHA_512:
if (!HKDF_X(&pRecipient->m_encrypt.m_message, true, false, false,
- true, algIn, pRecipient->m_pkey, nullptr, pb, cbitKeySize, 512,
- CBOR_CONTEXT_PARAM_COMMA perr)) {
+ true, algIn, pRecipient->m_pkey, nullptr, pb, cbitKeySize,
+ 512, CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
break;
@@ -1300,8 +1298,8 @@
#ifdef USE_Direct_HKDF_AES_128
case COSE_Algorithm_Direct_HKDF_AES_128:
if (!HKDF_X(&pRecipient->m_encrypt.m_message, false, false, false,
- true, algIn, pRecipient->m_pkey, nullptr, pb, cbitKeySize, 128,
- CBOR_CONTEXT_PARAM_COMMA perr)) {
+ true, algIn, pRecipient->m_pkey, nullptr, pb, cbitKeySize,
+ 128, CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
break;
@@ -1310,8 +1308,8 @@
#ifdef USE_Direct_HKDF_AES_256
case COSE_Algorithm_Direct_HKDF_AES_256:
if (!HKDF_X(&pRecipient->m_encrypt.m_message, false, false, false,
- true, algIn, pRecipient->m_pkey, nullptr, pb, cbitKeySize, 256,
- CBOR_CONTEXT_PARAM_COMMA perr)) {
+ true, algIn, pRecipient->m_pkey, nullptr, pb, cbitKeySize,
+ 256, CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
break;
@@ -1320,8 +1318,8 @@
#ifdef USE_ECDH_ES_HKDF_256
case COSE_Algorithm_ECDH_ES_HKDF_256:
if (!HKDF_X(&pRecipient->m_encrypt.m_message, true, true, false,
- true, algIn, nullptr, pRecipient->m_pkey, pb, cbitKeySize, 256,
- CBOR_CONTEXT_PARAM_COMMA perr)) {
+ true, algIn, nullptr, pRecipient->m_pkey, pb, cbitKeySize,
+ 256, CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
break;
@@ -1330,8 +1328,8 @@
#ifdef USE_ECDH_ES_HKDF_512
case COSE_Algorithm_ECDH_ES_HKDF_512:
if (!HKDF_X(&pRecipient->m_encrypt.m_message, true, true, false,
- true, algIn, nullptr, pRecipient->m_pkey, pb, cbitKeySize, 512,
- CBOR_CONTEXT_PARAM_COMMA perr)) {
+ true, algIn, nullptr, pRecipient->m_pkey, pb, cbitKeySize,
+ 512, CBOR_CONTEXT_PARAM_COMMA perr)) {
goto errorReturn;
}
break;
@@ -1525,8 +1523,7 @@
cn_cbor_context *context = &p->m_encrypt.m_message.m_allocContext;
#endif
- hkey = COSE_KEY_FromCbor(
- (cn_cbor *)pKey, CBOR_CONTEXT_PARAM_COMMA perr);
+ hkey = COSE_KEY_FromCbor((cn_cbor *)pKey, CBOR_CONTEXT_PARAM_COMMA perr);
CHECK_CONDITION(hkey != nullptr, COSE_ERR_OUT_OF_MEMORY);
if (!COSE_Recipient_SetKey2(h, hkey, perr)) {
goto errorReturn;
@@ -1545,7 +1542,7 @@
p = (COSE_RecipientInfo *)h;
if (p->m_pkey != nullptr) {
- COSE_KEY_Free((HCOSE_KEY) p->m_pkey);
+ COSE_KEY_Free((HCOSE_KEY)p->m_pkey);
}
p->m_pkey = (COSE_KEY *)hKey;
@@ -1594,7 +1591,7 @@
CHECK_CONDITION(IsValidRecipientHandle(h), COSE_ERR_INVALID_HANDLE);
CHECK_CONDITION(pKey != nullptr, COSE_ERR_INVALID_PARAMETER);
- #ifdef USE_CBOR_CONTEXT
+#ifdef USE_CBOR_CONTEXT
COSE_RecipientInfo *pRecipient = (COSE_RecipientInfo *)h;
cn_cbor_context *context = &pRecipient->m_encrypt.m_message.m_allocContext;
#endif
@@ -1699,7 +1696,7 @@
case COSE_DONT_SEND:
break;
-
+
default:
FAIL_CONDITION(COSE_ERR_INVALID_PARAMETER);
}
@@ -2094,7 +2091,6 @@
context = &pEncrypt->m_message.m_allocContext;
#endif // USE_CBOR_CONTEXT
-
pRecipients = _COSE_arrayget_int(&pEncrypt->m_message, INDEX_RECIPIENTS);
if (pRecipients == nullptr) {
pRecipients =
diff --git a/src/Sign.cpp b/src/Sign.cpp
index e8697e2..739dd44 100644
--- a/src/Sign.cpp
+++ b/src/Sign.cpp
@@ -49,7 +49,7 @@
{
if (false) {
errorReturn:
- return nullptr;
+ return nullptr;
}
CHECK_CONDITION(flags == COSE_INIT_FLAGS_NONE, COSE_ERR_INVALID_PARAMETER);
COSE_SignMessage *pobj =
@@ -295,7 +295,8 @@
#endif
pcborBody = _COSE_arrayget_int(&pMessage->m_message, INDEX_BODY);
- CHECK_CONDITION((pcborBody != nullptr) && (pcborBody->type == CN_CBOR_BYTES),
+ CHECK_CONDITION(
+ (pcborBody != nullptr) && (pcborBody->type == CN_CBOR_BYTES),
COSE_ERR_INVALID_PARAMETER);
pcborProtected = _COSE_encode_protected(&pMessage->m_message, perr);
@@ -353,7 +354,8 @@
COSE_ERR_INVALID_PARAMETER);
cnProtected = _COSE_arrayget_int(&pSign->m_message, INDEX_PROTECTED);
- CHECK_CONDITION(cnProtected != nullptr && cnProtected->type == CN_CBOR_BYTES,
+ CHECK_CONDITION(
+ cnProtected != nullptr && cnProtected->type == CN_CBOR_BYTES,
COSE_ERR_INVALID_PARAMETER);
f = _COSE_Signer_validate(
@@ -384,7 +386,6 @@
pSign = (COSE_SignMessage *)hSign;
pSigner = (COSE_SignerInfo *)hSigner;
-
#ifdef USE_CBOR_CONTEXT
context = &pSign->m_message.m_allocContext;
#endif // USE_CBOR_CONTEXT
diff --git a/src/Sign1.cpp b/src/Sign1.cpp
index 77a3595..efd7775 100644
--- a/src/Sign1.cpp
+++ b/src/Sign1.cpp
@@ -50,7 +50,7 @@
{
if (false) {
errorReturn:
- return nullptr;
+ return nullptr;
}
CHECK_CONDITION(flags == COSE_INIT_FLAGS_NONE, COSE_ERR_INVALID_PARAMETER);
@@ -307,7 +307,7 @@
if (pcose != nullptr) {
COSE_KEY_Free((HCOSE_KEY)pcose);
}
- return false;
+ return false;
}
CHECK_CONDITION(IsValidSign1Handle(hSign), COSE_ERR_INVALID_HANDLE);
@@ -315,18 +315,19 @@
COSE_Sign1Message *pSign = (COSE_Sign1Message *)hSign;
- const cn_cbor* cnContent =
+ const cn_cbor *cnContent =
_COSE_arrayget_int(&pSign->m_message, INDEX_BODY);
CHECK_CONDITION(cnContent != nullptr && cnContent->type == CN_CBOR_BYTES,
COSE_ERR_INVALID_PARAMETER);
- const cn_cbor* cnProtected = _COSE_arrayget_int(
- &pSign->m_message, INDEX_PROTECTED);
- CHECK_CONDITION(cnProtected != nullptr && cnProtected->type == CN_CBOR_BYTES,
+ const cn_cbor *cnProtected =
+ _COSE_arrayget_int(&pSign->m_message, INDEX_PROTECTED);
+ CHECK_CONDITION(
+ cnProtected != nullptr && cnProtected->type == CN_CBOR_BYTES,
COSE_ERR_INVALID_PARAMETER);
pcose = (COSE_KEY *)hKey;
-
+
f = _COSE_Signer1_validate(pSign, pcose, perr);
return f;
@@ -343,7 +344,7 @@
CHECK_CONDITION(IsValidSign1Handle(hSign), COSE_ERR_INVALID_HANDLE);
CHECK_CONDITION(pKey != NULL, COSE_ERR_INVALID_PARAMETER);
-
+
#ifdef USE_CBOR_CONTEXT
COSE_Sign1Message *pSign = (COSE_Sign1Message *)hSign;
@@ -424,8 +425,8 @@
CHECK_CONDITION(cn2 != nullptr, COSE_ERR_INVALID_PARAMETER);
if ((cn2->length == 1) && (cn2->v.bytes[0] == 0xa0)) {
- cn =
- cn_cbor_data_create(nullptr, 0, CBOR_CONTEXT_PARAM_COMMA & cbor_error);
+ cn = cn_cbor_data_create(
+ nullptr, 0, CBOR_CONTEXT_PARAM_COMMA & cbor_error);
}
else {
cn = cn_cbor_data_create(cn2->v.bytes, (int)cn2->length,
diff --git a/src/SignerInfo.cpp b/src/SignerInfo.cpp
index 0874bc9..e1692a9 100644
--- a/src/SignerInfo.cpp
+++ b/src/SignerInfo.cpp
@@ -174,8 +174,8 @@
cn = nullptr;
if (pcborProtected->length == 1 && (pcborProtected->v.bytes[0] == 0xa0)) {
- cn =
- cn_cbor_data_create(nullptr, 0, CBOR_CONTEXT_PARAM_COMMA & cbor_error);
+ cn = cn_cbor_data_create(
+ nullptr, 0, CBOR_CONTEXT_PARAM_COMMA & cbor_error);
}
else {
cn = cn_cbor_data_create(pcborProtected->v.bytes,
@@ -188,8 +188,8 @@
if ((pcborProtectedSign->length == 1) &&
(pcborProtectedSign->v.bytes[0] == 0xa0)) {
- cn =
- cn_cbor_data_create(nullptr, 0, CBOR_CONTEXT_PARAM_COMMA & cbor_error);
+ cn = cn_cbor_data_create(
+ nullptr, 0, CBOR_CONTEXT_PARAM_COMMA & cbor_error);
}
else {
cn = cn_cbor_data_create(pcborProtectedSign->v.bytes,
@@ -387,19 +387,19 @@
if (cose != nullptr) {
COSE_KEY_Free(cose);
}
- return fRet;
+ return fRet;
}
CHECK_CONDITION(pKey != nullptr, COSE_ERR_INVALID_PARAMETER);
CHECK_CONDITION(IsValidSignerHandle(h), COSE_ERR_INVALID_HANDLE);
-
+
#ifdef USE_CBOR_CONTEXT
COSE_SignerInfo *p = (COSE_SignerInfo *)h;
cn_cbor_context *context = &p->m_message.m_allocContext;
#endif
cose = COSE_KEY_FromCbor((cn_cbor *)pKey, CBOR_CONTEXT_PARAM_COMMA perr);
-
+
CHECK_CONDITION(cose != nullptr, COSE_ERR_OUT_OF_MEMORY);
fRet = COSE_Signer_SetKey2(h, cose, perr);
diff --git a/src/bcrypt.cpp b/src/bcrypt.cpp
index 6739751..067b60d 100644
--- a/src/bcrypt.cpp
+++ b/src/bcrypt.cpp
@@ -45,8 +45,8 @@
pHdr->cbKeyData = KSize / 8;
memcpy(&pHdr[1], pcose->pbKey, pcose->cbKey);
- err = BCryptImportKey(hAlg, nullptr, BCRYPT_KEY_DATA_BLOB, &hKey, nullptr, 0,
- pHdr, (sizeof(*pHdr) + KSize / 8), 0);
+ err = BCryptImportKey(hAlg, nullptr, BCRYPT_KEY_DATA_BLOB, &hKey, nullptr,
+ 0, pHdr, (sizeof(*pHdr) + KSize / 8), 0);
if (err != 0)
goto error;
diff --git a/src/cbor.cpp b/src/cbor.cpp
index 25866b5..4499d6d 100644
--- a/src/cbor.cpp
+++ b/src/cbor.cpp
@@ -144,16 +144,16 @@
cn_cbor *cn_cbor_clone(const cn_cbor *pIn,
CBOR_CONTEXT_COMMA cn_cbor_errback *pcn_cbor_error)
{
- cn_cbor * pOut = nullptr;
+ cn_cbor *pOut = nullptr;
char *sz;
unsigned char *pb;
cn_cbor *pTemp;
cn_cbor *pLast;
int count;
-
+
switch (pIn->type) {
case CN_CBOR_TEXT:
- sz = (char*)( CN_CBOR_CALLOC(pIn->length + 1, 1, context));
+ sz = (char *)(CN_CBOR_CALLOC(pIn->length + 1, 1, context));
if (sz == nullptr) {
return nullptr;
}
diff --git a/src/cose_int.h b/src/cose_int.h
index 3cb2f4f..5209cc9 100644
--- a/src/cose_int.h
+++ b/src/cose_int.h
@@ -365,7 +365,7 @@
{ \
if (!(condition)) { \
DO_ASSERT; \
- if (perr != nullptr) { \
+ if (perr != nullptr) { \
perr->err = error; \
} \
goto errorReturn; \
@@ -375,7 +375,7 @@
{ \
if ((condition)) { \
DO_ASSERT; \
- if (perr != nullptr) { \
+ if (perr != nullptr) { \
perr->err = error; \
} \
goto errorReturn; \
@@ -384,7 +384,7 @@
#define FAIL_CONDITION(error) \
{ \
DO_ASSERT; \
- if (perr != nullptr) { \
+ if (perr != nullptr) { \
perr->err = error; \
} \
goto errorReturn; \
@@ -393,7 +393,7 @@
{ \
if (!(condition)) { \
DO_ASSERT; \
- if (perr != nullptr) { \
+ if (perr != nullptr) { \
perr->err = _MapFromCBOR(error); \
} \
goto errorReturn; \
diff --git a/src/mbedtls.cpp b/src/mbedtls.cpp
index b2d7c90..4294e86 100644
--- a/src/mbedtls.cpp
+++ b/src/mbedtls.cpp
@@ -50,7 +50,8 @@
mbedtls_ccm_init(&ctx);
// Setup the IV/Nonce and put it into the message
- pIV = _COSE_map_get_int(&pcose->m_message, COSE_Header_IV, COSE_BOTH, nullptr);
+ pIV = _COSE_map_get_int(
+ &pcose->m_message, COSE_Header_IV, COSE_BOTH, nullptr);
if ((pIV == nullptr) || (pIV->type != CN_CBOR_BYTES)) {
if (perr != nullptr) {
perr->err = COSE_ERR_INVALID_PARAMETER;
@@ -121,7 +122,7 @@
cbor_iv =
_COSE_map_get_int(&pcose->m_message, COSE_Header_IV, COSE_BOTH, perr);
if (cbor_iv == nullptr) {
- pbIV = (byte *) COSE_CALLOC(NSize, 1, context);
+ pbIV = (byte *)COSE_CALLOC(NSize, 1, context);
CHECK_CONDITION(pbIV != nullptr, COSE_ERR_OUT_OF_MEMORY);
rand_bytes(pbIV, NSize);
memcpy(rgbIV, pbIV, NSize);
@@ -160,8 +161,8 @@
&rgbOut[pcose->cbContent], TSize),
COSE_ERR_CRYPTO_FAIL);
- cnTmp = cn_cbor_data_create2(
- rgbOut, (int)pcose->cbContent + TSize, 0, CBOR_CONTEXT_PARAM_COMMA nullptr);
+ cnTmp = cn_cbor_data_create2(rgbOut, (int)pcose->cbContent + TSize, 0,
+ CBOR_CONTEXT_PARAM_COMMA nullptr);
CHECK_CONDITION(cnTmp != nullptr, COSE_ERR_CBOR);
rgbOut = nullptr;
@@ -217,7 +218,8 @@
// Setup the IV/Nonce and put it into the message
- pIV = _COSE_map_get_int(&pcose->m_message, COSE_Header_IV, COSE_BOTH, nullptr);
+ pIV = _COSE_map_get_int(
+ &pcose->m_message, COSE_Header_IV, COSE_BOTH, nullptr);
if ((pIV == nullptr) || (pIV->type != CN_CBOR_BYTES)) {
if (perr != nullptr) {
perr->err = COSE_ERR_INVALID_PARAMETER;
@@ -324,7 +326,7 @@
cbor_iv =
_COSE_map_get_int(&pcose->m_message, COSE_Header_IV, COSE_BOTH, perr);
if (cbor_iv == nullptr) {
- pbIV = (byte*) COSE_CALLOC(96, 1, context);
+ pbIV = (byte *)COSE_CALLOC(96, 1, context);
CHECK_CONDITION(pbIV != nullptr, COSE_ERR_OUT_OF_MEMORY);
rand_bytes(pbIV, 96 / 8);
memcpy(rgbIV, pbIV, 96 / 8);
@@ -378,8 +380,8 @@
mbedtls_gcm_finish(&ctx, &rgbOut[pcose->cbContent], 128 / 8),
COSE_ERR_CRYPTO_FAIL);
- cn_cbor *cnTmp = cn_cbor_data_create2(
- rgbOut, (int)pcose->cbContent + 128 / 8, 0, CBOR_CONTEXT_PARAM_COMMA nullptr);
+ cn_cbor *cnTmp = cn_cbor_data_create2(rgbOut,
+ (int)pcose->cbContent + 128 / 8, 0, CBOR_CONTEXT_PARAM_COMMA nullptr);
CHECK_CONDITION(cnTmp != nullptr, COSE_ERR_CBOR);
rgbOut = nullptr;
CHECK_CONDITION(_COSE_array_replace(&pcose->m_message, cnTmp, INDEX_BODY,
@@ -387,7 +389,7 @@
COSE_ERR_CBOR);
mbedtls_gcm_free(&ctx);
-
+
if (pbIV != nullptr) {
COSE_FREE(pbIV, context);
}
@@ -561,7 +563,7 @@
info = mbedtls_md_info_from_string(md_name);
mbedtls_md_setup(&contx, info, 1);
- rgbOut = (byte *) COSE_CALLOC(mbedtls_md_get_size(info), 1, context);
+ rgbOut = (byte *)COSE_CALLOC(mbedtls_md_get_size(info), 1, context);
CHECK_CONDITION(rgbOut != nullptr, COSE_ERR_OUT_OF_MEMORY);
CHECK_CONDITION(
@@ -633,7 +635,7 @@
mbedtls_md_setup(&contx, info, 1);
cbOut = mbedtls_md_get_size(info);
- rgbOut = (byte*) COSE_CALLOC(cbOut, 1, context);
+ rgbOut = (byte *)COSE_CALLOC(cbOut, 1, context);
CHECK_CONDITION(rgbOut != nullptr, COSE_ERR_OUT_OF_MEMORY);
CHECK_CONDITION(
@@ -685,8 +687,8 @@
}
p = cn_cbor_mapget_int(pKey->m_cborKey, COSE_Key_EC_Curve);
- CHECK_CONDITION(
- (p != nullptr) && (p->type == CN_CBOR_UINT), COSE_ERR_INVALID_PARAMETER);
+ CHECK_CONDITION((p != nullptr) && (p->type == CN_CBOR_UINT),
+ COSE_ERR_INVALID_PARAMETER);
switch (p->v.uint) {
case 1: // P-256
@@ -709,8 +711,8 @@
cbGroup = (int)(keypair->grp.nbits + 7) / 8;
p = cn_cbor_mapget_int(pKey->m_cborKey, COSE_Key_EC_X);
- CHECK_CONDITION(
- (p != nullptr) && (p->type == CN_CBOR_BYTES), COSE_ERR_INVALID_PARAMETER);
+ CHECK_CONDITION((p != nullptr) && (p->type == CN_CBOR_BYTES),
+ COSE_ERR_INVALID_PARAMETER);
CHECK_CONDITION(p->length == cbGroup, COSE_ERR_INVALID_PARAMETER);
memcpy(rgbKey + 1, p->v.str, p->length);
@@ -820,7 +822,7 @@
cbR = (keypair.grp.nbits + 7) / 8;
- pbSig = (byte *) COSE_CALLOC(cbR, 2, context);
+ pbSig = (byte *)COSE_CALLOC(cbR, 2, context);
CHECK_CONDITION(pbSig != nullptr, COSE_ERR_OUT_OF_MEMORY);
CHECK_CONDITION(
@@ -832,8 +834,8 @@
pbSig, cbR * 2, CBOR_CONTEXT_PARAM_COMMA & cbor_error);
CHECK_CONDITION_CBOR(p != nullptr, cbor_error);
- CHECK_CONDITION(
- _COSE_array_replace(pSigner, p, index, CBOR_CONTEXT_PARAM_COMMA nullptr),
+ CHECK_CONDITION(_COSE_array_replace(
+ pSigner, p, index, CBOR_CONTEXT_PARAM_COMMA nullptr),
COSE_ERR_CBOR);
p = nullptr;
@@ -1155,8 +1157,8 @@
}
p = cn_cbor_mapget_int(pKeyPublic->m_cborKey, COSE_Key_EC_Curve);
- CHECK_CONDITION(
- (p != nullptr) && (p->type == CN_CBOR_UINT), COSE_ERR_INVALID_PARAMETER);
+ CHECK_CONDITION((p != nullptr) && (p->type == CN_CBOR_UINT),
+ COSE_ERR_INVALID_PARAMETER);
switch (p->v.uint) {
case 1: // P-256
@@ -1220,7 +1222,7 @@
cbor_error);
p = nullptr;
- pbsecret = (byte *) COSE_CALLOC(cbSize, 1, context);
+ pbsecret = (byte *)COSE_CALLOC(cbSize, 1, context);
CHECK_CONDITION(pbsecret != nullptr, COSE_ERR_OUT_OF_MEMORY);
memcpy(pbsecret, buff + 1, cbSize);
@@ -1233,7 +1235,7 @@
cbor_error);
p = nullptr;
- pbsecret = (byte *) COSE_CALLOC(cbSize, 1, context);
+ pbsecret = (byte *)COSE_CALLOC(cbSize, 1, context);
CHECK_CONDITION(pbsecret != nullptr, COSE_ERR_OUT_OF_MEMORY);
memcpy(pbsecret, buff + 1 + cbSize, cbSize);
@@ -1254,7 +1256,8 @@
cbor_error);
p = nullptr;
- COSE_KEY *coseKey = (COSE_KEY*) COSE_KEY_FromCbor(pkey, CBOR_CONTEXT_PARAM_COMMA perr);
+ COSE_KEY *coseKey =
+ (COSE_KEY *)COSE_KEY_FromCbor(pkey, CBOR_CONTEXT_PARAM_COMMA perr);
if (coseKey == nullptr) {
goto errorReturn;
}
@@ -1272,12 +1275,12 @@
p = nullptr;
}
- CHECK_CONDITION0(
- mbedtls_ecdh_compute_shared(&group, &z, &keypair.Q, &d, nullptr, nullptr),
+ CHECK_CONDITION0(mbedtls_ecdh_compute_shared(
+ &group, &z, &keypair.Q, &d, nullptr, nullptr),
COSE_ERR_CRYPTO_FAIL);
cbsecret = cbGroup;
- pbsecret = (byte *) COSE_CALLOC(cbsecret, 1, context);
+ pbsecret = (byte *)COSE_CALLOC(cbsecret, 1, context);
CHECK_CONDITION(pbsecret != nullptr, COSE_ERR_OUT_OF_MEMORY);
CHECK_CONDITION0(
diff --git a/src/openssl.cpp b/src/openssl.cpp
index bc137d7..b9e54e0 100644
--- a/src/openssl.cpp
+++ b/src/openssl.cpp
@@ -28,7 +28,7 @@
HMAC_CTX *HMAC_CTX_new()
{
- HMAC_CTX *foo = (HMAC_CTX *) malloc(sizeof(HMAC_CTX));
+ HMAC_CTX *foo = (HMAC_CTX *)malloc(sizeof(HMAC_CTX));
if (foo != nullptr) {
HMAC_CTX_init(foo);
}
@@ -89,7 +89,8 @@
// Setup the IV/Nonce and put it into the message
- pIV = _COSE_map_get_int(&pcose->m_message, COSE_Header_IV, COSE_BOTH, nullptr);
+ pIV = _COSE_map_get_int(
+ &pcose->m_message, COSE_Header_IV, COSE_BOTH, nullptr);
if ((pIV == nullptr) || (pIV->type != CN_CBOR_BYTES)) {
if (perr != nullptr) {
perr->err = COSE_ERR_INVALID_PARAMETER;
@@ -215,7 +216,7 @@
cbor_iv =
_COSE_map_get_int(&pcose->m_message, COSE_Header_IV, COSE_BOTH, perr);
if (cbor_iv == nullptr) {
- pbIV = (byte *) COSE_CALLOC(NSize, 1, context);
+ pbIV = (byte *)COSE_CALLOC(NSize, 1, context);
CHECK_CONDITION(pbIV != nullptr, COSE_ERR_OUT_OF_MEMORY);
rand_bytes(pbIV, NSize);
memcpy(rgbIV, pbIV, NSize);
@@ -248,11 +249,12 @@
COSE_ERR_CRYPTO_FAIL);
// CHECK_CONDITION(EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_CCM_SET_IVLEN, NSize,
// 0), COSE_ERR_CRYPTO_FAIL);
- CHECK_CONDITION(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_TAG, TSize, nullptr),
+ CHECK_CONDITION(
+ EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_TAG, TSize, nullptr),
COSE_ERR_CRYPTO_FAIL); // Say we are doing an 8 byte tag
- CHECK_CONDITION(
- EVP_EncryptInit_ex(ctx, 0, nullptr, pbKey, rgbIV), COSE_ERR_CRYPTO_FAIL);
+ CHECK_CONDITION(EVP_EncryptInit_ex(ctx, 0, nullptr, pbKey, rgbIV),
+ COSE_ERR_CRYPTO_FAIL);
CHECK_CONDITION(EVP_EncryptUpdate(ctx, 0, &cbOut, 0, (int)pcose->cbContent),
COSE_ERR_CRYPTO_FAIL);
@@ -275,8 +277,8 @@
&rgbOut[pcose->cbContent]),
COSE_ERR_CRYPTO_FAIL);
- cnTmp = cn_cbor_data_create2(
- rgbOut, (int)pcose->cbContent + TSize, 0, CBOR_CONTEXT_PARAM_COMMA nullptr);
+ cnTmp = cn_cbor_data_create2(rgbOut, (int)pcose->cbContent + TSize, 0,
+ CBOR_CONTEXT_PARAM_COMMA nullptr);
CHECK_CONDITION(cnTmp != nullptr, COSE_ERR_CBOR);
rgbOut = nullptr;
@@ -330,7 +332,8 @@
// Setup the IV/Nonce and put it into the message
- pIV = _COSE_map_get_int(&pcose->m_message, COSE_Header_IV, COSE_BOTH, nullptr);
+ pIV = _COSE_map_get_int(
+ &pcose->m_message, COSE_Header_IV, COSE_BOTH, nullptr);
if ((pIV == nullptr) || (pIV->type != CN_CBOR_BYTES)) {
if (perr != nullptr) {
perr->err = COSE_ERR_INVALID_PARAMETER;
@@ -461,7 +464,7 @@
cbor_iv =
_COSE_map_get_int(&pcose->m_message, COSE_Header_IV, COSE_BOTH, perr);
if (cbor_iv == nullptr) {
- pbIV = (byte *) COSE_CALLOC(96, 1, context);
+ pbIV = (byte *)COSE_CALLOC(96, 1, context);
CHECK_CONDITION(pbIV != nullptr, COSE_ERR_OUT_OF_MEMORY);
rand_bytes(pbIV, 96 / 8);
memcpy(rgbIV, pbIV, 96 / 8);
@@ -506,8 +509,8 @@
CHECK_CONDITION(EVP_EncryptInit_ex(ctx, cipher, nullptr, nullptr, nullptr),
COSE_ERR_CRYPTO_FAIL);
- CHECK_CONDITION(
- EVP_EncryptInit_ex(ctx, 0, nullptr, pbKey, rgbIV), COSE_ERR_CRYPTO_FAIL);
+ CHECK_CONDITION(EVP_EncryptInit_ex(ctx, 0, nullptr, pbKey, rgbIV),
+ COSE_ERR_CRYPTO_FAIL);
CHECK_CONDITION(
EVP_EncryptUpdate(ctx, nullptr, &outl, pbAuthData, (int)cbAuthData),
@@ -527,8 +530,8 @@
&rgbOut[pcose->cbContent]),
COSE_ERR_CRYPTO_FAIL);
- cn_cbor *cnTmp = cn_cbor_data_create2(
- rgbOut, (int)pcose->cbContent + 128 / 8, 0, CBOR_CONTEXT_PARAM_COMMA nullptr);
+ cn_cbor *cnTmp = cn_cbor_data_create2(rgbOut,
+ (int)pcose->cbContent + 128 / 8, 0, CBOR_CONTEXT_PARAM_COMMA nullptr);
CHECK_CONDITION(cnTmp != nullptr, COSE_ERR_CBOR);
rgbOut = nullptr;
CHECK_CONDITION(_COSE_array_replace(&pcose->m_message, cnTmp, INDEX_BODY,
@@ -566,7 +569,7 @@
ctx = EVP_CIPHER_CTX_new();
CHECK_CONDITION(nullptr != ctx, COSE_ERR_OUT_OF_MEMORY);
- rgbOut = (byte *) COSE_CALLOC(16, 1, context);
+ rgbOut = (byte *)COSE_CALLOC(16, 1, context);
CHECK_CONDITION(rgbOut != nullptr, COSE_ERR_OUT_OF_MEMORY);
switch (cbKey * 8) {
@@ -601,7 +604,8 @@
COSE_ERR_CRYPTO_FAIL);
}
- cn = cn_cbor_data_create2(rgbOut, TSize / 8, 0, CBOR_CONTEXT_PARAM_COMMA nullptr);
+ cn = cn_cbor_data_create2(
+ rgbOut, TSize / 8, 0, CBOR_CONTEXT_PARAM_COMMA nullptr);
CHECK_CONDITION(cn != nullptr, COSE_ERR_OUT_OF_MEMORY);
rgbOut = nullptr;
@@ -864,8 +868,8 @@
cnSalt = _COSE_map_get_int(pcose, COSE_Header_HKDF_salt, COSE_BOTH, perr);
if (cnSalt != nullptr) {
- CHECK_CONDITION(
- HMAC_Init_ex(ctx, cnSalt->v.bytes, (int)cnSalt->length, pmd, nullptr),
+ CHECK_CONDITION(HMAC_Init_ex(ctx, cnSalt->v.bytes, (int)cnSalt->length,
+ pmd, nullptr),
COSE_ERR_CRYPTO_FAIL);
}
else {
@@ -986,20 +990,21 @@
break;
}
- rgbOut = (byte *) COSE_CALLOC(EVP_MAX_MD_SIZE, 1, context);
+ rgbOut = (byte *)COSE_CALLOC(EVP_MAX_MD_SIZE, 1, context);
CHECK_CONDITION(rgbOut != nullptr, COSE_ERR_OUT_OF_MEMORY);
- CHECK_CONDITION(
- HMAC_Init_ex(ctx, pbKey, (int)cbKey, pmd, nullptr), COSE_ERR_CRYPTO_FAIL);
+ CHECK_CONDITION(HMAC_Init_ex(ctx, pbKey, (int)cbKey, pmd, nullptr),
+ COSE_ERR_CRYPTO_FAIL);
CHECK_CONDITION(
HMAC_Update(ctx, pbAuthData, cbAuthData), COSE_ERR_CRYPTO_FAIL);
CHECK_CONDITION(HMAC_Final(ctx, rgbOut, &cbOut), COSE_ERR_CRYPTO_FAIL);
-cbor = cn_cbor_data_create2(rgbOut, TSize / 8, 0, CBOR_CONTEXT_PARAM_COMMA nullptr);
+ cbor = cn_cbor_data_create2(
+ rgbOut, TSize / 8, 0, CBOR_CONTEXT_PARAM_COMMA nullptr);
CHECK_CONDITION(cbor != nullptr, COSE_ERR_OUT_OF_MEMORY);
- CHECK_CONDITION(_COSE_array_replace(&pcose->m_message, cbor,
- INDEX_MAC_TAG, CBOR_CONTEXT_PARAM_COMMA nullptr),
+ CHECK_CONDITION(_COSE_array_replace(&pcose->m_message, cbor, INDEX_MAC_TAG,
+ CBOR_CONTEXT_PARAM_COMMA nullptr),
COSE_ERR_CBOR);
HMAC_CTX_free(ctx);
@@ -1018,7 +1023,7 @@
HMAC_CTX *ctx = nullptr;
const EVP_MD *pmd = nullptr;
byte *rgbOut = nullptr;
- unsigned int cbOut = 0 ;
+ unsigned int cbOut = 0;
bool f = false;
#ifdef USE_CBOR_CONTEXT
cn_cbor_context *context = &pcose->m_message.m_allocContext;
@@ -1050,11 +1055,11 @@
break;
}
- rgbOut = (byte *) COSE_CALLOC(EVP_MAX_MD_SIZE, 1, context);
+ rgbOut = (byte *)COSE_CALLOC(EVP_MAX_MD_SIZE, 1, context);
CHECK_CONDITION(rgbOut != nullptr, COSE_ERR_OUT_OF_MEMORY);
- CHECK_CONDITION(
- HMAC_Init_ex(ctx, pbKey, (int)cbKey, pmd, nullptr), COSE_ERR_CRYPTO_FAIL);
+ CHECK_CONDITION(HMAC_Init_ex(ctx, pbKey, (int)cbKey, pmd, nullptr),
+ COSE_ERR_CRYPTO_FAIL);
CHECK_CONDITION(
HMAC_Update(ctx, pbAuthData, cbAuthData), COSE_ERR_CRYPTO_FAIL);
CHECK_CONDITION(HMAC_Final(ctx, rgbOut, &cbOut), COSE_ERR_CRYPTO_FAIL);
@@ -1088,7 +1093,7 @@
if (pNewKey != nullptr) {
EC_KEY_free(pNewKey);
}
- return nullptr;
+ return nullptr;
}
if (pKey->m_opensslKey != nullptr) {
@@ -1105,7 +1110,7 @@
pNewKey = EC_KEY_new();
CHECK_CONDITION(pNewKey != nullptr, COSE_ERR_OUT_OF_MEMORY);
-
+
p = cn_cbor_mapget_int(pKey->m_cborKey, COSE_Key_EC_Curve);
CHECK_CONDITION(p != nullptr, COSE_ERR_INVALID_PARAMETER);
@@ -1135,8 +1140,8 @@
EC_KEY_set_group(pNewKey, ecgroup) == 1, COSE_ERR_CRYPTO_FAIL);
p = cn_cbor_mapget_int(pKey->m_cborKey, COSE_Key_EC_X);
- CHECK_CONDITION(
- (p != nullptr) && (p->type == CN_CBOR_BYTES), COSE_ERR_INVALID_PARAMETER);
+ CHECK_CONDITION((p != nullptr) && (p->type == CN_CBOR_BYTES),
+ COSE_ERR_INVALID_PARAMETER);
CHECK_CONDITION(p->length == (size_t)*cbGroup, COSE_ERR_INVALID_PARAMETER);
memcpy(rgbKey + 1, p->v.str, p->length);
@@ -1145,7 +1150,8 @@
if (p->type == CN_CBOR_BYTES) {
rgbKey[0] = POINT_CONVERSION_UNCOMPRESSED;
cbKey = (*cbGroup * 2) + 1;
- CHECK_CONDITION(p->length == (size_t)*cbGroup, COSE_ERR_INVALID_PARAMETER);
+ CHECK_CONDITION(
+ p->length == (size_t)*cbGroup, COSE_ERR_INVALID_PARAMETER);
memcpy(rgbKey + p->length + 1, p->v.str, p->length);
}
else if (p->type == CN_CBOR_TRUE) {
@@ -1179,8 +1185,9 @@
pKey->m_opensslKey = EVP_PKEY_new();
CHECK_CONDITION(pKey->m_opensslKey != nullptr, COSE_ERR_OUT_OF_MEMORY);
-
- CHECK_CONDITION(EVP_PKEY_set1_EC_KEY(pKey->m_opensslKey, pNewKey) == 1, COSE_ERR_CRYPTO_FAIL);
+
+ CHECK_CONDITION(EVP_PKEY_set1_EC_KEY(pKey->m_opensslKey, pNewKey) == 1,
+ COSE_ERR_CRYPTO_FAIL);
return pNewKey;
}
@@ -1234,7 +1241,7 @@
cbSize = EC_POINT_point2oct(
pgroup, pPoint, POINT_CONVERSION_COMPRESSED, nullptr, 0, nullptr);
CHECK_CONDITION(cbSize > 0, COSE_ERR_CRYPTO_FAIL);
- pbPoint = (byte *) COSE_CALLOC(cbSize, 1, context);
+ pbPoint = (byte *)COSE_CALLOC(cbSize, 1, context);
CHECK_CONDITION(pbPoint != nullptr, COSE_ERR_OUT_OF_MEMORY);
CHECK_CONDITION(
EC_POINT_point2oct(pgroup, pPoint, POINT_CONVERSION_COMPRESSED,
@@ -1246,7 +1253,7 @@
cbSize = EC_POINT_point2oct(
pgroup, pPoint, POINT_CONVERSION_UNCOMPRESSED, nullptr, 0, nullptr);
CHECK_CONDITION(cbSize > 0, COSE_ERR_CRYPTO_FAIL);
- pbPoint = (byte *) COSE_CALLOC(cbSize, 1, context);
+ pbPoint = (byte *)COSE_CALLOC(cbSize, 1, context);
CHECK_CONDITION(pbPoint != nullptr, COSE_ERR_OUT_OF_MEMORY);
CHECK_CONDITION(
EC_POINT_point2oct(pgroup, pPoint, POINT_CONVERSION_UNCOMPRESSED,
@@ -1255,7 +1262,7 @@
cbX = cbSize / 2;
}
- pbOut = (byte *) COSE_CALLOC((int)(cbX), 1, context);
+ pbOut = (byte *)COSE_CALLOC((int)(cbX), 1, context);
CHECK_CONDITION(pbOut != nullptr, COSE_ERR_OUT_OF_MEMORY);
memcpy(pbOut, pbPoint + 1, (int)(cbX));
p = cn_cbor_data_create2(
@@ -1277,13 +1284,13 @@
p = nullptr;
}
else {
- pbOut = (byte *) COSE_CALLOC((int)(cbX), 1, context);
+ pbOut = (byte *)COSE_CALLOC((int)(cbX), 1, context);
CHECK_CONDITION(pbOut != nullptr, COSE_ERR_OUT_OF_MEMORY);
memcpy(pbOut, pbPoint + cbSize / 2 + 1, (int)(cbX));
- p = cn_cbor_data_create2(pbOut, (int)(cbX), 0,
- CBOR_CONTEXT_PARAM_COMMA & cbor_error);
+ p = cn_cbor_data_create2(
+ pbOut, (int)(cbX), 0, CBOR_CONTEXT_PARAM_COMMA & cbor_error);
CHECK_CONDITION_CBOR(p != nullptr, cbor_error);
- pbOut = nullptr;
+ pbOut = nullptr;
CHECK_CONDITION_CBOR(cn_cbor_mapput_int(pkey, COSE_Key_EC_Y, p,
CBOR_CONTEXT_PARAM_COMMA & cbor_error),
cbor_error);
@@ -1298,7 +1305,8 @@
cbor_error);
p = nullptr;
- coseKey = (COSE_KEY*) COSE_KEY_FromCbor(pkey, CBOR_CONTEXT_PARAM_COMMA perr);
+ coseKey =
+ (COSE_KEY *)COSE_KEY_FromCbor(pkey, CBOR_CONTEXT_PARAM_COMMA perr);
CHECK_CONDITION(coseKey != nullptr, COSE_ERR_OUT_OF_MEMORY);
pkey = nullptr;
@@ -1395,7 +1403,7 @@
psig = ECDSA_do_sign(rgbDigest, cbDigest, eckey);
CHECK_CONDITION(psig != nullptr, COSE_ERR_CRYPTO_FAIL);
- pbSig = (byte *) COSE_CALLOC(cbR, 2, context);
+ pbSig = (byte *)COSE_CALLOC(cbR, 2, context);
CHECK_CONDITION(pbSig != nullptr, COSE_ERR_OUT_OF_MEMORY);
const BIGNUM *r;
@@ -1413,8 +1421,8 @@
pbSig, cbR * 2, 0, CBOR_CONTEXT_PARAM_COMMA & cbor_error);
CHECK_CONDITION_CBOR(p != nullptr, cbor_error);
- CHECK_CONDITION(
- _COSE_array_replace(pSigner, p, index, CBOR_CONTEXT_PARAM_COMMA nullptr),
+ CHECK_CONDITION(_COSE_array_replace(
+ pSigner, p, index, CBOR_CONTEXT_PARAM_COMMA nullptr),
COSE_ERR_CBOR);
pbSig = nullptr;
@@ -1486,7 +1494,8 @@
CHECK_CONDITION(cbSignature / 2 == (size_t)cbR, COSE_ERR_INVALID_PARAMETER);
r = BN_bin2bn(pSig->v.bytes, (int)cbSignature / 2, nullptr);
CHECK_CONDITION(nullptr != r, COSE_ERR_OUT_OF_MEMORY);
- s = BN_bin2bn(pSig->v.bytes + cbSignature / 2, (int)cbSignature / 2, nullptr);
+ s = BN_bin2bn(
+ pSig->v.bytes + cbSignature / 2, (int)cbSignature / 2, nullptr);
CHECK_CONDITION(nullptr != s, COSE_ERR_OUT_OF_MEMORY);
sig = ECDSA_SIG_new();
@@ -1573,11 +1582,12 @@
mdCtx = EVP_MD_CTX_new();
CHECK_CONDITION(mdCtx != nullptr, COSE_ERR_OUT_OF_MEMORY);
- CHECK_CONDITION(EVP_DigestSignInit(mdCtx, &keyCtx, nullptr, nullptr, pkey) == 1,
+ CHECK_CONDITION(
+ EVP_DigestSignInit(mdCtx, &keyCtx, nullptr, nullptr, pkey) == 1,
COSE_ERR_CRYPTO_FAIL);
keyCtx = nullptr;
- pbSig = (byte *) COSE_CALLOC(cbSig, 1, context);
+ pbSig = (byte *)COSE_CALLOC(cbSig, 1, context);
CHECK_CONDITION(pbSig != nullptr, COSE_ERR_OUT_OF_MEMORY);
size_t cb2 = cbSig;
@@ -1590,8 +1600,8 @@
CHECK_CONDITION(p != nullptr, COSE_ERR_OUT_OF_MEMORY);
pbSig = nullptr;
- CHECK_CONDITION(
- _COSE_array_replace(pSigner, p, index, CBOR_CONTEXT_PARAM_COMMA nullptr),
+ CHECK_CONDITION(_COSE_array_replace(
+ pSigner, p, index, CBOR_CONTEXT_PARAM_COMMA nullptr),
COSE_ERR_CBOR);
if (mdCtx != nullptr) {
@@ -1718,7 +1728,7 @@
#endif
cn_cbor *cnTmp = nullptr;
- pbOut = (byte *) COSE_CALLOC(cbContent + 8, 1, context);
+ pbOut = (byte *)COSE_CALLOC(cbContent + 8, 1, context);
CHECK_CONDITION(pbOut != nullptr, COSE_ERR_OUT_OF_MEMORY);
CHECK_CONDITION(
@@ -1810,7 +1820,7 @@
}
}
- pbsecret = (byte *) COSE_CALLOC(cbGroup, 1, context);
+ pbsecret = (byte *)COSE_CALLOC(cbGroup, 1, context);
CHECK_CONDITION(pbsecret != nullptr, COSE_ERR_OUT_OF_MEMORY);
cbsecret = ECDH_compute_key(pbsecret, cbGroup,
diff --git a/test/Encrypt_test.cpp b/test/Encrypt_test.cpp
index b32c710..f463ef5 100644
--- a/test/Encrypt_test.cpp
+++ b/test/Encrypt_test.cpp
@@ -269,7 +269,8 @@
return 0;
}
- if (!SetReceivingAttributes(h, counterSigner, Attributes_Countersign1_protected)) {
+ if (!SetReceivingAttributes(
+ h, counterSigner, Attributes_Countersign1_protected)) {
return 0;
}
@@ -679,8 +680,6 @@
if (!COSE_Enveloped_AddRecipient(hEncObj, hRecip, nullptr)) {
goto returnError;
}
-
-
}
#if INCLUDE_COUNTERSIGNATURE
@@ -1321,8 +1320,7 @@
// - nullptr pointer
//
- CHECK_FAILURE(
- COSE_Enveloped_SetContent(hEncryptNULL, rgb, 10, &cose_error),
+ CHECK_FAILURE(COSE_Enveloped_SetContent(hEncryptNULL, rgb, 10, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
CHECK_FAILURE(COSE_Enveloped_SetContent(hEncryptBad, rgb, 10, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
@@ -1354,13 +1352,11 @@
CHECK_FAILURE(COSE_Enveloped_encrypt(hEncryptBad, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
- CHECK_FAILURE(
- COSE_Enveloped_decrypt(hEncryptNULL, hRecipient, &cose_error),
+ CHECK_FAILURE(COSE_Enveloped_decrypt(hEncryptNULL, hRecipient, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
CHECK_FAILURE(COSE_Enveloped_decrypt(hEncryptBad, hRecipient, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
- CHECK_FAILURE(
- COSE_Enveloped_decrypt(hEncrypt, hRecipientNULL, &cose_error),
+ CHECK_FAILURE(COSE_Enveloped_decrypt(hEncrypt, hRecipientNULL, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
CHECK_FAILURE(COSE_Enveloped_decrypt(hEncrypt, hRecipientBad, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
@@ -1378,8 +1374,7 @@
COSE_Enveloped_AddRecipient(hEncrypt, hRecipientBad, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
- CHECK_FAILURE_PTR(
- COSE_Enveloped_GetRecipient(hEncryptNULL, 0, &cose_error),
+ CHECK_FAILURE_PTR(COSE_Enveloped_GetRecipient(hEncryptNULL, 0, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
CHECK_FAILURE_PTR(COSE_Enveloped_GetRecipient(hEncryptBad, 0, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
@@ -1389,7 +1384,8 @@
COSE_ERR_INVALID_HANDLE, CFails++);
CHECK_FAILURE(COSE_Enveloped_SetExternal(hEncryptBad, rgb, 10, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
- CHECK_FAILURE(COSE_Enveloped_SetExternal(hEncrypt, nullptr, 10, &cose_error),
+ CHECK_FAILURE(
+ COSE_Enveloped_SetExternal(hEncrypt, nullptr, 10, &cose_error),
COSE_ERR_INVALID_PARAMETER, CFails++);
if (!COSE_Enveloped_Free(hEncrypt)) {
@@ -1532,8 +1528,8 @@
//
// Unsupported algorithm
- hEncrypt =
- COSE_Encrypt_Init(COSE_INIT_FLAGS_NONE, CBOR_CONTEXT_PARAM_COMMA nullptr);
+ hEncrypt = COSE_Encrypt_Init(
+ COSE_INIT_FLAGS_NONE, CBOR_CONTEXT_PARAM_COMMA nullptr);
if (hEncrypt == nullptr) {
CFails++;
}
@@ -1549,8 +1545,8 @@
COSE_ERR_UNKNOWN_ALGORITHM, CFails++);
COSE_Encrypt_Free(hEncrypt);
- hEncrypt =
- COSE_Encrypt_Init(COSE_INIT_FLAGS_NONE, CBOR_CONTEXT_PARAM_COMMA nullptr);
+ hEncrypt = COSE_Encrypt_Init(
+ COSE_INIT_FLAGS_NONE, CBOR_CONTEXT_PARAM_COMMA nullptr);
if (hEncrypt == nullptr) {
CFails++;
}
@@ -1612,8 +1608,7 @@
CHECK_FAILURE(COSE_Recipient_SetKey(hRecip, nullptr, &cose_error),
COSE_ERR_INVALID_PARAMETER, CFails++);
- CHECK_FAILURE(
- COSE_Recipient_SetSenderKey(hRecipNULL, cn, 0, &cose_error),
+ CHECK_FAILURE(COSE_Recipient_SetSenderKey(hRecipNULL, cn, 0, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
cn = cn_cbor_int_create(1, CBOR_CONTEXT_PARAM_COMMA nullptr);
CHECK_FAILURE(COSE_Recipient_SetSenderKey(hRecipBad, cn, 0, &cose_error),
@@ -1628,8 +1623,7 @@
COSE_ERR_NONE, CFails++);
cn = cn_cbor_int_create(1, CBOR_CONTEXT_PARAM_COMMA nullptr);
- CHECK_FAILURE(
- COSE_Recipient_SetExternal(hRecipNULL, rgb, 10, &cose_error),
+ CHECK_FAILURE(COSE_Recipient_SetExternal(hRecipNULL, rgb, 10, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
CHECK_FAILURE(COSE_Recipient_SetExternal(hRecipBad, rgb, 10, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
@@ -1658,13 +1652,11 @@
COSE_PROTECT_ONLY | COSE_UNPROTECT_ONLY, &cose_error),
COSE_ERR_INVALID_PARAMETER, CFails++);
- CHECK_FAILURE(
- COSE_Recipient_AddRecipient(hRecipNULL, hRecip, &cose_error),
+ CHECK_FAILURE(COSE_Recipient_AddRecipient(hRecipNULL, hRecip, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
CHECK_FAILURE(COSE_Recipient_AddRecipient(hRecipBad, hRecip, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
- CHECK_FAILURE(
- COSE_Recipient_AddRecipient(hRecip, hRecipNULL, &cose_error),
+ CHECK_FAILURE(COSE_Recipient_AddRecipient(hRecip, hRecipNULL, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
CHECK_FAILURE(COSE_Recipient_AddRecipient(hRecip, hRecipBad, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
diff --git a/test/Mac_test.cpp b/test/Mac_test.cpp
index 6707a37..8487a3f 100644
--- a/test/Mac_test.cpp
+++ b/test/Mac_test.cpp
@@ -844,7 +844,6 @@
else {
returnCode = COSE_MIN(returnCode, 1);
}
-
}
#if INCLUDE_COUNTERSIGNATURE
@@ -946,11 +945,11 @@
return 0;
}
- if (!SetReceivingAttributes(
+ if (!SetReceivingAttributes(
h, countersigners, Attributes_Countersign1_protected)) {
return 0;
}
-
+
if (COSE_Mac0_CounterSign1_validate(hMAC, h, &coseError)) {
// I don't think we have any forced errors yet.
}
diff --git a/test/Sign_test.cpp b/test/Sign_test.cpp
index 2332ba9..1b73ea4 100644
--- a/test/Sign_test.cpp
+++ b/test/Sign_test.cpp
@@ -214,11 +214,11 @@
return 0;
}
- if (!SetReceivingAttributes(
+ if (!SetReceivingAttributes(
h, counterSigner, Attributes_Countersign1_protected)) {
return 0;
}
-
+
if (COSE_Signer_CounterSign1_validate(hSigner, h, &coseError)) {
// I don't think we have any forced errors yet.
}
@@ -341,8 +341,8 @@
if (!COSE_CounterSign1_SetKey(h, hkeyCountersign, nullptr)) {
return 0;
}
-
- if (!SetReceivingAttributes(
+
+ if (!SetReceivingAttributes(
h, counterSigner, Attributes_Countersign1_protected)) {
return 0;
}
@@ -621,8 +621,8 @@
int SignMessage()
{
- Safe_HCOSE_SIGN hEncObj =
- (HCOSE_SIGN) COSE_Sign_Init(COSE_INIT_FLAGS_NONE, CBOR_CONTEXT_PARAM_COMMA nullptr);
+ Safe_HCOSE_SIGN hEncObj = (HCOSE_SIGN)COSE_Sign_Init(
+ COSE_INIT_FLAGS_NONE, CBOR_CONTEXT_PARAM_COMMA nullptr);
const char *sz = "This is the content to be used";
size_t cb;
@@ -855,8 +855,8 @@
for (size_t counterNo = 0; counterNo < count; counterNo++) {
bool noSignAlg = false;
- Safe_HCOSE_COUNTERSIGN1 h = COSE_Sign1_get_countersignature1(
- hSig, nullptr);
+ Safe_HCOSE_COUNTERSIGN1 h =
+ COSE_Sign1_get_countersignature1(hSig, nullptr);
if (h == nullptr) {
return 0;
}
@@ -875,7 +875,8 @@
return 0;
}
- if (!SetReceivingAttributes(h, counterSigner, Attributes_Countersign1_protected)) {
+ if (!SetReceivingAttributes(
+ h, counterSigner, Attributes_Countersign1_protected)) {
return 0;
}
@@ -899,7 +900,7 @@
}
}
#endif
-
+
return returnCode;
}
@@ -1066,7 +1067,8 @@
cn_cbor *cn = cn_cbor_int_create(5, CBOR_CONTEXT_PARAM_COMMA nullptr);
cose_errback cose_error;
- hSign = COSE_Sign_Init(COSE_INIT_FLAGS_NONE, CBOR_CONTEXT_PARAM_COMMA nullptr);
+ hSign =
+ COSE_Sign_Init(COSE_INIT_FLAGS_NONE, CBOR_CONTEXT_PARAM_COMMA nullptr);
#if INCLUDE_SIGN1
hSignBad = (HCOSE_SIGN)COSE_Sign1_Init(
COSE_INIT_FLAGS_NONE, CBOR_CONTEXT_PARAM_COMMA nullptr);
@@ -1095,25 +1097,25 @@
COSE_ERR_INVALID_HANDLE, CFails++);
CHECK_FAILURE(COSE_Sign_SetContent(hSignBad, rgb, sizeof(rgb), &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
- CHECK_FAILURE(COSE_Sign_SetContent(hSign, nullptr, sizeof(rgb), &cose_error),
+ CHECK_FAILURE(
+ COSE_Sign_SetContent(hSign, nullptr, sizeof(rgb), &cose_error),
COSE_ERR_INVALID_PARAMETER, CFails++);
- CHECK_FAILURE(
- COSE_Sign_map_get_int(hSignNULL, 1, COSE_BOTH, &cose_error),
+ CHECK_FAILURE(COSE_Sign_map_get_int(hSignNULL, 1, COSE_BOTH, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
CHECK_FAILURE(COSE_Sign_map_get_int(hSignBad, 1, COSE_BOTH, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
CHECK_FAILURE(COSE_Sign_map_get_int(hSign, 1, COSE_BOTH, &cose_error),
COSE_ERR_INVALID_PARAMETER, CFails++);
- CHECK_FAILURE(COSE_Sign_map_put_int(
- hSignNULL, 1, cn, COSE_PROTECT_ONLY, &cose_error),
+ CHECK_FAILURE(
+ COSE_Sign_map_put_int(hSignNULL, 1, cn, COSE_PROTECT_ONLY, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
CHECK_FAILURE(
COSE_Sign_map_put_int(hSignBad, 1, cn, COSE_PROTECT_ONLY, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
- CHECK_FAILURE(
- COSE_Sign_map_put_int(hSign, 1, nullptr, COSE_PROTECT_ONLY, &cose_error),
+ CHECK_FAILURE(COSE_Sign_map_put_int(
+ hSign, 1, nullptr, COSE_PROTECT_ONLY, &cose_error),
COSE_ERR_INVALID_PARAMETER, CFails++);
CHECK_FAILURE(COSE_Sign_map_put_int(hSign, 1, cn,
COSE_PROTECT_ONLY | COSE_UNPROTECT_ONLY, &cose_error),
@@ -1199,7 +1201,8 @@
//
// Unsupported algorithm
- hSign = COSE_Sign_Init(COSE_INIT_FLAGS_NONE, CBOR_CONTEXT_PARAM_COMMA nullptr);
+ hSign =
+ COSE_Sign_Init(COSE_INIT_FLAGS_NONE, CBOR_CONTEXT_PARAM_COMMA nullptr);
if (hSign == nullptr) {
CFails++;
}
@@ -1227,7 +1230,8 @@
COSE_Sign_Free(hSign);
COSE_Signer_Free(hSigner);
- hSign = COSE_Sign_Init(COSE_INIT_FLAGS_NONE, CBOR_CONTEXT_PARAM_COMMA nullptr);
+ hSign =
+ COSE_Sign_Init(COSE_INIT_FLAGS_NONE, CBOR_CONTEXT_PARAM_COMMA nullptr);
if (hSign == nullptr) {
CFails++;
}
@@ -1298,8 +1302,7 @@
CHECK_FAILURE(COSE_Sign1_SetContent(hSign, nullptr, 10, &cose_error),
COSE_ERR_INVALID_PARAMETER, CFails++);
- CHECK_FAILURE(
- COSE_Sign1_map_get_int(hSignNULL, 1, COSE_BOTH, &cose_error),
+ CHECK_FAILURE(COSE_Sign1_map_get_int(hSignNULL, 1, COSE_BOTH, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
CHECK_FAILURE(COSE_Sign1_map_get_int(hSignBad, 1, COSE_BOTH, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
@@ -1312,8 +1315,8 @@
CHECK_FAILURE(
COSE_Sign1_map_put_int(hSignBad, 1, cn, COSE_PROTECT_ONLY, &cose_error),
COSE_ERR_INVALID_HANDLE, CFails++);
- CHECK_FAILURE(
- COSE_Sign1_map_put_int(hSign, 1, nullptr, COSE_PROTECT_ONLY, &cose_error),
+ CHECK_FAILURE(COSE_Sign1_map_put_int(
+ hSign, 1, nullptr, COSE_PROTECT_ONLY, &cose_error),
COSE_ERR_INVALID_PARAMETER, CFails++);
CHECK_FAILURE(COSE_Sign1_map_put_int(hSign, 1, cn,
COSE_PROTECT_ONLY | COSE_UNPROTECT_ONLY, &cose_error),
diff --git a/test/context.cpp b/test/context.cpp
index 14ce7c4..a45797c 100644
--- a/test/context.cpp
+++ b/test/context.cpp
@@ -110,7 +110,7 @@
return;
}
- if (pItem->pad[0] == (byte) 0xab) {
+ if (pItem->pad[0] == (byte)0xab) {
// already freed.
assert(false);
}
@@ -140,7 +140,8 @@
CheckMemory(myContext);
- for (pItem = (MyItem *)myContext->pFirst; pItem != nullptr; pItem = pItem2) {
+ for (pItem = (MyItem *)myContext->pFirst; pItem != nullptr;
+ pItem = pItem2) {
pItem2 = pItem->pNext;
free(pItem);
}
diff --git a/test/test.cpp b/test/test.cpp
index 6c1c0f5..9998be6 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -408,9 +408,8 @@
}
else if (strcmp(pKey->v.str, "compressed") == 0) {
keyNew = COSE_Header_UseCompressedECDH;
- pValueNew = cn_cbor_bool_create(
- pValue->v.sint == 1 ? true
- : false, CBOR_CONTEXT_PARAM_COMMA nullptr);
+ pValueNew = cn_cbor_bool_create(pValue->v.sint == 1 ? true : false,
+ CBOR_CONTEXT_PARAM_COMMA nullptr);
if (pValueNew == nullptr) {
return false;
}
@@ -496,7 +495,7 @@
assert(false);
break;
}
-
+
if (fRet) {
pValueNew.Clear();
}
@@ -770,7 +769,7 @@
((RgStringKeys[i].kty == 0) ||
(RgStringKeys[i].kty == kty))) {
Safe_CN_CBOR pValueNew;
-
+
switch (RgStringKeys[i].operation) {
case OPERATION_NONE:
pValueNew = cn_cbor_clone(
@@ -805,9 +804,10 @@
break;
case OPERATION_STRING:
- pValueNew = cn_cbor_int_create(MapName(pValue, RgCurveNames,
+ pValueNew =
+ cn_cbor_int_create(MapName(pValue, RgCurveNames,
_countof(RgCurveNames)),
- CBOR_CONTEXT_PARAM_COMMA nullptr);
+ CBOR_CONTEXT_PARAM_COMMA nullptr);
if (pValueNew == nullptr) {
return nullptr;
}
@@ -855,7 +855,8 @@
}
cose_errback coseError;
- HCOSE_KEY key = COSE_KEY_FromCbor(pKeyOut, CBOR_CONTEXT_PARAM_COMMA &coseError);
+ HCOSE_KEY key =
+ COSE_KEY_FromCbor(pKeyOut, CBOR_CONTEXT_PARAM_COMMA & coseError);
if (key == nullptr) {
CN_CBOR_FREE(pKeyOut, context);
}
diff --git a/test/test.h b/test/test.h
index d756e38..a9a4203 100644
--- a/test/test.h
+++ b/test/test.h
@@ -130,27 +130,28 @@
Set(pIn); \
return pIn; \
} \
- handleName Transfer(Safe_##handleName* hIn) \
- { \
- if (h != NULL) { \
-freeFunction(h); \
-} \
-h = hIn->h; \
-hIn->h = NULL; \
-return h; \
-} \
- handleName operator=(Safe_##handleName hIn) \
- { \
- Set(hIn.h); \
- return h; \
- } \
+ handleName Transfer(Safe_##handleName* hIn) \
+ { \
+ if (h != NULL) { \
+ freeFunction(h); \
+ } \
+ h = hIn->h; \
+ hIn->h = NULL; \
+ return h; \
+ } \
+ handleName operator=(Safe_##handleName hIn) \
+ { \
+ Set(hIn.h); \
+ return h; \
+ } \
void Clear() { h = NULL; } \
- handleName Release() { \
- handleName h2 = h; \
- freeFunction(h); \
- h = NULL; \
- return h2; \
- } \
+ handleName Release() \
+ { \
+ handleName h2 = h; \
+ freeFunction(h); \
+ h = NULL; \
+ return h2; \
+ } \
};
Safe_Handle(HCOSE_ENCRYPT, COSE_Encrypt_Free);