译者注:这篇翻译缘起 Telegram 的相关群组讨论到 CryptoCat这个加密通讯工具。虽然它好像不怎么名声远扬(github仓库上 star 不多),但笔者发现它的开发者「诚恳诚实」地在做这款软件,也有一些创新之处(请看稍后的测评)。他们的这篇软件加密介绍便值得一学。

Source: https://crypto.cat/security.html

Encryption Overview

加密技术总览

Cryptocat uses a Double Ratchet-based encryption protocol that combines a forward-secure ratchet with a zero round-trip authenticated key exchange. As a transport layer for encrypted messages, Cryptocat adopts the OMEMO Multi-End Message and Object Encryption standard, which also gives Cryptocat multi-device support and allows for offline messaging. In terms of the transport layer, Cryptocat uses XMPP over a long-standing, TLS-encrypted WebSockets connection. Cryptocat 使用了「双棘轮」为本的加密协议,该协议结合了一个向前安全的“棘轮,及一个零巡回验证的密钥交换过程。在承载加密信息的传输层上,Cryptocat 采用了 OMEMO 多端信息和对象加密标准,能提供多设备支持并允许离线消息。至于这传输层,Cryptocat使用通过一个长期性的TLS加密的 WebSockets连接的 XMPP(协议)。

Every Cryptocat device owns a long-term identityKey pair which helps with the establishment of the initial authenticated key exchange. This key pair also serves to sign the device’s signedPreKey, an ephemeral public key that also is mixed into the authenticated key exchange. The signedPreKey is also shipped with 100, unsigned, one-time-use preKeys, and is regenerated and re-signed every week.

Suppose Alice wanted to start a new session with Bob. Alice would then fetch Bob’s current signedPreKey and his list of 100 preKeys from the Cryptocat network. Alice would then select a random preKey from the list. Alice then generates her own initKey pair, which is a keypair used only for the purposes of initializing a new session. Alice then performs the following computation in order to obtain the initial session secret S:

S = SHA256(
	X25519(AliceIdentityKey, BobSignedPreKey) ||
	X25519(AliceInitKey, BobIdentityKey)      ||
	X25519(AliceInitKey, BobSignedPreKey)     ||
	X25519(AliceInitKey, BobPreKey)
)
(
	AliceReceivingRootKey,
	AliceReceivingChainKey
) = HKDF(S, Constant1, Constant2)

Between messages, Cryptocat maintains a forward-secure ratcheting chain that creates a new ephemeral key pair for each message, and derives their chain of authenticity by mixing in a chain going back to S via a Hash-Based Key Derivation Function (HKDF). Here is an example occuring later in the conversation, after Bob had also derived a BobMessageEphemeralKey and other session state elements:

AliceMessageEphemeralKey = X25519_NewKeyPair()
AliceSharedKey = X25519(
	AliceMessageEphemeralKey,
	BobMessageEphemeralKey
)
(
	AliceSendingRootKey,
	AliceSendingChainKey
) = HKDF(S, AliceReceivingRootKey, Constant2)
AliceMessageEncryptionKey = HKDF(
	HMAC(AliceSendingChainKey, Constant3),
	Constant1,
	Constant4
)
(
	AliceEncryptedMessage,
	AliceEncryptedMessageTag
) = AESGCM256(
	Key:AliceMessageEncryptionKey,
	Plaintext:AliceMessagePlaintext,
	AddedData:(
		AliceMessageEphemeralKeyPublic ||
		BobMessageEphemeralKeyPublic   ||
		AliceIdentityKeyPublic         ||
		BobIdentityKeyPublic
	)
)

Alice then sends (AliceMessageEphemeralKeyPublic, AliceEncryptedMessage, AliceEncryptedMessageTag). Constant1, Constant2 and Constant3 are some publicly known constant strings coded into the protocol implementation.

Primitives

术语

Threat Model

威胁模式

Cryptocat makes the following assumptions: 我们有以下的(风险)预设:

Security Goals

安全目标

Given our threat model, Cryptocat aims to accomplish the following security goals: 就以上的威胁模式,我们旨在达到以下安全目标:

Authentication Overview

(身份)验证技术总览

Cryptocat offers users the ability to verify the authenticity of their buddies’ devices. In that way, they can ensure that a malicious party (including, potentially, the Cryptocat network itself) is not masquerading as the device of another individual. Device fingeprints are calculated thus: 我们可以让用户有能力验证他们的好友的设备的真实性(即该设备是不是该好友的)。这样,他们可以确保捣乱者(包括,可能的话,Cryptocat网络自己)没有拿别人的设备做伪装。设备指纹是这样计算的:

DeviceFingerprint = SHA256(
	deviceId                ||
	SHA256(
		username   ||
		deviceName ||
		deviceIcon
	)                       ||
	deviceIdentityKeyPublic
).HexString().First32Characters()

In the above example, deviceId is a random 32-byte device identifier that is generated upon device registration and that never changes. deviceName is a name that the user assigns to the device that also cannot be later modified. deviceIcon is one of three icons (0, representing a laptop, 1, representing an all-in-one desktop and 2, representing a PC) and also cannot be modified.

File Sharing

Cryptocat software provides users with the ability to share documents, video recordings, photos and other such media. These are all threated (似乎是笔误,应该是treated)as the same type of plaintext (a “file”) and are all handled as follows: 我们让用户可以传文档、影音记录、照片等。他们都被视作同类型的纯文本(作为一个“文件”),都按以下方式处理:

Note that fileUrl cannot be just any HTTP URI but is specially restricted for the purposes of Cryptocat file sharing. 需要留意的是 fileUrl 并不只是任何一种 HTTP URI,而是为文件分享的目的的特别严格的格式。

Miscellaneous Security Features

其他安全特性

Aside of the message encryption protocol, Cryptocat adopts the following security features in order to provide a generally more robust experience across the client:

报告安全问题

(略)



Copyleft

Initially translated by @mdrights

Released under CC-BY-SA 4.0

Posted on January 31, 2017