Mistake on this page? Email us

Integrating the factory ID and public key into your device firmware

To enable devices in the factory and Secure Factory Service to trust each other in the factory line, you must update the device firmware with the factory public key.

If you have multiple factories, you must associate the public key with the factory ID.

To integrating the factory ID and public key into your device firmware:

  1. Retrieve the factory ID and public key from Secure Factory Command:

    1. Select Status from the Secure Factory Command side menu.

      The Factory ID and Factory public key appear in the Key agreement section of the screen.

    2. Click the Copy as bytes button next to the Factory public key.

  2. In the factory_id_config.c file:

    1. Set the PEER_FACTORY_ID_1 to the value shown in the factory Factory ID field in Secure Factory Command.

      If you have multiple factories, set PEER_FACTORY_ID_2, and add PEER_FACTORY_ID_3 and so on.

    2. Set the peer_factory_1[65] to the Factory public key value you copied from Secure Factory Command.

      If you have multiple factories, set PEER_FACTORY_ID_3, and add PEER_FACTORY_ID_3 and so on.

For information about building the device firmware, please see the nanoclient-example documentation (ark-stm32l0/apps/nanoclient-example/README.md).

factory_id_config.c example

#include "factory_id_config.h"
​
/** Peer FACTORY ID values.
 *  Allowed range is 0x1 to 0xFF
 */
typedef enum peer_factory_id {
    PEER_FACTORY_ID_1   =  0x1,
    PEER_FACTORY_ID_2   =  0x81,
} peer_factory_id_e;
​
​
/** peer factory parameters array. Contains list of FACTORY IDs and peer public keys.
 */
const peer_factory_config_s peer_factory_params[]  =   {
                                                       /*  peer factory id           peer factory public key
                                                       ============================================================================== */
                                                         { PEER_FACTORY_ID_1,      { 0x04,0xf1,0x56,0x37,0xf8,0xf8,0xd5,0xf2,0x39,0x88,
                                                                                     0x0d,0x7f,0x0f,0x3f,0xf1,0x7f,0xed,0x3a,0x8b,0xe1,
                                                                                     0x8f,0xc2,0xfb,0x5c,0x53,0x3d,0xce,0xb3,0xde,0xeb,
                                                                                     0xd8,0xdd,0xf7,0x81,0x77,0x08,0x74,0xd6,0xc9,0x1d,
                                                                                     0x15,0x06,0x21,0xa3,0xe1,0x93,0xa4,0x23,0xe6,0x27,
                                                                                     0xd5,0xad,0x46,0xde,0x05,0x62,0x43,0x74,0xb3,0x12,
                                                                                     0x81,0x6b,0x88,0x2a,0x25
                                                                                   }
                                                         },
                                                         { PEER_FACTORY_ID_2,      { 0x04,0x61,0xa7,0x54,0xf8,0x67,0x99,0xbb,0x18,0x15,
                                                                                     0x0e,0x17,0xd4,0xe4,0xa3,0x1f,0x39,0xcf,0xbc,0x68,
                                                                                     0x7e,0xf4,0x91,0x54,0xe1,0x24,0xef,0x25,0x49,0x43,
                                                                                     0x14,0x99,0x9c,0xa5,0x6b,0x1a,0x72,0x25,0xc4,0x58,
                                                                                     0x25,0x42,0xf5,0x6d,0x71,0xeb,0xb5,0xf2,0x72,0x37,
                                                                                     0x0c,0xc2,0x06,0x57,0xb0,0x0a,0x2d,0xee,0x2b,0x58,
                                                                                     0xb0,0xe7,0x8d,0x61,0xf7
                                                                                   }
                                                         }
                                                       };
​
//number of peer factories
const size_t num_of_peer_factories = (sizeof(peer_factory_params) / sizeof(peer_factory_params[0]));