2017-08-30

•秘钥生成算法HDhttps://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=15&ved=0ahUKEwj-hKjT8_3VAhUFqo8KHfBYDT0QFgiSATAO&url=https%3A%2F%2Fread01.com%2Fy2nAOd.html&usg=AFQjCNGk4pjRYbuo67m1sMyBtYP2VOLdkA  

Identity Key Pair – A long-term Curve25519 key pair,

在应用安装的时候生成

• Signed Pre Key – A medium-term Curve25519 key pair,

在应用安装的时候生成,用IDK签名。generated at install time, signed by the Identity Key, and rotated

on a periodic timed basis.

• One-Time Pre Keys – A queue of Curve25519 key pairs

预先生成的只能使用一次的key。 WhatsAp是每次上传100个otpk到服务器。

session key types

ROOT KEY  根密钥

chain key 发送链密钥

message key


客户端注册: 上传IK, SPK,和一批otpk到服务器

session初始化:

1.sender 请求对方的IK, SPK,和一个otpk

2.服务器返回对应的key,由于otpk只能使用一次,所以当前使返回的otpk 会被删除

3.sender 保存从服务器拿到的key ,The initiator saves the recipient’s Identity Key as Irecipient, the

Signed Pre Key as Srecipient, and the One-Time Pre Key as Orecipient. 

4.发起方生成一个ephemeral Curve25519 key pair, Einitiato

5.发起方 加载自己的IK 为Iinitiator

6.master_secret =

ECDH(Iinitiator, Srecipient) || ECDH(Einitiator, Irecipient) ||

ECDH(Einitiator, Srecipient) || ECDH(Einitiator, Orecipient). 

The initiator uses HKDF to create a Root Key and Chain Keys

from the master_secret.

至此初始化方就可以直接发送消息到接收方

接收方的session创建

你可能感兴趣的:(2017-08-30)