| 1 | [[PageOutline]] |
| 2 | |
| 3 | = NXP !EdgeLock Secure Enclave |
| 4 | While the i.MX8M does have its own internal !EdgeLock Secure Enclave it only allows up to FIPS level 2 and in some cases level 3 is required (which requires the keys are stored in a different IC). |
| 5 | |
| 6 | The SE05x speaks SCP03 on top of I2C and can co-exist with other I2C devices. It is often used within OPTEE with a trampoline driver that hooks into Linux with an SMC call to allow Linux owning the I2C bus but OPTEE still allowed controlled access |
| 7 | |
| 8 | The NXP !EdgeLock SE05x Plug & Trust middleware package is a software stack provided by NXP for integrating the SE050 with Linux systems. |
| 9 | - Supports cryptographic operations like ECC, RSA, AES, and more, leveraging the SE050’s hardware security. |
| 10 | - Provides APIs for session management, key storage, and cryptographic functions. |
| 11 | - Includes support for secure communication protocols like !GlobalPlatform Secure Channel Protocol 03 (SCP03) over an I²C interface. |
| 12 | - Offers pre-integrated libraries for Linux, simplifying integration with host systems. |
| 13 | |
| 14 | The package can be downloaded from NXP's website while derivatives for specific use cases are available github NXP plug-and-trust repository: |
| 15 | * https://github.com/NXP/plug-and-trust - middleware mini package with minimum files requires to connect to SE05x using t1oi2c protocol |
| 16 | |
| 17 | References: |
| 18 | * [https://www.nxp.com/products/SE052F SE052F Product Page] |
| 19 | * [https://www.nxp.com/docs/en/application-note/AN14277.pdf AN14277 SE052 Configuration Details] |
| 20 | * [https://www.nxp.com/docs/en/application-note/AN13013.pdf AN13013 Get started with EdgeLock SE05x support package] |
| 21 | |
| 22 | |
| 23 | == Hardware |
| 24 | The following Gateworks boards have a SE05x chip on-board: |
| 25 | ||= Family =||= Board =||= Chip =||= bus/address =||= reset =|| |
| 26 | || Venice || GW8201-C+ || SE052F || I2C2@0x48 || N/A || |
| 27 | |
| 28 | |
| 29 | == Software |
| 30 | The SE05x family uses a T=1 over I2C (T1oI2C) protocol, not standard I2C register based communication. It encapsulates its communication in a higher-level protocol (ISO/IEC 7816-4 APDUs over I2C). For this reason Linux and U-Boot can detect the device as long as the I2C frame addressed to the device contains at least one byte of data but can not access registers over I2C: |
| 31 | * U-Boot device detection: |
| 32 | {{{#!bash |
| 33 | u-boot=> i2c dev 1 && i2c probe 0x48 |
| 34 | Setting bus to 1 |
| 35 | Valid chip addresses: 48 |
| 36 | }}} |
| 37 | - the valid chip address above confirms SCL/SDA/VDD_3V3/GND are wired correctly and powered |
| 38 | |
| 39 | Because there is no U-Boot or Linux kernel driver there does not need to be any device-tree node for the device. |
| 40 | |
| 41 | Note the SE052F errata sheet notes a potential problem where an acknowledged I2C frame addressed to the device must contain at least one byte of data. If not the SE052F may enter an unresponsive state requiring a power cycle. In a shared bus scenario if other devices send incomplete or malformed frames they could trigger this. |
| 42 | |
| 43 | === NXP Plug & Trust Middleware |
| 44 | The NXP Plug & Trust middleware communicates with the SE05x directly in userspace via the I2C device file (e.g., /dev/i2c-1). It uses the Linux I2C userspace interface (ioctl calls) to send T1oI2C APDUs, bypassing the need for a dedicated kernel driver. The middleware handles all protocol details, including authentication (e.g., SCP03) and command formatting. Because this is in userspace there is no dt entry needed as long as the I2C bus is enabled. |
| 45 | |
| 46 | There are multiple flavors of the NXP Plug & Trust Middleware below are very minimal examples of getting it up and running by building software on the target board itself. |
| 47 | |
| 48 | ==== Full package (zip downloaded from NXP) |
| 49 | You can download the full package middleware by going to https://www.nxp.com/products/SE052F selecting 'Design Resources' then 'Software' then download '!EdgeLock SE05x Plug & Trust Middleware. (NXP account required). |
| 50 | |
| 51 | Notes: |
| 52 | - example apps take a 'port' argument identifying the bus and address via <busdev>:<slaveaddr> (ie '/dev/i2c-1:0x48' for GW8201). Note that while the busdev is a Linux path that exists the ':0x48' will not exist in a device path) |
| 53 | - the ssscli ssscli tool isnt' a standalone binary; its a python based CLI installed via setup.py after building the middleware libraries. |
| 54 | - there are fairly detailed HTML docs within the docs directory |
| 55 | |
| 56 | Building: |
| 57 | {{{#!bash |
| 58 | # install pre-requisites |
| 59 | apt update && apt install -y build-essential git cmake python3 python3-pip python3-setuptools python3-wheel libssl-dev libusb-1.0-0-dev pkg-config unzip wget |
| 60 | |
| 61 | # unzip release package |
| 62 | unzip SE-PLUG-TRUST-MW_04.07.01.zip |
| 63 | cd simw-top |
| 64 | |
| 65 | # script uses hostname to determine system its running on, needs to be imx8 if building on imx8m target |
| 66 | hostname imx8 |
| 67 | # create various cmake projects in ~/simw-top_build |
| 68 | python3 ./scripts/create_cmake_projects.py |
| 69 | # list example projects |
| 70 | ls ~/simw-top_build |
| 71 | # build imx_native_se050_t1oi2c |
| 72 | cd ~/simw-top_build/imx_native_se050_t1oi2c |
| 73 | # configure it (see ~/simw-top/doc/scripts/cmake_options.html) |
| 74 | cmake . \ |
| 75 | -DPTMW_Applet=SE05X_C \ |
| 76 | -DPTMW_SE05X_Ver=07_02 \ |
| 77 | -DPTMW_HostCrypto=OPENSSL \ |
| 78 | -DPTMW_Host=iMXLinux \ |
| 79 | -DPTMW_HostOS=Linux \ |
| 80 | |
| 81 | # build it |
| 82 | cmake --build . -j$(nproc) |
| 83 | # install it |
| 84 | make install |
| 85 | # update library cache |
| 86 | ldconfig /usr/local/lib/ |
| 87 | # install ssscli python tool |
| 88 | cd ~/simw-top/pycli/src/ |
| 89 | python3 setup.py develop |
| 90 | }}} |
| 91 | |
| 92 | The ssscli tool is a Python based tool to manipulate the SE050 Secure Element. See ~/simw-top/doc/cli-tool.html for details. It can be used to: |
| 93 | - Insert Keys, Certficates |
| 94 | - Generate Keys |
| 95 | - Attach policies to objects |
| 96 | - Control Cloud for CLI (To Be Done) |
| 97 | |
| 98 | Running some examples: |
| 99 | * ssscli: |
| 100 | {{{#!bash |
| 101 | # ssscli --version |
| 102 | ssscli, version v04.07.01 |
| 103 | }}} |
| 104 | * se05x_GetInfo (show device configuration) |
| 105 | {{{#!bash |
| 106 | # se05x_GetInfo |
| 107 | App :INFO :Running se05x_GetInfo /dev/i2c-1:0x48 |
| 108 | App :INFO :If you want to over-ride the selection, use ENV=EX_SSS_BOOT_SSS_PORT or pass in command line arguments. |
| 109 | App :INFO :PlugAndTrust_v04.07.01_20250519 |
| 110 | sss :INFO :atr (Len=35) |
| 111 | 01 A0 00 00 03 96 04 03 E8 00 FE 02 0B 03 E8 00 |
| 112 | 01 00 00 00 00 64 13 88 0A 00 65 53 45 30 35 31 |
| 113 | 00 00 00 |
| 114 | App :WARN :##################################################### |
| 115 | App :INFO :uid (Len=18) |
| 116 | 04 00 50 01 A4 D8 98 71 0E EC 5D 04 57 48 BA 98 |
| 117 | 1E 90 |
| 118 | App :INFO :Running se05x_GetInfo |
| 119 | App :INFO :If you want to over-ride the selection, use ENV=EX_SSS_BOOT_SSS_PORT or pass in command line arguments. |
| 120 | sss :INFO :atr (Len=35) |
| 121 | 01 A0 00 00 03 96 04 03 E8 00 FE 02 0B 03 E8 00 |
| 122 | 01 00 00 00 00 64 13 88 0A 00 65 53 45 30 35 31 |
| 123 | 00 00 00 |
| 124 | sss :INFO :Newer version of Applet Found |
| 125 | sss :INFO :Compiled for 0x70200. Got newer 0x70216 |
| 126 | sss :WARN :Communication channel is Plain. |
| 127 | sss :WARN :!!!Not recommended for production use.!!! |
| 128 | App :WARN :##################################################### |
| 129 | App :INFO :Applet Major = 7 |
| 130 | App :INFO :Applet Minor = 2 |
| 131 | App :INFO :Applet patch = 22 |
| 132 | App :INFO :AppletConfig = 26F2 |
| 133 | App :INFO :With ECDSA_ECDH_ECDHE |
| 134 | App :INFO :WithOut EDDSA |
| 135 | App :INFO :WithOut DH_MONT |
| 136 | App :INFO :With HMAC |
| 137 | App :INFO :With RSA_PLAIN |
| 138 | App :INFO :With RSA_CRT |
| 139 | App :INFO :With AES |
| 140 | App :INFO :WithOut DES |
| 141 | App :INFO :With PBKDF |
| 142 | App :INFO :With TLS |
| 143 | App :INFO :WithOut MIFARE |
| 144 | App :INFO :With I2CM |
| 145 | App :INFO :Internal = FFFF |
| 146 | App :WARN :##################################################### |
| 147 | App :INFO :Tag value - proprietary data 0xFE = 0xFE |
| 148 | App :INFO :Length of following data 0x45 = 0x4F |
| 149 | App :INFO :Tag card identification data (Len=2) |
| 150 | DF 28 |
| 151 | App :INFO :Length of card identification data = 0x4C |
| 152 | App :INFO :Tag configuration ID (Must be 0x01) = 0x01 |
| 153 | App :INFO :Configuration ID (Len=12) |
| 154 | 00 05 B5 01 1B 7D B8 1B 89 99 D0 5D |
| 155 | App :INFO :OEF ID (Len=2) |
| 156 | B5 01 |
| 157 | App :INFO :Tag patch ID (Must be 0x02) = 0x02 |
| 158 | App :INFO :Patch ID (Len=8) |
| 159 | 00 00 00 00 00 00 00 00 |
| 160 | App :INFO :Tag platform build ID1 (Must be 0x03) = 0x03 |
| 161 | App :INFO :Platform build ID (Len=24) |
| 162 | 4A 33 52 36 30 30 30 33 37 33 31 38 31 32 30 30 |
| 163 | 6D 20 B6 19 7D 63 5E 7C |
| 164 | App :INFO :JCOP Platform ID = J3R6000373181200 |
| 165 | App :INFO :Tag FIPS mode (Must be 0x05) = 0x05 |
| 166 | App :INFO :FIPS mode var = 0x01 |
| 167 | App :INFO :Tag pre-perso state (Must be 0x07) = 0x07 |
| 168 | App :INFO :Bit mask of pre-perso state var = 0x00 |
| 169 | App :INFO :Tag ROM ID (Must be 0x08) = 0x08 |
| 170 | App :INFO :ROM ID (Len=8) |
| 171 | B3 37 5F E9 B5 50 8B C4 |
| 172 | App :INFO :Tag JCOP OS Core ID (Must be 0x0A) = 0x0A |
| 173 | App :INFO :JCOP OS Core (Len=8) |
| 174 | 55 60 6F D4 BE EC F3 CD |
| 175 | App :INFO :Status Word (SW) (Len=2) |
| 176 | 90 00 |
| 177 | App :INFO :se05x_GetInfoPlainApplet Example Success !!!... |
| 178 | App :WARN :##################################################### |
| 179 | App :INFO :cplc_data.IC_fabricator (Len=2) |
| 180 | 47 90 |
| 181 | App :INFO :cplc_data.IC_type1 (Len=2) |
| 182 | D6 00 |
| 183 | App :INFO :cplc_data.Operating_system_identifier (Len=2) |
| 184 | 47 00 |
| 185 | App :INFO :cplc_data.Operating_system_release_date (Len=2) |
| 186 | 00 00 |
| 187 | App :INFO :cplc_data.Operating_system_release_level (Len=2) |
| 188 | 00 00 |
| 189 | App :INFO :cplc_data.IC_fabrication_date (Len=2) |
| 190 | 42 44 |
| 191 | App :INFO :cplc_data.IC_Serial_number (Len=4) |
| 192 | 36 90 47 21 |
| 193 | App :INFO :cplc_data.IC_Batch_identifier (Len=2) |
| 194 | 11 91 |
| 195 | App :INFO :cplc_data.IC_module_fabricator (Len=2) |
| 196 | 00 00 |
| 197 | App :INFO :cplc_data.IC_module_packaging_date (Len=2) |
| 198 | 00 00 |
| 199 | App :INFO :cplc_data.ICC_manufacturer (Len=2) |
| 200 | 00 00 |
| 201 | App :INFO :cplc_data.IC_embedding_date (Len=2) |
| 202 | 00 00 |
| 203 | App :INFO :cplc_data.IC_OS_initializer (Len=2) |
| 204 | 17 57 |
| 205 | App :INFO :cplc_data.IC_OS_initialization_date (Len=2) |
| 206 | 48 36 |
| 207 | App :INFO :cplc_data.IC_OS_initialization_equipment (Len=4) |
| 208 | 39 30 34 37 |
| 209 | App :INFO :cplc_data.IC_personalizer (Len=2) |
| 210 | 00 00 |
| 211 | App :INFO :cplc_data.IC_personalization_date (Len=2) |
| 212 | 00 00 |
| 213 | App :INFO :cplc_data.IC_personalization_equipment_ID (Len=4) |
| 214 | 00 00 00 00 |
| 215 | App :INFO :cplc_data.SW (Len=2) |
| 216 | 90 00 |
| 217 | App :INFO :ex_sss Finished |
| 218 | }}} |
| 219 | - The 'Newer version of Applet Found' 'Compiled for 0x70200. Got newer 0x70216' simply means that the middleware was built for an earlier version of the chip which is ok as the middleware is backward compatible. At the time of this writing the middleware does not have an option for PTMW_Applet=SE052F |
| 220 | - The 'Communication channel is Plain' and '!!!Not recommended for production use.!!!' means that we are not using SCP03 which you should use for production use and must be enabled by building with '-DPTMW_SE05X_Auth=PlatfSCP03 -DPTMW_SCP=SCP03_SSS' and providing keys with -DPTMW_SCP03KeyFile or EX_SSS_BOOT_SCP03_PATH env var) |
| 221 | |
| 222 | |
| 223 | ==== Plug and Trust middleware mini package (github) |
| 224 | NXP provides derivatives of the full Plug & Trust middleware package for specific use cases via github. For development purposes still look at the full package as well as it contains large amounts of examples, tools and additional documentation. |
| 225 | |
| 226 | Example: |
| 227 | {{{#!bash |
| 228 | # install pre-requisites |
| 229 | apt update && apt install -y build-essential git cmake python3 python3-pip python3-setuptools python3-wheel libssl-dev libusb-1.0-0-dev pkg-config unzip wget |
| 230 | |
| 231 | # fetch code |
| 232 | git clone https://github.com/NXP/plug-and-trust |
| 233 | cd plug-and-trust |
| 234 | |
| 235 | # configure |
| 236 | cd ecc_example |
| 237 | mkdir build |
| 238 | cd build |
| 239 | cmake .. |
| 240 | |
| 241 | # build |
| 242 | cmake --build . |
| 243 | |
| 244 | # execute |
| 245 | ./ex_ecc /dev/i2c-1:0x48 |
| 246 | }}} |
| 247 | |
| 248 | Notes: |
| 249 | * see https://github.com/NXP/plug-and-trust/blob/master/simwlib_cmake_options.cmake for cmake options |
| 250 | * A reset GPIO is configured and toggled to reset the device which may be invalid for your hardware. See (hostlib/hostLib/platform/rsp/se05x_reset.c for reset configuration |
| 251 | * The port/address |
| 252 | |
| 253 | === Plug and Trust middleware nano package (github) |
| 254 | The Plug and Trust middleware nano package is a minimalistic version of the Plug & Trust middleware optimized for constrained devices. It also provides an integration with Zephyr OS and an example of Qi 1.3 authentication |
| 255 | |
| 256 | Example: |
| 257 | * build |
| 258 | {{{#!bash |
| 259 | # install pre-requisites |
| 260 | apt update && apt install -y build-essential git cmake python3 python3-pip python3-setuptools python3-wheel libssl-dev libusb-1.0-0-dev pkg-config unzip wget |
| 261 | |
| 262 | # fetch code |
| 263 | git clone https://github.com/NXPPlugNTrust/nano-package |
| 264 | cd nano-package |
| 265 | |
| 266 | # configure |
| 267 | cd examples/se05x_GetInfo/linux |
| 268 | mkdir build |
| 269 | cd build |
| 270 | cmake ../ |
| 271 | |
| 272 | # build |
| 273 | make |
| 274 | }}} |
| 275 | * execute |
| 276 | {{{#!bash |
| 277 | # ./ex_se05x_GetInfo |
| 278 | Se05x Getinfo Example ! |
| 279 | Plug and Trust nano package - version: 1.5.4 |
| 280 | I2C driver supports plain i2c-level commands. |
| 281 | ##################################################### |
| 282 | Close i2c device 3. |
| 283 | Plug and Trust nano package - version: 1.5.4 |
| 284 | I2C driver supports plain i2c-level commands. |
| 285 | ##################################################### |
| 286 | Applet Major = 7 |
| 287 | Applet Minor = 2 |
| 288 | Applet patch = 22 |
| 289 | AppletConfig = 26F2 |
| 290 | With ECDSA_ECDH_ECDHE |
| 291 | WithOut EDDSA |
| 292 | WithOut DH_MONT |
| 293 | With HMAC |
| 294 | With RSA_PLAIN |
| 295 | With RSA_CRT |
| 296 | With AES |
| 297 | WithOut DES |
| 298 | With PBKDF |
| 299 | With TLS |
| 300 | WithOut MIFARE |
| 301 | With I2CM |
| 302 | ##################################################### |
| 303 | Tag value - proprietary data 0xFE = 0xFE |
| 304 | Length of following data 0x45 = 0x4F |
| 305 | Length of card identification data = 0x4C |
| 306 | Tag configuration ID (Must be 0x01) = 0x01 |
| 307 | OEF ID = 0xB5 0x01 |
| 308 | Tag patch ID (Must be 0x02) = 0x02 |
| 309 | Tag platform build ID1 (Must be 0x03) = 0x03 |
| 310 | JCOP Platform ID = J3R6000373181200 |
| 311 | Tag FIPS mode (Must be 0x05) = 0x05 |
| 312 | FIPS mode var = 0x01 |
| 313 | Tag pre-perso state (Must be 0x07) = 0x07 |
| 314 | Bit mask of pre-perso state var = 0x00 |
| 315 | Tag ROM ID (Must be 0x08) = 0x08 |
| 316 | se05x_GetInfoPlainApplet Example Success !!!... |
| 317 | ##################################################### |
| 318 | Close i2c device 3. |
| 319 | SE05x Getinfo Example Success ! |
| 320 | }}} |
| 321 | |
| 322 | Notes |
| 323 | - the bus path and address are hard coded in lib/platform/linux/sm_i2c.c: SE05X_I2C_DEV_NAME, SE05X_I2C_DEV_ADDR |
| 324 | |