Added support for CCM and CCM_8 cipher suites.
[BearSSL] / src / x509 / skey_decoder.c
index 6788145..f4e43e7 100644 (file)
@@ -58,7 +58,7 @@ t0_parse7E_signed(const unsigned char **p)
 #define T0_INT4(x)       T0_VBYTE(x, 21), T0_VBYTE(x, 14), T0_VBYTE(x, 7), T0_FBYTE(x, 0)
 #define T0_INT5(x)       T0_SBYTE(x), T0_VBYTE(x, 21), T0_VBYTE(x, 14), T0_VBYTE(x, 7), T0_FBYTE(x, 0)
 
-static const uint8_t t0_datablock[];
+/* static const unsigned char t0_datablock[]; */
 
 
 void br_skey_decoder_init_main(void *t0ctx);
@@ -75,7 +75,7 @@ void br_skey_decoder_run(void *t0ctx);
 
 #include "inner.h"
 
-#define CTX   ((br_skey_decoder_context *)((unsigned char *)t0ctx - offsetof(br_skey_decoder_context, cpu)))
+#define CTX   ((br_skey_decoder_context *)(void *)((unsigned char *)t0ctx - offsetof(br_skey_decoder_context, cpu)))
 #define CONTEXT_NAME   br_skey_decoder_context
 
 /* see bearssl_x509.h */
@@ -101,14 +101,14 @@ br_skey_decoder_push(br_skey_decoder_context *ctx,
 
 
 
-static const uint8_t t0_datablock[] = {
+static const unsigned char t0_datablock[] = {
        0x00, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x07,
        0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01, 0x08, 0x2A, 0x86, 0x48, 0xCE,
        0x3D, 0x03, 0x01, 0x07, 0x05, 0x2B, 0x81, 0x04, 0x00, 0x22, 0x05, 0x2B,
        0x81, 0x04, 0x00, 0x23
 };
 
-static const uint8_t t0_codeblock[] = {
+static const unsigned char t0_codeblock[] = {
        0x00, 0x01, 0x01, 0x07, 0x00, 0x00, 0x01, 0x01, 0x08, 0x00, 0x00, 0x13,
        0x13, 0x00, 0x00, 0x01, T0_INT1(BR_ERR_X509_BAD_TAG_CLASS), 0x00, 0x00,
        0x01, T0_INT1(BR_ERR_X509_BAD_TAG_VALUE), 0x00, 0x00, 0x01,
@@ -177,7 +177,7 @@ static const uint8_t t0_codeblock[] = {
        0x14, 0x35, 0x1C, 0x08, 0x20, 0x1C, 0x07, 0x20, 0x4E, 0x00, 0x01, 0x59,
        0x14, 0x01, 0x81, 0x00, 0x0A, 0x06, 0x01, 0x00, 0x01, 0x81, 0x00, 0x08,
        0x14, 0x05, 0x02, 0x28, 0x16, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01,
-       0x00, 0x0E, 0x06, 0x19, 0x02, 0x00, 0x23, 0x03, 0x00, 0x14, 0x01, 0x87,
+       0x00, 0x0E, 0x06, 0x19, 0x02, 0x00, 0x23, 0x03, 0x00, 0x14, 0x01, 0x83,
        0xFF, 0xFF, 0x7F, 0x0E, 0x06, 0x02, 0x29, 0x16, 0x01, 0x08, 0x0B, 0x20,
        0x59, 0x1C, 0x07, 0x04, 0x60, 0x00, 0x00, 0x52, 0x4A, 0x00, 0x00, 0x57,
        0x3C, 0x53, 0x00, 0x01, 0x53, 0x14, 0x05, 0x02, 0x2E, 0x16, 0x59, 0x14,
@@ -285,6 +285,8 @@ name(void *ctx) \
 
 T0_DEFENTRY(br_skey_decoder_init_main, 73)
 
+#define T0_NEXT(t0ipp)   (*(*(t0ipp)) ++)
+
 void
 br_skey_decoder_run(void *t0ctx)
 {
@@ -332,15 +334,17 @@ br_skey_decoder_run(void *t0ctx)
 #define T0_CO()         do { \
        goto t0_exit; \
 } while (0)
-#define T0_RET()        break
+#define T0_RET()        goto t0_next
 
        dp = ((t0_context *)t0ctx)->dp;
        rp = ((t0_context *)t0ctx)->rp;
        ip = ((t0_context *)t0ctx)->ip;
+       goto t0_next;
        for (;;) {
                uint32_t t0x;
 
-               t0x = t0_parse7E_unsigned(&ip);
+       t0_next:
+               t0x = T0_NEXT(&ip);
                if (t0x < T0_INTERPRETED) {
                        switch (t0x) {
                                int32_t t0off;