cryptex

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2015 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package cryptex is a generated protocol buffer package.

It is generated from these files:

cryptex/cryptex.proto
cryptex/sss.proto
cryptex/xor.proto
cryptex/secretbox.proto
cryptex/box.proto
cryptex/rsa.proto
cryptex/openpgp.proto
cryptex/mux.proto
cryptex/demux.proto

It has these top-level messages:

Envelope

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthBox = fmt.Errorf("proto: negative length found during unmarshaling")
)
View Source
var (
	ErrInvalidLengthCryptex = fmt.Errorf("proto: negative length found during unmarshaling")
)
View Source
var (
	ErrInvalidLengthDemux = fmt.Errorf("proto: negative length found during unmarshaling")
)
View Source
var (
	ErrInvalidLengthMux = fmt.Errorf("proto: negative length found during unmarshaling")
)
View Source
var (
	ErrInvalidLengthOpenpgp = fmt.Errorf("proto: negative length found during unmarshaling")
)
View Source
var (
	ErrInvalidLengthRsa = fmt.Errorf("proto: negative length found during unmarshaling")
)
View Source
var (
	ErrInvalidLengthSecretbox = fmt.Errorf("proto: negative length found during unmarshaling")
)
View Source
var (
	ErrInvalidLengthSss = fmt.Errorf("proto: negative length found during unmarshaling")
)
View Source
var (
	ErrInvalidLengthXor = fmt.Errorf("proto: negative length found during unmarshaling")
)

Functions

func Marshal

func Marshal(cptx Cryptex) ([]byte, error)

Marshal returns the proto3 encoding of cptx.

Types

type Box

type Box struct {
	PublicKey []byte `protobuf:"bytes,2,opt,name=public_key,proto3" json:"public_key,omitempty"`
	// contains filtered or unexported fields
}

func NewBox

func NewBox(publicKey []byte, comment string) *Box

NewBox constructs a new Box for the PublicKey keypair.

func (*Box) Close

func (c *Box) Close(inputs, secrets [][]byte) error

Close seals the secret using PublicKey. The ciphertext is stored in the input data.

func (*Box) Comment

func (c *Box) Comment() string

Comment string

func (*Box) Marshal

func (m *Box) Marshal() (data []byte, err error)

func (*Box) MarshalTo

func (m *Box) MarshalTo(data []byte) (int, error)

func (*Box) Open

func (c *Box) Open(secrets, inputs [][]byte) error

Open unseals a secret from the ciphertext & private key portions of the input data.

func (*Box) ProtoMessage

func (*Box) ProtoMessage()

func (*Box) Reset

func (m *Box) Reset()

func (*Box) Size

func (m *Box) Size() (n int)

func (*Box) String

func (m *Box) String() string

func (*Box) Unmarshal

func (m *Box) Unmarshal(data []byte) error

type ByteStream

type ByteStream struct {
	Chunks [][]byte `protobuf:"bytes,1,rep,name=chunks" json:"chunks,omitempty"`
}

func (*ByteStream) Marshal

func (m *ByteStream) Marshal() (data []byte, err error)

func (*ByteStream) MarshalTo

func (m *ByteStream) MarshalTo(data []byte) (int, error)

func (*ByteStream) ProtoMessage

func (*ByteStream) ProtoMessage()

func (*ByteStream) Reset

func (m *ByteStream) Reset()

func (*ByteStream) Size

func (m *ByteStream) Size() (n int)

func (*ByteStream) String

func (m *ByteStream) String() string

func (*ByteStream) Unmarshal

func (m *ByteStream) Unmarshal(data []byte) error

type Cryptex

type Cryptex interface {
	// Optional description of the cryptex usage.
	Comment() string

	// Close encloses the inputs into the secret.
	Close(inputs, secrets [][]byte) error

	// Open unwraps the secrets contained in the inputs.
	Open(secrets, inputs [][]byte) error

	// Marshal returns the binary representation of the Cryptex.
	Marshal() (data []byte, err error)

	// Unmarshal parses the Cryptex encoded in data.
	Unmarshal(data []byte) error
}

Cryptex lock intermediate secrets.

func Unmarshal

func Unmarshal(data []byte) (Cryptex, error)

Unmarshal parses the proto3 encoded cryptex.

type Demux

type Demux struct {
	Seed []byte `protobuf:"bytes,2,opt,name=seed,proto3" json:"seed,omitempty"`
	// contains filtered or unexported fields
}

func NewDemux

func NewDemux(comment string) (*Demux, error)

NewDemux constructs a new Demux cryptex. The HKDF cryptographic key derivation function is combined with XOR pads to map a multiple secrets to a single input.

func (*Demux) Close

func (c *Demux) Close(inputs, secrets [][]byte) error

Close seals two or more non-nil secrets to an input.

func (*Demux) Comment

func (c *Demux) Comment() string

Comment string

func (*Demux) Marshal

func (m *Demux) Marshal() (data []byte, err error)

func (*Demux) MarshalTo

func (m *Demux) MarshalTo(data []byte) (int, error)

func (*Demux) Open

func (c *Demux) Open(secrets, inputs [][]byte) error

Open unseals two or more secrets from a single input.

func (*Demux) ProtoMessage

func (*Demux) ProtoMessage()

func (*Demux) Reset

func (m *Demux) Reset()

func (*Demux) Size

func (m *Demux) Size() (n int)

func (*Demux) String

func (m *Demux) String() string

func (*Demux) Unmarshal

func (m *Demux) Unmarshal(data []byte) error

type Envelope

type Envelope struct {
	SSS       *SSS       `protobuf:"bytes,1,opt,name=sss" json:"sss,omitempty"`
	XOR       *XOR       `protobuf:"bytes,2,opt,name=xor" json:"xor,omitempty"`
	SecretBox *SecretBox `protobuf:"bytes,3,opt,name=secretbox" json:"secretbox,omitempty"`
	Box       *Box       `protobuf:"bytes,4,opt,name=box" json:"box,omitempty"`
	RSA       *RSA       `protobuf:"bytes,5,opt,name=rsa" json:"rsa,omitempty"`
	OpenPGP   *OpenPGP   `protobuf:"bytes,6,opt,name=openpgp" json:"openpgp,omitempty"`
	Mux       *Mux       `protobuf:"bytes,7,opt,name=mux" json:"mux,omitempty"`
	Demux     *Demux     `protobuf:"bytes,8,opt,name=demux" json:"demux,omitempty"`
}

func Wrap

func Wrap(cptx Cryptex) (*Envelope, error)

Wrap returns an intermediate form of the cryptex for marshalling.

func (*Envelope) Cryptex

func (e *Envelope) Cryptex() (Cryptex, error)

Cryptex returns the concrete type from the intermediate form.

func (*Envelope) GetBox

func (m *Envelope) GetBox() *Box

func (*Envelope) GetDemux

func (m *Envelope) GetDemux() *Demux

func (*Envelope) GetMux

func (m *Envelope) GetMux() *Mux

func (*Envelope) GetOpenPGP

func (m *Envelope) GetOpenPGP() *OpenPGP

func (*Envelope) GetRSA

func (m *Envelope) GetRSA() *RSA

func (*Envelope) GetSSS

func (m *Envelope) GetSSS() *SSS

func (*Envelope) GetSecretBox

func (m *Envelope) GetSecretBox() *SecretBox

func (*Envelope) GetValue

func (this *Envelope) GetValue() interface{}

func (*Envelope) GetXOR

func (m *Envelope) GetXOR() *XOR

func (*Envelope) Marshal

func (m *Envelope) Marshal() (data []byte, err error)

func (*Envelope) MarshalTo

func (m *Envelope) MarshalTo(data []byte) (int, error)

func (*Envelope) ProtoMessage

func (*Envelope) ProtoMessage()

func (*Envelope) Reset

func (m *Envelope) Reset()

func (*Envelope) SetValue

func (this *Envelope) SetValue(value interface{}) bool

func (*Envelope) Size

func (m *Envelope) Size() (n int)

func (*Envelope) String

func (m *Envelope) String() string

func (*Envelope) Unmarshal

func (m *Envelope) Unmarshal(data []byte) error

type Mux

type Mux struct {
	Seed []byte `protobuf:"bytes,2,opt,name=seed,proto3" json:"seed,omitempty"`
	// contains filtered or unexported fields
}

func NewMux

func NewMux(comment string) (*Mux, error)

NewMux constructs a new Mux cryptex. The HKDF cryptographic key derivation function is used to stretch the secret into multiple inputs.

func (*Mux) Close

func (c *Mux) Close(inputs, secrets [][]byte) error

Close seals a single secret to two or more inputs. Each input is unique and any single input may recover the secret.

func (*Mux) Comment

func (c *Mux) Comment() string

Comment string

func (*Mux) Marshal

func (m *Mux) Marshal() (data []byte, err error)

func (*Mux) MarshalTo

func (m *Mux) MarshalTo(data []byte) (int, error)

func (*Mux) Open

func (c *Mux) Open(secrets, inputs [][]byte) error

Open unseals a single secret from at least one input.

func (*Mux) ProtoMessage

func (*Mux) ProtoMessage()

func (*Mux) Reset

func (m *Mux) Reset()

func (*Mux) Size

func (m *Mux) Size() (n int)

func (*Mux) String

func (m *Mux) String() string

func (*Mux) Unmarshal

func (m *Mux) Unmarshal(data []byte) error

type OpenPGP

type OpenPGP struct {
	Entities [][]byte `protobuf:"bytes,2,rep,name=entities" json:"entities,omitempty"`
	// contains filtered or unexported fields
}

func NewOpenPGP

func NewOpenPGP(entities []*openpgp.Entity, comment string) (*OpenPGP, error)

NewOpenPGP constructs a new OpenPGP for one or more entities containing a public key for encryption.

func (*OpenPGP) Close

func (c *OpenPGP) Close(inputs, secrets [][]byte) error

Close seals a single secret by encrypting with the public keys from the entities.

func (*OpenPGP) Comment

func (c *OpenPGP) Comment() string

Comment string

func (*OpenPGP) Marshal

func (m *OpenPGP) Marshal() (data []byte, err error)

func (*OpenPGP) MarshalTo

func (m *OpenPGP) MarshalTo(data []byte) (int, error)

func (*OpenPGP) Open

func (c *OpenPGP) Open(secrets, inputs [][]byte) error

Open unseals a single secret with a private key input matching a public key from the entities.

func (*OpenPGP) ProtoMessage

func (*OpenPGP) ProtoMessage()

func (*OpenPGP) Reset

func (m *OpenPGP) Reset()

func (*OpenPGP) Size

func (m *OpenPGP) Size() (n int)

func (*OpenPGP) String

func (m *OpenPGP) String() string

func (*OpenPGP) Unmarshal

func (m *OpenPGP) Unmarshal(data []byte) error

type RSA

type RSA struct {
	PublicKey []byte `protobuf:"bytes,2,opt,name=public_key,proto3" json:"public_key,omitempty"`
	// contains filtered or unexported fields
}

func NewRSA

func NewRSA(publicKey []byte, comment string) *RSA

NewRSA constructs a new RSA for the RSA PublicKey pair.

func (*RSA) Close

func (c *RSA) Close(inputs, secrets [][]byte) error

Close seals the secret using OAEP encryption with the PublicKey. The ciphertext is stored in the input data.

func (*RSA) Comment

func (c *RSA) Comment() string

Comment string

func (*RSA) Marshal

func (m *RSA) Marshal() (data []byte, err error)

func (*RSA) MarshalTo

func (m *RSA) MarshalTo(data []byte) (int, error)

func (*RSA) Open

func (c *RSA) Open(secrets, inputs [][]byte) error

Open unseals a secret using OAEP decryption from the ciphertext & RSA private key portions of the input data.

func (*RSA) ProtoMessage

func (*RSA) ProtoMessage()

func (*RSA) Reset

func (m *RSA) Reset()

func (*RSA) Size

func (m *RSA) Size() (n int)

func (*RSA) String

func (m *RSA) String() string

func (*RSA) Unmarshal

func (m *RSA) Unmarshal(data []byte) error

type SSS

type SSS struct {
	N uint32 `protobuf:"varint,2,opt,name=n,proto3" json:"n,omitempty"`
	K uint32 `protobuf:"varint,3,opt,name=k,proto3" json:"k,omitempty"`
	// contains filtered or unexported fields
}

func NewSSS

func NewSSS(n, k uint32, comment string) *SSS

NewSSS constructs a new SSS for N shares of which K are required to recover the secrets.

func (*SSS) Close

func (c *SSS) Close(inputs, secrets [][]byte) error

Close seals the secret to the N inputs.

func (*SSS) Comment

func (c *SSS) Comment() string

Comment string

func (*SSS) Marshal

func (m *SSS) Marshal() (data []byte, err error)

func (*SSS) MarshalTo

func (m *SSS) MarshalTo(data []byte) (int, error)

func (*SSS) Open

func (c *SSS) Open(secrets, inputs [][]byte) error

Open unseals the secret from the N inputs, of which K are required.

func (*SSS) ProtoMessage

func (*SSS) ProtoMessage()

func (*SSS) Reset

func (m *SSS) Reset()

func (*SSS) Size

func (m *SSS) Size() (n int)

func (*SSS) String

func (m *SSS) String() string

func (*SSS) Unmarshal

func (m *SSS) Unmarshal(data []byte) error

type SecretBox

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

func NewSecretBox

func NewSecretBox(comment string) *SecretBox

NewSecretBox constructs a new SecretBox for a single input.

func (*SecretBox) Close

func (c *SecretBox) Close(inputs, secrets [][]byte) error

Close seals the secret to the input key. The input key is generated if not present in the inputs data.

func (*SecretBox) Comment

func (c *SecretBox) Comment() string

Comment string

func (*SecretBox) Marshal

func (m *SecretBox) Marshal() (data []byte, err error)

func (*SecretBox) MarshalTo

func (m *SecretBox) MarshalTo(data []byte) (int, error)

func (*SecretBox) Open

func (c *SecretBox) Open(secrets, inputs [][]byte) error

Open unseals a secret from the key in input data.

func (*SecretBox) ProtoMessage

func (*SecretBox) ProtoMessage()

func (*SecretBox) Reset

func (m *SecretBox) Reset()

func (*SecretBox) Size

func (m *SecretBox) Size() (n int)

func (*SecretBox) String

func (m *SecretBox) String() string

func (*SecretBox) Unmarshal

func (m *SecretBox) Unmarshal(data []byte) error

type XOR

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

func NewXOR

func NewXOR(comment string) *XOR

NewXOR constructs a new XOR for the input parts.

func (*XOR) Close

func (c *XOR) Close(inputs, secrets [][]byte) error

Close seals the secret to the xor of all the generated inputs.

func (*XOR) Comment

func (c *XOR) Comment() string

Comment string

func (*XOR) Marshal

func (m *XOR) Marshal() (data []byte, err error)

func (*XOR) MarshalTo

func (m *XOR) MarshalTo(data []byte) (int, error)

func (*XOR) Open

func (c *XOR) Open(secrets, inputs [][]byte) error

Open unseals the secret by xor'ing all inputs data.

func (*XOR) ProtoMessage

func (*XOR) ProtoMessage()

func (*XOR) Reset

func (m *XOR) Reset()

func (*XOR) Size

func (m *XOR) Size() (n int)

func (*XOR) String

func (m *XOR) String() string

func (*XOR) Unmarshal

func (m *XOR) Unmarshal(data []byte) error

Jump to

Keyboard shortcuts

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