crypto

package
v0.0.0-...-da0747f Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2017 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PGPMessageType = "PGP MESSAGE"
View Source
var ParticipantNotFound = errors.New("participant not found")

Functions

func Combine

func Combine(shares []*Share) []byte

func Decrypt

func Decrypt(keyStore KeyStore, cipherText []byte, shares *pb.Shares) (io.Reader, error)

func DecryptSharesAndCombine

func DecryptSharesAndCombine(keyStore KeyStore, shares *pb.Shares) ([]byte, error)

func EncryptPrivateShare

func EncryptPrivateShare(e Encryptor, p Participant, serializedShare []byte) (*pb.PrivateShare, error)

func LoadX509Certificate

func LoadX509Certificate(certFile string) (*x509.Certificate, error)

func SplitAndEncrypt

func SplitAndEncrypt(key []byte, encryptor Encryptor, participants []Participant, numPublicShares, threshold int) (*pb.Shares, error)

Types

type EncryptionResult

type EncryptionResult struct {
	CipherText *pb.CipherText
	Shares     *pb.Shares
}

type EncryptionScheme

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

func NewEncryptionScheme

func NewEncryptionScheme(encryptor Encryptor, participants []Participant, numPublicShares, threshold int) (*EncryptionScheme, error)

func (EncryptionScheme) Encrypt

func (e EncryptionScheme) Encrypt(msg []byte) (*EncryptionResult, error)

type Encryptor

type Encryptor interface {
	crypto.Signer
	Identifier() string
	Decrypt([]byte) ([]byte, error)
}

type KeyStore

type KeyStore interface {
	Participant(identifier string) (Participant, error)
	Encryptor() Encryptor
}

func KeyStoreFromConfig

func KeyStoreFromConfig(cfg *config.Config) (KeyStore, error)

func NewMemoryKeyStore

func NewMemoryKeyStore(store map[string]Participant, encryptor Encryptor) KeyStore

type MemoryKeyStore

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

func (*MemoryKeyStore) Encryptor

func (s *MemoryKeyStore) Encryptor() Encryptor

func (*MemoryKeyStore) Participant

func (s *MemoryKeyStore) Participant(identifier string) (Participant, error)

type Participant

type Participant interface {
	Encrypt(msg []byte) ([]byte, error)
	Verify(signature, hash []byte) error
	Identifier() string
}

type Share

type Share struct {
	X byte
	Y []byte
}

func DecryptAndVerifyShare

func DecryptAndVerifyShare(keyStore KeyStore, s *pb.PrivateShare) (*Share, error)

func DeserializeShare

func DeserializeShare(r io.Reader) (*Share, error)

func Split

func Split(secret []byte, threshold, numShares int) ([]*Share, error)

func VerifyPublicShare

func VerifyPublicShare(keyStore KeyStore, s *pb.PublicShare) (*Share, error)

func (*Share) Serialize

func (s *Share) Serialize(w io.Writer) error

type TLSEncryptor

type TLSEncryptor struct {
	TlsCert tls.Certificate
	// contains filtered or unexported fields
}

func LoadTLSEncryptor

func LoadTLSEncryptor(certFile, keyFile string) (*TLSEncryptor, error)

func NewTLSEncryptor

func NewTLSEncryptor(tlsCert tls.Certificate, x509Cert *x509.Certificate) *TLSEncryptor

func (*TLSEncryptor) Decrypt

func (e *TLSEncryptor) Decrypt(cipherText []byte) ([]byte, error)

func (*TLSEncryptor) Identifier

func (e *TLSEncryptor) Identifier() string

func (*TLSEncryptor) Public

func (e *TLSEncryptor) Public() crypto.PublicKey

func (*TLSEncryptor) Sign

func (e *TLSEncryptor) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) (signature []byte, err error)

type X509Participant

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

func LoadX509Participant

func LoadX509Participant(certFile string) (*X509Participant, error)

func NewX509Participant

func NewX509Participant(cert *x509.Certificate) *X509Participant

func (*X509Participant) Encrypt

func (p *X509Participant) Encrypt(msg []byte) ([]byte, error)

func (*X509Participant) Identifier

func (p *X509Participant) Identifier() string

func (*X509Participant) Verify

func (p *X509Participant) Verify(signature, hash []byte) error

Jump to

Keyboard shortcuts

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