doubleratchet: github.com/katzenpost/doubleratchet Index | Files

package ratchet

import "github.com/katzenpost/doubleratchet"

Package ratchet implements the axolotl ratchet, by Trevor Perrin. See https://github.com/trevp/axolotl/wiki.

Index

Package Files

constants.go ratchet.go

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
)

type KeyExchange Uses

type KeyExchange struct {
    PublicKey      []byte
    IdentityPublic []byte
    Dh             []byte
    Dh1            []byte
}

KeyExchange is structure containing the public keys

type MessageKey Uses

type MessageKey struct {
    Num          uint32
    Key          []byte
    CreationTime int64
}

MessageKey is structure containing the data associated with the message key

type Ratchet Uses

type Ratchet struct {
    TheirSigningPublic  [32]byte
    TheirIdentityPublic [32]byte
    MySigningPublic     [32]byte
    MySigningPrivate    [64]byte
    MyIdentityPrivate   [32]byte
    MyIdentityPublic    [32]byte

    // 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 NewRatchet Uses

func NewRatchet(rand io.Reader) (*Ratchet, error)

NewRatchet creates a new ratchet struct TODO: why does this use ed and montgomery forms?

func (*Ratchet) CompleteKeyExchange Uses

func (r *Ratchet) CompleteKeyExchange(kx *KeyExchange) error

CompleteKeyExchange takes a KeyExchange message from the other party and establishes the ratchet.

func (*Ratchet) CreateKeyExchange Uses

func (r *Ratchet) CreateKeyExchange() (*SignedKeyExchange, error)

CreateKeyExchange created and add the appropiate fields for the KeyExchange

func (*Ratchet) Decrypt Uses

func (r *Ratchet) Decrypt(ciphertext []byte) ([]byte, error)

Decrypt decrypts a message

func (*Ratchet) Encrypt Uses

func (r *Ratchet) Encrypt(out, msg []byte) []byte

Encrypt acts like append() but appends an encrypted version of msg to out.

func (*Ratchet) FillKeyExchange Uses

func (r *Ratchet) FillKeyExchange(kx *KeyExchange) error

FillKeyExchange sets elements of kx with key exchange information from the ratchet.

func (*Ratchet) Marshal Uses

func (r *Ratchet) Marshal(now time.Time, lifetime time.Duration) *State

Marshal transforms the object into a stream

func (*Ratchet) MarshalBinary Uses

func (r *Ratchet) MarshalBinary() (data []byte, err error)

MarshalBinary transforms the object into a stream

func (*Ratchet) ProcessKeyExchange Uses

func (r *Ratchet) ProcessKeyExchange(signedKeyExchange *SignedKeyExchange) error

ProcessKeyExchange processes the data of a KeyExchange

func (*Ratchet) Unmarshal Uses

func (r *Ratchet) Unmarshal(s *State) error

Unmarshal transforms the stream into the object

func (*Ratchet) UnmarshalBinary Uses

func (r *Ratchet) UnmarshalBinary(data []byte) error

UnmarshalBinary transforms the stream into the object

type SavedKeys Uses

type SavedKeys struct {
    HeaderKey   []byte
    MessageKeys []*MessageKey
}

SavedKeys is structure containing the saved keys from delayed messages

type SignedKeyExchange Uses

type SignedKeyExchange struct {
    Signed    []byte
    Signature []byte
}

SignedKeyExchange is structure containing the signature data

type State Uses

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 13 packages (graph) and is imported by 2 packages. Updated 2020-04-01. Refresh now. Tools for package owners.