Public-key (aka Asymmetric) cryptography

下图显示非对称加密过程是单向的,其中一条密钥加密后只能用相对应的另一条密钥解密

Untitled

它需要两个密钥,一个是公开密钥,另一个是私有密钥;公钥用作加密,私钥则用作解密。使用公钥把明文加密后所得的密文,只能用相对应的私钥才能解密并得到原本的明文,最初用来加密的公钥不能用作解密。由于加密和解密需要两个不同的密钥,故被称为非对称加密;不同于加密和解密都使用同一个密钥的对称加密。公钥可以公开,可任意向外发布;私钥不可以公开,必须由用户自行严格秘密保管,绝不透过任何途径向任何人提供,也不会透露给被信任的要通信的另一方。

Untitled

在现实世界上可作比拟的例子是,一个传统保管箱,开门和关门都是使用同一条钥匙,这是对称加密;而一个公开的邮箱,投递口是任何人都可以寄信进去的,这可视为公钥;而只有信箱主人拥有钥匙可以打开信箱,这就视为私钥。

Diffie-Hellman key exchange

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/9473190c-277b-46b0-840d-4ea9a47ec553/Untitled.png

In the Diffie–Hellman key exchange scheme, each party generates a public/private key pair and distributes the public key. After obtaining an authentic copy of each other's public keys, Alice and Bob can compute a shared secret offline. The shared secret can be used, for instance, as the key for a symmetric cipher.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/d6a6cf02-aefe-4687-8c7c-90ebbb64825e/Untitled.png