系統概要
mbedtls 也許是最小巧的ssl代碼庫。高效、便於移植和集成。支持常見的安全算法,如:AES、DES、RSA、ECC、SHA256、MD5、BASE64等等。除此之外還支持公鑰證書體系。它提供了具有直觀的 API 和可讀源代碼的 SSL 庫。該工具即開即用,可以在大部分系統上直接構建它,也可以手動選擇和配置各項功能。
mbedtls 沒有core,而是有一些組件構成,我們可以通過配置頭文件(include/mbedtls/config.h)加入或排除這些組件。 mbedtls主要包括以下模塊:
SSL/TLS communication
TCP/IP communication
Hashing
Random number generation (RNG)
Symmetric cipher (Cipher)
Public Key cryptography (PK)
X.509 public key infrastructure (X.509)
模塊之間的依賴關係如下
SSL/TLS 模塊需要 hashing, cipher, public key and X.509 可能用到 configured to use the RNG and TCP/IP
Public Key 模塊可能用到 RNG
編譯&安裝
下載源碼:
最新的版本可以通過github下載得到
git clone --recursive https://github.com/ARMmbed/mbedtls.git
編譯
Mbed TLS releases 版本提供三種編譯安裝方式,
GNU Make
CMake
Microsoft Visual Studio (Microsoft Visual Studio 2013 or later)
官方推薦使用GNU Make和CMake,我在項目中使用cmake,下面分別介紹一下make和cmake。
make
make | 可直接編譯 |
make check | 需要運行測試程序 |
cmake
cmake 可以將文件單獨編譯在一個目錄,
mkdir /path/to/build_dir && cd /path/to/build_dir
cmake /path/to/mbedtls_source || 交叉編譯 CC=your_cc cmake /path/to/mbedtls_source
make