cblib

package module
v0.0.0-...-099258a Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	P521 = "P521"
	P384 = "P384"
	P256 = "P256"
)

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(ownerPrivateKey, otherPublicKey, text []byte) ([]byte, error)

func Encrypt

func Encrypt(ownerPrivateKey, otherPublicKey, text []byte) ([]byte, error)

Encrypt secures and authenticates its input using the public key using ECDHE with AES-128-CBC-HMAC-SHA1.

func GenerateSharedSecret

func GenerateSharedSecret(privKey, pubKey []byte) ([]byte, error)

func Sign

func Sign(str []byte, private []byte, reader io.Reader) ([]byte, error)

func Verify

func Verify(pub []byte, str []byte, sigb []byte) (bool, error)

Types

type Keys

type Keys struct {
	PublicKey  []byte
	PrivateKey []byte
}

func GenerateKeys

func GenerateKeys(curve_name string, reader io.Reader) (*Keys, error)

type PrivateKey

type PrivateKey struct {
	PublicKey
	D *big.Int
}

PrivateKey represents an ECDSA private key.

func (*PrivateKey) MarshalText

func (p *PrivateKey) MarshalText() (text []byte, err error)

func (*PrivateKey) Sign

func (p *PrivateKey) Sign(data []byte, reader io.Reader) *Signature

func (*PrivateKey) UnmarshalText

func (p *PrivateKey) UnmarshalText(text []byte) error

type PublicKey

type PublicKey struct {
	X, Y      *big.Int
	CurveName string
}

PublicKey represents an ECDSA public key.

func (*PublicKey) IsZero

func (p *PublicKey) IsZero() bool

func (*PublicKey) MarshalText

func (p *PublicKey) MarshalText() (text []byte, err error)

func (*PublicKey) UnmarshalText

func (p *PublicKey) UnmarshalText(text []byte) error

func (*PublicKey) Verify

func (p *PublicKey) Verify(data []byte, sign *Signature) bool

type Signature

type Signature struct {
	R, S *big.Int
}

func (*Signature) MarshalText

func (s *Signature) MarshalText() ([]byte, error)

func (*Signature) UnmarshalText

func (s *Signature) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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