Merge pull request #42 from jimsch/master
Kill unused #ifdefs
diff --git a/src/Cose.c b/src/Cose.c
index dd2bb1a..930f42e 100644
--- a/src/Cose.c
+++ b/src/Cose.c
@@ -36,16 +36,7 @@
CHECK_CONDITION_CBOR(pobj->m_cbor != NULL, errState);
pobj->m_ownMsg = 1;
-#ifdef TAG_IN_ARRAY
- if (msgType > 0) {
- cn_cbor * cn = cn_cbor_int_create(msgType, CBOR_CONTEXT_PARAM_COMMA &errState);
- CHECK_CONDITION_CBOR(cn != NULL, errState);
- CHECK_CONDITION_CBOR(cn_cbor_array_append(pobj->m_cbor, cn, &errState), errState);
- pobj->m_msgType = msgType;
- }
-#else
pobj->m_msgType = msgType;
-#endif
pobj->m_unprotectMap = cn_cbor_map_create(CBOR_CONTEXT_PARAM_COMMA &errState);
CHECK_CONDITION_CBOR(pobj->m_unprotectMap != NULL, errState);
@@ -72,9 +63,6 @@
{
const cn_cbor * pmap = NULL;
cn_cbor_errback errState; // = { 0 };
-#ifdef TAG_IN_ARRAY
- cn_cbor * cbor;
-#endif // TAG_IN_ARRAY
cn_cbor_errback cbor_error;
#ifdef USE_CBOR_CONTEXT
@@ -83,19 +71,10 @@
pobj->m_cborRoot = pcbor;
pobj->m_cbor = pcbor;
-#ifdef TAG_IN_ARRAY
- cbor = cn_cbor_index(pobj->m_cbor, 0);
- CHECK_CONDITION(cbor != NULL, COSE_ERR_INVALID_PARAMETER);
-
- if (cbor->type == CN_CBOR_UINT) {
- pobj->m_msgType = (int) cbor->v.uint;
- }
-#else
// Check if we have a tag
if (pcbor->type == CN_CBOR_TAG) {
pcbor = pobj->m_cbor = pcbor->first_child;
}
-#endif
pmap = _COSE_arrayget_int(pobj, INDEX_PROTECTED);
@@ -146,9 +125,6 @@
{
cn_cbor * cbor = NULL;
cn_cbor * cborRoot = NULL;
-#ifdef TAG_IN_ARRAY
- const cn_cbor * pType = NULL;
-#endif
cn_cbor_errback cbor_err;
HCOSE h;
@@ -157,14 +133,6 @@
cbor = cborRoot = cn_cbor_decode(rgbData, cbData, CBOR_CONTEXT_PARAM_COMMA &cbor_err);
CHECK_CONDITION_CBOR(cbor != NULL, cbor_err);
-#ifdef TAG_IN_ARRAY
- CHECK_CONDITION(cbor->type == CN_CBOR_ARRAY, COSE_ERR_INVALID_PARAMETER);
-
- pType = cn_cbor_index(cbor, 0);
- CHECK_CONDITION(((pType != NULL) && (pType->type == CN_CBOR_UINT)), COSE_ERR_INVALID_PARAMETER);
- *ptype = pType->v.sint;
-#else // ! TAG_IN_ARRAY
-
if (cbor->type == CN_CBOR_TAG) {
if (struct_type != 0) {
CHECK_CONDITION(struct_type == (COSE_object_type) cbor->v.sint, COSE_ERR_INVALID_PARAMETER);
@@ -180,7 +148,6 @@
}
CHECK_CONDITION(cbor->type == CN_CBOR_ARRAY, COSE_ERR_INVALID_PARAMETER);
-#endif // TAG_IN_ARRAY
switch (*ptype) {
case COSE_enveloped_object:
@@ -357,11 +324,7 @@
cn_cbor_context * context = &pMessage->m_allocContext;
#endif // USE_CBOR_CONTEXT
-#ifdef TAG_IN_ARRAY
- pProtected = cn_cbor_index(pMessage->m_cbor, INDEX_PROTECTED + (pMessage->m_msgType == 0 ? 0 : 1));
-#else
pProtected = cn_cbor_index(pMessage->m_cbor, INDEX_PROTECTED);
-#endif
if ((pProtected != NULL) &&(pProtected->type != CN_CBOR_INVALID)) {
errorReturn:
if (pbProtected != NULL) COSE_FREE(pbProtected, context);
@@ -476,17 +439,11 @@
bool _COSE_array_replace(COSE * pMessage, cn_cbor * cb_value, int index, CBOR_CONTEXT_COMMA cn_cbor_errback * errp)
{
-#ifdef TAG_IN_ARRAY
- if (pMessage->m_msgType != 0) index += 1;
-#endif
return cn_cbor_array_replace(pMessage->m_cbor, cb_value, index, CBOR_CONTEXT_PARAM_COMMA errp);
}
cn_cbor * _COSE_arrayget_int(COSE * pMessage, int index)
{
-#ifdef TAG_IN_ARRAY
- if (pMessage->m_msgType != 0) index += 1;
-#endif
return cn_cbor_index(pMessage->m_cbor, index);
}
diff --git a/src/Recipient.c b/src/Recipient.c
index b970106..1ba5f2c 100644
--- a/src/Recipient.c
+++ b/src/Recipient.c
@@ -88,15 +88,7 @@
pRecipient = (COSE_RecipientInfo *)COSE_CALLOC(1, sizeof(COSE_RecipientInfo), context);
CHECK_CONDITION(pRecipient != NULL, COSE_ERR_OUT_OF_MEMORY);
-#ifdef USE_ARRAY
CHECK_CONDITION(cbor->type == CN_CBOR_ARRAY, COSE_ERR_INVALID_PARAMETER);
-#else
- if (cbor->type != CN_CBOR_MAP) {
- if (errp != NULL) errp->err = COSE_ERR_INVALID_PARAMETER;
- COSE_FREE(pRecipient, context);
- return NULL;
- }
-#endif
if (_COSE_Enveloped_Init_From_Object(cbor, &pRecipient->m_encrypt, CBOR_CONTEXT_PARAM_COMMA perr) == NULL) {
goto errorReturn;
diff --git a/src/cose.h b/src/cose.h
index 12be235..d63ce12 100644
--- a/src/cose.h
+++ b/src/cose.h
@@ -334,3 +334,5 @@
extern cn_cbor * cn_cbor_clone(const cn_cbor * pIn, CBOR_CONTEXT_COMMA cn_cbor_errback * perr);
extern cn_cbor * cn_cbor_tag_create(int tag, cn_cbor * child, CBOR_CONTEXT_COMMA cn_cbor_errback * perr);
extern cn_cbor * cn_cbor_bool_create(int boolValue, CBOR_CONTEXT_COMMA cn_cbor_errback * errp);
+extern cn_cbor * cn_cbor_null_create(CBOR_CONTEXT_COMMA cn_cbor_errback * errp);
+