[riot-notifications] [RIOT-OS/RIOT] suit: Initial minimal SUIT parser (#10315)

Kaspar Schleiser notifications at github.com
Tue Feb 26 12:08:06 CET 2019


kaspar030 requested changes on this pull request.

Code looks good. Will do some testing now.

> + *
+ * The parser is based on draft version 1 of the specification.
+ *
+ * @see https://tools.ietf.org/html/draft-moran-suit-manifest-01
+ *
+ * @{
+ *
+ * @brief       Decoding functions for a SUIT manifest
+ * @author      Koen Zandberg <koen at bergzand.net>
+ */
+
+#ifndef SUIT_H
+#define SUIT_H
+
+#ifdef __cplusplus
+extern "C" {

pls move this below the includes

> + *
+ * @param           manifest    manifest to retrieve the digest from
+ * @param           digest      type of digest to retrieve
+ * @param[inout]    buf         buffer to write the digest in
+ * @param[inout]    len         size of the buffer and length of the digest
+ *
+ * @return                      @ref SUIT_OK on success
+ * @return                      negative on error
+ */
+int suit_payload_get_digest(const suit_manifest_t *manifest,
+            suit_digest_type_t digest, uint8_t *buf, size_t *len);
+
+#ifdef __cplusplus
+}
+#endif
+/** @} */

maybe move this line below the next - so it is

```
/** @{ */
#header guard open
...
#header guard close
/* @} */
```

(if you have the file open anyways)

> +#define ENABLE_DEBUG (0)
+#include "debug.h"
+
+static int _advance_x(CborValue *it, unsigned x)
+{
+    for(unsigned i=0; i < x; i++)
+    {
+        cbor_value_advance(it);
+        if (cbor_value_at_end(it)) {
+            return -1;
+        }
+    }
+    return 0;
+}
+
+static int parse_manifest_version(CborValue *it,

please rename ```parse_*``` to ```_parse_*``` if static.

> + *
+ * @}
+ */
+#include <string.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "suit.h"
+#include "cbor.h"
+
+#define ENABLE_DEBUG (0)
+#include "debug.h"
+
+static int _advance_x(CborValue *it, unsigned x)
+{
+    for(unsigned i=0; i < x; i++)

uncrustify

> +
+    if(_advance_x(&arr, SUIT_MANIFEST_IDX_PAYLOADINFO) < 0) {
+        /* If it is impossible to advance to the payloadinfo we assume that
+         * there is no payloadinfo. Length validation is already done by
+         * _validate_manifest, an invalid array length should not be possible
+         * at this point.
+         */
+        return SUIT_OK;
+    }
+
+    if (_validate_payloadinfo(&arr)) {
+        return SUIT_ERR_INVALID_MANIFEST;
+    }
+    return SUIT_OK;
+}
+

extra newline

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10315#pullrequestreview-207890644
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190226/e015270b/attachment.html>


More information about the notifications mailing list