关于im:TLS协议分析-九-现代加密通信协议设计

2次阅读

共计 7122 个字符,预计需要花费 18 分钟才能阅读完成。

六. TLS 协定给咱们的启发 — 古代加密通信协议设计

在看了这么多的剖析和案例之后,咱们曾经能够演绎出加密通信协议设计的广泛问题,和常见设计决策,

设计决策点:

  1. 四类根底算法 加密 /MAC/ 签名 / 密钥替换 如何抉择?
    对称加密目前毫无疑问应该间接用 aead,最佳抉择就是 aes-128-gcm/aes-256-gcm/chacha20-poly1305 了
    数字签名 / 验证计划,如果是挪动互联网,应该思考间接放弃 RSA,思考 P-256 的 ECDSA 公钥证书,或者更进一步的 ed25519 公钥证书。
    密钥替换算法,目前最佳抉择就是 curve25519,或者 P-256。
  2. 对称加密算法 + 认证算法,如何抉择?或者间接用 aead?
  3. 签名算法如何抉择?RSA or ECDSA or Ed25519?
  4. 思考未来的算法调整,要加版本号机制吗?
    倡议是加上,起码在密钥协商的步骤,要加上版本号。便于未来更新算法。
  5. RSA 用作密钥替换是一个好的抉择吗?思考 PFS
    倡议间接放弃 RSA,RSA 服务器端性能比 ECDSA 更差,签名更大费流量,而且没有前向安全性,给私钥保存带来更大危险。
  6. 自建 PKI,是个好的抉择吗?crl 如何解决?
    自建 PKI 能够做到更平安,比方简略的客户端内置数字签名公钥。可是当须要紧急撤消一个证书的时候,只能通过紧急公布新版客户端来解决。
  7. 必须用蹩脚的 openssl 吗?or something better?crypto++,botan, nacl/libsodium, polarssl?libsodium: ed25519+curve2519+chacha20+poly1305
  8. 重放攻打如何解决?某种 seq?或者 nonce 如何生成?
  9. 握手过程被中间人篡改的问题怎么解决?
  10. 性能:私钥运算的 cpu 耗费能够接受吗?加上某种 cache?
    要解决私钥运算的高 cpu 耗费,必然就须要 session ticket/session id 这种 cache 机制。显然 session ticket 更好
  11. 提早:密钥协商须要几个 rtt?起码多少?加上 cache 后?和 tcp 比照如何
  12. TLS 的性能 (次要指服务器 cpu 耗费) 还有空间能够压迫吗?我能设计一个性能更牛逼的吗?

七. 附录:密码学根底概念

本文曾经很长了,根底概念的内容更多,再开展介绍就太长了,上面就列一下点,贴一下参考资料,就先这样, 当前再说吧。

当然,最好的材料是上面列的书。

1. 块加密算法 block cipher

AES 等

《AES 后分组明码的钻研现状 及发展趋势》
http://www.ccf.org.cn/resourc…

aead 的介绍(作者是大神)
https://www.imperialviolet.or…

3 种组合形式之争
http://www.thoughtcrime.org/b…

CBC 模式 +MAC-then-encrypt 的 padding oracle 攻打, tls POODLE 破绽
http://drops.wooyun.org/paper…
https://defuse.ca/blog/recove…

128 bit 和 256 bit key size 之争
https://www.schneier.com/blog…

nist 对 aes gcm 的技术标准,官网权威文档:
http://csrc.nist.gov/groups/S…

一个 gcm 的调用范例
https://github.com/facebook/c…

DES
1 天之内破解 DES(2008 年)
http://www.sciengines.com/com…

iPhone 5S 开始,A7 芯片也有了 aes 硬件指令 (ARMv8 指令集),有 825% 的性能晋升:
http://www.anandtech.com/show…

2. 流加密算法 stream cipher

RC4,ChaCha20 等

序列密码倒退现状
http://www.ccf.org.cn/resourc…

rc4 : http://www.rc4nomore.com/

[RC4 加密已不再平安,破解效率极高(含视频)] http://www.freebuf.com/news/7…

3. Hash 函数 hash funtion

MD5,sha1,sha256,sha512 , ripemd 160,poly1305 等

MD5 被碰撞:
http://natmchugh.blogspot.com…

http://blog.avira.com/md5-the…

4. 音讯验证码函数 message authentication code

HMAC-sha256,AEAD 等

为什么要用 MAC
http://www.happybearsoftware….

Flickr 的破绽案例:
http://netifera.com/research/…

http://www.ietf.org/rfc/rfc21…

5. 密钥替换 key exchange

DH,ECDH,RSA,PFS 形式的(DHE,ECDHE)等

https://blog.cloudflare.com/a…

对于 前向安全性(Perfect Forward Secrecy)
http://vincent.bernat.im/en/b…

http://www.cryptopp.com/wiki/…

google 对 openssl 外面的椭圆曲线的优化:
http://static.googleuserconte…

http://www.math.brown.edu/~jh…

ripple 从 nistp256k1 曲线迁徙到 ed25519
https://ripple.com/uncategori…

openssh 6.5 开始反对 ed25519, curve25519, chacha20-poly1305
http://www.openssh.org/txt/re…

6. 公钥加密 public-key encryption

RSA,rabin-williams 等

RSA 入门必读(斯坦福,普渡的课件):
http://crypto.stanford.edu/~d…
https://engineering.purdue.ed…

PKCS1 规范,利用 RSA 必读:
https://www.ietf.org/rfc/rfc3447

RSA 的公钥为什么比 AES 的 key 长?
http://crypto.stackexchange.c…

http://cryptofails.blogspot.c…

应用什么 padding?OAEP,为什么不要用 PKCS V1.5

http://stackoverflow.com/ques…

http://crypto.stackexchange.c…
http://en.wikipedia.org/wiki/…

PKCS #1 — #15 标准协议官方网站:
http://www.emc.com/emc-plus/r…
http://arxiv.org/pdf/1207.544…

blinding 一种实现上的技术,用来解决 timing 侧通道攻打的问题
https://en.wikipedia.org/wiki…(cryptography)
http://crypto.stanford.edu/~d…

Twenty Years of Attacks on the RSA Cryptosystem:
http://crypto.stanford.edu/~d…

电子信封(digital envelope)
http://www.emc.com/emc-plus/r…

在 openssl 的 evp 接口中有间接反对:
https://wiki.openssl.org/inde…

7. 数字签名算法 signature algorithm

RSA,DSA,ECDSA (secp256r1 , ed25519) 等

三大公钥体制:RSA,DSA,ECDSA
RSA 目前是支流,占据绝大多数市场份额
DSA 曾经被废除
ECDSA 是将来的趋势,例如 bitcoin 就用 ECDSA
https://blog.cloudflare.com/e…
https://blog.cloudflare.com/a…

8. 明码衍生函数 key derivation function

TLS-12-PRF(SHA-256) , bcrypto,scrypto,pbkdf2 等

hkdf:http://tools.ietf.org/html/rf…
https://cryptography.io/en/la…

9. 随机数生成器 random number generators

/dev/urandom 等

[古代密码学实际指南[2015 年]] https://blog.helong.info/blog…

八. 参考文献:

TLS/SSL 相干 RFC 及规范

  • [TLS 1.2] 链接 https://tools.ietf.org/html/r…
  • [TLS 1.3 draft specification] 链接 https://github.com/tlswg/tls1…
  • [AES GCM for TLS] 链接 https://tools.ietf.org/html/r…
  • [ECC cipher suites for TLS] 链接 https://tools.ietf.org/html/r…
  • [TLS extensions] 链接 https://tools.ietf.org/html/r…
  • [Application-Layer Protocol Negotiation Extension] 链接 https://tools.ietf.org/html/r…
  • [X.509 PKI] 链接 https://tools.ietf.org/html/r…
  • [X.509 PKI and CRLs] 链接 https://tools.ietf.org/html/r…
  • [美国国家标准局 NIST 的密码学规范] 链接 http://csrc.nist.gov/groups/S…
  • [NIST SP 800-90A] 链接 http://csrc.nist.gov/publicat…
  • [nsa 的 SuiteB 密码学规范] 链接 https://www.nsa.gov/ia/progra…
  • [TLS on wikipedia] 链接 https://en.wikipedia.org/wiki…

协定剖析文章

  • http://www.root.org/talks/TLS…
  • [20 Years of SSL/TLS Research An Analysis of the Internet’s Security Foundation] 链接 http://www-brs.ub.ruhr-uni-bo…
  • https://www.slideshare.net/ya…
  • http://security.stackexchange…
  • [SSL/TLS in Detail] 链接 https://technet.microsoft.com…(v=ws.10).aspx
  • [SSL/TLS] 链接 http://www.spiegel.de/media/m…
  • [The Sorry State Of SSL] 链接 https://hynek.me/talks/tls/
  • [What’s the matter with TLS?] 链接 http://hyperelliptic.org/inte…
  • http://blog.csdn.net/CaesarZo…
  • )
  • [X.509 PKI and CRLs] 链接 https://tools.ietf.org/html/r…
  • [Layman’s Guide to ASN.1] 链接 http://luca.ntop.org/Teaching…

理论部署调优相干

  • https://bit.ly/gottls
  • https://istlsfastyet.com/
  • https://www.imperialviolet.org/
  • https://letsencrypt.org/
  • http://chimera.labs.oreilly.c…
  • [RSA Conference 2015 : New Trends In Cryptographic Algorithm Suites Used For TLS Communications] 链接 http://www.rsaconference.com/…

密码学相干

  • [Stanford Cryptography open course] 链接 https://www.coursera.org/cour…
  • [crypto101,一本很棒的开源电子书] 链接 http://crypto101.io
  • [古代密码学实践与实际] 链接 https://book.douban.com/subje… – 毛文波
  • [古代密码学: 原理与协定] 链接 http://book.douban.com/subjec… – Katz and Lindell
  • [“Modern Crypto: 15 Years of Advancement in Cryptography”— 2015 defcon 大会 Steve Weis 演讲] 链接 http://saweis.net/pdfs/weis-m…
  • 强烈建议不要看 90 年代的书,广泛重大过期,比方《利用密码学:协定、算法与 C 源程序(原书第 2 版)》
  • [DJBs crypto page] 链接 http://cr.yp.to/crypto.html
  • [DJBs entropy attacks] 链接 http://blog.cr.yp.to/20140205…
  • [Cryptographic Right Answers] 链接 https://gist.github.com/tqbf/…
  • http://www.slideshare.net/yas…
  • [Schneier 对于密码学 2010 年现状的评述] 链接 <https://www.schneier.com/blog…
  • http://security.stackexchange…
  • http://chargen.matasano.com/c…
  • http://kodu.ut.ee/~swen/publi…
  • https://www.enisa.europa.eu/a…
  • https://github.com/sweis/cryp…
  • [Cryptographic Best Practices in the Post-Snowden Era] 链接 http://pages.uoregon.edu/joe/…
  • [Crypto War] 链接 http://en.wikipedia.org/wiki/…
  • [52 Things People Should Know To Do Cryptography] 链接 http://www.cs.bris.ac.uk/Rese…
  • http://bristolcrypto.blogspot…
  • https://www.schneier.com/
  • https://www.imperialviolet.or…
  • https://crypto.stanford.edu/~…
  • http://saweis.net/pdfs/weis-m…

相干开源我的项目

  • [GoTLS] 链接 http://golang.org/pkg/crypto/… – go 语言本人搞的 TLS 协定实现
  • [OpenSSL] 链接 https://www.openssl.org/ – 事实上的规范
  • [LibreSSL] 链接 http://www.libressl.org/ – OpenBSD 搞的 OpenSSL 的分支,代码可读性大大提高
  • [BoringSSL] 链接 https://boringssl.googlesourc… – Google Security team 保护的 OpenSSL 分支
  • [NSS] 链接 https://developer.mozilla.org… – Mozilla 保护的 TLS 协定实现
  • [s2n] 链接 https://github.com/awslabs/s2n/ – Amazon 搞的 tls 协定实现
  • [MiTLS] 链接 http://www.mitls.org/wsgi/home , [TLS Attacks] 链接 http://www.mitls.org/wsgi/tls…
  • [NaCL] 链接 http://nacl.cr.yp.to/ and [libsodium] 链接 https://github.com/jedisct1/l…
  • [spiped] 链接 http://www.tarsnap.com/spiped…

本文转自微信后盾团队, 如有进犯, 请分割咱们立刻删除

OpenIMgithub 开源地址:

https://github.com/OpenIMSDK/…

OpenIM 官网: https://www.rentsoft.cn

OpenIM 官方论坛: https://forum.rentsoft.cn/

更多技术文章:

开源 OpenIM:高性能、可伸缩、易扩大的即时通讯架构
https://forum.rentsoft.cn/thr…

【OpenIM 原创】简略轻松入门 一文解说 WebRTC 实现 1 对 1 音视频通信原理
https://forum.rentsoft.cn/thr…

【OpenIM 原创】开源 OpenIM:轻量、高效、实时、牢靠、低成本的音讯模型
https://forum.rentsoft.cn/thr…

正文完
 0