Documentation ¶
Overview ¶
Package ratchet implements the axolotl ratchet, by Trevor Perrin. See https://github.com/trevp/axolotl/wiki.
Index ¶
- Constants
- func DestroyRatchet(r *Ratchet)
- type KeyExchange
- type MessageKey
- type Ratchet
- func (r *Ratchet) CompleteKeyExchange(kx *KeyExchange) error
- func (r *Ratchet) CreateKeyExchange() (*SignedKeyExchange, error)
- func (r *Ratchet) Decrypt(ciphertext []byte) ([]byte, error)
- func (r *Ratchet) Encrypt(out, msg []byte) []byte
- func (r *Ratchet) FillKeyExchange(kx *KeyExchange) error
- func (r *Ratchet) Marshal(now time.Time, lifetime time.Duration) *State
- func (r *Ratchet) MarshalBinary() (data []byte, err error)
- func (r *Ratchet) ProcessKeyExchange(signedKeyExchange *SignedKeyExchange) error
- func (r *Ratchet) Unmarshal(s *State) error
- func (r *Ratchet) UnmarshalBinary(data []byte) error
- type SavedKeys
- type SignedKeyExchange
- type State
Constants ¶
const ( // 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 )
Variables ¶
This section is empty.
Functions ¶
func DestroyRatchet ¶ added in v0.0.1
func DestroyRatchet(r *Ratchet)
DestroyRatchet destroys the ratchet
Types ¶
type KeyExchange ¶
KeyExchange is structure containing the public keys
type MessageKey ¶
MessageKey is structure containing the data associated with the message key
type Ratchet ¶
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.
func InitRatchet ¶ added in v0.0.1
InitRatchet initializes a ratchet struct
func (*Ratchet) CompleteKeyExchange ¶
func (r *Ratchet) CompleteKeyExchange(kx *KeyExchange) error
CompleteKeyExchange takes a KeyExchange message from the other party and establishes the ratchet.
func (*Ratchet) CreateKeyExchange ¶
func (r *Ratchet) CreateKeyExchange() (*SignedKeyExchange, error)
CreateKeyExchange created and add the appropiate fields for the KeyExchange
func (*Ratchet) Encrypt ¶
Encrypt acts like append() but appends an encrypted version of msg to out.
func (*Ratchet) FillKeyExchange ¶
func (r *Ratchet) FillKeyExchange(kx *KeyExchange) error
FillKeyExchange sets elements of kx with key exchange information from the ratchet.
func (*Ratchet) MarshalBinary ¶
MarshalBinary transforms the object into a stream
func (*Ratchet) ProcessKeyExchange ¶
func (r *Ratchet) ProcessKeyExchange(signedKeyExchange *SignedKeyExchange) error
ProcessKeyExchange processes the data of a KeyExchange
func (*Ratchet) UnmarshalBinary ¶
UnmarshalBinary transforms the stream into the object
type SavedKeys ¶
type SavedKeys struct { HeaderKey []byte MessageKeys []*MessageKey }
SavedKeys is structure containing the saved keys from delayed messages
type SignedKeyExchange ¶
SignedKeyExchange is structure containing the signature data
type State ¶ added in v0.0.1
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