doubleratchet: Index | Files

package ratchet

import ""

Package ratchet implements the axolotl ratchet, by Trevor Perrin. See


Package Files

constants.go ratchet.go


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

type MessageKey Uses

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

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 contains the per-contact, crypto state.

func New Uses

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

New creates a new ratchet struct

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)

func (*Ratchet) Decrypt Uses

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

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) *RatchetState

func (*Ratchet) MarshalBinary Uses

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

func (*Ratchet) ProcessKeyExchange Uses

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

func (*Ratchet) Unmarshal Uses

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

func (*Ratchet) UnmarshalBinary Uses

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

type RatchetState Uses

type RatchetState 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

type SavedKeys Uses

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

type SignedKeyExchange Uses

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

Package ratchet imports 13 packages (graph) and is imported by 3 packages. Updated 2020-01-30. Refresh now. Tools for package owners.