crypto

package
v0.0.0-...-bebc87d Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2014 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package crypto is a generated protocol buffer package.

It is generated from these files:

encode.proto

It has these top-level messages:

PBPublicKey
PBPrivateKey

Index

Constants

View Source
const (
	RSA = iota
)

Variables

View Source
var ErrBadKeyType = errors.New("invalid or unsupported key type")
View Source
var KeyType_name = map[int32]string{
	0: "RSA",
}
View Source
var KeyType_value = map[string]int32{
	"RSA": 0,
}

Functions

func GenerateKeyPair

func GenerateKeyPair(typ, bits int) (PrivKey, PubKey, error)

func KeyEqual

func KeyEqual(k1, k2 Key) bool

KeyEqual checks whether two

func KeyStretcher

func KeyStretcher(cmp int, cipherType string, hashType string, secret []byte) ([]byte, []byte, []byte, []byte, []byte, []byte)

Generates a set of keys for each party by stretching the shared key. (myIV, theirIV, myCipherKey, theirCipherKey, myMACKey, theirMACKey)

Types

type GenSharedKey

type GenSharedKey func([]byte) ([]byte, error)

Given a public key, generates the shared key.

func GenerateEKeyPair

func GenerateEKeyPair(curveName string) ([]byte, GenSharedKey, error)

Generates an ephemeral public key and returns a function that will compute the shared secret key. Used in the identify module.

Focuses only on ECDH now, but can be made more general in the future.

type Key

type Key interface {
	// Bytes returns a serialized, storeable representation of this key
	Bytes() ([]byte, error)

	// Equals checks whether two PubKeys are the same
	Equals(Key) bool
}

type KeyType

type KeyType int32
const (
	KeyType_RSA KeyType = 0
)

func (KeyType) Enum

func (x KeyType) Enum() *KeyType

func (KeyType) String

func (x KeyType) String() string

func (*KeyType) UnmarshalJSON

func (x *KeyType) UnmarshalJSON(data []byte) error

type PBPrivateKey

type PBPrivateKey struct {
	Type             *KeyType `protobuf:"varint,1,req,enum=crypto.KeyType" json:"Type,omitempty"`
	Data             []byte   `protobuf:"bytes,2,req" json:"Data,omitempty"`
	XXX_unrecognized []byte   `json:"-"`
}

func (*PBPrivateKey) GetData

func (m *PBPrivateKey) GetData() []byte

func (*PBPrivateKey) GetType

func (m *PBPrivateKey) GetType() KeyType

func (*PBPrivateKey) ProtoMessage

func (*PBPrivateKey) ProtoMessage()

func (*PBPrivateKey) Reset

func (m *PBPrivateKey) Reset()

func (*PBPrivateKey) String

func (m *PBPrivateKey) String() string

type PBPublicKey

type PBPublicKey struct {
	Type             *KeyType `protobuf:"varint,1,req,enum=crypto.KeyType" json:"Type,omitempty"`
	Data             []byte   `protobuf:"bytes,2,req" json:"Data,omitempty"`
	XXX_unrecognized []byte   `json:"-"`
}

func (*PBPublicKey) GetData

func (m *PBPublicKey) GetData() []byte

func (*PBPublicKey) GetType

func (m *PBPublicKey) GetType() KeyType

func (*PBPublicKey) ProtoMessage

func (*PBPublicKey) ProtoMessage()

func (*PBPublicKey) Reset

func (m *PBPublicKey) Reset()

func (*PBPublicKey) String

func (m *PBPublicKey) String() string

type PrivKey

type PrivKey interface {
	Key

	// Cryptographically sign the given bytes
	Sign([]byte) ([]byte, error)

	// Return a public key paired with this private key
	GetPublic() PubKey

	// Generate a secret string of bytes
	GenSecret() []byte
}

func UnmarshalPrivateKey

func UnmarshalPrivateKey(data []byte) (PrivKey, error)

type PubKey

type PubKey interface {
	Key

	// Verify that 'sig' is the signed hash of 'data'
	Verify(data []byte, sig []byte) (bool, error)
}

func UnmarshalPublicKey

func UnmarshalPublicKey(data []byte) (PubKey, error)

type RsaPrivateKey

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

func UnmarshalRsaPrivateKey

func UnmarshalRsaPrivateKey(b []byte) (*RsaPrivateKey, error)

func (*RsaPrivateKey) Bytes

func (sk *RsaPrivateKey) Bytes() ([]byte, error)

func (*RsaPrivateKey) Equals

func (sk *RsaPrivateKey) Equals(k Key) bool

Equals checks whether this key is equal to another

func (*RsaPrivateKey) GenSecret

func (sk *RsaPrivateKey) GenSecret() []byte

func (*RsaPrivateKey) GetPublic

func (sk *RsaPrivateKey) GetPublic() PubKey

func (*RsaPrivateKey) Sign

func (sk *RsaPrivateKey) Sign(message []byte) ([]byte, error)

type RsaPublicKey

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

func UnmarshalRsaPublicKey

func UnmarshalRsaPublicKey(b []byte) (*RsaPublicKey, error)

func (*RsaPublicKey) Bytes

func (pk *RsaPublicKey) Bytes() ([]byte, error)

func (*RsaPublicKey) Equals

func (pk *RsaPublicKey) Equals(k Key) bool

Equals checks whether this key is equal to another

func (*RsaPublicKey) Verify

func (pk *RsaPublicKey) Verify(data, sig []byte) (bool, error)

Directories

Path Synopsis
Package spipe is a generated protocol buffer package.
Package spipe is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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