Add QCBOREncode_AddBytesLenOnly(), special for COSE sig verification
diff --git a/test/qcbor_encode_tests.c b/test/qcbor_encode_tests.c
index ad17feb..f08927c 100644
--- a/test/qcbor_encode_tests.c
+++ b/test/qcbor_encode_tests.c
@@ -1380,6 +1380,12 @@
static const uint8_t spExpectedBstrWrap[] = {0x82, 0x19, 0x01, 0xC3, 0x43, 0x19, 0x01, 0xD2};
/*
+ 81 #array(1)
+ 0x58 0x25 # string of length 37 (length of "This is longer than twenty four bytes")
+ */
+static const uint8_t spExpectedTypeAndLen[] = {0x81, 0x58, 0x25};
+
+/*
Very basic bstr wrapping test
*/
int BstrWrapTest()
@@ -1424,6 +1430,20 @@
if(BStr.ptr != NULL || BStr.len != 3) {
return -5;
}
+
+ // Third, test QCBOREncode_AddBytesLenOnly() here as it is part of the
+ // bstr wrapping use cases.
+ UsefulBuf_MAKE_STACK_UB(StuffBuf, 50);
+ QCBOREncode_Init(&EC, StuffBuf);
+ QCBOREncode_OpenArray(&EC);
+ QCBOREncode_AddBytesLenOnly(&EC, UsefulBuf_FROM_SZ_LITERAL("This is longer than twenty four bytes"));
+ QCBOREncode_CloseArray(&EC);
+ if(QCBOREncode_Finish(&EC, &Encoded)) {
+ return -6;
+ }
+ if(CheckResults(Encoded, spExpectedTypeAndLen)) {
+ return -7;
+ }
return 0;
}