cipherset

package
v0.0.0-...-c0ffc74 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2015 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownCSID    = errors.New("cipherset: unknown CSID")
	ErrInvalidKey     = errors.New("cipherset: invalid key")
	ErrInvalidState   = errors.New("cipherset: invalid state")
	ErrInvalidMessage = errors.New("cipherset: invalid message")
	ErrInvalidPacket  = errors.New("cipherset: invalid packet")
)
View Source
var ErrInvalidKeys = errors.New("chipherset: invalid keys")
View Source
var ErrInvalidParts = errors.New("chipherset: invalid parts")

Functions

func DecryptMessage

func DecryptMessage(csid uint8, localKey, remoteKey Key, p []byte) ([]byte, error)

func Register

func Register(csid uint8, c Cipher)

func SelectCSID

func SelectCSID(a, b Keys) uint8

Types

type Cipher

type Cipher interface {
	CSID() uint8

	DecodeKeyBytes(pub, prv []byte) (Key, error)
	GenerateKey() (Key, error)

	DecryptMessage(localKey, remoteKey Key, p []byte) ([]byte, error)
	DecryptHandshake(localKey Key, p []byte) (Handshake, error)

	NewState(localKey Key) (State, error)
}

type Handshake

type Handshake interface {
	CSID() uint8

	At() uint32
	PublicKey() Key // The sender public key
	Parts() Parts   // The sender parts
}

func DecryptHandshake

func DecryptHandshake(csid uint8, localKey Key, p []byte) (Handshake, error)

type Key

type Key interface {
	CSID() uint8

	String() string
	Public() []byte
	Private() []byte
	CanSign() bool
	CanEncrypt() bool
}

func DecodeKey

func DecodeKey(csid uint8, pub, prv string) (Key, error)

func DecodeKeyBytes

func DecodeKeyBytes(csid uint8, pub, prv []byte) (Key, error)

func GenerateKey

func GenerateKey(csid uint8) (Key, error)

type Keys

type Keys map[uint8]Key

func GenerateKeys

func GenerateKeys(csids ...uint8) (Keys, error)

func KeysFromJSON

func KeysFromJSON(i interface{}) (Keys, error)

func (Keys) ApplyToHeader

func (k Keys) ApplyToHeader(h *lob.Header)

func (Keys) MarshalJSON

func (k Keys) MarshalJSON() ([]byte, error)

func (*Keys) UnmarshalJSON

func (k *Keys) UnmarshalJSON(data []byte) error

type Parts

type Parts map[uint8]string

func PartsFromHeader

func PartsFromHeader(h *lob.Header) (Parts, error)

func (Parts) ApplyToHeader

func (p Parts) ApplyToHeader(h *lob.Header)

func (Parts) MarshalJSON

func (p Parts) MarshalJSON() ([]byte, error)

func (*Parts) UnmarshalJSON

func (p *Parts) UnmarshalJSON(data []byte) error

type PrivateKeys

type PrivateKeys Keys

func (PrivateKeys) MarshalJSON

func (p PrivateKeys) MarshalJSON() ([]byte, error)

func (*PrivateKeys) UnmarshalJSON

func (p *PrivateKeys) UnmarshalJSON(data []byte) error

type State

type State interface {
	CSID() uint8

	LocalToken() Token
	RemoteToken() Token

	SetRemoteKey(k Key) error

	NeedsRemoteKey() bool
	CanEncryptMessage() bool
	CanEncryptHandshake() bool
	CanEncryptPacket() bool
	CanDecryptMessage() bool
	CanDecryptHandshake() bool
	CanDecryptPacket() bool

	IsHigh() bool

	EncryptMessage(in []byte) ([]byte, error)
	EncryptHandshake(at uint32, compact Parts) ([]byte, error)
	ApplyHandshake(Handshake) bool

	EncryptPacket(pkt *lob.Packet) (*lob.Packet, error)
	DecryptPacket(pkt *lob.Packet) (*lob.Packet, error)
}

func NewState

func NewState(csid uint8, localKey Key) (State, error)

type Token

type Token [16]byte
var ZeroToken Token

func ExtractToken

func ExtractToken(msg []byte) Token

Directories

Path Synopsis
Package cs1a implements Cipher Set 1a.
Package cs1a implements Cipher Set 1a.
eccp
Elliptic Curve Compressed Point marshaler
Elliptic Curve Compressed Point marshaler
ecdh
Elliptic curve Diffie–Hellman key sharing
Elliptic curve Diffie–Hellman key sharing
secp160r1
Parameters for the secp160r1 Elliptic curve
Parameters for the secp160r1 Elliptic curve
Package cs3a implements Cipher Set 3a.
Package cs3a implements Cipher Set 3a.

Jump to

Keyboard shortcuts

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