Request a firmware review
Menu

Factory provisioning: giving every device a unique identity

Reader question: How should each device get its unique keys and certificates during manufacturing when a contract manufacturer builds our boards, and what has to be locked before units ship?

Micrograph-style illustration of fingertip skin ridges seen very close with their rows of sweat pores, with one ridge tinted amber.

Give every unit its own private key, created inside the device or inside a secure element so it never exists anywhere else, and let the factory handle only public keys, certificate signing requests and the signed certificates that come back. You have three ways to do that with a contract manufacturer: create the identity on the line, buy a secure element that arrives with one, or create it at first boot and claim it later. Before a unit ships, enable secure boot and flash encryption in the order your chip vendor documents, lock the debug port, remove factory commands, and record which serial number carries which identity.

This guide compares those three models for IoT device provisioning in manufacturing: what each exposes to the factory, what it adds to line time and how it fits AWS IoT, Azure IoT Device Provisioning Service (DPS) or your own certificate authority (CA). It then covers the end-of-line locking steps and the factory record. Regulatory and platform details are as of November 2026.

Fumbar is a Denver firmware company that writes embedded firmware for hardware startups and the over-the-air update path that keeps it improving after devices ship. Factory firmware and provisioning scripts are part of its manufacturing firmware work; this article explains the decisions so your team can make them with any partner.

What a device identity is, and why each unit needs its own

A device identity is a secret that only one unit holds, plus a way for your cloud to check it: usually a private key and an X.509 certificate, sometimes a symmetric key. One identity per unit lets you trust messages from that unit and revoke a single stolen or cloned unit without touching the rest of the fleet.

The credential types you will meet

Microsoft’s security practices for Azure IoT device manufacturers names three widely used authentication types: X.509 certificates, Trusted Platform Modules (TPM) and symmetric keys.

  • X.509 certificate. A signed statement, defined in IETF RFC 5280, that binds a public key to a device name. The device proves it holds the matching private key without revealing it.
  • TPM. A standardized security chip (ISO/IEC 11889) that generates and stores keys. Azure DPS uses its endorsement key to attest the device.
  • Symmetric key. The same secret sits in the device and in the service. Microsoft recommends protecting such keys in a hardware security module (HSM) and says to “avoid using shared symmetric keys on your devices”.

AWS makes the same point for certificates. Its X.509 client certificate guide recommends “that each device or client be given a unique certificate to enable fine-grained client management actions, including certificate revocation”, and says devices “must also support rotation and replacement of certificates”.

What goes into a device certificate

A device certificate is small, but four choices in it are hard to change once units ship:

  • Name. Put the serial number, or a value derived from it, in the certificate’s subject so every log line can be tied to a physical unit.
  • Key algorithm. Pick one your cloud and your chip both support. AWS IoT, for example, accepts RSA keys of at least 2048 bits and ECC keys on the NIST P-256, P-384 and P-521 curves, per its X.509 client certificate guide.
  • Validity. Long enough to cover warehouse time and the support period, or short with renewal built into the firmware. Microsoft’s guidance compares certificates to a driver’s license: they expire, and “you need a strategy for renewal”.
  • Issuer chain. Which CA signed the certificate, and which root your cloud trusts. A root kept offline with one intermediate per factory or line makes a factory problem revocable without replacing the root.

Device identity is not the firmware signing key

Two kinds of keys meet at the factory, and they must not be confused. The firmware signing key proves an image came from you; only its public half goes into every device, and its private half never goes near the line.

The device identity key is the opposite: a different private key in every unit. Where to keep and rotate the signing key is covered in firmware signing keys: storage, rotation and revocation.

Regulators now expect unique credentials

The UK’s product security regulations came into force on April 29, 2024. For consumer connectable products in scope, passwords must be “unique per product” or “defined by the user of the product”.

Unique passwords must not be based on incremental counters, on public information, or on serial numbers unless derived with “an encryption method, or keyed hashing algorithm, that is accepted as part of good industry practice”. Cryptographic keys are outside that password rule, but the intent is the same.

In the EU, Annex I of the Cyber Resilience Act asks products in scope to ship “with a secure by default configuration” and to “ensure protection from unauthorised access by appropriate control mechanisms, including but not limited to authentication, identity or access management systems”. It also asks for products designed “to limit attack surfaces, including external interfaces”, which includes debug ports.

Its main obligations apply from December 11, 2027. This summary is not legal advice.

Three models for IoT device provisioning in manufacturing

Every factory provisioning plan is one of three models, or a mix: create the identity on the line, buy it inside a secure element, or create it at first boot and claim it. They differ in what the factory can see, what they cost per unit and per second of line time, and what can go wrong.

1. Created on the line2. Pre-provisioned secure element3. Created at first boot, then claimed
Where the private key is bornOn the device at the station (best), or on a station or HSM and then written inInside the secure element, at the vendor's facilityOn the device after it leaves the factory
What the factory handlesCSRs and certificates, plus access to a signing CA or a key-generating HSMNothing secret; reels of parts and the vendor's certificate listFirmware and, often, a shared claim credential
Added bill of materialsNone if the chip can store keys wellA secure element and its board spaceNone
Added line timeKey generation, signing round trip, certificate writeReading the certificate or public key and logging itLeast; the work moves to installation
Main riskMisuse of the factory's signing accessTrusting the vendor and registering only units you builtA leaked claim credential used to enroll fake devices
Cloud fitYour CA registered in the cloud; AWS JITP or JITR; DPS enrollment groupsVendor certificate lists; AWS multi-account registration; DPSAWS fleet provisioning by claim or by trusted user; DPS at installation
Figure 1. The three factory provisioning models compared. Editorial summary based on AWS IoT Core and Microsoft Azure DPS documentation and vendor secure element pages, checked November 2026.

Model 1 suits most startups whose microcontroller can generate and protect a key. Model 2 suits chips without good key storage, or a factory you cannot give signing access to. Model 3 suits products installed by a person with an app, or factories with no connectivity, provided the claim step is guarded.

Model 1: create the identity on the line

In this model the station at the end of the line gives each unit its identity while it is being programmed. The safest variant has the device generate its own key pair and send out only a certificate signing request (CSR), so the private key never exists outside the unit.

Variant A: the device generates its key and the station collects a CSR

The firmware or a factory image generates a key pair inside the chip, stores the private key in protected storage, and hands the station a CSR containing only the public key. The station sends the CSR to your CA, receives a certificate and writes it back. Microsoft’s guidance calls these “device-generated certificates”, where “you must extract the public X.509 certificate from the device to enroll it in DPS”.

On AWS, the device provisioning guide points teams that can install unique certificates before delivery to just-in-time provisioning (JITP) or just-in-time registration (JITR). The CA that signs device certificates is registered with AWS IoT, and the device is provisioned on its first connection. AWS’s fleet provisioning API also offers CreateCertificateFromCsr for devices that keep their own key.

Variant B: keys are generated off the device and written in

Here a station, an HSM or a provisioning service generates the key and writes it into the device. Microsoft’s guidance suggests installing credentials “at the same time that you flash the initial firmware image”, and in this variant the private key goes in with the certificate. It is often the only option for chips that cannot generate keys, but every private key exists outside the unit for a moment.

The worst version is a file of pre-generated private keys copied to a factory PC. Microsoft notes that an offline factory using a third-party PKI “must generate the certificates ahead of time”. If you go that way, keep the keys inside an HSM at the station rather than in a file, and destroy the batch once the run ends.

Azure DPS has a symmetric-key form of this model. In its symmetric key attestation design, each device key is derived by hashing the device’s registration ID with an enrollment group key. Microsoft says device keys are ideally “derived and installed in the factory”, so the group key is never included in any software deployed to the device.

The factory system that derives the keys still needs the group key, so that is where your protection goes.

Running the CA

Someone has to operate the CA that signs device certificates. Microsoft notes that it “can be costly and complex to manage a public key infrastructure (PKI)”, and lists two options: a third-party PKI, where you buy intermediate signing certificates or use a private CA, or a self-managed PKI you run yourself. A hosted service moves the hardware security and audit logs to a vendor; running your own keeps them in-house along with the work.

Whichever you choose, keep the root key offline and let only an intermediate CA sign device certificates. Give the factory access to that intermediate through a narrow interface that accepts a CSR and returns a certificate, never a copy of the intermediate’s private key.

What it exposes and what it costs

The factory never needs your firmware signing key, but in variant A it needs the ability to get certificates signed. Anyone who controls the station can request certificates for devices that do not exist. Limit that with a dedicated intermediate CA for each manufacturer or line, a short validity for that intermediate, a cap on how many certificates it issues per day, and a daily reconciliation of issued certificates against units that passed test.

Line time grows by the key generation, the signing round trip and the certificate write. Connectivity matters: Microsoft lists connected factories, offline factories with your own PKI, and offline factories with a third-party PKI as distinct cases. Measure the step on your chip rather than estimating it.

Example (fictional). Loamwick’s LW-1 probe uses variant A. At the station, the probe’s firmware generates its key pair, and the station forwards the CSR to an intermediate CA that Loamwick issued only for this contract manufacturer. The certificate comes back, is written to the probe, and the station logs the certificate’s fingerprint next to the serial number.

The intermediate is valid for the length of the production run and is capped at a few hundred certificates per day, well above the line’s output. Each evening, Loamwick compares certificates issued with probes that passed test; any difference is investigated before the next shift.

Model 2: buy a secure element that arrives provisioned

In this model a separate security chip, called a secure element, leaves its maker’s facility with a key pair generated inside it and a certificate already signed. Your factory solders it on and reads out the certificate; nothing secret passes through the line.

How it works

Infineon’s product page, for example, describes the OPTIGA Trust M as “a pre-provisioned discrete secure element” that “can be integrated with any MCU that lacks security by design”. Other secure element makers sell comparable parts; the point is the model, not the brand. Microsoft’s guidance describes the same idea as “preloaded certificates”: “the HSM vendor installs certificates signed by that signing certificate onto each HSM the customer buys”.

Certificates from such parts may chain to the vendor’s CA rather than yours. AWS supports that case through multi-account registration, which lets you register a device certificate without registering the CA that signed it. Azure DPS can enroll the certificates or, for TPM-based designs, the endorsement keys.

What it exposes and what it costs

The factory handles reels of parts and a certificate list from the vendor, not secrets. You do trust the vendor’s facility and its records, and you add a part, board space and an I2C or SPI connection to the bill of materials. Line time is small: the station reads the certificate or public key and logs it.

The risk to manage is registration. Register only the identities of units your factory record says were built and passed test, not every certificate on the vendor’s list, so a lost reel does not become a set of trusted devices.

What the firmware has to do differently

With a secure element, the private key never enters the microcontroller, so the firmware cannot sign with a key in flash. The TLS library has to hand each signing operation to the secure element over the bus, and the driver has to handle a busy or missing part gracefully.

Check three things before choosing the part:

  • Your TLS stack supports handing the signature to the secure element.
  • The secure element’s library builds cleanly in your firmware and toolchain.
  • One signing operation over the bus is fast enough for your connection setup.

Build a working connection on an evaluation board before the part goes on the schematic.

A caution from the TPM world

Microsoft’s TPM timeline suggests asking the TPM maker for a list of public endorsement keys with each shipment. It also mentions letting the TPM maker add devices to your enrollment list directly, then adds: “Do so at your own risk.” The same caution applies to any supplier you let write into your device registry.

Model 3: create the identity at first boot, then claim it

In this model units leave the factory without a unique credential. The identity is created or issued when the device first connects, and a person or a service claims it. Line time is lowest, but the claim step carries the security weight.

Claim with a shared credential

AWS calls this provisioning by claim. Every unit carries the same claim certificate, and on first connection AWS IoT exchanges it for a unique device certificate.

AWS says this “could present a larger risk in the event of a compromised claim certificate”. Deactivating a leaked claim certificate stops future registrations, but “does not block devices that have already been provisioned”.

AWS recommends pre-provisioning hooks: functions that “validate parameters passed from the device before allowing the device to be provisioned”. A hook that checks each serial number against your factory record, once, closes most of the gap a shared claim credential opens.

Claim through a trusted user

AWS’s provisioning by trusted user fits products set up by an installer or an owner with an app. The device holds a temporary certificate that lets it connect “for only 5 minutes”, and during that window the app obtains a long-lived unique certificate and installs it. Microsoft’s TPM timeline follows a similar path: the device is enrolled in the factory and provisions itself through DPS once installed at its final location.

Where onboarding standards fit

NIST’s SP 1800-36, final in November 2025, demonstrates “trusted network-layer onboarding”: attesting and verifying “the identity and posture of the device and the network” before a device receives network credentials. The identity your factory provisions is what that kind of onboarding checks, so even a first-boot model usually needs some factory-installed proof that the unit is genuine.

Network credentials are a separate step

Joining a Wi-Fi network is not the same as having a device identity. Espressif’s security overview describes “Secure Provisioning” as “secure on-boarding of the ESP device on to the Wi-Fi network”, with a secure session between the device and a provisioning app on a phone. NIST’s guide draws the same line between network-layer onboarding and the device identity that onboarding relies on.

Plan both. The factory installs the identity, and the installer or owner supplies the network credentials, ideally over a session the identity protects.

Two limits to respect

A claim flow must not fall back on a default password; the UK rules above make that explicit for consumer products. Warehouse time also matters. Microsoft notes a device “can sometimes sit in a warehouse for up to a year” before installation, so any credential set at the factory needs a validity period and a renewal path that survive storage.

Choosing a model with a contract manufacturer

Choose by three facts: whether your chip can generate and protect a private key, whether you can give the factory controlled signing access, and whether a trusted person will be present at installation. Most microcontroller products with secure key storage end up on model 1, variant A.

Decision rules

  1. If the chip can generate a key pair and keep the private key unreadable, use model 1, variant A.
  2. If it cannot, or your security review rules out signing access at the factory, use model 2 and budget the secure element.
  3. If an installer or owner sets up every unit with an app, model 3 by trusted user is reasonable, often combined with a factory-installed identity for attestation.
  4. Use a shared claim credential only with a pre-provisioning check against your factory record.
  5. Never ship a fleet-wide symmetric key or a default password.

Example (fictional). Loamwick’s product has two kinds of units: LW-1 probes that talk Bluetooth LE to a gateway, and solar-powered gateways that forward readings over LTE-M cellular. Each needs its own identity.

Each gateway gets a certificate on the line and uses it to connect to Loamwick’s cloud. Each probe gets its own certificate too, and the gateway forwards readings with the probe’s serial number and a signature the cloud can check. A stolen gateway can then be revoked without touching the probes it served, and a cloned probe stands out because its signature does not match the registered public key.

Example (fictional). A two-founder team is preparing a Wi-Fi air-quality monitor on an ESP32-family chip for a first run of a few thousand units. The chip can generate keys internally, so they choose model 1, variant A, for the cloud identity.

For flash encryption they compare the two Espressif workflows on ten boards. Letting each device generate its own key keeps it off the station but adds the first-boot encryption pass to the line; generating keys on the station is quicker but puts a key on the factory PC for a moment. They keep keys on the device and accept the longer cycle, because the extra seconds cost less than a new control at the factory.

Comparing the cost per unit

Put the models side by side with one formula: cost per unit equals added parts, plus added station seconds times what a second of line time costs you, plus any per-certificate fee. Engineering time to build the flow is a one-off cost on top.

For example, suppose a secure element adds a part costing a little under a dollar, while on-device key generation adds eight seconds per unit on a line that charges five cents per station second. Both land near forty cents to a dollar per unit, so the decision usually turns on risk and chip capability rather than price. Replace these hypothetical numbers with your manufacturer’s quote and your measured station times.

Questions to settle with the manufacturer before the pilot run

  • Who owns and maintains the provisioning station PC, and who can log in to it?
  • How does the station reach your CA or provisioning service, and what happens when that link is down?
  • Are any secret files ever copied to the factory, and how are they destroyed after the run?
  • What happens to the identity of a unit that fails test or is scrapped?
  • In what format, and how often, does the factory send you the production record?
  • Who may change the station software, and how are changes approved?

Put the answers in the manufacturing agreement or the station procedure. The production readiness checklist places these items at the PVT gate, where the factory proves it can build the product.

End-of-line locking: the order matters

After identity, the station turns on the protections that make the unit hard to read or rewrite: secure boot, flash encryption where the chip has it, debug port lock, and removal of factory commands. Follow your chip vendor’s documented order, keep power stable, and verify each lock by trying to break it.

Why the order matters

Some of these steps are one-way. Espressif’s security enablement workflows recommend both flash encryption and Secure Boot v2 for production on the ESP32 and say “they must be enabled in the following order”: flash encryption first, then secure boot. The reason is eFuse write protection; reversing the order would leave the flash encryption key readable.

The same guide warns that power failures during this process “may cause permanent boot-up failures”, and marks burning the key into eFuses with “This action cannot be reverted.” A station that loses power mid-sequence can scrap a board, so put the station on stable power and test what happens when it does not have it.

Generating keys on the device or on the host

Espressif offers both. Its flash encryption guide says that if no key is burned, the ESP32 “will generate a random key that software cannot access or modify”, but encrypting in place “can take time, up to a minute for large partitions”.

The host-based workflow generates keys on the station and encrypts there, which its guide says is quicker. Espressif’s security overview also recommends “a unique flash encryption key per device”. That is the same trade as model 1: line time against what the factory sees.

Closing debug access

Debug locking differs by chip family, so read your vendor’s page rather than assuming.

  • Espressif ESP32. The security overview says the JTAG interface “stays disabled if any of the security features are enabled”, and that on ESP32 ECO3 the UART download mode stays disabled when those features run in their release configuration. It adds: “If UART Download mode is disabled then esptool can not work on the device.”
  • Nordic nRF devices. The nRF Connect SDK’s access port protection page says AP-Protect “blocks the debugger from read and write access to all CPU registers and memory-mapped addresses”. Older nRF52 builds ship with debug access open; newer nRF52 builds, nRF53, nRF54L and nRF91x1 ship with it enabled, and it “re-enables on every hard reset”. The same page warns that a device with both AP-Protect and UICR.ERASEPROTECT enabled can no longer be opened or recovered.

The lessons carry across vendors. Know whether your lock is reversible with a full erase or permanent, and whether your firmware must actively keep it closed.

Also know how you will diagnose a returned unit once the probe can no longer connect: through stored logs and a version and health readout, not a debugger.

Removing factory commands and test credentials

Factory test firmware often has commands that read memory, write calibration or switch the radio into test modes. Those commands, and any test certificates or keys used on the line, must be gone from shipping units. Either the station erases the test image and installs the shipping image, or the shipping image disables the test mode permanently once the unit passes.

Check it the same way as the debug lock: send the test commands to a finished unit and confirm nothing answers. A test credential that survives into the field is a shared credential by another name.

The station sequence

  1. Program the bootloader with your public verification key, and the signed application at the shipping version.
  2. Run the factory test while debug and test interfaces are still open.
  3. Provision the identity using your chosen model.
  4. Enable secure boot and flash encryption in the vendor’s order.
  5. Disable test commands and lock the debug port.
  6. Verify: attempt a debug connection and an unsigned image, and confirm both are refused.
  7. Write the factory record.
Program boot chain Factory test Identity: key, CSR, cert Lock debug, verify Record and label 22 s 20 s 6 s 4 s 3 s 60 s target 0 s102030405060 Step that may be permanent on some chips
Figure 2. A provisioning station sequence for the fictional Loamwick LW-1 probe, timed against its 60-second factory requirement (FW-006). The step durations are fictional example data for illustration; measure your own on 50 boards.

The secure boot checklist lists the lockdown checks to run on a finished unit, and the wider controls are described under firmware security.

The factory record: mapping serial numbers to identities

The factory record is the table that links each unit’s serial number to its identity, board revision, firmware version and test result. Without it you cannot revoke one unit, list the units affected by a fault, or tell a genuine device from a clone.

What each row should hold

Field Why you need it
Serial number and radio MAC address The names support and customers see
Certificate fingerprint or public key Links the physical unit to its cloud identity; never the private key
Provisioning model and issuing CA Shows which CA to use when revoking
Board revision and bill of materials revision Finds units affected by a hardware issue
Firmware version at shipment Tells you which update path the unit starts on
Factory test results Separates passed, reworked and scrapped units
Lock status, verified Confirms debug was refused on this unit
Station, operator ID and timestamp Traces a problem to a line, a shift or a software version

Where the record lives and who can see it

Keep the master copy in your own systems, not only in the factory’s. The factory sends records after each shift or batch, in a format you defined, and you import them into the same database your cloud uses to look up devices.

The record contains no secrets, but it is still sensitive. It tells an attacker which serial numbers are real and which board revisions have which faults, so give the factory write access to its own batches and nothing else.

Reconcile, revoke and renew

Reconcile three numbers every day of production: identities issued, units that passed test, and units scrapped or still in rework. Revoke the identity of every scrapped unit, and investigate any identity that does not match a unit.

Plan renewal from the start. Certificates carry an expiry date, and Microsoft notes you “need to renew the certificate during the lifetime of the device”, which depends on the over-the-air update path the devices have. Choose a validity period that covers warehouse time plus the support period, or ship renewal in the firmware.

Returned and refurbished units

Decide in advance what happens to the identity of a unit that comes back. If it is repaired and returned to the same customer, it can keep its identity. If it is refurbished for someone else, revoke the old certificate and issue a new one, so the first owner’s history and access do not follow the hardware.

Example (fictional). A Rev C probe in Loamwick’s field trial reads temperature 0.5 °C high above 40 °C. Because each row links a serial number to its board revision, Loamwick lists every affected Rev C unit in one query. Because each row also holds the certificate fingerprint, the cloud can tag those units for a corrected calibration in the next maintenance release, without touching Rev D probes.

Rehearsing the flow before the first production run

Run the whole station sequence on pre-production units before the pilot build, and try to break it. Faults found on ten boards on your bench cost a morning; found on a thousand at the factory, they can cost the run.

A rehearsal plan

  1. Time it. Run the station on 50 boards and compare the time per unit with your factory requirement. Loamwick’s FW-006, for example, asks for under 60 seconds per probe.
  2. Cut the power. Remove power during identity provisioning and during the security enablement step, then see whether the unit recovers, can be reworked or must be scrapped.
  3. Attack the locked unit. Attempt a debug connection, an unsigned image and an image signed with the development key, and confirm each is refused.
  4. Duplicate a serial number. Provision two units with the same serial and confirm the CA, the cloud or the pre-provisioning check rejects the second.
  5. Cut the link. Disconnect the station from the CA mid-run and check that units fail safely instead of shipping without an identity.
  6. Import the record. Load the factory record into your own systems and check every field.
  7. Diagnose a returned unit. Take a locked unit and read its version, health and logs using only the paths that remain open.

What to hand the manufacturer

The factory needs a package it can run without calling you at every step:

  • The station software, pinned to a version, with instructions to install it on a clean PC.
  • A written procedure with photos of the fixture, the expected screen at each step and the time each step should take.
  • A list of failure codes, each with the action to take: retest, rework or scrap.
  • The record format, with a sample file, and the schedule for sending it.
  • A named contact for the pilot run, and a rule for when to stop the line.

Where this sits in the run-up to production

Provisioning and locking are late decisions in time but early decisions in design. The flash layout, the key storage and the debug strategy are set when the prototype becomes product firmware, which is why from prototype code to production firmware asks about them before the code is frozen.

What to do next

Write down your provisioning model and your locking order before you send the first board files to a contract manufacturer. Both shape the station, the agreement and the firmware.

  • Confirm your chip can generate a key pair and keep the private key unreadable; if not, price a secure element.
  • Choose one of the three models and write down what the factory will see.
  • Set up a dedicated intermediate CA, or a provisioning account, for the manufacturer, with limits.
  • Read your chip vendor’s security enablement order and debug lock documentation, and note what is permanent.
  • Define the factory record fields and the daily reconciliation.
  • Rehearse the flow on pre-production units using the plan above.
  • Run the secure boot checklist on a finished unit.

If you want a second reader before the pilot run, a firmware review covers the schematics, any existing code, the flash layout and the update plan, including the factory flow, and ends with a written plan that lists the risks and the order of work.

Facing this decision on a real device?

If this article describes a choice in front of you, a firmware review puts it in writing for your board, your code and your update plan.

Request a firmware review

Or email sales@fumbar.com, or call (720) 675-4202.