Pecyn Meddalwedd X-CUBE-STSE01

Rhagymadrodd
This user manual describes how to get started with the X-CUBE-STSE01 software package.
The X-CUBE-STSE01 software package is a software component that provides several demonstration codes, which use the STSAFE-A110 and STSAFE-A120 device features from a host microcontroller.
These demonstration codes utilize the STSELib (Secured Element middleware) built on the STM32Cube software technology to ease portability across different STM32 microcontrollers. In addition, it is MCU-agnostic for portability to other MCUs.
These demonstration codes illustrate the following features:
- Authentication.
- Secured data storage.
- Secured usage counter.
- Pâr.
- Key establishment.
- Local envelope wrapping.
- Key pair generation.
Gwybodaeth gyffredinol
- The X-CUBE-STSE01 software package is a reference to integrate the STSAFE-A110 and STSAFE-A120 secure element services into a host MCU’s operating system (OS) and its application.
- It contains the STSAFE-A110 and STSAFE-A120 driver and demonstration codes to be executed on STM32 32-bit microcontrollers based on the Arm® Cortex®-M processor.
- Mae Arm yn nod masnach cofrestredig Arm Limited (neu ei is-gwmnïau) yn yr UD a / neu rywle arall.
- The X-CUBE-STSE01 software package is developed in ANSI C. Nevertheless, the platform-independent architecture allows easy portability to a variety of different platforms.
- The table below presents the definition of acronyms that are relevant for a better understanding of this document.
Elfen ddiogel STSAFE-A1x0
Mae'r STSAFE-A110 a'r STSAFE-A120 yn ddatrysiadau diogel iawn sy'n gweithredu fel elfen ddiogel sy'n darparu gwasanaethau dilysu a rheoli data i westeiwr lleol neu bell. Mae'n cynnwys datrysiad cyflawn parod gyda system weithredu ddiogel sy'n rhedeg ar y genhedlaeth ddiweddaraf o ficroreolyddion diogel.
The STSAFE-A110 and STSAFE-A120 can be integrated in IoT (Internet of things) devices, smart-home, smart-city and industrial applications, consumer electronics devices, consumables and accessories. Its key features are
- Dilysu (dyfeisiau perifferol, IoT a USB Type-C®).
- Sefydlu sianel ddiogel gyda gwesteiwr o bell gan gynnwys ysgwyd llaw diogelwch haen trafnidiaeth (TLS).
- Gwasanaeth gwirio llofnodion (cychwyn diogel ac uwchraddio cadarnwedd).
- Monitro defnydd gyda chownteri diogel.
- Paru a sicrhau sianel gyda phrosesydd cymhwysiad gwesteiwr.
- Lapio a dadlapio amlenni gwesteiwr lleol neu anghysbell.
- Cynhyrchu pâr allweddi ar y sglodion.
Disgrifiad o Lyfrgell STSecureElement (STSELib)
Mae'r adran hon yn manylu ar gynnwys pecyn meddalwedd canolradd STSELib a'r ffordd i'w ddefnyddio.
Disgrifiad cyffredinol
Mae'r middleware STSELib yn set o gydrannau meddalwedd a gynlluniwyd i:
- rhyngwynebu'r ddyfais elfen ddiogel STSAFE-A110 a STSAFE-A120 gydag MCU.
- gweithredu'r achosion defnydd STSAFE-A110 ac STSAFE-A120 mwyaf generig.
- Mae meddalwedd canol STSELib wedi'i integreiddio'n llawn o fewn pecynnau meddalwedd ST fel cydran meddalwedd canol i ychwanegu nodweddion elfen ddiogel.
- Mae'r feddalwedd ganol STSELib yn darparu set gyflawn o swyddogaethau Rhyngwyneb Rhaglennu Cymwysiadau lefel uchel i'r datblygwr system fewnosodedig. Mae'r feddalwedd ganol hon yn crynhoi'r adeiladwaith a dilyniant y gorchmynion sydd eu hangen i sicrhau diogelwch brand dyfeisiau, ategolion a nwyddau traul gan ddefnyddio teulu elfennau diogel STMicroelectronics STSAFE-A.
- Mae'r meddalwedd canolradd hwn yn caniatáu integreiddio di-dor o un neu fwy o STSAFE-A mewn amrywiol ecosystemau MCU/MPU gwesteiwr.
- Cyfeiriwch at y nodiadau rhyddhau sydd ar gael yn y ffolder gwraidd pecyn i gael gwybodaeth am y fersiynau IDE a gefnogir.
Pensaernïaeth
Mae meddalwedd canol STSELib yn cynnwys tri modiwl meddalwedd fel y dangosir yn y ffigur isod. Mae pob haen yn darparu lefel wahanol o haniaeth system i'r datblygwr system fewnosodedig.

Mae'r ffigur isod yn dangos y meddalwedd canolradd STSELib wedi'i integreiddio mewn cymhwysiad safonol STM32Cube, yn rhedeg ar fwrdd ehangu X-NUCLEO-SAFEA1 neu X-NUCLEO-ESE01A1 wedi'i osod ar fwrdd STM32 Nucleo.
Ffigur 2. Diagram bloc cymhwysiad X-CUBE-STSE01

Er mwyn darparu'r annibyniaeth galedwedd a llwyfan orau, nid yw'r feddalwedd ganol STSELib wedi'i chysylltu'n uniongyrchol â'r STM32Cube HAL, ond trwy ryngwyneb filewedi'u gweithredu ar lefel y cymhwysiad
- Haen Rhyngwyneb Rhaglennu Cymwysiadau (API)
Yr haen feddalwedd hon yw'r pwynt mynediad ar gyfer y cymhwysiad system. Mae'n darparu set o swyddogaethau lefel uchel sy'n caniatáu rhyngweithio ag Elfennau Diogel STMicroelectronics. Mae'r haen Api yn darparu haniaeth ar gyfer gwahanol gymwysiadau fel Rheoli Elfennau Diogel, Dilysu, Storio Data, Rheoli Allweddi. - Haen gwasanaeth
Mae'r haen SERVICE yn darparu set o wasanaethau cynnyrch sy'n fformatio'r holl orchmynion a gefnogir gan yr elfen ddiogel darged ac yn adrodd ymateb i API/Cymhwysiad haenau uwch. Gellir defnyddio'r haen hon yn uniongyrchol o'r Cymhwysiad (ar gyfer defnyddwyr uwch). - Haen graidd
Yn cynnwys diffiniad generig ar gyfer Elfen Ddiogel ST a swyddogaethau ar gyfer cyfathrebu â'r elfen ddiogel darged.
Mae'r haen graidd yn trin fframio'r negeseuon yn ogystal â darparu'r haniaeth platfform ar gyfer yr haenau uchod.
Strwythur ffolder
Mae'r ffigur isod yn cyflwyno strwythur ffolderi'r X-CUBE-STSE01.

Meddalwedd arddangos
Mae'r adran hon yn darlunio meddalwedd arddangos yn seiliedig ar feddalwedd ganol STSELib.
Dilysu
This demonstration illustrates the command flow where the STSAFE-A110/STSAFE-A120 is mounted on a device that authenticates to a remote host (IoT device case), the local host being used as a pass-through to the remote server.
The scenario where the STSAFE-A110/STSAFE-A120 is mounted on a peripheral that authenticates to a local host, for exampar gyfer gemau, ategolion symudol neu nwyddau traul, yn union yr un fath.
At ddibenion arddangos, yr un ddyfais yw'r gwesteiwyr lleol ac anghysbell yma.
- Extract, parse and verify the STSAFE-A110/ STSAFE-A120’s public certificate stored in the data partition zone 0 of the device in order to get the public key:
- Read the certificate using the STSELib middleware through the STSAFE-A110/STSAFE-A120’s zone 0.
- Parse the certificate using the cryptographic library’s parser.
- Read the CA certificate (available through the code).
- Parse the CA certificate using the cryptographic library’s parser.
- Verify the certificate validity using the CA certificate through the cryptographic library.
- Get the public key from the STSAFE-A110/STSAFE-A120 X.509 certificate.
- Generate and verify the signature over a challenge number:
- Generate a challenge number (random number).
- Hash the challenge.
- Fetch a signature over the hashed challenge using the STSAFE-A110/ STSAFE-A120 private key slot 0 through the STSELib middleware.
- Parse the generated signature using the cryptographic library.
- Verify the generated signature using the STSAFE-A110/STSAFE-A120’s public key through the cryptographic library.
- When this is valid, the host knows that the peripheral or IoT is authentic.
Paru (Darparu Allwedd Gwesteiwr)
Mae'r cod hwn example establishes a pairing between an device and the MCU it is connected to. The pairing allows the exchanges between the device and the MCU to be authenticated (that is, signed and verified). The STSAFE-A110 device becomes usable only in combination with the MCU it is paired with.
The pairing consists of the host MCU sending a host MAC key and a host cipher key to the STSAFE-A110 Both keys are stored to the protected NVM of the STSAFE-A110 and should be stored to the flash memory of the STM32 device.
By default, in this example, the host MCU sends well-known keys to the STSAFE-A110 (see command flow below) that are highly recommended to use for demonstration purposes. The code also allows the generation of random keys.
Moreover, the code example generates a local envelope key when the corresponding slot is not already populated in the STSAFE-A110. When the local envelope slot is populated, the STSAFE-A110 device allows the host MCU to wrap/unwrap a local envelope to securely store a key on the host MCU’s side.
Note: The pairing code examprhaid ei weithredu'n llwyddiannus cyn gweithredu'r holl god canlynol examples.
Llif gorchymyn
- Generate the local envelope key in the STSAFE-A110 using the STSELib middleware.
By default, this command is activated
Dim ond os nad yw slot allwedd amlen leol STSAFE-A110 eisoes yn llawn y bydd y weithred hon yn digwydd. - Define two 128-bit numbers to use as the host MAC key and the host cipher key.
By default, golden known keys are used. They have the following values:- Host MAC key
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF - Host Cipher Key 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF
- Host MAC key
- Store the host MAC key and the host cipher key to their respective slot in the STSAFE-A110/STSAFE-A120.
- Store the host MAC key and the host cipher key to the STM32’s flash memory.
Sefydlu allwedd (Allwedd gymesur AES-128 CMAC)
Mae'r arddangosiad hwn yn dangos yr achos lle mae dyfais STSAFE-A110 wedi'i gosod ar ddyfais (fel dyfais IoT), sy'n cyfathrebu â gweinydd o bell, ac mae angen sefydlu sianel ddiogel i gyfnewid data ag ef.
Yn y cynampLe, mae'r ddyfais STM32 yn chwarae rôl y gweinydd pell (gwesteiwr o bell) a'r gwesteiwr lleol sydd wedi'i gysylltu â'r ddyfais STSAFE-A110.
Nod yr achos defnydd hwn yw dangos sut i sefydlu cyfrinach a rennir rhwng y gwesteiwr lleol a'r gweinydd o bell gan ddefnyddio'r cynllun Diffie-Hellman cromlin eliptig gydag allwedd statig (ECDH) neu fyrhoedlog (ECDHE) yn y STSAFE-A110.
Dylai'r gyfrinach a rennir ddeillio ymhellach i un neu fwy o allweddi sy'n gweithio (heb eu dangos yma). Yna gellir defnyddio'r allweddi gweithio hyn mewn protocolau cyfathrebu fel TLS, ar gyfer example ar gyfer diogelu cyfrinachedd, cywirdeb a dilysrwydd y data sy'n cael eu cyfnewid rhwng y gwesteiwr lleol a'r gweinydd pell.
Llif gorchymyn
Mae Ffigur 4. Llif gorchymyn sefydlu allweddol yn dangos y llif gorchymyn:
- Mae allweddi preifat a chyhoeddus y gwesteiwr o bell wedi'u codio'n galed yn y cod example.
- The local host sends the Generate Keypair command to the STSAFE-A110/STSAFE-A120 to generate the key pair on its ephemeral slot (slot 0xFF).
- The STSAFE-A110 sends back the public key (which corresponds to slot 0xFF) to the STM32 (representing the remote host).
- The STM32 computes the remote host’s secret (using the STSAFE device’s public key and the remote host’s private key).
- The STM32 sends the remote host’s public key to the STSAFE-A110/STSAFE-A120 and asks the STSAFE-A110/STSAFE-A120 to compute the local host’s secret using the API.
- Mae'r STSAFE-A110/ STSAFE-A120 yn anfon cyfrinach y gwesteiwr lleol yn ôl i'r STM32.
- The STM32 compares the two secrets and prints the result. If the secrets are the same, the secret establishment is successful.

Lapiwch/dadlapiwch amlenni lleol
- This demonstration illustrates the case where the STSAFE-A110/STSAFE-A120 wraps/unwraps the local envelope in order to securely store a secret to any non-volatile memory (NVM).
- Encryption/decryption keys can be securely stored in that manner to additional memory or within the STSAFE-A110/STSAFE-A120’s user data memory.
- The wrapping mechanism is used to protect a secret or plain text. The output of wrapping is an envelope encrypted with an AES key wrap algorithm, and that contains the key or plain text to be protected. Command flow
- The local and remote hosts are the same device here.
- Generate random data assimilated to a local envelope.
- Wrap the local envelope using the STSELib middleware API.
- Store the wrapped envelope.
- Unwrap the wrapped envelope using the STSELIB middleware.
- Compare the unwrapped envelope to the initial local envelope. They should be equal.
Cenhedlaeth pâr allweddol
Mae'r arddangosiad hwn yn dangos y llif gorchymyn lle mae'r ddyfais STSAFE-A110/STSAFE-A120 wedi'i gosod ar westeiwr lleol. Mae gwesteiwr o bell yn gofyn i'r gwesteiwr lleol hwn gynhyrchu pâr allweddi (allwedd breifat ac allwedd gyhoeddus) ar slot 1 ac yna llofnodi her (rhif ar hap) gyda'r allwedd breifat a gynhyrchwyd.
Yna mae'r gwesteiwr o bell yn gallu gwirio'r llofnod gyda'r allwedd gyhoeddus a gynhyrchir.
Mae'r arddangosiad hwn yn debyg i'r arddangosiad Dilysu gyda dau wahaniaeth:
- Mae'r pâr allweddol yn yr arddangosiad Dilysu eisoes wedi'i gynhyrchu (ar slot 0), tra, yn yr example, we generate the key pair on slot 1. The STSAFE-A110/STSAFE-A120 device can also generate the key pair on slot 0xFF, but only for key establishment purposes.
- The public key in the Authentication demonstration is extracted from the certificate in zone 0. In this example, the public key is sent back with the STSAFE-A110/STSAFE-A120 response to the Generate Keypair command.
Llif gorchymyn
At ddibenion arddangos, yr un ddyfais yw'r gwesteiwyr lleol ac anghysbell yma.
- The host sends the Generate Keypair command to the STSAFE-A110/STSAFE-A120 which sends back the public key to the host MCU.
- The host generates a challenge (48-byte random number) using the Generate Random API. The STSAFE-A110 sends back the generated random number.
- The host computes the hash of the generated number using the cryptographic library.
- The host asks the STSAFE-A110/STSAFE-A120 to generate a signature of the computed hash using the
Generate Signature API. The STSAFE-A110/ STSAFE-A120 sends back the generated signature. - The host verifies the generated signature with the public key sent by the STSAFE-A110/ STSAFE-A120 in step 1.
- The signature verification result is printed.
Geirfa
| Talfyriad | Ystyr geiriau: |
| AES | Safon Amgryptio Uwch |
| ANSI | Sefydliad Safonau Cenedlaethol America |
| API | Rhyngwyneb rhaglennu cais |
| BSP | Pecyn cymorth y Bwrdd |
| CA | Awdurdod Ardystio |
| CC | Meini Prawf Cyffredin |
| C-MAC | Cod dilysu neges gorchymyn |
| ECC | Crypograffeg cromlin eliptig |
| ECDH | Elliptic curve Diffie–Hellman |
| ECDHE | Elliptic curve Diffie–Hellman – ephemeral |
| EWARM | IAR Embedded Workbench® for Arm® |
| HAL | Haen tynnu caledwedd |
| I/O | Mewnbwn/allbwn |
| IAR Systems® | World leader in software tools and services for embedded systems development. |
| IDE | Amgylchedd datblygu integredig. Cymhwysiad meddalwedd sy'n darparu cyfleusterau cynhwysfawr i raglenwyr cyfrifiadurol ar gyfer datblygu meddalwedd. |
| IoT | Rhyngrwyd o bethau |
| I²C | Cylched rhyng-integredig (IIC) |
| LL | Gyrwyr lefel isel |
| MAC | Cod dilysu negeseuon |
| MCU | Uned microcontroller |
| MDK-ARM | Keil® microcontroller development kit for Arm® |
| MPU | Uned amddiffyn cof |
| NVM | Cof anweddol |
| OS | System weithredu |
| SE | Elfen ddiogel |
| SHA | Algorithm Hash Diogel |
| CLG | Cytundeb trwydded meddalwedd |
| ST | STMicroelectroneg |
| TLS | Diogelwch Haen Trafnidiaeth |
| USB | Bws Cyfresol Cyffredinol |
Hanes adolygu
| Dyddiad | Adolygu | Newidiadau |
| 23-Mehefin-2025 | 1 | Rhyddhad cychwynnol. |
HYSBYSIAD PWYSIG – DARLLENWCH YN OFALUS
- Mae STMicroelectronics NV a'i is-gwmnïau (“ST”) yn cadw'r hawl i wneud newidiadau, cywiriadau, gwelliannau, addasiadau a gwelliannau i gynhyrchion ST a/neu i'r ddogfen hon ar unrhyw adeg heb rybudd. Dylai prynwyr gael y wybodaeth berthnasol ddiweddaraf am gynhyrchion ST cyn gosod archebion. Gwerthir cynhyrchion ST yn unol â thelerau ac amodau gwerthu ST sydd ar waith ar adeg cydnabod yr archeb.
- Prynwyr yn unig sy'n gyfrifol am ddewis, dewis a defnyddio cynhyrchion ST ac nid yw ST yn cymryd unrhyw atebolrwydd am gymorth ymgeisio neu ddyluniad cynhyrchion prynwyr.
- Ni roddir trwydded, yn benodol nac yn oblygedig, i unrhyw hawl eiddo deallusol gan ST yma.
- Bydd ailwerthu cynhyrchion ST gyda darpariaethau gwahanol i'r wybodaeth a nodir yma yn dileu unrhyw warant a roddir gan ST ar gyfer cynnyrch o'r fath.
- Mae ST a'r logo ST yn nodau masnach ST. I gael gwybodaeth ychwanegol am nodau masnach ST, cyfeiriwch at www.st.com/trademarks. Mae pob enw cynnyrch neu wasanaeth arall yn eiddo i'w perchnogion priodol.
- Mae gwybodaeth yn y ddogfen hon yn disodli ac yn disodli gwybodaeth a ddarparwyd yn flaenorol mewn unrhyw fersiynau blaenorol o'r ddogfen hon.
- © 2025 STMicroelectroneg – Cedwir pob hawl
Dogfennau / Adnoddau
![]() |
Pecyn Meddalwedd ST X-CUBE-STSE01 [pdfLlawlyfr Defnyddiwr Pecyn Meddalwedd X-CUBE-STSE01, Pecyn Meddalwedd, Meddalwedd |

