1. 摘要
本文主要列举实际测试的 mbedTLS 和 wolfSSL 的内存开销对比。
2. 测试版本
wolfSSL 版本: https://github.com/wolfSSL/wolfssl/releases/tag/v3.12.2-stable
ESP8266 SDK 版本:ESP8266_RTOS_SDK - c7b64043
3. 测试数据
本章主要列举各种配置参数和具体测试数据,由于 wolfSSL 宏观上不需要用户自己配置 fragment,所以也就不做相关的对比了,而且默认支持最大 RSA4096 计算,所以也就不做秘钥大于4096的对比。
wolfSSL内部会自动分配 fragment,所以为了相对公平起见,我们测试的时候会对 fragment 进行适配。
Mode: ESP8266 模式,作为 server 或 client。
Verification: ESP8266 校验方式。
Key size: 生成证书的 key 大小。
Reduction: mbedtls 所消耗的内存 - wolfSSL 所消耗的内存。
Ration: mbedtls 所消耗的内存/wolfSSL 所消耗的内存。
3.1 mbedTLS 与 wolfSSL 在握手建立后消耗内存对比
Mode | Verification | Key size | mbedTLS | wolfSSL | Reduction | Ratio |
---|---|---|---|---|---|---|
Server | None | 2048 | 15521 | 10448 | 5073 | 1.49 |
Server | None | 3072 | 18655 | 11696 | 6959 | 1.59 |
Server | Bi-directional | 2048 | 21110 | 10848 | 10262 | 1.95 |
Client | Bi-directional | 2048 | 16522 | 6776 | 9746 | 2.44 |
Client | Bi-directional | 3072 | 22725 | 7880 | 14845 | 2.88 |
Client | CA | 2048 | 13321 | 3824 | 9497 | 3.48 |
Client | CA | 3072 | 19855 | 3952 | 15903 | 5.02 |
Client | CA | 4096 | 20222 | 4088 | 16134 | 4.95 |
Client | None | 2048 | 10620 | 3416 | 7204 | 3.11 |
Client | None | 3072 | 16071 | 3416 | 12655 | 4.7 |
Client | None | 4096 | 21903 | 18756 | 3416 | 1.17 |
3.2 mbedTLS 与 wolfSSL 在握手过程中最大消耗内存对比
Mode | Verification | Key size | mbedTLS | wolfSSL | Reduction | Ratio |
---|---|---|---|---|---|---|
Server | None | 2048 | 22831 | 23264 | -433 | 0.98 |
Server | None | 3072 | 29915 | 28240 | 1675 | 1.06 |
Server | Bi-directional | 2048 | 29131 | 23648 | 5483 | 1.23 |
Client | Bi-directional | 2048 | 19542 | 25128 | -5586 | 0.78 |
Client | Bi-directional | 3072 | 26353 | 30688 | -4335 | 0.86 |
Client | CA | 2048 | 16205 | 16712 | -507 | 0.97 |
Client | CA | 3072 | 21522 | 19000 | 2522 | 1.13 |
Client | CA | 4096 | 24311 | 21616 | 2695 | 1.12 |
Client | None | 2048 | 14516 | 15568 | -1052 | 0.93 |
Client | None | 3072 | 17526 | 18208 | -682 | 0.96 |
Client | None | 4096 | 21903 | 20856 | 1047 | 1.05 |