How to protect your firmware against malicious attacks using the latest Kinetis development board
April 25, 2017
IoT and Security Solutions
PUBLIC PUBLIC 0 Agenda • IoT Phishing: “I have a bad feeling about this…” • Applying a security model • NXP Kinetis MCU solution − Kinetis K28F MCU − mbed TLS − KBOOT • Overview of methods • Development steps • Key management options • Resources and next steps
PUBLIC 2 1 IoT: Phishing with Edge Nodes
PUBLIC 3 3 Driving Internet of Things (IoT) Innovation
Society Data centers Vehicle
Cities Transactions
PUBLIC 4 Phishing with IoT Edge Node Lures – A new attack vector to prepare for.
• By now, people from all walks of life are aware of email phishing scams that are used to inject malware onto personal computing devices. • But what about a phishing attack that uses an IoT edge node as a lure? • How can this happen?
End node that has been tampered with to contain malicious firmware Attacker access to network interfaces leading to additional breaches or User dDoS acceptance and provisioning of the device with secret data PUBLIC 5 2 Applying a Security Model
PUBLIC 6 Begin with a Security Model
• The rules in place that identify the data that should be protected • For example • The management of firmware, secret keys, user and application data Policies • Passwords, personal information, network credentials
• The definition of the attacks and attackers that the end device will face and protect against • Considers the access to the device, and cost of the attack Threat • For example • Expert attackers who will use off the shelf tools to gain access and insert malware landscape
• The means by which the policies for the device are enforced • Involves the application of security technology to achieve product goals • For example Methods • Protecting secret keys with tamper response using the Kinetis MCU anti-tamper
PUBLIC 7 A Security Model | Methods Security Technology: Hardware View
Threat Policies Methods Landscape
• Crypto Acceleration
− ‘mmCAU’, for low-end Kinetis Only − ‘LTC’, for high-end Kinetis authenticated − ‘CAAM’ for i.MX firmware • Trusted Execution ® should be − ARM TrustZone − ‘Secure boot executed − ‘RTIC’ (Runtime Integrity Checker)
− Secure debug Physical access to − Secure storage − Resource domain isolation (MPU, FAC) the device • Tamper Resistance communication ports − Erases secrets at tamper detect
− Active and passive tampers
PUBLIC 8 Security Technology | Secure Boot System View
Authenticated Application code Manufacturing Development Tool chain, Key management, Code Unchangeable Boot Code Signing tools RTOS Cryptography Stack Bootloader Code Confidentiality and/or Boot interfaces, Command parser, Middleware Authentication Memory programming
SDK Low Level Drivers SDK Deployment Trusted configurations for chip firewalls and interfaces for protection of resources Application tool chain, Host programmer Hardware providing physical & logical security MCU features for trust, crypto and anti-tamper
PUBLIC 9 3 NXP Kinetis MCU Solution
PUBLIC 10 10 Kinetis K27/K28 USB MCUs Industry’s Largest Embedded SRAM Memory on ARM® Cortex®-M4-based MCU, Optimized for Portable Devices
Largest Embedded SRAM • 1MB of embedded SRAM plus 2MB of Flash memory to enable longer battery life and richer graphics in portable display applications Lower System Power • 150 MHz Kinetis MCU enables advanced integration in battery-operated applications Advanced Integration • Reduces system board footprint required by wearables and other low-end graphic display systems Complete Enablement • Low-cost FRDM-K28F development platform, optional 5” LCD display board with capacitive touch from MikroElektronika, MCUXpresso software and tools
PUBLIC 11 Kinetis K27F/K28F HW and SW Enablement Plan
K28F ADDS-ON BASELINE SW OPTIONAL BORAD HW BOARD HW BOARDS SW ENABLEMENT ENABLEMENT FEATURES CONNECTOR Kinetis SDK 2.x FRDM-KW41Z Arduino IDE: BLE + IAR BLE stack running on KW41Z (UART) • MCUXPresso IDE + FreeRTOS • IAR Arrow GT202 QCA4002 Wi-Fi drivers to be Arduino WI-FI • KEIL Wi-Fi stack running on QCA4002 ported to Kinetis SDK 2.x (UART) Kinetis SDK 2.x (TBD) FRDM-K28F FRDM-KW24D512 or FRDM-KW41Z + FreeRTOS Arduino THREAD SW Stack running on KWx wireless SoC + IAR (UART) RTOS: Low-cost evaluation + NXP Thread SW SDK • FreeRTOS platform for K27F/K28F family Bare metal (no RTOS) MikroElectronika MCUXPresso SDK 2.x with on-board discrete power LCD 5' LCD display + capacitive touch + MicroEJ (3rd party) SW support FlexIO management, Accelerometer, DISPLAY connected through FlexIO interface + emWIN (3rd party) SW support SDRAM memory, QuadSPI (8080 and/or 6800 modes) Kinetis Expert: Serial Flash, USB High-Speed • Power Estimator tool FRDM-STBC-AGM01 (Sensor Fusion) Kinetis SDK 2.x (TBD) connector and Full-Speed USB Arduino • Pin Configuration tool SENSOR 9-axis inertial measurement solution: + FreeRTOS/Bare Metal OpenSDA (I2C / SPI) • Clock Configuration tool 3-axis Gyro, 3D Accelero + Magneto + Sensing SDK 1.0 • Peripheral configuration ARD-AUDIO-DA7212 Target resale price: $40 2-channel audio codec w/ capless Arduino tool AUDIO Kinetis SDK 2.x (TBD) headphone driver and 3.5mm stereo (I2S) AUX input jack socket NXP HomeKit SDK 1.x MCUXPresso SDK 2.x HOMEKIT FRDM-TWRPI + TWRPI-I2C* + Kinetis SDK 1.3 Arduino & MFI MFi Adaptor boards + FreeRTOS (I2C) + IDE (IAR or KDS)
PUBLIC 12 Security Technology | System view : Hardware
Authenticated Application code Manufacturing Development Tool chain, Key management, Code Unchangeable Boot Code Signing tools RTOS Cryptography Stack Bootloader Code Confidentiality and/or Boot interfaces, Command parser, Middleware Authentication Memory programming
SDK Low Level Drivers SDK Deployment Trusted configurations for chip firewalls and interfaces for protection of resources Application tool chain, Host programmer Kinetis K28F Hardware Features: Flash Security, Flash Block Protection, HW acceleration for SHA256 and AES, TRNG
PUBLIC 13 Kinetis Low Power 32-bit MCs Based on ARM® Cortex®-M Cores
PUBLIC 14 Kinetis Security Technology | Essential Hardware Features
• Flash security and protection features are found on all Kinetis devices • Security features − Kinetis offers several levels of flash security − Flash security is a system-level feature ▪ The flash is fully functional when secured (firmware updates are still possible if resident firmware is setup to program the flash) ▪ Security effects are really a system level concern. The security setting determines what the SoC will allow. − Software IP is a large investment. Enabling security helps to protect that IP investment.
• Protection features − Flash protection can be used to prevent erase or programming − Initial protection values are loaded from the flash configuration field at reset
PUBLIC 15 Flash Block Protections to Protect Boot Code
0x0000_0000 Program Flash size / 32 FPROT3[PROT0]
Program Flash size / 32 FPROT3[PROT1]
Program Flash size / 32 FPROT3[PROT2]
*** *** ***
Program Flash size / 32 FPROT0[PROT30]
0x0020_0000 Program Flash size / 32 FPROT0[PROT31]
PUBLIC 16 Security Technology | System View : SDK & Toolchain
Authenticated Application code
Manufacturing MCUXpresso IDE, Key management, Code Signing tools Unchangeable Boot Code RTOS Cryptography Stack Bootloader Code Confidentiality and/or Boot interfaces, Command parser, Middleware Authentication Memory programming
MCUXpresso SDK SDK Deployment Application tool chain, Host programmer Kinetis K28F Hardware Features: Flash Security, Flash Block Protection, HW acceleration for SHA256 and AES, TRNG
PUBLIC 17 Tool Chain and Software Feature-rich, unlimited code size, optimized for ease-of-use, based on industry standard Eclipse framework MCUXpresso Software and Tools for NXP’s Kinetis and LPC MCUs for Kinetis and LPC microcontrollers Application development with Eclipse and GCC-based IDE for advanced editing, compiling and debugging MCUXpresso IDE Supports custom development Available Edit, compile, debug and optimize in an boards, Freedom, Tower and now! intuitive and powerful IDE LPCXpresso boards with debug probes from NXP, P&E and Segger
Free Edition: Full Featured, unlimited MCUXpresso SDK Code Size, no special activation Available Runtime software including peripheral needed, community based support now! drivers, middleware, RTOS, demos and Pro Edition: Email IDE support, more Advanced Trace Features
MCUXpresso Config Tools Available now! Online and desktop tool suite for system configuration and optimization
PUBLIC 18 Tool Chain and Software
MCUXpresso Software and Tools for Kinetis and LPC microcontrollers
Architecture: MCUXpresso IDE ▪ CMSIS-CORE compatible Available ▪ Single driver for each peripheral now! Edit, compile, debug and optimize in an ▪ Transactional APIs w/ optional DMA intuitive and powerful IDE support for communication peripherals
Integrated RTOS: MCUXpresso SDK ▪ FreeRTOS v9 ▪ RTOS-native driver wrappers Available Runtime software including peripheral now! drivers, middleware, RTOS, demos and more Integrated Stacks and Middleware ▪ USB Host, Device and OTG ▪ lwIP, FatFS ▪ Crypto acceleration plus wolfSSL & MCUXpresso Config Tools mbedTLS Available ▪ SD and eMMC card support now! Online and desktop tool suite for system configuration and optimization
PUBLIC 19 Security Technology | System View : Cryptography Stack
Authenticated Application code
Manufacturing MCUXpresso IDE, Key management, Code Signing tools Unchangeable Boot Code RTOS mbed TLS Bootloader Public Key/Private Key Generation, Boot interfaces, Command parser, Middleware Signature Generation &Verification Memory programming
MCUXpresso SDK SDK Deployment Application tool chain, Host programmer Kinetis K28F Hardware Features: Flash Security, Flash Block Protection, HW acceleration for SHA256 and AES, TRNG
PUBLIC 20 Support For Use of HW Accelerators with mbed TLS
PUBLIC 21 mbed TLS
PUBLIC 22 https://tls.mbed.org/high-level-design https://tls.mbed.org/module-level-design-public-key
PUBLIC 23 https://tls.mbed.org/core-features
Scalable Security Level Align to HW Capabilities & Security levels
PUBLIC 24 mbed TLS file Structure Allows Lightweight Implementations
PUBLIC 25 Security Technology | System View: Bootloader and Tools
Manufacturing Authenticated Application code MCUXpresso IDE, Key management, Code Signing tools (Kinetis hardware with Unchangeable Boot Code KBOOT and host RTOS tools) mbed TLS KBOOT Public Key/Private Key Generation, Boot interfaces, Command parser, Middleware Signature Generation &Verification Memory programming
MCUXpresso SDK SDK Deployment Application tool chain, Host programmer Kinetis K28F Hardware Features: Flash Security, Flash Block Protection, HW acceleration for SHA256 and AES, TRNG
PUBLIC 26 KBOOT: Kinetis Bootloadercccccc
HOST TOOLS: Kinetis Flash Tool, blhost, elftosb, Kinetis MCU Host
PUBLIC 27 HOST TOOLS: Kinetis Flash Tool, blhost, elftosb, Kinetis MCU Host
Elftosb : Command line Graphical user Kinetis K66 processing of program that interface to application that binaries, elf and interfaces to a interface to a performs host
SREC files into Blhost Kinetis MCU Kinetis MCU functionality to a Elftosb secure binaries running KBOOT running KBOOT Kinetis MCU (Special formats running KBOOT to work with KBOOT) Supports every Easier to use than KBOOT command blhost, but not as
Capable of powerful Kinetis Flash Tool Kinetis Flash encrypting files, Kinetis MCU Host generating keys
The Elftosb and blhost tool is command line driven and can be separately built to run on Windows® OS, Linux® OS, and Apple Mac® OS.
PUBLIC 28 KBOOT Definitions and Use
• BD file: Short for boot descriptor file. This is an input command file to be used by elftosb for created SB files • SB file: Short for secure binary file. This is the output of elftosb which is used to pass commands and data to a Kinetis MCU running KBOOT Input files
Input files Keys for Firmware encrypt
SREC USB FS K28F HW blhost with KBOOT Binary elftosb SB file
ELF
Input files Commands
BD file PUBLIC 29 4 Overview of Methods
PUBLIC 30 30 Using KBOOT for Signature Generation
• Factory KBOOT application • Production KBOOT application − This bootloader application is for use in a − This bootloader application is for use in a secure manufacturing environment. The deployed device. The main security main security functions in addition to functions in addition to bootloader bootloader functions are to generate a functions are to check the signature of PUB/PRIV key pair and to generate the application code using the public key, signature for application code using the and only allow execution of the application private key. code if the signature is authentic. K28F Hardware Production KBOOT HW for KBOOT Factory Application
HOST TOOLS: Kinetis Flash Tool, blhost, elftosb, Kinetis MCU Host
PUBLIC 31 Overview of the Method
• Typical Application Development • Final production image
0x0000_0000 0x0000_0000 KBOOT Your IoT Protected 0x0000_8000 Public key Application mbed TLS Unchangeable code 0x0000_FFFF (Cryptography)
0x0001_0000 Manufacturing Your IoT application code
0x0020_0000 0x0020_0000 Signature
PUBLIC 32 Overview of the Method
• Typical Application Development • Final production image
0x0000_0000 0x0000_0000 KBOOT KBOOT Your IoT Public key 0x0000_8000 KBOOT : Secure BootApplication mbed TLS 1) Always runs after chipcode reset and (Cryptography) checks defined interfaces (ie. USB) for 0x0000_FFFF host connection to get new firmware • Application code authentication is 0x0001_0000 applied before allowing application to run Your IoT • Protected by chip HW application mechanisms, can be made code immutable
0x0020_0000 0x0020_0000 Signature
PUBLIC 33 Overview of the Method
• Typical Application Development • Final production image
0x0000_0000 0x0000_0000 mbed TLS KBOOT Your IoT KBOOT 1) Used to hash the application code 0x0000_8000 Public key space then toApplication perform an ECDSA mbed TLS Verify using the signaturecode provided (Cryptography) by the firmware 0x0000_FFFF 0x0001_0000 Your IoT application code
0x0020_0000 0x0020_0000 Signature
PUBLIC 34 Overview of the Method
• Typical Application Development • Final production image
0x0000_0000 0x0000_0000 KBOOT Your IoT KBOOT Application Code Changes 0x0000_8000 Public key 1) Only use internalApplication flash after mbed TLS KBOOT (0xFFFF)code (Cryptography) 2) Add Boot Configuration area 0x0000_FFFF to hold information for the 0x0001_0000 bootloader Your IoT application code
0x0020_0000 0x0020_0000 Signature
PUBLIC 35 Using KBOOT for Signature Generation
Your Secure manufacturing facility
Factory App SREC SB Host PC with Host PC with K28F HW KBOOT tools KBOOT tools for KBOOT USB FS Factory Factory Elftosb Factory Application BD blhost PubKey SB bin Signature bin Elftosb blhost
App SREC Production SB PubKey bin Host PC with Host PC with KBOOT tools KBOOT tools USB FS Signature bin Production Production KBOOT HW Elftosb SB blhost Production BD
PUBLIC 36 Using KBOOT for Signature Generation 1) Application SREC is Your Secure manufacturing facility combined with Factory Factory App SREC BD to create the SB Host PC with FactoryHost PC Secure with Binary K28F HW KBOOT tools KBOOT tools for KBOOT (Factory.SB) USB FS Factory Factory Elftosb Factory Application BD blhost PubKey SB bin Signature bin Elftosb blhost
App SREC Production SB PubKey bin Host PC with Host PC with KBOOT tools KBOOT tools USB FS Signature bin Production Production KBOOT HW Elftosb SB blhost Production BD
PUBLIC 37 Using KBOOT for Signature Generation
Your Secure manufacturing facility 2) Using HW with the Factory App SREC KBOOT Factory SB programmed,Host PC withthe Host PC with K28F HW Factory.sbKBOOT is downloaded tools KBOOT tools for KBOOT and blhost commands are USB FS Factory Factory Elftosb Factory Application BD used to generate binaries blhost PubKey SB bin for signature and public Signature bin keysElftosb blhost
App SREC Production SB PubKey bin Host PC with Host PC with KBOOT tools KBOOT tools USB FS Signature bin Production Production KBOOT HW Elftosb SB blhost Production BD
PUBLIC 38 Using KBOOT for Signature Generation
Your Secure manufacturing facility
Factory App SREC SB Host PC with 3) Application SRECHost PC is with K28F HW KBOOT tools combined with signatureKBOOT tools for KBOOT binary to make the USB FS Factory Factory Elftosb Factory Application BD blhost PubKey SB Production secure binary bin Signature bin Elftosb blhost
App SREC Production SB PubKey bin Host PC with Host PC with KBOOT tools KBOOT tools USB FS Signature bin Production Production KBOOT HW Elftosb SB blhost Production BD
PUBLIC 39 Using KBOOT for Signature Generation
Your Secure manufacturing facility 4) Production secure Factory App SREC binary is used to program SB Host PC with final hardware.Host One PC with K28F HW KBOOT tools production secureKBOOT binary tools is for KBOOT programmed to all units USB FS Factory Factory Elftosb Factory Application BD blhost PubKey SB containing the same bin version of application Signature bin Elftosb srecord. blhost
App SREC Production SB PubKey bin Host PC with Host PC with KBOOT tools KBOOT tools USB FS Signature bin Production Production KBOOT HW Elftosb SB blhost Production BD
PUBLIC 40 Using KBOOT for Signature Generation
Your Secure manufacturing facility For updated application Factory App SREC code the Pub/Priv key pair SB Host PCis withnot erased - this way the Host PC with K28F HW KBOOT toolsnew signature that is KBOOT tools for KBOOT USB FS generated uses the same Factory Factory Elftosb Factory Application BD blhost PubKey SBkey pair bin Signature bin Elftosb blhost
App SREC Production SB PubKey bin Host PC with Host PC with KBOOT tools KBOOT tools USB FS Signature bin Production Production KBOOT HW Elftosb SB blhost Production BD
PUBLIC 41 5 Development Steps
PUBLIC 42 42 Overview of Development Steps for K28F KBOOT
1. Port KBOOT for K28F • Development Environments ▪ Porting guidelines are provided in the KBOOT reference Manual Chapter 10 − KDS is used for KBOOT development • K66F is the starting point ▪ Other tool chains are available and on the ▪ File renaming and copying over from SDK of roadmap K28F ▪ Could be ported to MCUXpesso ▪ Account for HW differences • LPUART versus standard UART − PC with KBOOT tools is used for factory 2. Add mbed TLS support to KBOOT for signing and initial provisioning cryptography ▪ Add relevant files • SHA-256, ECC, ECDSA 3. Defines are used to use one application which can be configured for factory mode or production mode
PUBLIC 43 Overview of Development Steps for K28F Application
1. Application development changes • Development Environments when starting from K28F SDK − MCUXpresso with SDK ▪ Update Linker File • Code must be placed after KBOOT • New range from 0x3C0 to 0x400 for BCA (boot config area)
PUBLIC 44 5 Key Management Options
PUBLIC 45 45 Cryptography Key Table
Key Name or Key Type Key Location(s) Comments Description Private Key Enc. Key Simple Xor Factory.bd text file (calls 2 parameter as Used in SEC Kboot Factory to output the with key simple private key enc key) private key after encryption. (To improvement to use AES CBC enc this key.)
Private Key for KBOOT ECDSA- On-chip flash 0x0003_f000 only at RAM of SEC Boot Factory, encrypted and BP256 factory mode stored externally
Public Key for KBOOT ECDSA- Included in the product bootloader image Exported to binary by factory bootloader, BP256 at compiling. stored in production boot code No fixed address. Signature of application SHA-256 On-chip flash 0x001F_ff80, after on chip firmware Based for application image. ECDSA BP256
Private key must be protected, and a secure manufacturing environment is needed
PUBLIC 46 Alternative Key Management with embedded secure element
PUBLIC 47 A700X with KBOOT
Kinetis with Modified KBOOT to interface to A700X
Before jumping to application code, the signature is verified using credentials COMMS A700X provided by the A700x
The A700x family is delivered with pre-programmed, die-specific keys and certificates which are being generated and programmed in a certified (Common Criteria) secure NXP internal environment
NXP Semiconductors offers a pre-personalizations service where customer-specific initialization data can be preprogrammed. This data can be die-individual card manager keys, symmetric DES-or AES keys, random data, X509 certificates, RSA signing keys or any other constant data like application code.
PUBLIC 48 6 Resources and Next Steps
PUBLIC 49 49 https://mcuxpresso.nxp.com/en/welcome
PUBLIC 50 Downloading SDK with mbed TLS
PUBLIC 51 LINK: Download KBOOT 2.0 Package
Extract the zip file to create \NXP_Kinetis_Bootloader_2_0_0 and SDK for K28F
PUBLIC 52 SLN-POS-RDR – Secure Card Reader Solution
PUBLIC 53 Resources
• AN4507: “Using the Kinetis Security and Flash Protection Features”
• AN5112: “Using the Kinetis Flash Execute-only Access Control Feature”
• AN4307: “Using the mmCAU in Kinetis” − AN4307SW: Example software for AN4307
• AN4733: “Using the DryIce Tamper Detection Unit on Kinetis Microcontrollers” (available under NDA only)
PUBLIC 54 Summary
• In today’s connected world, security is important for protecting you and your customers.
• Firmware must be protected to maintain the security of end devices and the data they generate
• NXP’s microcontrollers contain HW features and software enablements that can be integrated to strengthen your end device
Download MCUXpresso SDK for K28F and KBOOT today to secure your firmware!
PUBLIC 55 NXP UNIQUELY POSITIONED TO DELIVER SECURE SMART CONNECTED SOLUTIONS Security Technology Smart Connected Application Device Identification SMART SMART Identification HOME INDUSTRY Certification Compliance Cryptography Network Security Acceleration NFC RFID
Secure Boot Secure Keys SMART INFRASTRUCTURE Secure Memory Secure Update Trusted Execution Unique Chip Identity Environments Security Expertise
WEARABLES SMART HEALTHCARE E-Passport Mobile Transactions Banking
PUBLIC 56