We reorder the array, so the test needs to know that.
diff --git a/test/encrypt.c b/test/encrypt.c
index 863bbad..511c4fd 100644
--- a/test/encrypt.c
+++ b/test/encrypt.c
@@ -41,8 +41,9 @@
pRecipients = cn_cbor_mapget_string(pEnveloped, "recipients");
if ((pRecipients == NULL) || (pRecipients->type != CN_CBOR_ARRAY)) exit(1);
+ iRecipient = (int) pRecipients->length - 1;
pRecipients = pRecipients->first_child;
- for (iRecipient = 0; pRecipients != NULL; iRecipient++, pRecipients = pRecipients->next) {
+ for (; pRecipients != NULL; iRecipient--, pRecipients = pRecipients->next) {
hEnc = (HCOSE_ENCRYPT)COSE_Decode(pbEncoded, cbEncoded, &type, COSE_enveloped_object, CBOR_CONTEXT_PARAM_COMMA NULL);
if (hEnc == NULL) exit(1);
diff --git a/test/sign.c b/test/sign.c
index f118742..ab0507c 100644
--- a/test/sign.c
+++ b/test/sign.c
@@ -40,8 +40,9 @@
pSigners = cn_cbor_mapget_string(pSign, "signers");
if ((pSigners == NULL) || (pSigners->type != CN_CBOR_ARRAY)) exit(1);
+ iSigner = pSigners->length - 1;
pSigners = pSigners->first_child;
- for (iSigner = 0; pSigners != NULL; iSigner++, pSigners = pSigners->next) {
+ for (; pSigners != NULL; iSigner--, pSigners = pSigners->next) {
hSig = (HCOSE_SIGN)COSE_Decode(pbEncoded, cbEncoded, &type, COSE_sign_object, CBOR_CONTEXT_PARAM_COMMA NULL);
if (hSig == NULL) exit(1);
diff --git a/test/test.c b/test/test.c
index f70f0bb..c86ffc4 100644
--- a/test/test.c
+++ b/test/test.c
@@ -55,7 +55,7 @@
NameMap RgCurveNames[3] = {
{"P-256", 1},
{"P-384", 2},
- {"P-512", 3}
+ {"P-521", 3}
};
int MapName(const cn_cbor * p, NameMap * rgMap, unsigned int cMap)
@@ -300,8 +300,9 @@
pRecipients = cn_cbor_mapget_string(pMac, "recipients");
if ((pRecipients == NULL) || (pRecipients->type != CN_CBOR_ARRAY)) exit(1);
+ iRecipient = (int) pRecipients->length - 1;
pRecipients = pRecipients->first_child;
- for (iRecipient = 0; pRecipients != NULL; iRecipient++,pRecipients=pRecipients->next) {
+ for (; pRecipients != NULL; iRecipient--, pRecipients=pRecipients->next) {
cn_cbor * pkey = BuildKey(cn_cbor_mapget_string(pRecipients, "key"));
if (pkey == NULL) {
fFail = true;