signal

package module
v0.0.0-...-88c94ff Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2019 License: MIT Imports: 13 Imported by: 1

README

libsignal-protocol-go

A GoLang library for communicating using the Signal .

This library currently implements the "X3DH" (or "Extended Triple Diffie-Hellman") key agreement protocol. X3DH establishes a shared secret key between two parties who mutually authenticate each other based on public keys. X3DH provides forward secrecy and cryptographic deniability. Work is currently on to implement the Double Ratchet Algorithm that provides perfect forward secrecy.

  1. https://signal.org/docs/specifications/x3dh
  2. https://signal.org/docs/specifications/doubleratchet/
Try the end-to-end sending and receiving signal protocol flow
go test -v -timeout 30s github.com/dosco/signal-go -run ^TestFlow$

Documentation

Index

Constants

View Source
const (
	KeySize   = 32
	NonceSize = 24
)

Variables

View Source
var (
	NotFound error = fmt.Errorf("not found")
)

Functions

func DH

func DH(priv *PrivKey, pub *PubKey) *[32]byte

func DecryptAEAD

func DecryptAEAD(key, message, ad []byte) ([]byte, error)

func EncryptAEAD

func EncryptAEAD(key, message, ad []byte) ([]byte, error)

func GenerateNonce

func GenerateNonce() (*[NonceSize]byte, error)

GenerateNonce creates a new random nonce.

func GenerateRegistrationId

func GenerateRegistrationId() uint64

func HKDF

func HKDF(km, salt, info []byte, size int) []byte

func KDF

func KDF(dh ...[]byte) *derivedKeys

func Sign

func Sign(privateKey *[32]byte, message []byte, random [64]byte) *[64]byte

func Verify

func Verify(publicKey [32]byte, message []byte, signature *[64]byte) bool

Verify checks whether the message has a valid signature.

Types

type Address

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

func NewAddress

func NewAddress(name string, deviceID uint32) *Address

func (*Address) DeviceID

func (a *Address) DeviceID() uint32

func (*Address) Name

func (a *Address) Name() string

type AliceMessage

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

type BobPreKeyBundle

type BobPreKeyBundle struct {
	Recipient      *Address
	RegistrationId uint64
	DeviceID       uint32

	IdentityKeyPub *PubKey

	SignedPreKeyID        uint32
	SignedPreKeyPub       *PubKey
	SignedPreKeySignature *[64]byte

	OneTimePreKeyID  int32
	OneTimePreKeyPub *PubKey
}

type KeyPair

type KeyPair struct {
	Priv *PrivKey
	Pub  *PubKey
}

func GenerateEphemeralKeyPair

func GenerateEphemeralKeyPair() *KeyPair

func GenerateIdentityKeyPair

func GenerateIdentityKeyPair() *KeyPair

func GenerateKeyPair

func GenerateKeyPair() *KeyPair

type MemoryStore

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

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func (*MemoryStore) GetIdentityKey

func (s *MemoryStore) GetIdentityKey(keyID uint32) (*[32]byte, error)

func (*MemoryStore) GetIdentityKeyPair

func (s *MemoryStore) GetIdentityKeyPair() (*KeyPair, error)

func (*MemoryStore) GetLocalRegistrationID

func (s *MemoryStore) GetLocalRegistrationID() (uint64, error)

func (*MemoryStore) GetPreKey

func (s *MemoryStore) GetPreKey(keyID uint32) (*PreKey, error)

func (*MemoryStore) GetSignedPreKey

func (s *MemoryStore) GetSignedPreKey(keyID uint32) (*SignedPreKey, error)

func (*MemoryStore) PutIdentityKey

func (s *MemoryStore) PutIdentityKey(keyID uint32, identityKey *[32]byte) error

func (*MemoryStore) PutIdentityKeyPair

func (s *MemoryStore) PutIdentityKeyPair(keyPair *KeyPair) error

func (*MemoryStore) PutLocalRegistrationID

func (s *MemoryStore) PutLocalRegistrationID(id uint64) error

func (*MemoryStore) PutPreKey

func (s *MemoryStore) PutPreKey(keyID uint32, preKey *PreKey) error

func (*MemoryStore) PutSignedPreKey

func (s *MemoryStore) PutSignedPreKey(keyID uint32, signedPreKey *SignedPreKey) error

type PreKey

type PreKey struct {
	KeyID int64
	*KeyPair
}

func GeneratePreKey

func GeneratePreKey(keyID int64) *PreKey

type PrivKey

type PrivKey struct {
	Key [32]byte
}

type PubKey

type PubKey struct {
	Key [32]byte
}

type ReceiverSession

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

func NewReceiverSession

func NewReceiverSession(store Store, a *AliceMessage) (*ReceiverSession, error)

type SenderSession

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

func NewSenderSession

func NewSenderSession(store Store, b *BobPreKeyBundle) (*SenderSession, error)

type SignedPreKey

type SignedPreKey struct {
	KeyID     int64
	Signature *[64]byte
	*KeyPair
}

func GenerateSignedPreKey

func GenerateSignedPreKey(identityKeyPair *KeyPair, keyID int64) *SignedPreKey

type Store

type Store interface {
	GetIdentityKeyPair() (*KeyPair, error)

	PutIdentityKeyPair(keyPair *KeyPair) error

	GetLocalRegistrationID() (uint64, error)

	PutLocalRegistrationID(id uint64) error

	GetIdentityKey(keyID uint32) (*[32]byte, error)

	PutIdentityKey(keyID uint32, identityKey *[32]byte) error

	GetPreKey(keyID uint32) (*PreKey, error)

	PutPreKey(keyID uint32, preKey *PreKey) error

	GetSignedPreKey(keyID uint32) (*SignedPreKey, error)

	PutSignedPreKey(keyID uint32, signedPreKey *SignedPreKey) error
}

Jump to

Keyboard shortcuts

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