系统概要
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