Merge pull request #26 from jimsch/master

Add AES-wrap test cases
diff --git a/src/Recipient.c b/src/Recipient.c
index 9d59202..ddbdf9a 100644
--- a/src/Recipient.c
+++ b/src/Recipient.c
@@ -205,6 +205,7 @@
 
 	switch (alg) {
 	case COSE_Algorithm_AES_KW_128:
+	case COSE_Algorithm_AES_KW_192:
 	case COSE_Algorithm_AES_KW_256:
 		CHECK_CONDITION((pcose->pbKey != NULL) || (pRecip->m_pkey != NULL), COSE_ERR_INVALID_PARAMETER);
 		if (pRecip->m_pkey != NULL) {
@@ -374,6 +375,8 @@
 		break;
 
 
+	case COSE_Algorithm_AES_KW_128:
+	case COSE_Algorithm_AES_KW_192:
 	case COSE_Algorithm_AES_KW_256:
 		if (pRecipient->m_pkey != NULL) {
 			cn_cbor * pK = cn_cbor_mapget_int(pRecipient->m_pkey, -1);
@@ -718,7 +721,7 @@
 	if (cnParam != NULL) {
 		cnT = cn_cbor_clone(cnParam, CBOR_CONTEXT_PARAM_COMMA &cbor_error);
 		CHECK_CONDITION_CBOR(cnT != NULL, cbor_error);
-		CHECK_CONDITION_CBOR(cn_cbor_array_append(cnArrayT, cnT, &cbor_error), cbor_error);
+		CHECK_CONDITION_CBOR(cn_cbor_array_append(pArray, cnT, &cbor_error), cbor_error);
 		cnT = NULL;
 		cnParam = NULL;
 	}
diff --git a/src/cose_int.h b/src/cose_int.h
index 855fa29..f3a834e 100644
--- a/src/cose_int.h
+++ b/src/cose_int.h
@@ -199,8 +199,8 @@
 //
 //  Debugging Items
 
-//#define DO_ASSERT assert(false);
-#define DO_ASSERT
+#define DO_ASSERT assert(false);
+//#define DO_ASSERT
 #define CHECK_CONDITION(condition, error) { if (!(condition)) { DO_ASSERT; if (perr != NULL) {perr->err = error;} goto errorReturn;}}
 #define FAIL_CONDITION(error) { DO_ASSERT; if (perr != NULL) {perr->err = error;} goto errorReturn;}
 #define CHECK_CONDITION_CBOR(condition, error) { if (!(condition)) { DO_ASSERT; if (perr != NULL) {perr->err = _MapFromCBOR(error);} goto errorReturn;}}
diff --git a/src/openssl.c b/src/openssl.c
index 4345037..351b76e 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -950,7 +950,7 @@
 
 bool AES_KW_Decrypt(COSE_Enveloped * pcose, const byte * pbKeyIn, size_t cbitKey, const byte * pbCipherText, size_t cbCipherText, byte * pbKeyOut, int * pcbKeyOut, cose_errback * perr)
 {
-	byte rgbOut[256 / 8];
+	byte rgbOut[512 / 8];
 	AES_KEY key;
 
 	CHECK_CONDITION(AES_set_decrypt_key(pbKeyIn, (int)cbitKey, &key) == 0, COSE_ERR_CRYPTO_FAIL);
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 4a8d1f2..ecd4054 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -55,6 +55,8 @@
 add_test (NAME hkdf-hmac-sha WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND cose_test --dir Examples/hkdf-hmac-sha-examples )
 add_test (NAME hkdf-aes WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND cose_test --dir Examples/hkdf-aes-examples )
 
+add_test (NAME aes-wrap WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND cose_test --dir Examples/aes-wrap-examples )
+
 
 add_test (NAME corner-cases WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND cose_test --corners )
 add_test (NAME Memory-mac WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND cose_test --memory Examples/hmac-examples/HMac-01.json )
diff --git a/test/test.c b/test/test.c
index 17c2c99..2395be7 100644
--- a/test/test.c
+++ b/test/test.c
@@ -199,12 +199,12 @@
 			if (pValueNew == NULL) return false;
 
 		}
-		else if (strcmp(pKey->v.str, "supp_pub_other") == 0) {
+		else if (strcmp(pKey->v.str, "pub_other") == 0) {
 			keyNew = COSE_Header_KDF_PUB_other;
 			pValueNew = cn_cbor_data_create(pValue->v.bytes, (int)pValue->length, CBOR_CONTEXT_PARAM_COMMA NULL);
 			if (pValueNew == NULL) return false;
 		}
-		else if (strcmp(pKey->v.str, "supp_priv_other") == 0) {
+		else if (strcmp(pKey->v.str, "priv_other") == 0) {
 			keyNew = COSE_Header_KDF_PRIV;
 			pValueNew = cn_cbor_data_create(pValue->v.bytes, (int)pValue->length, CBOR_CONTEXT_PARAM_COMMA NULL);
 			if (pValueNew == NULL) return false;