hardwarekey – Cryptographic operations with keys held in hardware

The hardwarekey module exposes keys that live in a hardware key store – eFuse, a key manager, a secure element – and can be used but never read back. Application code can compute a MAC with the key; there is no API to read the raw key bytes, and no API to write or burn keys. Provisioning a key is a manufacturing-time step done with vendor tools (for example espefuse.py on Espressif chips).

HardwareKey objects are not created by application code. Every hardware key slot the board has is exposed as a fixed object in board (for example board.EFUSE_KEY0), in the same way that pins are. Compute a MAC with one by passing it to hmac.new().

Available on these boards
  • 01Space 0.42 OLED ESP32C3
  • AITHinker ESP32-C3S_Kit
  • AITHinker ESP32-C3S_Kit_2M
  • ATMegaZero ESP32-S2
  • Adafruit Camera
  • Adafruit Feather ESP32-C6 4MB Flash No PSRAM
  • Adafruit Feather ESP32-S2 Reverse TFT
  • Adafruit Feather ESP32-S2 TFT
  • Adafruit Feather ESP32-S3 Reverse TFT
  • Adafruit Feather ESP32-S3 TFT
  • Adafruit Feather ESP32S2
  • Adafruit Feather ESP32S3 4MB Flash 2MB PSRAM
  • Adafruit Feather ESP32S3 No PSRAM
  • Adafruit FunHouse
  • Adafruit MagTag
  • Adafruit MatrixPortal S3
  • Adafruit Metro ESP32S2
  • Adafruit Metro ESP32S3
  • Adafruit P4 GPIO
  • Adafruit QT Py ESP32-S3 4MB Flash 2MB PSRAM
  • Adafruit QT Py ESP32-S3 no psram
  • Adafruit QT Py ESP32C3
  • Adafruit QT Py ESP32S2
  • Adafruit Vindie S2
  • Adafruit-Qualia-S3-RGB666
  • Arduino Nano ESP32
  • Artisense Reference Design RD00
  • AutosportLabs-ESP32-CAN-X2
  • BARDUINO 4.0.2
  • BLING!
  • BPI-Bit-S2
  • BPI-Leaf-S3
  • BPI-PicoW-S3
  • BastWiFi
  • Bee-Data-Logger
  • Bee-Motion-S3
  • Bee-S3
  • BlizzardS3
  • CircuitART Zero S3
  • ColumbiaDSL-Sensor-Board-V1
  • CrowPanel 4.2 EPaper
  • CrumpS2
  • Cytron Maker Feather AIoT S3
  • DFRobot Beetle ESP32-C3
  • DFRobot FireBeetle 2 ESP32-S3
  • Deneyap Kart 1A v2
  • Deneyap Kart G
  • Deneyap Mini
  • Deneyap Mini v2
  • EDGES3D
  • ES3ink
  • ESP 12k NodeMCU
  • ESP32-C3-DevKitM-1
  • ESP32-C3-Lyra-V2
  • ESP32-C5-DevKitC-1-N8R8
  • ESP32-C6-DevKitC-1-N8
  • ESP32-C6-DevKitM-1
  • ESP32-H2-DevKitM-1
  • ESP32-P4 Stamp XL
  • ESP32-P4-Function-EV
  • ESP32-P4X-Function-EV
  • ESP32-S2-DevKitC-1-N4
  • ESP32-S2-DevKitC-1-N4R2
  • ESP32-S2-DevKitC-1-N8R2
  • ESP32-S3-Box-2.5
  • ESP32-S3-Box-3
  • ESP32-S3-Box-Lite
  • ESP32-S3-DevKitC-1-N16
  • ESP32-S3-DevKitC-1-N32R16
  • ESP32-S3-DevKitC-1-N32R8
  • ESP32-S3-DevKitC-1-N8
  • ESP32-S3-DevKitC-1-N8R2
  • ESP32-S3-DevKitC-1-N8R2 (ROS version)
  • ESP32-S3-DevKitC-1-N8R8
  • ESP32-S3-DevKitC-1-N8R8-with-HACKTABLET
  • ESP32-S3-DevKitM-1-N8
  • ESP32-S3-EYE
  • ESP32-S3-USB-OTG-N8
  • Eliobot
  • Espressif-ESP32-S3-LCD-EV-Board
  • Espressif-ESP32-S3-LCD-EV-Board_v1.5
  • FeatherS2
  • FeatherS2 Neo
  • FeatherS2 PreRelease
  • FeatherS3
  • FeatherS3 Neo
  • Flipper Zero Wi-Fi Dev
  • Franzininho WIFI w/Wroom
  • Franzininho WIFI w/Wrover
  • Generic ESP32S3 Supermini
  • Gravitech Cucumber M
  • Gravitech Cucumber MS
  • Gravitech Cucumber R
  • Gravitech Cucumber RS
  • HMI-DevKit-1.1
  • Heltec ESP32-S3-WIFI-LoRa-V3
  • Heltec Vison Master E290
  • Heltec Wireless Paper
  • HexKyS2
  • Ikea Alpstuga Drop-In ESP32S3 4MB Flash 2MB PSRAM
  • IoTs2
  • Kaluga 1
  • LILYGO T-DISPLAY S3 v1.2
  • LILYGO T-Deck (Plus)
  • LILYGO T-Display S3 Pro
  • LILYGO T-Dongle S3
  • LILYGO T-QT PRO NO PSRAM
  • LILYGO T-QT PRO PSRAM
  • LILYGO T-Watch-S3
  • LILYGO TEMBED ESP32S3
  • LILYGO TTGO T-01C3
  • LILYGO TTGO T-OI PLUS
  • LILYGO TTGO T8 ESP32-S2
  • LILYGO TTGO T8 ESP32-S2 w/Display
  • LOLIN S3 16MB Flash 8MB PSRAM
  • LOLIN S3 MINI 4MB Flash 2MB PSRAM
  • LOLIN S3 MINI PRO 4MB Flash 2MB PSRAM
  • LOLIN S3 PRO 16MB Flash 8MB PSRAM
  • Luatos Core-ESP32C3
  • M5STACK STAMP-C3
  • M5Stack AtomS3
  • M5Stack AtomS3 Lite
  • M5Stack AtomS3U
  • M5Stack Cardputer
  • M5Stack Cardputer (ROS version)
  • M5Stack CoreS3
  • M5Stack CoreS3 SE
  • M5Stack Dial
  • M5Stack DinMeter
  • M5Stack Stamp-S3
  • M5Stack Tab5
  • MORPHEANS MorphESP-240
  • MagiClick S3 N4R2
  • Maker Go ESP32C3 Supermini
  • Maker Go ESP32C6 Supermini
  • Maker badge by Czech maker
  • MakerFabs-ESP32-S3-Parallel-TFT-With-Touch-7inch
  • MicroDev microC3
  • MicroDev microS2
  • MixGo CE
  • NHB Systems JL401-S3 4MB Flash 2MB PSRAM
  • NanoS3
  • Neuron
  • OMGS3
  • Oak Dev Tech PixelWing ESP32S2
  • PCBCupid GLYPH C3
  • PCBCupid GLYPH S3
  • Pcbcupid GLYPH C6
  • Pcbcupid GLYPH H2
  • ProS3
  • Prokyber Ai-On-The-Edge-Cam
  • RGBTouch Mini
  • Red S2-WROOM
  • S2Mini
  • S2Pico
  • Saola 1 w/Wroom
  • Saola 1 w/Wrover
  • Seeed Studio XIAO ESP32C3
  • Seeed Xiao ESP32-C6 4MB Flash 512KB SRAM
  • Seeed Xiao ESP32-S3 Sense
  • Seeed Xiao ESP32-S3 Trmnl DIY Kit
  • Spotpear ESP32C3 LCD 1.44
  • Spotpear ESP32C3 LCD 1.69
  • Sunton ESP32-2424S012
  • Sunton-ESP32-8048S050
  • Sunton-ESP32-8048S070
  • TTGO T8 ESP32-S2-WROOM
  • Targett Module Clip w/Wroom
  • Targett Module Clip w/Wrover
  • ThingPulse Pendrive S3
  • TinyC6
  • TinyS2
  • TinyS3
  • TinyWATCH S3
  • VCC-GND YD-ESP32-S3 (N16R8)
  • VCC-GND YD-ESP32-S3 (N8R8)
  • Waveshare ESP32-C5 LCD 1.47
  • Waveshare ESP32-C6 LCD 1.47
  • Waveshare ESP32-S2-Pico
  • Waveshare ESP32-S2-Pico-LCD
  • Waveshare ESP32-S3 LCD 1.47
  • Waveshare ESP32-S3 Touch LCD 1.47
  • Waveshare ESP32-S3 Touch LCD 2.8
  • Waveshare ESP32-S3-ETH
  • Waveshare ESP32-S3-GEEK
  • Waveshare ESP32-S3-Matrix
  • Waveshare ESP32-S3-Pico
  • Waveshare ESP32-S3-Tiny
  • Waveshare ESP32-S3-Tiny-N8R8
  • Waveshare ESP32-S3-Touch-AMOLED-2.41
  • Waveshare ESP32-S3-Touch-LCD-1.69
  • Waveshare ESP32-S3-Touch-LCD-2.1
  • Waveshare ESP32-S3-Zero
  • Waveshare ESP32S3 LCD 1.28
  • Waveshare ESP32S3 Touch LCD 2
  • WeAct ESP32-C6 (4MB)
  • WeAct ESP32-C6 (8MB)
  • Wemos Lolin C3 Mini
  • Wemos Lolin C3 Pico
  • Xteink X4
  • cezerio dev ESP32C6
  • nanoESP32-S2 w/Wrover
  • nanoESP32-S2 w/Wroom
  • senseBox MCU Eye ESP32S3
  • senseBox MCU-S2 ESP32S2
  • uGame S3

class hardwarekey.Purpose

What a hardware key slot is provisioned for. Instances are singletons; compare with is.

HMAC_UP: object

The slot holds an HMAC key. It can be used with hmac.new().

UNUSED: object

No key is burned into the slot (or it is burned for something this module does not expose). The slot’s HardwareKey still exists but cannot be used.

class hardwarekey.HardwareKey

A key held in a hardware key store, usable but not readable.

This class cannot be instantiated. Every hardware key slot the board has is exposed as a fixed HardwareKey in board – for example board.EFUSE_KEY0 – just like pins. A slot with no key burned into it still has a HardwareKey object; its purpose is hardwarekey.Purpose.UNUSED.

Compute a MAC with a key by passing it to hmac.new() in place of a bytes key.

On espressif the slots are the eFuse key blocks (BLOCK_KEY0 - BLOCK_KEY5); a slot is usable only if its block was burned with purpose HMAC_UP.

__bool__() → bool

False if purpose is hardwarekey.Purpose.UNUSED, True otherwise. This lets you write if key: to check whether a slot is usable.

key_slot: int

The port-defined key identifier this handle is bound to. On espressif, the eFuse key block index. (read-only)

purpose: Purpose

What this key slot is provisioned for – hardwarekey.Purpose.HMAC_UP or hardwarekey.Purpose.UNUSED. (read-only)

exportable: bool

Whether the raw key bytes can ever leave the hardware. Always informational.

On espressif this is False once the key block’s RD_DIS eFuse bit is set (which espefuse.py does by default). It is meant for manufacturing-time self-test code to confirm a key block was burned as expected. (read-only)