channels

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2019 License: AGPL-3.0 Imports: 12 Imported by: 1

README

.. image:: https://travis-ci.org/katzenpost/channels.svg?branch=master
  :target: https://travis-ci.org/katzenpost/channels

.. image:: https://godoc.org/github.com/katzenpost/channels?status.svg
  :target: https://godoc.org/github.com/katzenpost/channels

Channels Library
================

Katzenpost Mix Network Cryptographic communication channels library.
This library is meant to be used with our Katzenpost client library: https://github.com/katzenpost/client
and a Katzenpost mix network that has at least one memspool instance running: https://github.com/katzenpost/memspool

This library contains three channels:

* unreliable remote spool channel
* unreliable Noise X
* unreliable Double Ratchet

The Noise X and Double Ratchet channels both make use of the remote spool channel. That is to say,
we want to communicate with remote spools over our mix network. If we didn't use
spools then the other party would be required to be online at the same time as our client. The above
three channel types have differing use cases. Noise X is useful because it's nonce ensures each ciphertext
it produces is different even if message input was the same as a previous operation. We can use this
feature of the Noise X channel to ensure that we don't leak retransmissions from applications that
may retransmit an identical payload. Egress Providers on a Katzenpost mix network get to see the payload.
This is one reason why end to end encryption must always be used. The remote spool channel is intended
to be used by applications that already implement their own end to end encryption.


TODO
----

* publish-subscribe channels where clients can send the remote service
  some SURBs and then await replies from the remote subscription spool feed.
* optional reliable channels using a custome ARQ protocol scheme


license
=======

AGPL: see LICENSE file for details.

Documentation

Overview

Package channels provides a collection of channels for communicating over the Katzenpost mix network.

Index

Constants

View Source
const (
	// NoiseOverhead is amount of bytes overhead from the noise encryption.
	NoiseOverhead = keyLength + macLength + keyLength + macLength // e, es, s, ss

	// NoisePayloadLength is the length of the noise payload.
	NoisePayloadLength = SpoolPayloadLength - NoiseOverhead
)
View Source
const (
	// SpoolChannelOverhead is the number of bytes overhead from the spool CBOR encoding.
	SpoolChannelOverhead = common.QueryOverhead

	// SpoolPayloadLength is the length of the spool payload.
	SpoolPayloadLength = (constants.UserForwardPayloadLength - 4) - SpoolChannelOverhead
)
View Source
const (
	// DoubleRatchetPayloadLength is the length of the payload encrypted by the ratchet.
	DoubleRatchetPayloadLength = SpoolPayloadLength - ratchet.DoubleRatchetOverhead
)

Variables

This section is empty.

Functions

This section is empty.

Types

type NoiseWriterDescriptor

type NoiseWriterDescriptor struct {
	SpoolWriterChan      *UnreliableSpoolWriterChannel
	RemoteNoisePublicKey *ecdh.PublicKey
}

NoiseWriterDescriptor contains the information necessary to write to a remote spool.

type SerializedUnreliableSpoolChannel

type SerializedUnreliableSpoolChannel struct {
	WriterChan *UnreliableSpoolWriterChannel
	ReaderChan *UnreliableSpoolReaderChannel
}

SerializedUnreliableSpoolChannel is a type used to serialize/save the UnreliableSpoolChannel type.

type UnreliableDoubleRatchetChannel

type UnreliableDoubleRatchetChannel struct {
	SpoolCh *UnreliableSpoolChannel
	Ratchet *ratchet.Ratchet
}

UnreliableDoubleRatchetChannel is an unreliable channel which encrypts using the double ratchet.

func LoadUnreliableDoubleRatchetChannel

func LoadUnreliableDoubleRatchetChannel(data []byte, spoolService client.SpoolService) (*UnreliableDoubleRatchetChannel, error)

LoadUnreliableDoubleRatchetChannel loads the channel given the saved blob and a SpoolService interface.

func NewUnreliableDoubleRatchetChannel

func NewUnreliableDoubleRatchetChannel(spoolCh *UnreliableSpoolChannel) (*UnreliableDoubleRatchetChannel, error)

NewUnreliableDoubleRatchetChannel creates a new UnreliableDoubleRatchetChannel.

func (*UnreliableDoubleRatchetChannel) ChannelExchange

func (r *UnreliableDoubleRatchetChannel) ChannelExchange() ([]byte, error)

ChannelExchange returns a serialized UnreliableDoubleRatchetChannelExchange which is needed to connect channel endpoints.

func (*UnreliableDoubleRatchetChannel) KeyExchange

KeyExchange returns a signed key exchange or an error.

func (*UnreliableDoubleRatchetChannel) ProcessChannelExchange

func (r *UnreliableDoubleRatchetChannel) ProcessChannelExchange(cborExchange []byte) error

ProcessChannelExchange consumes a serialized UnreliableDoubleRatchetChannelExchange and uses it to connection spool channels and ratchet channels so that our UnreliableDoubleRatchetChannel is fully connected.

func (*UnreliableDoubleRatchetChannel) ProcessKeyExchange

ProcessKeyExchange processes the given signed key exchange.

func (*UnreliableDoubleRatchetChannel) Read

func (r *UnreliableDoubleRatchetChannel) Read() ([]byte, error)

Read reads ciphertext from a remote spool and decypts it with the double ratchet.

func (*UnreliableDoubleRatchetChannel) Save

func (r *UnreliableDoubleRatchetChannel) Save() ([]byte, error)

Save returns the serialization of this channel suitable to be used to "load" this channel and make use of it in the future.

func (*UnreliableDoubleRatchetChannel) Write

func (r *UnreliableDoubleRatchetChannel) Write(message []byte) error

Write writes a message, encrypting it with the double ratchet and sending the ciphertext to the remote spool.

type UnreliableDoubleRatchetChannelExchange

type UnreliableDoubleRatchetChannelExchange struct {
	SpoolWriter       *UnreliableSpoolWriterChannel
	SignedKeyExchange *ratchet.SignedKeyExchange
}

UnreliableDoubleRatchetChannelExchange is exchanged between endpoints to establish a bidirectional channel, the UnreliableDoubleRatchetChannel.

type UnreliableNoiseChannel

type UnreliableNoiseChannel struct {
	SpoolWriterChan      *UnreliableSpoolWriterChannel
	RemoteNoisePublicKey *ecdh.PublicKey

	SpoolReaderChan *UnreliableSpoolReaderChannel
	NoisePrivateKey *ecdh.PrivateKey
	ReadOffset      uint32
	// contains filtered or unexported fields
}

UnreliableNoiseChannel is an unreliable channel which encrypts using the Noise X one-way pattern.

func LoadUnreliableNoiseChannel

func LoadUnreliableNoiseChannel(data []byte, spoolService client.SpoolService) (*UnreliableNoiseChannel, error)

LoadUnreliableNoiseChannel loads a serialized channel and sets it's spoolService so that it may be used.

func NewUnreliableNoiseChannel

func NewUnreliableNoiseChannel(spoolReceiver, spoolProvider string, spool client.SpoolService) (*UnreliableNoiseChannel, error)

NewUnreliableNoiseChannel creates and returns a new UnreliableNoiseChannel or an error.

func (*UnreliableNoiseChannel) GetRemoteWriter

func (n *UnreliableNoiseChannel) GetRemoteWriter() *NoiseWriterDescriptor

GetRemoteWriter returns a NoiseWriterDescriptor which describes how a writer can write to the spool we are reading.

func (*UnreliableNoiseChannel) Read

func (n *UnreliableNoiseChannel) Read() ([]byte, error)

Read reads from a remote spool and decrypts.

func (*UnreliableNoiseChannel) Save

func (n *UnreliableNoiseChannel) Save() ([]byte, error)

Save returns a serialized form of this channel suitable to be reloaded for later use.

func (*UnreliableNoiseChannel) SetSpoolService

func (n *UnreliableNoiseChannel) SetSpoolService(spoolService client.SpoolService)

SetSpoolService sets this channel's spoolService field.

func (*UnreliableNoiseChannel) WithRemoteWriter

func (n *UnreliableNoiseChannel) WithRemoteWriter(writerDesc *NoiseWriterDescriptor)

WithRemoteWriter allows this channel to write to a remote spool.

func (*UnreliableNoiseChannel) Write

func (n *UnreliableNoiseChannel) Write(message []byte) error

Write encrypts and write to a remote spool.

type UnreliableSpoolChannel

type UnreliableSpoolChannel struct {
	// contains filtered or unexported fields
}

UnreliableSpoolChannel is an unreliable channel which reads and writes to a remote spool.

func LoadUnreliableSpoolChannel

func LoadUnreliableSpoolChannel(data []byte, spoolService client.SpoolService) (*UnreliableSpoolChannel, error)

LoadUnreliableSpoolChannel loads an UnreliableSpoolChannel from it's serialized form.

func NewUnreliableSpoolChannel

func NewUnreliableSpoolChannel(spoolReceiver, spoolProvider string, spool client.SpoolService) (*UnreliableSpoolChannel, error)

NewUnreliableSpoolChannel creates and returns a new UnreliableSpoolChannel.

func (*UnreliableSpoolChannel) GetSpoolWriter

GetSpoolWriter returns a UnreliableSpoolWriterChannel which writes to the spool that this UnreliableSpoolChannel is reading from.

func (*UnreliableSpoolChannel) MarshalBinary

func (s *UnreliableSpoolChannel) MarshalBinary() ([]byte, error)

MarshalBinary serializes this channel.

func (*UnreliableSpoolChannel) Read

func (s *UnreliableSpoolChannel) Read() ([]byte, error)

Read reads and returns a message from the remote spool.

func (*UnreliableSpoolChannel) Save

func (s *UnreliableSpoolChannel) Save() ([]byte, error)

Save serializes this channel.

func (*UnreliableSpoolChannel) SetSpoolService

func (s *UnreliableSpoolChannel) SetSpoolService(spoolService client.SpoolService)

SetSpoolService sets this channels spoolService.

func (*UnreliableSpoolChannel) UnmarshalBinary

func (s *UnreliableSpoolChannel) UnmarshalBinary(data []byte) error

UnmarshalBinary deserializes this channel.

func (*UnreliableSpoolChannel) WithRemoteWriter

func (s *UnreliableSpoolChannel) WithRemoteWriter(writer *UnreliableSpoolWriterChannel) error

WithRemoteWriter sets this channels writer to the given UnreliableSpoolWriterChannel.

func (*UnreliableSpoolChannel) Write

func (s *UnreliableSpoolChannel) Write(message []byte) error

Write writes a message to the remote spool.

type UnreliableSpoolReaderChannel

type UnreliableSpoolReaderChannel struct {
	SpoolPrivateKey *eddsa.PrivateKey
	SpoolID         []byte
	SpoolReceiver   string
	SpoolProvider   string
	ReadOffset      uint32
}

UnreliableSpoolReaderChannel is an unreliable channel which reads from a remote spool.

func NewUnreliableSpoolReaderChannel

func NewUnreliableSpoolReaderChannel(spoolReceiver, spoolProvider string, spool client.SpoolService) (*UnreliableSpoolReaderChannel, error)

NewUnreliableSpoolReaderChannel creates and returns a new UnreliableSpoolReaderChannel or an error.

func (*UnreliableSpoolReaderChannel) GetSpoolWriter

GetSpoolWriter returns an UnreliableSpoolWriterChannel which writes to the spool that this spool reader channel is reading.

func (*UnreliableSpoolReaderChannel) Read

Read reads and returns a message from a remote spool.

type UnreliableSpoolWriterChannel

type UnreliableSpoolWriterChannel struct {
	SpoolID       []byte
	SpoolReceiver string
	SpoolProvider string
}

UnreliableSpoolWriterChannel is an unreliable channel which writes to a remote spool.

func (*UnreliableSpoolWriterChannel) Write

func (w *UnreliableSpoolWriterChannel) Write(spool client.SpoolService, message []byte) error

Write writes the given message to a remote spool.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL