Memory reduction (#54)

* Reduce memory usage for determining encoding size.

Some devices don't have the memory to spare to use an 8K buffer to
determine the size of buffer that is needed for encoding.

* Enable limiting decoders

* Add COSE_ERR_UNSUPPORTED_COSE_TYPE

* Adapt tests for decoders not configured

* Setup to build individuals

Setup to do indivual COSE elements.  We are going to assume that if individuals build and all build then all combinations are going to build

* Pass NULL to cn_cbor_encoder_write to get the size.

* Conditional compilation based on INCLUDE_* defines

* Revert "Adapt tests for decoders not configured"

This reverts commit a66f0a7568beecec7e78275c4fa9e1bc92e328f1.

* Add missing compile checks in sign corner cases

* Fix cmake check for excluding sign0

* Fix unintentional whitespace differences
diff --git a/.travis.yml b/.travis.yml
index bfe920f..51edb56 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,6 +10,12 @@
   - USE_CONTEXT=ON
   - USE_CONTEXT=OFF
   - USE_CONTEXT=OFF USE_EMBEDTLS=ON
+  - CMAKE_OPTIONS="-Dinclude_encrypt=ON -Dinclude_encrypt0=OFF -Dinclude_mac0=OFF -Dinclude_mac=OFF -Dinclude_sign=OFF -Dinclude_sign0=OFF"
+  - CMAKE_OPTIONS="-Dinclude_encrypt=OFF -Dinclude_encrypt0=ON -Dinclude_mac0=OFF -Dinclude_mac=OFF -Dinclude_sign=OFF -Dinclude_sign0=OFF"
+  - CMAKE_OPTIONS="-Dinclude_encrypt=OFF -Dinclude_encrypt0=OFF -Dinclude_mac0=ON -Dinclude_mac=OFF -Dinclude_sign=OFF -Dinclude_sign0=OFF"
+  - CMAKE_OPTIONS="-Dinclude_encrypt=OFF -Dinclude_encrypt0=OFF -Dinclude_mac0=OFF -Dinclude_mac=ON -Dinclude_sign=OFF -Dinclude_sign0=OFF"
+  - CMAKE_OPTIONS="-Dinclude_encrypt=OFF -Dinclude_encrypt0=OFF -Dinclude_mac0=OFF -Dinclude_mac=OFF -Dinclude_sign=ON -Dinclude_sign0=OFF"
+  - CMAKE_OPTIONS="-Dinclude_encrypt=OFF -Dinclude_encrypt0=OFF -Dinclude_mac0=OFF -Dinclude_mac=OFF -Dinclude_sign=OFF -Dinclude_sign0=ON"
 matrix:
   exclude:
     - compiler: clang
@@ -31,7 +37,7 @@
   - cmake --version
   - git clone --depth 1 git://github.com/cose-wg/Examples Examples
   - mkdir build
-  - cd build && cmake -Duse_context=$USE_CONTEXT -Dcoveralls_send=ON  -Duse_embedtls=$USE_EMBEDTLS .. && make all test
+  - cd build && cmake -Duse_context=$USE_CONTEXT -Dcoveralls_send=ON  -Duse_embedtls=$USE_EMBEDTLS $CMAKE_OPTIONS .. && make all test
 
 after_success:
   - make coveralls
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f5f3836..1867068 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,6 +26,12 @@
 option (build_docs      "Create docs using Doxygen" ${DOXYGEN_FOUND} )
 option (build_shared_libs "Build Shared Libraries" ON)
 option (use_embedtls    "Use MBedTLS for the Crypto Package" OFF)
+option (include_encrypt  "Include COSE_ENCRYPT" ON)
+option (include_encrypt0 "Include COSE_ENCRYPT0" ON)
+option (include_mac      "Include COSE_MAC" ON)
+option (include_mac0     "Include COSE_MAC0" ON)
+option (include_sign     "Include COSE_SIGN" ON)
+option (include_sign0    "Include COSE_SIGN0" ON)
 
 set ( dist_dir          ${CMAKE_BINARY_DIR}/dist )
 set ( prefix            ${CMAKE_INSTALL_PREFIX} )
@@ -44,6 +50,25 @@
    endif ()
 endif ()
 
+if (NOT include_encrypt)
+   add_definitions( -DINCLUDE_ENCRYPT=0 )
+endif ()
+if (NOT include_encrypt0)
+   add_definitions( -DINCLUDE_ENCRYPT0=0 )
+endif ()
+if (NOT include_mac)
+   add_definitions( -DINCLUDE_MAC=0 )
+endif ()
+if (NOT include_mac0)
+   add_definitions( -DINCLUDE_MAC0=0 )
+endif ()
+if (NOT include_sign)
+   add_definitions( -DINCLUDE_SIGN=0 )
+endif ()
+if (NOT include_sign0)
+   add_definitions( -DINCLUDE_SIGN0=0 )
+endif ()
+
 if ( MSVC OR CMAKE_C_COMPILER_ID MATCHES "Clang" )
    set (coveralls OFF)
 endif ()
diff --git a/src/Cose.c b/src/Cose.c
index b82af84..5e86c71 100644
--- a/src/Cose.c
+++ b/src/Cose.c
@@ -151,45 +151,69 @@
 
 	switch (*ptype) {
 	case COSE_enveloped_object:
+#if INCLUDE_ENCRYPT
 		h = (HCOSE)_COSE_Enveloped_Init_From_Object(cbor, NULL, CBOR_CONTEXT_PARAM_COMMA perr);
 		if (h == NULL) {
 			goto errorReturn;
 		}
+#else
+		FAIL_CONDITION(COSE_ERR_UNSUPPORTED_COSE_TYPE);
+#endif
 		break;
 
 	case COSE_sign_object:
+#if INCLUDE_SIGN
 		h = (HCOSE)_COSE_Sign_Init_From_Object(cborRoot, NULL, CBOR_CONTEXT_PARAM_COMMA perr);
 		if (h == NULL) {
 			goto errorReturn;
 		}
+#else
+		FAIL_CONDITION(COSE_ERR_UNSUPPORTED_COSE_TYPE);
+#endif
 		break;
 
 	case COSE_sign0_object:
+#if INCLUDE_SIGN0
 		h = (HCOSE)_COSE_Sign0_Init_From_Object(cborRoot, NULL, CBOR_CONTEXT_PARAM_COMMA perr);
 		if (h == NULL) {
 			goto errorReturn;
 		}
+#else
+		FAIL_CONDITION(COSE_ERR_UNSUPPORTED_COSE_TYPE);
+#endif
 		break;
 
 	case COSE_mac_object:
+#if INCLUDE_MAC
 		h = (HCOSE)_COSE_Mac_Init_From_Object(cbor, NULL, CBOR_CONTEXT_PARAM_COMMA perr);
 		if (h == NULL) {
 			goto errorReturn;
 		}
+#else
+		FAIL_CONDITION(COSE_ERR_UNSUPPORTED_COSE_TYPE);
+#endif
 		break;
 
 	case COSE_mac0_object:
+#if INCLUDE_MAC0
 		h = (HCOSE)_COSE_Mac0_Init_From_Object(cbor, NULL, CBOR_CONTEXT_PARAM_COMMA perr);
 		if (h == NULL) {
 			goto errorReturn;
 		}
+#else
+		FAIL_CONDITION(COSE_ERR_UNSUPPORTED_COSE_TYPE);
+#endif
 		break;
 
 	case COSE_encrypt_object:
+#if INCLUDE_ENCRYPT0
 		h = (HCOSE)_COSE_Encrypt_Init_From_Object(cbor, NULL, CBOR_CONTEXT_PARAM_COMMA perr);
 		if (h == NULL) {
 			goto errorReturn;
 		}
+#else
+		FAIL_CONDITION(COSE_ERR_UNSUPPORTED_COSE_TYPE);
+#endif
 		break;
 
 	default:
diff --git a/src/Encrypt.c b/src/Encrypt.c
index 903bb66..04f4645 100644
--- a/src/Encrypt.c
+++ b/src/Encrypt.c
@@ -12,10 +12,13 @@
 #include "configure.h"
 #include "crypto.h"
 
+#if INCLUDE_ENCRYPT || INCLUDE_MAC
 void _COSE_Enveloped_Release(COSE_Enveloped * p);
 
 COSE * EnvelopedRoot = NULL;
+#endif
 
+#if INCLUDE_ENCRYPT
 /*! \private
 * @brief Test if a HCOSE_ENVELOPED handle is valid
 *
@@ -72,7 +75,9 @@
 errorReturn:
 	return NULL;
 }
+#endif
 
+#if INCLUDE_ENCRYPT || INCLUDE_MAC
 HCOSE_ENVELOPED _COSE_Enveloped_Init_From_Object(cn_cbor * cbor, COSE_Enveloped * pIn, CBOR_CONTEXT_COMMA cose_errback * perr)
 {
 	COSE_Enveloped * pobj = pIn;
@@ -114,7 +119,9 @@
 
 	return(HCOSE_ENVELOPED) pobj;
 }
+#endif
 
+#if INCLUDE_ENCRYPT
 bool COSE_Enveloped_Free(HCOSE_ENVELOPED h)
 {
 #ifdef USE_CBOR_CONTEXT
@@ -141,7 +148,9 @@
 
 	return true;
 }
+#endif
 
+#if INCLUDE_ENCRYPT || INCLUDE_MAC
 void _COSE_Enveloped_Release(COSE_Enveloped * p)
 {
 	COSE_RecipientInfo * pRecipient1;
@@ -157,7 +166,9 @@
 
 	_COSE_Release(&p->m_message);
 }
+#endif
 
+#if INCLUDE_ENCRYPT
 bool COSE_Enveloped_decrypt(HCOSE_ENVELOPED h, HCOSE_RECIPIENT hRecip, cose_errback * perr)
 {
 	COSE_Enveloped * pcose = (COSE_Enveloped *)h;
@@ -173,7 +184,9 @@
 	errorReturn:
 	return f;
 }
+#endif
 
+#if INCLUDE_ENCRYPT || INCLUDE_ENCRYPT0
 bool _COSE_Enveloped_decrypt(COSE_Enveloped * pcose, COSE_RecipientInfo * pRecip, const byte *pbKeyIn, size_t cbKeyIn, const char * szContext, cose_errback * perr)
 {
 	int alg;
@@ -405,7 +418,9 @@
 
 	return true;
 }
+#endif
 
+#if INCLUDE_ENCRYPT
 bool COSE_Enveloped_encrypt(HCOSE_ENVELOPED h, cose_errback * perr)
 {
 	COSE_Enveloped * pcose = (COSE_Enveloped *)h;
@@ -418,7 +433,9 @@
 errorReturn:
 	return false;
 }
+#endif
 
+#if INCLUDE_ENCRYPT || INCLUDE_ENCRYPT0
 bool _COSE_Enveloped_encrypt(COSE_Enveloped * pcose, const byte * pbKeyIn, size_t cbKeyIn, const char * szContext, cose_errback * perr)
 {
 	int alg;
@@ -654,7 +671,9 @@
 	}
 	return fRet;
 }
+#endif
 
+#if INCLUDE_ENCRYPT
 bool COSE_Enveloped_SetContent(HCOSE_ENVELOPED h, const byte * rgb, size_t cb, cose_errback * perr)
 {
 	CHECK_CONDITION(IsValidEnvelopedHandle(h), COSE_ERR_INVALID_HANDLE);
@@ -785,7 +804,9 @@
 errorReturn:
 	return false;
 }
+#endif
 
+#if INCLUDE_ENCRYPT || INCLUDE_ENCRYPT0 || INCLUDE_MAC || INCLUDE_MAC0
 bool _COSE_Encrypt_Build_AAD(COSE * pMessage, byte ** ppbAAD, size_t * pcbAAD, const char * szContext, cose_errback * perr)
 {
 #ifdef USE_CBOR_CONTEXT
@@ -841,7 +862,9 @@
 	if (pAuthData != NULL) CN_CBOR_FREE(pAuthData, context);
 	return false;
 }
+#endif
 
+#if INCLUDE_ENCRYPT
 HCOSE_RECIPIENT COSE_Enveloped_GetRecipient(HCOSE_ENVELOPED cose, int iRecipient, cose_errback * perr)
 {
 	int i;
@@ -880,3 +903,5 @@
 	return NULL;
 }
 #endif
+
+#endif
diff --git a/src/Encrypt0.c b/src/Encrypt0.c
index 1a031d1..2e228f4 100644
--- a/src/Encrypt0.c
+++ b/src/Encrypt0.c
@@ -12,10 +12,13 @@
 #include "configure.h"
 #include "crypto.h"
 
+#if INCLUDE_ENCRYPT0 || INCLUDE_MAC0
 void _COSE_Encrypt_Release(COSE_Encrypt * p);
 
 COSE * EncryptRoot = NULL;
+#endif
 
+#if INCLUDE_ENCRYPT0
 /*! \private
 * @brief Test if a HCOSE_ENCRYPT handle is valid
 *
@@ -35,8 +38,9 @@
 	COSE_Encrypt * p = (COSE_Encrypt *)h;
 	return _COSE_IsInList(EncryptRoot, (COSE *)p);
 }
+#endif
 
-
+#if INCLUDE_ENCRYPT0 || INCLUDE_MAC0
 HCOSE_ENCRYPT COSE_Encrypt_Init(COSE_INIT_FLAGS flags, CBOR_CONTEXT_COMMA cose_errback * perr)
 {
 	CHECK_CONDITION(flags == COSE_INIT_FLAGS_NONE, COSE_ERR_INVALID_PARAMETER);
@@ -56,7 +60,9 @@
 errorReturn:
 	return NULL;
 }
+#endif
 
+#if INCLUDE_ENCRYPT0
 HCOSE_ENCRYPT _COSE_Encrypt_Init_From_Object(cn_cbor * cbor, COSE_Encrypt * pIn, CBOR_CONTEXT_COMMA cose_errback * perr)
 {
 	COSE_Encrypt * pobj = pIn;
@@ -108,14 +114,18 @@
 
 	return true;
 }
+#endif
 
+#if INCLUDE_ENCRYPT0 || INCLUDE_MAC0
 void _COSE_Encrypt_Release(COSE_Encrypt * p)
 {
 	if (p->pbContent != NULL) COSE_FREE((void *) p->pbContent, &p->m_message.m_allocContext);
 
 	_COSE_Release(&p->m_message);
 }
+#endif
 
+#if INCLUDE_ENCRYPT0
 bool COSE_Encrypt_decrypt(HCOSE_ENCRYPT h, const byte * pbKey, size_t cbKey, cose_errback * perr)
 {
 	COSE_Encrypt * pcose = (COSE_Encrypt *)h;
@@ -210,3 +220,5 @@
 
 	return _COSE_map_put(&((COSE_Encrypt *)h)->m_message, key, value, flags, perror);
 }
+
+#endif
diff --git a/src/MacMessage.c b/src/MacMessage.c
index c638f6e..c0d5695 100644
--- a/src/MacMessage.c
+++ b/src/MacMessage.c
@@ -13,6 +13,8 @@
 #include "configure.h"
 #include "crypto.h"
 
+#if INCLUDE_MAC
+
 COSE * MacRoot = NULL;
 
 /*! \private
@@ -219,8 +221,9 @@
 
 	return _COSE_map_put(&((COSE_MacMessage *)h)->m_message, key, value, flags, perror);
 }
+#endif
 
-
+#if INCLUDE_MAC || INCLUDE_MAC0
 bool _COSE_Mac_Build_AAD(COSE * pCose, const char * szContext, byte ** ppbAuthData, size_t * pcbAuthData, CBOR_CONTEXT_COMMA cose_errback * perr)
 {
 	cn_cbor * pAuthData = NULL;
@@ -294,7 +297,9 @@
 	if (ptmp != NULL) CN_CBOR_FREE(ptmp, context);
 	return fRet;
 }
+#endif
 
+#if INCLUDE_MAC
 bool COSE_Mac_encrypt(HCOSE_MAC h, cose_errback * perr)
 {
 	COSE_MacMessage * pcose = (COSE_MacMessage *)h;
@@ -307,7 +312,9 @@
 	errorReturn:
 		return false;
 }
+#endif
 
+#if INCLUDE_MAC || INCLUDE_MAC0
 bool _COSE_Mac_compute(COSE_MacMessage * pcose, const byte * pbKeyIn, size_t cbKeyIn, const char * szContext, cose_errback * perr)
 {
 	int alg;
@@ -499,7 +506,9 @@
 	if (pbAuthData != NULL) COSE_FREE(pbAuthData, context);
 	return fRet;
 }
+#endif
 
+#if INCLUDE_MAC
 bool COSE_Mac_validate(HCOSE_MAC h, HCOSE_RECIPIENT hRecip, cose_errback * perr)
 {
 	COSE_MacMessage * pcose = (COSE_MacMessage *)h;
@@ -512,7 +521,9 @@
 errorReturn:
 	return false;
 }
+#endif
 
+#if INCLUDE_MAC || INCLUDE_MAC0
 bool _COSE_Mac_validate(COSE_MacMessage * pcose, COSE_RecipientInfo * pRecip, const byte * pbKeyIn, size_t cbKeyIn, const char * szContext, cose_errback * perr)
 {
 	byte * pbAuthData = NULL;
@@ -700,7 +711,9 @@
 
 	return fRet;
 }
+#endif
 
+#if INCLUDE_MAC
 bool COSE_Mac_AddRecipient(HCOSE_MAC hMac, HCOSE_RECIPIENT hRecip, cose_errback * perr)
 {
 	COSE_RecipientInfo * pRecip;
@@ -764,3 +777,5 @@
 errorReturn:
 	return NULL;
 }
+
+#endif
diff --git a/src/MacMessage0.c b/src/MacMessage0.c
index 2702985..f8e25f0 100644
--- a/src/MacMessage0.c
+++ b/src/MacMessage0.c
@@ -13,6 +13,8 @@
 #include "configure.h"
 #include "crypto.h"
 
+#if INCLUDE_MAC0
+
 COSE * Mac0Root = NULL;
 
 /*! \private
@@ -222,3 +224,5 @@
 errorReturn:
 	return false;
 }
+
+#endif
diff --git a/src/Recipient.c b/src/Recipient.c
index 993eb0e..a89a707 100644
--- a/src/Recipient.c
+++ b/src/Recipient.c
@@ -6,9 +6,11 @@
 #include "configure.h"
 #include "crypto.h"
 
+#if INCLUDE_ENCRYPT || INCLUDE_ENCRYPT0 || INCLUDE_MAC || INCLUDE_MAC0
 extern bool BuildContextBytes(COSE * pcose, int algID, size_t cbitKey, byte ** ppbContext, size_t * pcbContext, CBOR_CONTEXT_COMMA cose_errback * perr);
+#endif
 
-
+#if INCLUDE_ENCRYPT || INCLUDE_MAC
 COSE* RecipientRoot = NULL;
 
 /*! \private
@@ -114,7 +116,9 @@
 
 	return;
 }
+#endif
 
+#if INCLUDE_ENCRYPT || INCLUDE_ENCRYPT0 || INCLUDE_MAC || INCLUDE_MAC0
 #if defined(USE_HKDF_SHA2) || defined(USE_HKDF_AES)
 /**
 * Perform an AES-CCM Decryption operation
@@ -942,7 +946,9 @@
 	if (pb != NULL) COSE_FREE(pb, context);
 	return NULL;
 }
+#endif
 
+#if INCLUDE_ENCRYPT || INCLUDE_MAC
 bool COSE_Recipient_SetKey_secret(HCOSE_RECIPIENT hRecipient, const byte * rgbKey, int cbKey, const byte * rgbKid, int cbKid, cose_errback * perr)
 {
 	COSE_RecipientInfo * p;
@@ -1205,8 +1211,9 @@
 errorReturn:
 	return false;
 }
+#endif
 
-
+#if INCLUDE_ENCRYPT || INCLUDE_ENCRYPT0 || INCLUDE_MAC || INCLUDE_MAC0
 bool BuildContextBytes(COSE * pcose, int algID, size_t cbitKey, byte ** ppbContext, size_t * pcbContext, CBOR_CONTEXT_COMMA cose_errback * perr)
 {
 	cn_cbor * pArray;
@@ -1359,7 +1366,9 @@
 	fReturn = false;
 	goto returnHere;
 }
+#endif
 
+#if INCLUDE_ENCRYPT || INCLUDE_MAC
 /*! brief Retrieve header parameter from a recipient structure
 *
 * Retrieve a header parameter from the message.
@@ -1445,3 +1454,5 @@
 errorReturn:
 	return false;
 }
+
+#endif
diff --git a/src/Sign.c b/src/Sign.c
index 9466f85..7cd3f8a 100644
--- a/src/Sign.c
+++ b/src/Sign.c
@@ -7,6 +7,8 @@
 #include "cose.h"
 #include "cose_int.h"
 
+#if INCLUDE_SIGN
+
 COSE * SignRoot = NULL;
 
 /*! \private
@@ -368,4 +370,4 @@
 	return (HCOSE_SIGNER)p;
 }
 
-
+#endif
diff --git a/src/Sign0.c b/src/Sign0.c
index 6f44ebb..0df4207 100644
--- a/src/Sign0.c
+++ b/src/Sign0.c
@@ -8,6 +8,8 @@
 #include "cose_int.h"
 #include "crypto.h"
 
+#if INCLUDE_SIGN0
+
 bool _COSE_Signer0_sign(COSE_Sign0Message * pSigner, const cn_cbor * pKey, cose_errback * perr);
 bool _COSE_Signer0_validate(COSE_Sign0Message * pSign, const cn_cbor * pKey, cose_errback * perr);
 void _COSE_Sign0_Release(COSE_Sign0Message * p);
@@ -438,3 +440,5 @@
 
 	return fRet;
 }
+
+#endif
diff --git a/src/SignerInfo.c b/src/SignerInfo.c
index 04c8754..60c928f 100644
--- a/src/SignerInfo.c
+++ b/src/SignerInfo.c
@@ -10,6 +10,8 @@
 #include "configure.h"
 #include "crypto.h"
 
+#if INCLUDE_SIGN
+
 extern bool IsValidSignHandle(HCOSE_SIGN h);
 
 COSE * SignerRoot = NULL;
@@ -365,3 +367,5 @@
 errorReturn:
 	return fRet;
 }
+
+#endif
diff --git a/src/cbor.c b/src/cbor.c
index 68fb14e..8cac226 100644
--- a/src/cbor.c
+++ b/src/cbor.c
@@ -184,11 +184,8 @@
 	return pcn;
 }
 
-
-unsigned char RgbDontUse4[8 * 1024];
-
 size_t cn_cbor_encode_size(cn_cbor * object)
 {
-	ssize_t size = cn_cbor_encoder_write(RgbDontUse4, 0, sizeof(RgbDontUse4), object);
+	ssize_t size = cn_cbor_encoder_write(NULL, 0, 0, object);
 	return size >= 0 ? size : 0;
 }
diff --git a/src/configure.h b/src/configure.h
index a92ae9c..4d927f5 100644
--- a/src/configure.h
+++ b/src/configure.h
@@ -135,3 +135,26 @@
 
 
 //#define USE_COUNTER_SIGNATURES
+
+//
+//   Define which COSE objects are included
+//
+
+#ifndef INCLUDE_ENCRYPT
+#define INCLUDE_ENCRYPT 1
+#endif
+#ifndef INCLUDE_ENCRYPT0
+#define INCLUDE_ENCRYPT0 1
+#endif
+#ifndef INCLUDE_MAC
+#define INCLUDE_MAC 1
+#endif
+#ifndef INCLUDE_MAC0
+#define INCLUDE_MAC0 1
+#endif
+#ifndef INCLUDE_SIGN
+#define INCLUDE_SIGN 1
+#endif
+#ifndef INCLUDE_SIGN0
+#define INCLUDE_SIGN0 1
+#endif
diff --git a/src/cose.h b/src/cose.h
index bd870f8..5f0a414 100644
--- a/src/cose.h
+++ b/src/cose.h
@@ -35,7 +35,9 @@
 	/** Cryptographic failure */
 	COSE_ERR_CRYPTO_FAIL,
 	/** Internal Error */
-	COSE_ERR_INTERNAL
+	COSE_ERR_INTERNAL,
+	/** Type is not supported */
+	COSE_ERR_UNSUPPORTED_COSE_TYPE
 } cose_error;
 
 typedef enum cose_init_flags {
diff --git a/test/encrypt.c b/test/encrypt.c
index bf05fa1..434b4da 100644
--- a/test/encrypt.c
+++ b/test/encrypt.c
@@ -7,7 +7,9 @@
 #include <string.h>
 #include <cose.h>
 #include <cn-cbor/cn-cbor.h>
-
+#if (INCLUDE_ENCRYPT || INCLUDE_ENCRYPT0 || INCLUDE_MAC) && (!INCLUDE_MAC || !INCLUDE_SIGN)
+#include <cose_int.h>
+#endif
 #include "json.h"
 #include "test.h"
 #include "context.h"
@@ -16,6 +18,7 @@
 #pragma warning (disable: 4127)
 #endif
 
+#if INCLUDE_ENCRYPT
 bool DecryptMessage(const byte * pbEncoded, size_t cbEncoded, bool fFailBody, const cn_cbor * pEnveloped, const cn_cbor * pRecipient1, int iRecipient1, const cn_cbor * pRecipient2, int iRecipient2)
 {
 	HCOSE_ENVELOPED hEnc = NULL;
@@ -354,10 +357,10 @@
 	CFails++;
 	return 0;
 }
-
+#endif
 
 /********************************************/
-
+#if INCLUDE_ENCRYPT0
 int _ValidateEncrypt(const cn_cbor * pControl, const byte * pbEncoded, size_t cbEncoded)
 {
 	const cn_cbor * pInput = cn_cbor_mapget_string(pControl, "input");
@@ -493,7 +496,9 @@
 	CFails += 1;
 	return 1;
 }
+#endif
 
+#if INCLUDE_ENCRYPT
 void Enveloped_Corners()
 {
 	HCOSE_ENVELOPED hEncryptNULL = NULL;
@@ -507,9 +512,17 @@
 	cose_errback cose_error;
 
 	hEncrypt = COSE_Enveloped_Init(0, CBOR_CONTEXT_PARAM_COMMA NULL);
+#if INCLUDE_MAC
 	hEncryptBad = (HCOSE_ENVELOPED)COSE_Mac_Init(0, CBOR_CONTEXT_PARAM_COMMA NULL);
+#else
+	hEncryptBad = (HCOSE_ENVELOPED)COSE_CALLOC(1, sizeof(COSE), context);
+#endif
 	hRecipient = COSE_Recipient_Init(0, CBOR_CONTEXT_PARAM_COMMA NULL);
+#if INCLUDE_MAC
 	hRecipientBad = (HCOSE_RECIPIENT)COSE_Mac_Init(0, CBOR_CONTEXT_PARAM_COMMA NULL);
+#else
+	hRecipientBad = (HCOSE_RECIPIENT)COSE_CALLOC(1, sizeof(COSE), context);
+#endif
 
 	//  Missing case - addref then release on item
 
@@ -598,7 +611,9 @@
 
 	return;
 }
+#endif
 
+#if INCLUDE_ENCRYPT0
 void Encrypt_Corners()
 {
 	HCOSE_ENCRYPT hEncrypt = NULL;
@@ -620,7 +635,11 @@
 
 	//  Wrong type of handle checks
 
+#if INCLUDE_MAC
 	hEncrypt = (HCOSE_ENCRYPT) COSE_Mac_Init(0, CBOR_CONTEXT_PARAM_COMMA NULL);
+#else
+	hEncrypt = (HCOSE_ENCRYPT)COSE_CALLOC(1, sizeof(COSE), context);
+#endif
 
 	if (COSE_Encrypt_SetContent(hEncrypt, rgb, 10, NULL)) CFails++;
 	if (COSE_Encrypt_map_get_int(hEncrypt, 1, COSE_BOTH, NULL)) CFails++;
@@ -649,7 +668,9 @@
 
 	return;
 }
+#endif
 
+#if INCLUDE_ENCRYPT || INCLUDE_MAC
 void Recipient_Corners()
 {
 	HCOSE_RECIPIENT hRecip;
@@ -660,7 +681,11 @@
 	cn_cbor * cn = cn_cbor_int_create(1, CBOR_CONTEXT_PARAM_COMMA NULL);
 
 	hRecip = COSE_Recipient_Init(0, CBOR_CONTEXT_PARAM_COMMA &cose_error);
+#if INCLUDE_SIGN
 	hRecipBad = (HCOSE_RECIPIENT)COSE_Signer_Init(CBOR_CONTEXT_PARAM_COMMA &cose_error);
+#else
+	hRecipBad = (HCOSE_RECIPIENT)COSE_CALLOC(1, sizeof(COSE), context);
+#endif
 
 	//  Check for invalid parameters
 
@@ -700,7 +725,7 @@
 	COSE_Recipient_Free(hRecip);
 
 	//  Unknown algorithms
-
+#if INCLUDE_ENCRYPT
 	HCOSE_ENVELOPED hEnv = COSE_Enveloped_Init(0, CBOR_CONTEXT_PARAM_COMMA NULL);
 	hRecip = COSE_Recipient_Init(0, CBOR_CONTEXT_PARAM_COMMA NULL);
 
@@ -724,4 +749,6 @@
 
 	COSE_Enveloped_Free(hEnv);
 	COSE_Recipient_Free(hRecip);
+#endif
 }
+#endif
diff --git a/test/json.c b/test/json.c
index fbaca0b..9508126 100644
--- a/test/json.c
+++ b/test/json.c
@@ -9,9 +9,9 @@
 #include "json.h"
 
 #ifdef USE_CBOR_CONTEXT
-extern cn_cbor_context * allocator;
-#define CBOR_CONTEXT_PARAM , allocator
-#define CBOR_CONTEXT_PARAM_COMMA allocator,
+extern cn_cbor_context * context;
+#define CBOR_CONTEXT_PARAM , context
+#define CBOR_CONTEXT_PARAM_COMMA context ,
 #else
 #define CBOR_CONTEXT_PARAM
 #define CBOR_CONTEXT_PARAM_COMMA
diff --git a/test/mac_test.c b/test/mac_test.c
index 65ebd98..38aca75 100644
--- a/test/mac_test.c
+++ b/test/mac_test.c
@@ -5,6 +5,9 @@
 #include <string.h>
 #include <cose.h>
 #include <cn-cbor/cn-cbor.h>
+#if INCLUDE_MAC && !INCLUDE_ENCRYPT0
+#include <cose_int.h>
+#endif
 
 #include "json.h"
 #include "test.h"
@@ -14,7 +17,7 @@
 #pragma warning (disable: 4127)
 #endif
 
-
+#if INCLUDE_MAC
 int _ValidateMAC(const cn_cbor * pControl, const byte * pbEncoded, size_t cbEncoded)
 {
 	const cn_cbor * pInput = cn_cbor_mapget_string(pControl, "input");
@@ -269,8 +272,9 @@
 	CFails++;
 	return 1;
 }
+#endif
 
-
+#if INCLUDE_MAC0
 int _ValidateMac0(const cn_cbor * pControl, const byte * pbEncoded, size_t cbEncoded)
 {
 	const cn_cbor * pInput = cn_cbor_mapget_string(pControl, "input");
@@ -403,8 +407,9 @@
 	CFails += 1;
 	return 1;
 }
+#endif
 
-
+#if INCLUDE_MAC
 void MAC_Corners()
 {
     HCOSE_MAC hMAC;
@@ -432,7 +437,11 @@
 	if (COSE_Mac_SetExternal((HCOSE_MAC)hEncrypt, rgb, 0, NULL)) CFails++;
 	if (COSE_Mac_Free((HCOSE_MAC)hEncrypt)) CFails++;
 
-    hEncrypt = COSE_Encrypt_Init(0, CBOR_CONTEXT_PARAM_COMMA NULL);
+#if INCLUDE_ENCRYPT0
+	hEncrypt = COSE_Encrypt_Init(0, CBOR_CONTEXT_PARAM_COMMA NULL);
+#else
+	hEncrypt = (HCOSE_ENCRYPT)COSE_CALLOC(1, sizeof(COSE), context);
+#endif
 
 	if (COSE_Mac_SetContent((HCOSE_MAC)hEncrypt, rgb, 10, NULL)) CFails++;
 	if (COSE_Mac_map_get_int((HCOSE_MAC)hEncrypt, 1, COSE_BOTH, NULL)) CFails++;
@@ -473,7 +482,9 @@
 
     return;
 }
+#endif
 
+#if INCLUDE_MAC0
 void MAC0_Corners()
 {
 	HCOSE_ENCRYPT hEncrypt = NULL;
@@ -526,3 +537,4 @@
 
 	return;
 }
+#endif
diff --git a/test/sign.c b/test/sign.c
index b0fc222..0fdcb33 100644
--- a/test/sign.c
+++ b/test/sign.c
@@ -7,6 +7,9 @@
 #include <string.h>
 #include <cose.h>
 #include <cn-cbor/cn-cbor.h>
+#if (INCLUDE_SIGN && !(INCLUDE_SIGN0 || INCLUDE_ENCRYPT || INCLUDE_MAC)) || (INCLUDE_SIGN0 && !INCLUDE_SIGN)
+#include <cose_int.h>
+#endif
 
 #include "json.h"
 #include "test.h"
@@ -16,6 +19,7 @@
 #pragma warning (disable: 4127)
 #endif
 
+#if INCLUDE_SIGN
 int _ValidateSigned(const cn_cbor * pControl, const byte * pbEncoded, size_t cbEncoded)
 {
 	const cn_cbor * pInput = cn_cbor_mapget_string(pControl, "input");
@@ -246,8 +250,9 @@
 
 	return 1;
 }
+#endif
 
-
+#if INCLUDE_SIGN0
 int _ValidateSign0(const cn_cbor * pControl, const byte * pbEncoded, size_t cbEncoded)
 {
 	const cn_cbor * pInput = cn_cbor_mapget_string(pControl, "input");
@@ -366,7 +371,9 @@
 	CFails += 1;
 	return 1;
 }
+#endif
 
+#if INCLUDE_SIGN
 void Sign_Corners()
 {
 	HCOSE_SIGN hSign = NULL;
@@ -380,10 +387,18 @@
 	cose_errback cose_error;
 
 	hSign = COSE_Sign_Init(0, CBOR_CONTEXT_PARAM_COMMA  NULL);
+#if INCLUDE_SIGN0
 	hSignBad = (HCOSE_SIGN)COSE_Sign0_Init(0, CBOR_CONTEXT_PARAM_COMMA NULL);
+#else
+	hSignBad = (HCOSE_SIGN)COSE_CALLOC(1, sizeof(COSE), context);
+#endif
 
 	hSigner = COSE_Signer_Init(CBOR_CONTEXT_PARAM_COMMA  NULL);
+#if INCLUDE_ENCRYPT || INCLUDE_MAC
 	hSignerBad = (HCOSE_SIGNER)COSE_Recipient_Init(0, CBOR_CONTEXT_PARAM_COMMA NULL);
+#else
+	hSignerBad = (HCOSE_SIGNER)COSE_CALLOC(1, sizeof(COSE), context);
+#endif
 
 	//  Missing case - addref then release on item
 	//  Incorrect algorithm
@@ -481,7 +496,9 @@
 
 	return;
 }
+#endif
 
+#if INCLUDE_SIGN0
 void Sign0_Corners()
 {
 	HCOSE_SIGN0 hSign = NULL;
@@ -493,8 +510,11 @@
 	cose_errback cose_error;
 
 	hSign = COSE_Sign0_Init(0, CBOR_CONTEXT_PARAM_COMMA NULL);
+#if INCLUDE_SIGN
 	hSignBad = (HCOSE_SIGN0)COSE_Sign_Init(0, CBOR_CONTEXT_PARAM_COMMA NULL);
-
+#else
+	hSignBad = (HCOSE_SIGN0)COSE_CALLOC(1, sizeof(COSE), context);
+#endif
 
 	//  Look for invalid parameter
 	//		Null handle checks
@@ -551,3 +571,4 @@
 
 	return;
 }
+#endif
diff --git a/test/test.c b/test/test.c
index 64aaea4..17c8e53 100644
--- a/test/test.c
+++ b/test/test.c
@@ -372,37 +372,53 @@
 		}
 
 		switch (msgType) {
+#if INCLUDE_MAC
 		case Attributes_MAC_protected:
 			f = COSE_Mac_map_put_int((HCOSE_MAC)hHandle, keyNew, pValueNew, which, NULL);
 			break;
+#endif
 
+#if INCLUDE_MAC0
 		case Attributes_MAC0_protected:
 			f = COSE_Mac0_map_put_int((HCOSE_MAC0)hHandle, keyNew, pValueNew, which, NULL);
 			break;
+#endif
 
+#if INCLUDE_ENCRYPT || INCLUDE_MAC
 		case Attributes_Recipient_protected:
 			f = COSE_Recipient_map_put_int((HCOSE_RECIPIENT)hHandle, keyNew, pValueNew, which, NULL);
 			break;
+#endif
 
+#if INCLUDE_ENCRYPT
 		case Attributes_Enveloped_protected:
 			f = COSE_Enveloped_map_put_int((HCOSE_ENVELOPED)hHandle, keyNew, pValueNew, which, NULL);
 			break;
+#endif
 
+#if INCLUDE_ENCRYPT0
 		case Attributes_Encrypt_protected:
 			f = COSE_Encrypt_map_put_int((HCOSE_ENCRYPT)hHandle, keyNew, pValueNew, which, NULL);
 			break;
+#endif
 
+#if INCLUDE_SIGN
 		case Attributes_Sign_protected:
 			f = COSE_Sign_map_put_int((HCOSE_SIGN)hHandle, keyNew, pValueNew, which, NULL);
 			break;
+#endif
 
+#if INCLUDE_SIGN
 		case Attributes_Signer_protected:
 			f = COSE_Signer_map_put_int((HCOSE_SIGNER)hHandle, keyNew, pValueNew, which, NULL);
 			break;
+#endif
 
+#if INCLUDE_SIGN0
 		case Attributes_Sign0_protected:
 			f = COSE_Sign0_map_put_int((HCOSE_SIGN0)hHandle, keyNew, pValueNew, which, NULL);
 			break;
+#endif
 
 		}
 		// assert(f);
@@ -424,29 +440,41 @@
 		cn_cbor * pcn = cn_cbor_clone(pExternal, CBOR_CONTEXT_PARAM_COMMA NULL);
 		if (pcn == NULL) goto returnError;
 		switch (base) {
+#if INCLUDE_ENCRYPT0
 		case Attributes_Encrypt_protected:
 			if (!COSE_Encrypt_SetExternal((HCOSE_ENCRYPT)hMsg, FromHex(pcn->v.str, (int)pcn->length), pcn->length / 2, NULL)) goto returnError;
 			break;
+#endif
 
+#if INCLUDE_ENCRYPT
 		case Attributes_Enveloped_protected:
 			if (!COSE_Enveloped_SetExternal((HCOSE_ENVELOPED)hMsg, FromHex(pcn->v.str, (int)pcn->length), pcn->length / 2, NULL)) goto returnError;
 			break;
+#endif
 
+#if INCLUDE_MAC
 		case Attributes_MAC_protected:
 			if (!COSE_Mac_SetExternal((HCOSE_MAC)hMsg, FromHex(pcn->v.str, (int)pcn->length), pcn->length / 2, NULL)) goto returnError;
 			break;
+#endif
 
+#if INCLUDE_MAC0
 		case Attributes_MAC0_protected:
 			if (!COSE_Mac0_SetExternal((HCOSE_MAC0)hMsg, FromHex(pcn->v.str, (int)pcn->length), pcn->length / 2, NULL)) goto returnError;
 			break;
+#endif
 
+#if INCLUDE_SIGN
 		case Attributes_Signer_protected:
 			if (!COSE_Signer_SetExternal((HCOSE_SIGNER)hMsg, FromHex(pcn->v.str, (int)pcn->length), pcn->length / 2, NULL)) goto returnError;
 			break;
+#endif
 
+#if INCLUDE_SIGN0
 		case Attributes_Sign0_protected:
 			if (!COSE_Sign0_SetExternal((HCOSE_SIGN0)hMsg, FromHex(pcn->v.str, (int)pcn->length), pcn->length / 2, NULL)) goto returnError;
 			break;
+#endif
 		}
 	}
 
@@ -466,29 +494,41 @@
 		cn_cbor * pcn = cn_cbor_clone(pExternal, CBOR_CONTEXT_PARAM_COMMA NULL);
 		if (pcn == NULL) goto returnError;
 		switch (base) {
+#if INCLUDE_ENCRYPT0
 		case Attributes_Encrypt_protected:
 			if (!COSE_Encrypt_SetExternal((HCOSE_ENCRYPT)hMsg, FromHex(pcn->v.str, (int)pcn->length), pcn->length / 2, NULL)) goto returnError;
 			break;
+#endif
 
+#if INCLUDE_ENCRYPT
 		case Attributes_Enveloped_protected:
 			if (!COSE_Enveloped_SetExternal((HCOSE_ENVELOPED)hMsg, FromHex(pcn->v.str, (int)pcn->length), pcn->length / 2, NULL)) goto returnError;
 			break;
+#endif
 
+#if INCLUDE_MAC
 		case Attributes_MAC_protected:
 			if (!COSE_Mac_SetExternal((HCOSE_MAC)hMsg, FromHex(pcn->v.str, (int)pcn->length), pcn->length / 2, NULL)) goto returnError;
 			break;
+#endif
 
+#if INCLUDE_MAC0
 		case Attributes_MAC0_protected:
 			if (!COSE_Mac0_SetExternal((HCOSE_MAC0)hMsg, FromHex(pcn->v.str, (int)pcn->length), pcn->length / 2, NULL)) goto returnError;
 			break;
+#endif
 
+#if INCLUDE_SIGN
 		case Attributes_Signer_protected:
 			if (!COSE_Signer_SetExternal((HCOSE_SIGNER)hMsg, FromHex(pcn->v.str, (int)pcn->length), pcn->length / 2, NULL)) goto returnError;
 			break;
+#endif
 
+#if INCLUDE_SIGN0
 		case Attributes_Sign0_protected:
 			if (!COSE_Sign0_SetExternal((HCOSE_SIGN0)hMsg, FromHex(pcn->v.str, (int)pcn->length), pcn->length / 2, NULL)) goto returnError;
 			break;
+#endif
 		}
 	}
 
@@ -602,13 +642,27 @@
 void RunCorners()
 {
 	Test_cn_cbor_array_replace();
+#if INCLUDE_MAC
 	MAC_Corners();
+#endif
+#if INCLUDE_MAC0
 	MAC0_Corners();
+#endif
+#if INCLUDE_ENCRYPT0
 	Encrypt_Corners();
+#endif
+#if INCLUDE_ENCRYPT
 	Enveloped_Corners();
+#endif
+#if INCLUDE_SIGN
 	Sign_Corners();
+#endif
+#if INCLUDE_SIGN0
 	Sign0_Corners();
+#endif
+#if INCLUDE_ENCRYPT || INCLUDE_MAC
 	Recipient_Corners();
+#endif
 }
 
 void RunMemoryTest(const char * szFileName)
@@ -637,101 +691,131 @@
 	bool fBuildDone = false;
 
 	for (iFail = 0; !fValidateDone || !fBuildDone; iFail++) {
-		allocator = CreateContext(iFail);
+		context = CreateContext(iFail);
 
 		if (cn_cbor_mapget_string(pInput, "mac") != NULL) {
+#if INCLUDE_MAC
 			if (!fValidateDone) {
-				allocator = CreateContext(iFail);
+				context = CreateContext(iFail);
 				CFails = 0;
 				ValidateMAC(pControl);
 				if (CFails == 0) fValidateDone = true;
 			}
 
 			if (!fBuildDone) {
-				allocator = CreateContext(iFail);
+				context = CreateContext(iFail);
 				CFails = 0;
 				BuildMacMessage(pControl);
 				if (CFails == 0) fBuildDone = true;
 			}
+#else
+			fValidateDone = true;
+			fBuildDone = true;
+#endif
 		}
 		else if (cn_cbor_mapget_string(pInput, "mac0") != NULL) {
+#if INCLUDE_MAC0
 			if (!fValidateDone) {
-				allocator = CreateContext(iFail);
+				context = CreateContext(iFail);
 				CFails = 0;
 				ValidateMac0(pControl);
 				if (CFails == 0) fValidateDone = true;
 			}
 
 			if (!fBuildDone) {
-				allocator = CreateContext(iFail);
+				context = CreateContext(iFail);
 				CFails = 0;
 				BuildMac0Message(pControl);
 				if (CFails == 0) fBuildDone = true;
 			}
+#else
+			fValidateDone = true;
+			fBuildDone = true;
+#endif
 		}
 		else if (cn_cbor_mapget_string(pInput, "encrypted") != NULL) {
+#if INCLUDE_ENCRYPT0
 			if (!fValidateDone) {
-				allocator = CreateContext(iFail);
+				context = CreateContext(iFail);
 				CFails = 0;
 				ValidateEncrypt(pControl);
 				if (CFails == 0) fValidateDone = true;
 			}
 
 			if (!fBuildDone) {
-				allocator = CreateContext(iFail);
+				context = CreateContext(iFail);
 				CFails = 0;
 				BuildEncryptMessage(pControl);
 				if (CFails == 0) fBuildDone = true;
 			}
+#else
+			fValidateDone = true;
+			fBuildDone = true;
+#endif
 		}
 		else if (cn_cbor_mapget_string(pInput, "enveloped") != NULL) {
+#if INCLUDE_ENCRYPT
 			if (!fValidateDone) {
-				allocator = CreateContext(iFail);
+				context = CreateContext(iFail);
 				CFails = 0;
 				ValidateEnveloped(pControl);
 				if (CFails == 0) fValidateDone = true;
 			}
 
 			if (!fBuildDone) {
-				allocator = CreateContext(iFail);
+				context = CreateContext(iFail);
 				CFails = 0;
 				BuildEnvelopedMessage(pControl);
 				if (CFails == 0) fBuildDone = true;
 			}
+#else
+			fValidateDone = true;
+			fBuildDone = true;
+#endif
 		}
 		else if (cn_cbor_mapget_string(pInput, "sign") != NULL) {
+#if INCLUDE_SIGN
 			if (!fValidateDone) {
-				allocator = CreateContext(iFail);
+				context = CreateContext(iFail);
 				CFails = 0;
 				ValidateSigned(pControl);
 				if (CFails == 0) fValidateDone = true;
 			}
 
 			if (!fBuildDone) {
-				allocator = CreateContext(iFail);
+				context = CreateContext(iFail);
 				CFails = 0;
 				BuildSignedMessage(pControl);
 				if (CFails == 0) fBuildDone = true;
 			}
+#else
+			fValidateDone = true;
+			fBuildDone = true;
+#endif
 		}
 		else if (cn_cbor_mapget_string(pInput, "sign0") != NULL) {
+#if INCLUDE_SIGN0
 			if (!fValidateDone) {
-				allocator = CreateContext(iFail);
+				context = CreateContext(iFail);
 				CFails = 0;
 				ValidateSign0(pControl);
 				if (CFails == 0) fValidateDone = true;
 			}
 
 			if (!fBuildDone) {
-				allocator = CreateContext(iFail);
+				context = CreateContext(iFail);
 				CFails = 0;
 				BuildSign0Message(pControl);
 				if (CFails == 0) fBuildDone = true;
 			}
+#else
+			fValidateDone = true;
+			fBuildDone = true;
+#endif
 		}
 	}
 	CFails = 0;
-	allocator = NULL;
+	context = NULL;
 #else
 	return;
 #endif
@@ -762,34 +846,46 @@
 	}
 
 	if (cn_cbor_mapget_string(pInput, "mac") != NULL) {
+#if INCLUDE_MAC
 		if (ValidateMAC(pControl)) {
 			BuildMacMessage(pControl);
 		}
+#endif
 	}
 	else if (cn_cbor_mapget_string(pInput, "mac0") != NULL) {
+#if INCLUDE_MAC0
 		if (ValidateMac0(pControl)) {
 			BuildMac0Message(pControl);
 		}
+#endif
 	}
 	else if (cn_cbor_mapget_string(pInput, "enveloped") != NULL) {
+#if INCLUDE_ENCRYPT
 		if (ValidateEnveloped(pControl)) {
 			BuildEnvelopedMessage(pControl);
 		}
+#endif
 	}
 	else if (cn_cbor_mapget_string(pInput, "sign") != NULL) {
+#if INCLUDE_SIGN
 		if (ValidateSigned(pControl)) {
 			BuildSignedMessage(pControl);
 		}
+#endif
 	}
 	else if (cn_cbor_mapget_string(pInput, "sign0") != NULL) {
+#if INCLUDE_SIGN0
 		if (ValidateSign0(pControl)) {
 			BuildSign0Message(pControl);
 		}
+#endif
 	}
 	else if (cn_cbor_mapget_string(pInput, "encrypted") != NULL) {
+#if INCLUDE_ENCRYPT0
 		if (ValidateEncrypt(pControl)) {
 			BuildEncryptMessage(pControl);
 		}
+#endif
 	}
 
 	return;
@@ -934,13 +1030,19 @@
 	}
 	else {
 #ifdef USE_CBOR_CONTEXT
-		allocator = CreateContext((unsigned int) -1);
+		context = CreateContext((unsigned int) -1);
 #endif
+#if INCLUDE_MAC
 		MacMessage();
+#endif
+#if INCLUDE_SIGN
 		SignMessage();
+#endif
+#if INCLUDE_ENCRYPT
 		EncryptMessage();
+#endif
 #ifdef USE_CBOR_CONTEXT
-		FreeContext(allocator);
+		FreeContext(context);
 #endif
 	}
 
diff --git a/test/test.h b/test/test.h
index 1a010a0..752f788 100644
--- a/test/test.h
+++ b/test/test.h
@@ -4,9 +4,9 @@
 #endif
 
 #ifdef USE_CBOR_CONTEXT
-cn_cbor_context * allocator;
-#define CBOR_CONTEXT_PARAM , allocator
-#define CBOR_CONTEXT_PARAM_COMMA allocator,
+cn_cbor_context * context;
+#define CBOR_CONTEXT_PARAM , context
+#define CBOR_CONTEXT_PARAM_COMMA context ,
 #else
 #define CBOR_CONTEXT_PARAM
 #define CBOR_CONTEXT_PARAM_COMMA