import "github.com/katzenpost/doubleratchet"
Package ratchet implements the axolotl ratchet, by Trevor Perrin. See https://github.com/trevp/axolotl/wiki.
constants.go helpers.go ratchet.go
const ( // MaxMissingMessages is the maximum number of missing messages that // we'll keep track of. MaxMissingMessages = 8 // RatchetKeyMaxLifetime is the maximum lifetime of the ratchet RatchetKeyMaxLifetime = time.Hour * 672 // DoubleRatchetOverhead is the number of bytes the ratchet adds in ciphertext overhead. DoubleRatchetOverhead = 120 )
var ( ErrDuplicateOrDelayed = errors.New("Ratchet: duplicate message or message delayed longer than tolerance") ErrHandshakeAlreadyComplete = errors.New("Ratchet: handshake already complete") ErrCannotDecrypt = errors.New("Ratchet: cannot decrypt") ErrIncorrectHeaderSize = errors.New("Ratchet: incorrect header size") ErrSerialisedKeyLength = errors.New("Ratchet: bad serialised key length") ErrNextEncryptedMessageWithoutRatchetFlag = errors.New("Ratchet: received message encrypted to next header key without ratchet flag set") ErrOldFormKeyExchange = errors.New("Ratchet: peer using old-form key exchange") ErrCorruptMessage = errors.New("Ratchet: corrupt message") ErrMessageExceedsReorderingLimit = errors.New("Ratchet: message exceeds reordering limit") ErrEchoedDHValues = errors.New("Ratchet: peer echoed our own DH values back") ErrInvalidSignatureLength = errors.New("Ratchet: invalid signature length") ErrRatchetHeaderTooSmall = errors.New("Ratchet: header too small to be valid") ErrInvalidKeyExchange = errors.New("Ratchet: peer's key exchange is invalid") ErrFailedToInitializeRatchet = errors.New("Ratchet: failed to initialize") ErrInvalidPubkey = errors.New("Ratchet: invalid public key") ErrInvalidPublicIdentityKey = errors.New("Ratchet: invalid public identity key") ErrInvalidSignature = errors.New("Ratchet: invalid signature") ErrKeyExchangeKeysNotIsomorphicallyEqual = errors.New("Ratchet: key exchange and identity public keys must be isomorphically equal") )
DestroyRatchet destroys the ratchet
KeyExchange is structure containing the public keys
MessageKey is structure containing the data associated with the message key
type Ratchet struct { TheirSigningPublic *memguard.LockedBuffer // 32 bytes long TheirIdentityPublic *memguard.LockedBuffer // 32 bytes long MySigningPublic *memguard.LockedBuffer // 32 bytes long MySigningPrivate *memguard.LockedBuffer // 64 bytes long MyIdentityPrivate *memguard.LockedBuffer // 32 bytes long MyIdentityPublic *memguard.LockedBuffer // 32 bytes long // Now is an optional function that will be used to get the current // time. If nil, time.Now is used. Now func() time.Time // contains filtered or unexported fields }
Ratchet stucture contains the per-contact, crypto state.
InitRatchet initializes a ratchet struct
func (r *Ratchet) CompleteKeyExchange(kx *KeyExchange) error
CompleteKeyExchange takes a KeyExchange message from the other party and establishes the ratchet.
func (r *Ratchet) CreateKeyExchange() (*SignedKeyExchange, error)
CreateKeyExchange created and add the appropiate fields for the KeyExchange
Decrypt decrypts a message
Encrypt acts like append() but appends an encrypted version of msg to out.
func (r *Ratchet) FillKeyExchange(kx *KeyExchange) error
FillKeyExchange sets elements of kx with key exchange information from the ratchet.
Marshal transforms the object into a stream
MarshalBinary transforms the object into a stream
func (r *Ratchet) ProcessKeyExchange(signedKeyExchange *SignedKeyExchange) error
ProcessKeyExchange processes the data of a KeyExchange
Unmarshal transforms the stream into the object
UnmarshalBinary transforms the stream into the object
type SavedKeys struct { HeaderKey []byte MessageKeys []*MessageKey }
SavedKeys is structure containing the saved keys from delayed messages
MarshalBinary implements encoding.BinaryUnmarshaler interface
UnmarshalBinary instantiates memguard.LockedBuffer instances for each deserialized key
SignedKeyExchange is structure containing the signature data
type State struct { TheirSigningPublic []byte TheirIdentityPublic []byte MySigningPublic []byte MySigningPrivate []byte MyIdentityPrivate []byte MyIdentityPublic []byte SavedKeys []*SavedKeys RootKey []byte SendHeaderKey []byte RecvHeaderKey []byte NextSendHeaderKey []byte NextRecvHeaderKey []byte SendChainKey []byte RecvChainKey []byte SendRatchetPrivate []byte RecvRatchetPublic []byte SendCount uint32 RecvCount uint32 PrevSendCount uint32 Private0 []byte Private1 []byte Ratchet bool }
State constains all the data associated with a ratchet
Package ratchet imports 14 packages (graph) and is imported by 2 packages. Updated 2020-11-22. Refresh now. Tools for package owners.