dm00105446 Stm32cube Polarssl Example Stmicroelectronics
dm00105446 Stm32cube Polarssl Example Stmicroelectronics
User Manual
STM32Cube PolarSSL example
Introduction
The STM32Cube initiative was originated by STMicroelectronics to ease developers life, by
reducing development efforts, time and cost. STM32Cube covers the STM32 portfolio.
STM32Cube Version 1.x includes:
The STM32CubeMX, a graphical software configuration tool that allows to generate C
initialization code, using graphical wizards
A comprehensive embedded software platform, delivered per series (such as
STM32CubeF4 for STM32F4 series)
– The STM32Cube HAL, an STM32 abstraction layer embedded software, ensuring
maximized portability across the STM32 portfolio
– A consistent set of middleware components such as RTOS, USB, TCP/IP and
graphics
– All embedded software utilities coming with a full set of examples.
With the increasing number of embedded devices interconnected over the network,
hardware-based cryptographic capabilities are required, to ensure secure transactions. The
integrated Ethernet MAC and cryptographic processor of the STM32, make it best fits for
such applications. The embedded Ethernet features a 10/100 Mbit/s MAC, it supports both
the Media Independent Interface (MII) and the Reduced Media Independent Interface
(RMII), giving developers the flexibility to connect to the PHY of their choice. Performance is
further enhanced through the use of a dedicated DMA controller, and hardware checksums
for the IP, UDP, TCP and ICMP protocols.
The hardware cryptographic processor supports AES/128/192/256, Triple DES, DES, SHA-
1, SHA-2, MD5 and RNG.
Secure Sockets Layer (SSL) and Transport Layer Security (TLS) cryptographic protocols
provide security for communications over networks, such as the Internet, and allow client
and server applications to communicate in a way that is private and secure.The purpose of
this user manual is to present an SSL Client/Server example, built on top of STM32Cube
HAL drivers and the PolarSSL library (a free SSL/TLS library).
Note: This document is applicable to all STM32 Series featuring an Ethernet peripheral and
hardware cryptographic processor; for simplicity reason, STM32F4xx and STM32CubeF4
are used as reference platform within all the documents.The same description, file names
and screenshot are applicable as well to other Series offering Ethernet connectivity, such as
STM32F217xx and STM32F756xx.
To know more about the PolarSSLexample implementation on STM32 Series, refer to the
documentation provided within the associated STM32Cube firmware package.
Contents
2 PolarSSL library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2 License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
7 FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
8 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
List of figures
The Secure Socket Layer (SSL) and Transport Layer Security (TLS) protocols provide
communications security over the Internet and allow client/server applications to
communicate in a way that is private and reliable. These protocols are layered above a
transport protocol such as TCP/IP.
SSL is the standard security technology for creating an encrypted link between server and
client. This link ensures that all communication data remains private and secure.
The major objectives of SSL/TLS are:
Provide data integrity between two communicating applications.
Protect information transmitted between server and client.
Authenticate the server to the client.
Allow the client and server to select the cryptographic algorithms that they both
support.
Optionally authenticate the client to the server.
Use public-key encryption techniques to generate shared secrets.
Establish an encrypted SSL connection.
TCP layer: the Transport Layer responsibilities include end-to-end message transfer
capabilities independent of the underlying network, along with error control,
segmentation, flow control, congestion control, and application addressing
IP layer: the Internet Protocol layer is responsible for addressing hosts and routing
packets from a source host to the destination host
Physical layer: the Physical Layer consists of the basic hardware transmission
technologies of a network
$SSOLFDWLRQOD\HU
66/7/6OD\HU
7&3OD\HU
,3OD\HU
3K\VLFDOOD\HU
069
$SSOLFDWLRQ
+DQGVKDNH
66/76/
$OHUW &&6
5HFRUG
7&3,3
069
$SSOLFDWLRQGDWD
&RPSUHVVLRQ
$XWKHQWLFDWLRQ
(QFU\SWLRQ
06Y9
2 PolarSSL library
2.1 Overview
PolarSSL is a light-weight open source cryptographic and SSL/TLS library written in C. This
library contains all needed functions to implement an SSL/TLS server or client. It contains
also a set of hashing functions and cryptographic algorithms.
Library features:
SSL 3.0, TLS 1.0 TLS 1.1 and TLS 1.2 client/server support
Symmetric encryption algorithms: AES, Blowfish, Triple-DES (3DES), DES, ARC4,
Camellia, XTEA
Modes of operation: ECB, CBC, CFB, CTR, GCM
Hash algorithms: MD2, MD4, MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512
Software random number generator: HAVEGE, CTR-DRBG
X509 certificates, CRLs, Keys and ASN.1
Public key cryptography: RSA and Diffie-Hellman (DHM) key exchange
The source code of the PolarSSL library can be downloaded from this link:
http://polarssl.org/
2.2 License
PolarSSL is licensed according to the dual licensing model. PolarSSL is available under the
open source GPL version two license, as well as under a commercial license for closed
source projects.
For detailed information about licensing, please refer to this link:
https://polarssl.org/
This package contains two applications running on top of the PolarSSL library and LwIP
stack in RTOS mode:
SSL_Client: This application proves the ability of the STM32F4xx device to exchange
messages with a server over TCP/IP connectivity through a SSL connection. This
application allows the user to connect the STM324xx-EVAL board to a secure web
server with SSL protocol
SSL_Server: This application is a combination of HTTP with SSL protocol to provide
encryption and secure identification of the server. This application allows the user to
connect from a web browser to a STM324xx-EVAL evaluation board using SSL
protocol
These two applications are located under:
Projects\STM324xx_EVAL\Applications\PolarSSL\, where STM324xx_EVAL refers to
STM32F4xx evaluation board such as STM324xG_EVAL for STM32F407xx/417xx devices.
66/FOLHQWWKUHDG
3RODU66/
66/7/6
)UHH5726
/Z,3
7&3,37KUHDG
(WKHUQHW7KUHDG
670&XEH/LEUDU\
069
The ssl_server.exe application window is shown in Figure 8. The SSL server application
displays the connection request status; all exchanged messages between the server and
the client, are displayed.
HyperTerminal
HyperTerminal window (Figure 9) displays the status of the SSL client application running
on the STM32F4xx device (write and read messages):
Status of SSL structures (SSL context, SSL session, SSL RNG)
Client request to the server: “GET”
The received message contains the result of Handshake protocol: for example
“Successful connection using: SSL_EDH_RSA_AES_256_SHA”.
66/FOLHQWWKUHDG
3RODU66/
66/7/6
)UHH5726
/Z,3
7&3,37KUHDG
(WKHUQHW7KUHDG
670&XEH/LEUDU\
069
On successful connection, a page is displayed showing the running tasks and their status.
This page contains also the number of page hits and the list of cipher suites, used in the
connection.
The user can monitor the connection status of the SSL server application, running on
STM32F4xx device, using the HyperTerminal window. This window (Figure 13) shows:
The status of connection, SSL structures and Handshake protocol
The size of the client request message
The size of the server response (html page)
Note: The first time that the user connects to the server, he receives a warning message from the
browser about the certificate presented. This warning occurs when the certificate has been
issued by a certification authority (CA), that is not recognized by the browser or when the
certificate was issued to a different web address.
6 Conclusion
This user manual describes two STM32F4xx applications that implement the PolarSSL
library with the STM32Cube drivers.
The first one demonstrates the ability of the STM32F4xx devices to exchange messages
with a server through an SSL connection. This application allows the STM32 to connect to a
secure web server.
The second one is a combination of HTTP with SSL protocol to provide encryption and
secure identification of the server. This application allows the user to connect to an STM32
using the SSL protocol from a web browser.
7 FAQ
6WDUW
P HPVHW
$OORFDWHDOO0HPRU\ EXI
KDYHJH B LQLW
,QLWLDOL]HWKH51*DQGWKH
VHVVLRQGDWD
UHW
QHW B FRQQHFW
6WDUWWKHFRQQHFWLRQ
QR
UHW
\HV
UHW
VVO B LQLW
,QLWLDOL]HDQ66/FRQWH[W
UHW QR
\HV
UHW
VVO B ZULWH
6HQG DSSOLFDWLRQGDWD
UHW! QR
\HV
UHW
VVO B UHDG
5HDGWKH+773UHVSRQVH
QHW B FORVH
&ORVHWKH FRQQHFWLRQ
VVO B IUHH
&OHDQXSDOOPHPRU\
(QG
069
6WDUW
/RDGWKHFHUWLILFDWH
%LQGRQKWWSVSRUW
:DLWXQWLODFOLHQWFRQQHFWV
QR &OLHQW
FRQQHFWV
\HV
,QLWLDOL]HWKH51*DQGWKH
VHVVLRQGDWD
UHW QR
\HV
UHW
VVOB UHDG
5HDGWKH+7735HTXHVW
UHW! QR
\HV
UHW
VVOB ZULWH
:ULWHWKHUHVSRQVH
QHWB FORVH
&ORVHWKHFRQQHFWLRQ
VVOB IUHH
&OHDQXSDOOPHPRU\
(QG
069
8 Revision history
STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and
improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on
ST products before placing orders. ST products are sold pursuant to ST’s terms and conditions of sale in place at the time of order
acknowledgement.
Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or
the design of Purchasers’ products.
Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.
ST and the ST logo are trademarks of ST. All other product or service names are the property of their respective owners.
Information in this document supersedes and replaces information previously supplied in any prior versions of this document.