<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/44392/adding-encryption-to-secure-dfu-sdk-v15</link><description>I am attempting to add encryption to the secure DFU process with SDK 15.2. I am following the process described in this post , however am running into an issue related to the firmware type. 
 
 I have made all of the changes to nrfutil as described in</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 14 Mar 2019 19:45:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/44392/adding-encryption-to-secure-dfu-sdk-v15" /><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/176306?ContentTypeID=1</link><pubDate>Thu, 14 Mar 2019 19:45:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3926de5d-649a-4fc5-afd3-e2f6752b3ae2</guid><dc:creator>ibeckermayer</dc:creator><description>&lt;p&gt;Hey Stian, thanks for the reply. Yes I am compiling the&amp;nbsp;&lt;span&gt;the &lt;strong&gt;dfu-cc.pb.c&lt;/strong&gt; and &lt;strong&gt;dfu-cc.pb.h&lt;/strong&gt; files. We contacted VisualGDB support and received the newest distribution, so the user-added include directories are being included before the default system directories (confirmed this is the case by checking the generated&amp;nbsp;&lt;strong&gt;.gcc.rsp&lt;/strong&gt; files). I dealt with the&amp;nbsp;&lt;strong&gt;.c&lt;/strong&gt; files by changing their &amp;quot;Excluded From Build&amp;quot; property to &amp;quot;Yes&amp;quot;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I went back to try simply using a custom nrfutil without making any of the changes in that tutorial (just build pc-nrfutil-4.0.0 from source, generate our own &lt;strong&gt;dfu-cc.pb.c/h&lt;/strong&gt;&amp;nbsp;using the default &lt;strong&gt;dfu-cc.proto&lt;/strong&gt; included in the SDK)&amp;nbsp;and I can get everything to build and preform DFU&amp;#39;s. This is bizarre, however, because there is a discrepancy between the SDK&amp;#39;s&amp;nbsp;&lt;strong&gt;dfu-cc.proto&lt;/strong&gt; and the pc-nrfutil-4.0.0&amp;#39;s&amp;nbsp;&lt;strong&gt;dfu-cc.proto&lt;/strong&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;SDK:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;package dfu;

// Version 0.1

enum FwType {
	APPLICATION				= 0; // default, compatible with proto3
	SOFTDEVICE				= 1;
	BOOTLOADER				= 2;
	SOFTDEVICE_BOOTLOADER	= 3;
}

enum HashType {
	NO_HASH	= 0;
	CRC		= 1;
	SHA128	= 2;
	SHA256	= 3;
	SHA512	= 4;
}

message Hash {
	required HashType	hash_type	= 1;
	required bytes		hash		= 2;
}

// Commands data
message InitCommand {
	optional uint32	fw_version	= 1;
	optional uint32	hw_version	= 2;
	repeated uint32	sd_req		= 3 [packed = true]; // packed option is default in proto3
	optional FwType	type		= 4;

	optional uint32	sd_size		= 5;
	optional uint32	bl_size		= 6;
	optional uint32	app_size	= 7;

	optional Hash	hash		= 8;

	optional bool	is_debug	= 9 [default = false];
}

// Command type
message Command {
	enum OpCode {
		INIT = 1;
	}
	optional OpCode			op_code	= 1;
	optional InitCommand	init	= 2;
}

// Signed command types
enum SignatureType {
	ECDSA_P256_SHA256	= 0;
	ED25519				= 1;
}

message SignedCommand {
	required Command		command			= 1;
	required SignatureType	signature_type	= 2;
	required bytes			signature		= 3;
}

// Parent packet type
message Packet {
	optional Command		command			= 1;
	optional SignedCommand	signed_command	= 2;
}
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;vs pc-nrfutil-4.0.0&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;package dfu;

// Version 0.1

// Definition of enums and types
enum OpCode {
	RESET	= 0;
	INIT	= 1;
}

enum FwType {
	APPLICATION				= 0; // default, compatible with proto3
	SOFTDEVICE				= 1;
	BOOTLOADER				= 2;
	SOFTDEVICE_BOOTLOADER	= 3;
}

enum HashType {
	NO_HASH	= 0;
	CRC		= 1;
	SHA128	= 2;
	SHA256	= 3;
	SHA512	= 4;
}

message Hash {
	required HashType 	hash_type	= 1;
	required bytes 		hash		= 2;
}

// Commands data
message InitCommand {
	optional uint32	fw_version	= 1;
	optional uint32	hw_version	= 2;
	repeated uint32	sd_req		= 3 [packed = true]; // packed option is default in proto3
	optional FwType	type		= 4;

	optional uint32	sd_size		= 5;
	optional uint32	bl_size		= 6;
	optional uint32	app_size	= 7;

	optional Hash	hash		= 8;
    
    optional bool   is_debug    = 9 [default = false];
}

message ResetCommand {
	required uint32 timeout	= 1;
}

// Command type
message Command {
	optional OpCode			op_code	= 1;
	optional InitCommand	init 	= 2;
	optional ResetCommand	reset 	= 3;
}

// Signed command types
enum SignatureType {
	ECDSA_P256_SHA256	= 0;
	ED25519				= 1;
}

message SignedCommand {
	required Command		command			= 1;
	required SignatureType	signature_type	= 2;
	required bytes			signature		= 3;
}

// Parent packet type
message Packet {
	optional Command 		command			= 1;
	optional SignedCommand	signed_command	= 2;
}
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Despite this discrepancy,&amp;nbsp;&lt;em&gt;I can only get the DFU to work&lt;/em&gt;&lt;em&gt; when I use the differing defaults for both&lt;/em&gt;. By that, I mean I need to compile (using protoc, and in the case of pb.c/h, &lt;strong&gt;nanopb_generator.py&lt;/strong&gt;) the &lt;strong&gt;dfu-cc.pb.h/c&lt;/strong&gt; files using the SDK version of&amp;nbsp;&lt;strong&gt;dfu-cc.proto&lt;/strong&gt;, and I need to compile the&amp;nbsp;&lt;strong&gt;dfu_cc_pb2.py&lt;/strong&gt; file in pc-nrfutil using it&amp;#39;s default version of&amp;nbsp;&lt;strong&gt;dfu-cc.proto&lt;/strong&gt;. If I use either&amp;nbsp;&lt;strong&gt;dfu-cc.proto&lt;/strong&gt; file to compile both of them, I get an error. This makes no sense to me, since given my understanding of protobuf&amp;#39;s it seems to me as if they should both need to be using the same&amp;nbsp;&lt;strong&gt;dfu-cc.proto&lt;/strong&gt; files in order to work together properly. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Any idea how this might be possible? I&amp;#39;m completely stumped, don&amp;#39;t know where to go from here...&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Here are the generated&amp;nbsp;&lt;strong&gt;dfu-cc.pb.h/c&lt;/strong&gt; files, these are from a branch where I attempted to use the&amp;nbsp;&lt;strong&gt;dfu-cc.pb.proto&lt;/strong&gt; that is distributed with pc-nrfutil-4.0.0 for both pieces, without modifications:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;dfu-cc.pb.h:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/* Automatically generated nanopb header */
/* Generated by nanopb-0.3.6-dev at Thu Mar 14 12:43:43 2019. */

#ifndef PB_DFU_CC_PB_H_INCLUDED
#define PB_DFU_CC_PB_H_INCLUDED
#include &amp;lt;pb.h&amp;gt;

/* @@protoc_insertion_point(includes) */
#if PB_PROTO_HEADER_VERSION != 30
#error Regenerate this file with the current version of nanopb generator.
#endif

#ifdef __cplusplus
extern &amp;quot;C&amp;quot; {
#endif

/* Enum definitions */
typedef enum
{
    DFU_OP_CODE_RESET = 0,
    DFU_OP_CODE_INIT = 1
} dfu_op_code_t;
#define DFU_OP_CODE_MIN DFU_OP_CODE_RESET
#define DFU_OP_CODE_MAX DFU_OP_CODE_INIT
#define DFU_OP_CODE_ARRAYSIZE ((dfu_op_code_t)(DFU_OP_CODE_INIT+1))

typedef enum
{
    DFU_FW_TYPE_APPLICATION = 0,
    DFU_FW_TYPE_SOFTDEVICE = 1,
    DFU_FW_TYPE_BOOTLOADER = 2,
    DFU_FW_TYPE_SOFTDEVICE_BOOTLOADER = 3
} dfu_fw_type_t;
#define DFU_FW_TYPE_MIN DFU_FW_TYPE_APPLICATION
#define DFU_FW_TYPE_MAX DFU_FW_TYPE_SOFTDEVICE_BOOTLOADER
#define DFU_FW_TYPE_ARRAYSIZE ((dfu_fw_type_t)(DFU_FW_TYPE_SOFTDEVICE_BOOTLOADER+1))

typedef enum
{
    DFU_HASH_TYPE_NO_HASH = 0,
    DFU_HASH_TYPE_CRC = 1,
    DFU_HASH_TYPE_SHA128 = 2,
    DFU_HASH_TYPE_SHA256 = 3,
    DFU_HASH_TYPE_SHA512 = 4
} dfu_hash_type_t;
#define DFU_HASH_TYPE_MIN DFU_HASH_TYPE_NO_HASH
#define DFU_HASH_TYPE_MAX DFU_HASH_TYPE_SHA512
#define DFU_HASH_TYPE_ARRAYSIZE ((dfu_hash_type_t)(DFU_HASH_TYPE_SHA512+1))

typedef enum
{
    DFU_SIGNATURE_TYPE_ECDSA_P256_SHA256 = 0,
    DFU_SIGNATURE_TYPE_ED25519 = 1
} dfu_signature_type_t;
#define DFU_SIGNATURE_TYPE_MIN DFU_SIGNATURE_TYPE_ECDSA_P256_SHA256
#define DFU_SIGNATURE_TYPE_MAX DFU_SIGNATURE_TYPE_ED25519
#define DFU_SIGNATURE_TYPE_ARRAYSIZE ((dfu_signature_type_t)(DFU_SIGNATURE_TYPE_ED25519+1))

/* Struct definitions */
typedef PB_BYTES_ARRAY_T(32) dfu_hash_hash_t;
typedef struct {
    dfu_hash_type_t hash_type;
    dfu_hash_hash_t hash;
/* @@protoc_insertion_point(struct:dfu_hash_t) */
} dfu_hash_t;

typedef struct {
    uint32_t timeout;
/* @@protoc_insertion_point(struct:dfu_reset_command_t) */
} dfu_reset_command_t;

typedef struct {
    bool has_fw_version;
    uint32_t fw_version;
    bool has_hw_version;
    uint32_t hw_version;
    pb_size_t sd_req_count;
    uint32_t sd_req[4];
    bool has_type;
    dfu_fw_type_t type;
    bool has_sd_size;
    uint32_t sd_size;
    bool has_bl_size;
    uint32_t bl_size;
    bool has_app_size;
    uint32_t app_size;
    bool has_hash;
    dfu_hash_t hash;
    bool has_is_debug;
    bool is_debug;
/* @@protoc_insertion_point(struct:dfu_init_command_t) */
} dfu_init_command_t;

typedef struct {
    bool has_op_code;
    dfu_op_code_t op_code;
    bool has_init;
    dfu_init_command_t init;
    bool has_reset;
    dfu_reset_command_t reset;
/* @@protoc_insertion_point(struct:dfu_command_t) */
} dfu_command_t;

typedef PB_BYTES_ARRAY_T(64) dfu_signed_command_signature_t;
typedef struct {
    dfu_command_t command;
    dfu_signature_type_t signature_type;
    dfu_signed_command_signature_t signature;
/* @@protoc_insertion_point(struct:dfu_signed_command_t) */
} dfu_signed_command_t;

typedef struct {
    bool has_command;
    dfu_command_t command;
    bool has_signed_command;
    dfu_signed_command_t signed_command;
/* @@protoc_insertion_point(struct:dfu_packet_t) */
} dfu_packet_t;

/* Default values for struct fields */
extern const bool dfu_init_command_is_debug_default;

/* Initializer values for message structs */
#define DFU_HASH_INIT_DEFAULT                    {(dfu_hash_type_t)0, {0, {0}}}
#define DFU_INIT_COMMAND_INIT_DEFAULT            {false, 0, false, 0, 0, {0, 0, 0, 0}, false, (dfu_fw_type_t)0, false, 0, false, 0, false, 0, false, DFU_HASH_INIT_DEFAULT, false, false}
#define DFU_RESET_COMMAND_INIT_DEFAULT           {0}
#define DFU_COMMAND_INIT_DEFAULT                 {false, (dfu_op_code_t)0, false, DFU_INIT_COMMAND_INIT_DEFAULT, false, DFU_RESET_COMMAND_INIT_DEFAULT}
#define DFU_SIGNED_COMMAND_INIT_DEFAULT          {DFU_COMMAND_INIT_DEFAULT, (dfu_signature_type_t)0, {0, {0}}}
#define DFU_PACKET_INIT_DEFAULT                  {false, DFU_COMMAND_INIT_DEFAULT, false, DFU_SIGNED_COMMAND_INIT_DEFAULT}
#define DFU_HASH_INIT_ZERO                       {(dfu_hash_type_t)0, {0, {0}}}
#define DFU_INIT_COMMAND_INIT_ZERO               {false, 0, false, 0, 0, {0, 0, 0, 0}, false, (dfu_fw_type_t)0, false, 0, false, 0, false, 0, false, DFU_HASH_INIT_ZERO, false, 0}
#define DFU_RESET_COMMAND_INIT_ZERO              {0}
#define DFU_COMMAND_INIT_ZERO                    {false, (dfu_op_code_t)0, false, DFU_INIT_COMMAND_INIT_ZERO, false, DFU_RESET_COMMAND_INIT_ZERO}
#define DFU_SIGNED_COMMAND_INIT_ZERO             {DFU_COMMAND_INIT_ZERO, (dfu_signature_type_t)0, {0, {0}}}
#define DFU_PACKET_INIT_ZERO                     {false, DFU_COMMAND_INIT_ZERO, false, DFU_SIGNED_COMMAND_INIT_ZERO}

/* Field tags (for use in manual encoding/decoding) */
#define DFU_HASH_HASH_TYPE_TAG                   1
#define DFU_HASH_HASH_TAG                        2
#define DFU_RESET_COMMAND_TIMEOUT_TAG            1
#define DFU_INIT_COMMAND_FW_VERSION_TAG          1
#define DFU_INIT_COMMAND_HW_VERSION_TAG          2
#define DFU_INIT_COMMAND_SD_REQ_TAG              3
#define DFU_INIT_COMMAND_TYPE_TAG                4
#define DFU_INIT_COMMAND_SD_SIZE_TAG             5
#define DFU_INIT_COMMAND_BL_SIZE_TAG             6
#define DFU_INIT_COMMAND_APP_SIZE_TAG            7
#define DFU_INIT_COMMAND_HASH_TAG                8
#define DFU_INIT_COMMAND_IS_DEBUG_TAG            9
#define DFU_COMMAND_OP_CODE_TAG                  1
#define DFU_COMMAND_INIT_TAG                     2
#define DFU_COMMAND_RESET_TAG                    3
#define DFU_SIGNED_COMMAND_COMMAND_TAG           1
#define DFU_SIGNED_COMMAND_SIGNATURE_TYPE_TAG    2
#define DFU_SIGNED_COMMAND_SIGNATURE_TAG         3
#define DFU_PACKET_COMMAND_TAG                   1
#define DFU_PACKET_SIGNED_COMMAND_TAG            2

/* Struct field encoding specification for nanopb */
extern const pb_field_t dfu_hash_fields[3];
extern const pb_field_t dfu_init_command_fields[10];
extern const pb_field_t dfu_reset_command_fields[2];
extern const pb_field_t dfu_command_fields[4];
extern const pb_field_t dfu_signed_command_fields[4];
extern const pb_field_t dfu_packet_fields[3];

/* Maximum encoded size of messages (where known) */
#define DFU_HASH_SIZE                            36
#define DFU_INIT_COMMAND_SIZE                    96
#define DFU_RESET_COMMAND_SIZE                   6
#define DFU_COMMAND_SIZE                         108
#define DFU_SIGNED_COMMAND_SIZE                  178
#define DFU_PACKET_SIZE                          291

/* Message IDs (where set with &amp;quot;msgid&amp;quot; option) */
#ifdef PB_MSGID

#define DFU_CC_MESSAGES \


#endif

#ifdef __cplusplus
} /* extern &amp;quot;C&amp;quot; */
#endif
/* @@protoc_insertion_point(eof) */

#endif
&lt;/pre&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;dfu-cc.pb.c:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/* Automatically generated nanopb constant definitions */
/* Generated by nanopb-0.3.6-dev at Thu Mar 14 12:43:43 2019. */

#include &amp;quot;dfu-cc.pb.h&amp;quot;

/* @@protoc_insertion_point(includes) */
#if PB_PROTO_HEADER_VERSION != 30
#error Regenerate this file with the current version of nanopb generator.
#endif

const bool dfu_init_command_is_debug_default = false;


const pb_field_t dfu_hash_fields[3] = {
    PB_FIELD(  1, UENUM   , REQUIRED, STATIC  , FIRST, dfu_hash_t, hash_type, hash_type, 0),
    PB_FIELD(  2, BYTES   , REQUIRED, STATIC  , OTHER, dfu_hash_t, hash, hash_type, 0),
    PB_LAST_FIELD
};

const pb_field_t dfu_init_command_fields[10] = {
    PB_FIELD(  1, UINT32  , OPTIONAL, STATIC  , FIRST, dfu_init_command_t, fw_version, fw_version, 0),
    PB_FIELD(  2, UINT32  , OPTIONAL, STATIC  , OTHER, dfu_init_command_t, hw_version, fw_version, 0),
    PB_FIELD(  3, UINT32  , REPEATED, STATIC  , OTHER, dfu_init_command_t, sd_req, hw_version, 0),
    PB_FIELD(  4, UENUM   , OPTIONAL, STATIC  , OTHER, dfu_init_command_t, type, sd_req, 0),
    PB_FIELD(  5, UINT32  , OPTIONAL, STATIC  , OTHER, dfu_init_command_t, sd_size, type, 0),
    PB_FIELD(  6, UINT32  , OPTIONAL, STATIC  , OTHER, dfu_init_command_t, bl_size, sd_size, 0),
    PB_FIELD(  7, UINT32  , OPTIONAL, STATIC  , OTHER, dfu_init_command_t, app_size, bl_size, 0),
    PB_FIELD(  8, MESSAGE , OPTIONAL, STATIC  , OTHER, dfu_init_command_t, hash, app_size, &amp;amp;dfu_hash_fields),
    PB_FIELD(  9, BOOL    , OPTIONAL, STATIC  , OTHER, dfu_init_command_t, is_debug, hash, &amp;amp;dfu_init_command_is_debug_default),
    PB_LAST_FIELD
};

const pb_field_t dfu_reset_command_fields[2] = {
    PB_FIELD(  1, UINT32  , REQUIRED, STATIC  , FIRST, dfu_reset_command_t, timeout, timeout, 0),
    PB_LAST_FIELD
};

const pb_field_t dfu_command_fields[4] = {
    PB_FIELD(  1, UENUM   , OPTIONAL, STATIC  , FIRST, dfu_command_t, op_code, op_code, 0),
    PB_FIELD(  2, MESSAGE , OPTIONAL, STATIC  , OTHER, dfu_command_t, init, op_code, &amp;amp;dfu_init_command_fields),
    PB_FIELD(  3, MESSAGE , OPTIONAL, STATIC  , OTHER, dfu_command_t, reset, init, &amp;amp;dfu_reset_command_fields),
    PB_LAST_FIELD
};

const pb_field_t dfu_signed_command_fields[4] = {
    PB_FIELD(  1, MESSAGE , REQUIRED, STATIC  , FIRST, dfu_signed_command_t, command, command, &amp;amp;dfu_command_fields),
    PB_FIELD(  2, UENUM   , REQUIRED, STATIC  , OTHER, dfu_signed_command_t, signature_type, command, 0),
    PB_FIELD(  3, BYTES   , REQUIRED, STATIC  , OTHER, dfu_signed_command_t, signature, signature_type, 0),
    PB_LAST_FIELD
};

const pb_field_t dfu_packet_fields[3] = {
    PB_FIELD(  1, MESSAGE , OPTIONAL, STATIC  , FIRST, dfu_packet_t, command, command, &amp;amp;dfu_command_fields),
    PB_FIELD(  2, MESSAGE , OPTIONAL, STATIC  , OTHER, dfu_packet_t, signed_command, command, &amp;amp;dfu_signed_command_fields),
    PB_LAST_FIELD
};


/* Check that field information fits in pb_field_t */
#if !defined(PB_FIELD_32BIT)
/* If you get an error here, it means that you need to define PB_FIELD_32BIT
 * compile-time option. You can do that in pb.h or on compiler command line.
 * 
 * The reason you need to do this is that some of your messages contain tag
 * numbers or field sizes that are larger than what can fit in 8 or 16 bit
 * field descriptors.
 */
PB_STATIC_ASSERT((pb_membersize(dfu_init_command_t, hash) &amp;lt; 65536 &amp;amp;&amp;amp; pb_membersize(dfu_command_t, init) &amp;lt; 65536 &amp;amp;&amp;amp; pb_membersize(dfu_command_t, reset) &amp;lt; 65536 &amp;amp;&amp;amp; pb_membersize(dfu_signed_command_t, command) &amp;lt; 65536 &amp;amp;&amp;amp; pb_membersize(dfu_packet_t, command) &amp;lt; 65536 &amp;amp;&amp;amp; pb_membersize(dfu_packet_t, signed_command) &amp;lt; 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_dfu_hash_dfu_init_command_dfu_reset_command_dfu_command_dfu_signed_command_dfu_packet)
#endif

#if !defined(PB_FIELD_16BIT) &amp;amp;&amp;amp; !defined(PB_FIELD_32BIT)
/* If you get an error here, it means that you need to define PB_FIELD_16BIT
 * compile-time option. You can do that in pb.h or on compiler command line.
 * 
 * The reason you need to do this is that some of your messages contain tag
 * numbers or field sizes that are larger than what can fit in the default
 * 8 bit descriptors.
 */
PB_STATIC_ASSERT((pb_membersize(dfu_init_command_t, hash) &amp;lt; 256 &amp;amp;&amp;amp; pb_membersize(dfu_command_t, init) &amp;lt; 256 &amp;amp;&amp;amp; pb_membersize(dfu_command_t, reset) &amp;lt; 256 &amp;amp;&amp;amp; pb_membersize(dfu_signed_command_t, command) &amp;lt; 256 &amp;amp;&amp;amp; pb_membersize(dfu_packet_t, command) &amp;lt; 256 &amp;amp;&amp;amp; pb_membersize(dfu_packet_t, signed_command) &amp;lt; 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_dfu_hash_dfu_init_command_dfu_reset_command_dfu_command_dfu_signed_command_dfu_packet)
#endif


/* @@protoc_insertion_point(eof) */
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/175984?ContentTypeID=1</link><pubDate>Wed, 13 Mar 2019 14:47:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eda664ac-c531-4907-8843-e377d8afab22</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;Hi, are you sure you are actually compiling with the dfu-cc.pb.c and dfu-cc.pb.h files you generated? The old dfu-cc.pb.h file in the components/libraries/bootloader/dfu folder will probably still be used if you don&amp;#39;t rename/delete it.&lt;/p&gt;
&lt;p&gt;Can you post the generated files here so I can see if they look correct?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/174398?ContentTypeID=1</link><pubDate>Tue, 05 Mar 2019 23:59:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:071f4e24-1bb3-49f1-9c1b-6e52e7ab4e8b</guid><dc:creator>ibeckermayer</dc:creator><description>&lt;p&gt;I changed&amp;nbsp;&lt;strong&gt;dfu-cc.options&amp;nbsp;&lt;/strong&gt;to&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;dfu.Hash.hash				max_size:32
dfu.SignedCommand.signature	max_size:64
dfu.InitCommand.sd_req		max_count:12
dfu.InitCommand.nonce		max_size:12&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;since I noticed that&amp;#39;s how @Matthew has it (sd_req max_count is 12 instead of 4), and now I&amp;#39;m passing the firmware type check but getting caught at the hash type check:&lt;/p&gt;
&lt;p&gt;&amp;quot;Invalid hash type of 189.&amp;quot;&lt;/p&gt;
&lt;p&gt;My intuition is that there&amp;#39;s some sort of &amp;#39;alignment&amp;#39; issue here with parsing the message, but I&amp;#39;m not an expert in how proto messages work so I&amp;#39;m still not quite sure how I might go about debugging this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/174394?ContentTypeID=1</link><pubDate>Tue, 05 Mar 2019 23:36:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:766fc321-90b5-4162-8e88-958cddf6b44d</guid><dc:creator>ibeckermayer</dc:creator><description>&lt;p&gt;One thing I can imagine might potentially be causing a problem is that when I compile the .proto into&amp;nbsp;&lt;strong&gt;dfu_cc_pb2.py (&lt;/strong&gt;as described in step 3 &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.tools%2Fdita%2Ftools%2Fnrfutil%2Fnrfutil_customizing.html&amp;amp;cp=5_5_8"&gt;here&lt;/a&gt;), I am not making use of the&amp;nbsp;&lt;strong&gt;dfu-cc.options&lt;/strong&gt; file, however when I compile it into&amp;nbsp;&lt;strong&gt;dfu-cc.pb.c/h&lt;/strong&gt;, I am using&amp;nbsp;&lt;strong&gt;nanopb_generator.py&lt;/strong&gt; with the&amp;nbsp;&lt;strong&gt;-f&lt;/strong&gt; option to include&amp;nbsp;&lt;strong&gt;dfu-cc.options&amp;nbsp;&lt;/strong&gt;i.e.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;pre class="ui-code" data-mode="text"&gt;python $NANO_PB_GEN_PATH dfu-cc.pb -f dfu-cc.options&lt;/pre&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Could that be causing some sort of misalignment when the package is created? My&amp;nbsp;&lt;strong&gt;dfu-cc.options&lt;/strong&gt; file looks like:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;dfu.Hash.hash				max_size:32
dfu.SignedCommand.signature	max_size:64
dfu.InitCommand.sd_req		max_count:4
dfu.InitCommand.nonce		max_size:12&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/174392?ContentTypeID=1</link><pubDate>Tue, 05 Mar 2019 23:21:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b16ec860-8c5c-491a-bb05-53e97bea1ef9</guid><dc:creator>ibeckermayer</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/matthew"&gt;Matthew&lt;/a&gt; &lt;a href="https://devzone.nordicsemi.com/members/hungbui"&gt;Hung Bui&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I just retried this using&amp;nbsp;&lt;strong&gt;pc-nrfutil-3.5.1&lt;/strong&gt; and am getting a similar error (this time it says&amp;nbsp;type of 38). My protobuf message is as follows:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;package dfu;

// Version 0.1

// Definition of enums and types
enum OpCode {
	RESET	= 0;
	INIT	= 1;
}

enum FwType {
	APPLICATION				= 0; // default, compatible with proto3
	SOFTDEVICE				= 1;
	BOOTLOADER				= 2;
	SOFTDEVICE_BOOTLOADER	= 3;
}

enum HashType {
	NO_HASH	= 0;
	CRC		= 1;
	SHA128	= 2;
	SHA256	= 3;
	SHA512	= 4;
}

message Hash {
	required HashType 	hash_type	= 1;
	required bytes 		hash		= 2;
}

// Commands data
message InitCommand {
	optional uint32	fw_version	= 1;
	optional uint32	hw_version	= 2;
	repeated uint32	sd_req		= 3 [packed = true]; // packed option is default in proto3
	optional FwType	type		= 4;

	optional uint32	sd_size		= 5;
	optional uint32	bl_size		= 6;
	optional uint32	app_size	= 7;

	optional Hash	hash		= 8;
    
  optional bool   is_debug    = 9 [default = false];
	optional bytes  nonce		= 10;
}

message ResetCommand {
	required uint32 timeout	= 1;
}

// Command type
message Command {
	optional OpCode			op_code	= 1;
	optional InitCommand	init 	= 2;
	optional ResetCommand	reset 	= 3;
}

// Signed command types
enum SignatureType {
	ECDSA_P256_SHA256	= 0;
	ED25519				= 1;
}

message SignedCommand {
	required Command		command			= 1;
	required SignatureType	signature_type	= 2;
	required bytes			signature		= 3;
}

// Parent packet type
message Packet {
	optional Command 		command			= 1;
	optional SignedCommand	signed_command	= 2;
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/174387?ContentTypeID=1</link><pubDate>Tue, 05 Mar 2019 21:17:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0fd8c48f-93dd-47cc-b6f8-9448751ad63d</guid><dc:creator>ibeckermayer</dc:creator><description>&lt;p&gt;Thanks Hung. I believe there is a mistake with my protobuf message now, I realized that Matthew&amp;#39;s tutorial is modifying nrfutil 3.5.1 but I&amp;#39;ve been hacking it together with 4.0.0. I&amp;#39;m going to test this out with 3.5.1 and will report back if I manage to solve it that way.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/174332?ContentTypeID=1</link><pubDate>Tue, 05 Mar 2019 15:14:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:264aaa41-c0c7-4bb6-a09b-a13718263bf6</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I hope you will get help from &lt;a href="https://devzone.nordicsemi.com/members/mathew"&gt;Mathew&lt;/a&gt; on this case. Just want to let you know the m_packet (which&amp;nbsp;p_command-&amp;gt;init get the pointer from ) is generated when we decode the protobuf inside&amp;nbsp;stored_init_cmd_decode(). You can step in&amp;nbsp;pb_decode() to see why you get type = 62.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Maybe you can post your protobuf message format.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>