encryption

package
v0.0.0-...-b01a591 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: GPL-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package encryption contains the encryption API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VerifyECDSAKey

func VerifyECDSAKey(v *ECDSAKey) error

VerifyECDSAKey is a helper function to verify an ecdsa key.

func VerifyEd25519Key

func VerifyEd25519Key(v *Ed25519Key) error

VerifyEd25519Key is a helper function to verify an ed25519 key.

func VerifyRSAKey

func VerifyRSAKey(v *RSAKey) error

VerifyRSAKey is a helper function to verify a rsa key.

Types

type ECDSAKey

type ECDSAKey struct {
	Key
	Verifier
	Signer
	PublicKey  *ecdsa.PublicKey
	PrivateKey *ecdsa.PrivateKey
	// contains filtered or unexported fields
}

ECDSAKey is a verifier for ecdsa keys

func GenerateECDSAKey

func GenerateECDSAKey() (*ECDSAKey, error)

GenerateECDSAKey generates a new ecdsa private key and returns it

func UnmarshalECDSAKey

func UnmarshalECDSAKey(key *data.Key) (*ECDSAKey, error)

UnmarshalECDSAKey is a helper function to unmarshal an ecdsa key from a data.Key.

func (*ECDSAKey) MarshalAllData

func (k *ECDSAKey) MarshalAllData() (*data.Key, error)

MarshalAllData returns the data.Key object associated with the verifier contains public and private keys.

func (*ECDSAKey) MarshalPublicData

func (k *ECDSAKey) MarshalPublicData() (*data.Key, error)

MarshalPublicData returns the data.Key object associated with the verifier contains only public key.

func (*ECDSAKey) Public

func (k *ECDSAKey) Public() string

Public this is the public string used as a unique identifier for the verifier instance.

func (*ECDSAKey) SignMessage

func (k *ECDSAKey) SignMessage(message []byte) ([]byte, error)

SignMessage signs a message with the private key.

func (*ECDSAKey) Type

func (k *ECDSAKey) Type() data.KeyType

Type returns the type of key.

func (*ECDSAKey) Verify

func (k *ECDSAKey) Verify(msg, sig []byte) error

Verify takes a message and signature, all as byte slices, and determines whether the signature is valid for the given key and message.

type Ed25519Key

type Ed25519Key struct {
	Key
	Verifier
	Signer
	ed25519.PrivateKey
	PublicKey ed25519.PublicKey
	// contains filtered or unexported fields
}

Ed25519Key is a verifier for ed25519 keys

func GenerateEd25519Key

func GenerateEd25519Key() (*Ed25519Key, error)

GenerateEd25519Key generates a new ed25519 private key and returns it

func UnmarshalEd25519Key

func UnmarshalEd25519Key(key *data.Key) (*Ed25519Key, error)

UnmarshalEd25519Key is a helper function to unmarshal an ed25519 key from a data.Key.

func (*Ed25519Key) MarshalAllData

func (k *Ed25519Key) MarshalAllData() (*data.Key, error)

MarshalAllData returns the data.Key object associated with the verifier contains public and private keys.

func (*Ed25519Key) MarshalPublicData

func (k *Ed25519Key) MarshalPublicData() (*data.Key, error)

MarshalPublicData returns the data.PublicKey object associated with the verifier.

func (*Ed25519Key) Public

func (k *Ed25519Key) Public() string

Public this is the public string used as a unique identifier for the verifier instance.

func (*Ed25519Key) SignMessage

func (k *Ed25519Key) SignMessage(message []byte) ([]byte, error)

SignMessage signs a message with the private key.

func (*Ed25519Key) Type

func (k *Ed25519Key) Type() data.KeyType

Type returns the type of the signature scheme.

func (*Ed25519Key) Verify

func (k *Ed25519Key) Verify(msg, sig []byte) error

Verify takes a message and signature, all as byte slices, and determines whether the signature is valid for the given key and message.

type Key

type Key interface {
	// Type returns the type of key.
	Type() data.KeyType
	// MarshalAllData returns the data.Key object associated with the verifier contains public and private keys.
	MarshalAllData() (*data.Key, error)
}

Key represents a common methods of different keys.

func NewKey

func NewKey(keyType data.KeyType) (Key, error)

NewKey creates a new encryption key of the given type.

type RSAKey

type RSAKey struct {
	Key
	Verifier
	Signer
	PublicKey  *rsa.PublicKey
	PrivateKey *rsa.PrivateKey
	// contains filtered or unexported fields
}

RSAKey is

func GenerateRSAKey

func GenerateRSAKey() (*RSAKey, error)

GenerateRSAKey generates a new rsa private key and returns it

func UnmarshalRSAKey

func UnmarshalRSAKey(key *data.Key) (*RSAKey, error)

UnmarshalRSAKey is a helper function to unmarshal an RSA key from a data.Key.

func (*RSAKey) MarshalAllData

func (k *RSAKey) MarshalAllData() (*data.Key, error)

MarshalAllData returns the data.Key object associated with the verifier contains public and private keys.

func (*RSAKey) MarshalPublicData

func (k *RSAKey) MarshalPublicData() (*data.Key, error)

MarshalPublicData returns the data.Key object associated with the verifier contains only public key.

func (*RSAKey) Public

func (k *RSAKey) Public() string

Public this is the public string used as a unique identifier for the verifier instance.

func (*RSAKey) SignMessage

func (k *RSAKey) SignMessage(message []byte) ([]byte, error)

SignMessage signs a message with the private key.

func (*RSAKey) Type

func (k *RSAKey) Type() data.KeyType

Type returns the type of key.

func (*RSAKey) Verify

func (k *RSAKey) Verify(msg, sig []byte) error

Verify takes a message and signature, all as byte slices, and determines whether the signature is valid for the given key and message.

type Signer

type Signer interface {
	// SignMessage signs a message with the private key.
	SignMessage(message []byte) ([]byte, error)
}

Signer is an interface for an opaque private key that can be used for signing operations.

type Verifier

type Verifier interface {
	// MarshalPublicData returns the data.Key object associated with the verifier contains only public key.
	MarshalPublicData() (*data.Key, error)
	// Public this is the public string used as a unique identifier for the verifier instance.
	Public() string
	// Verify takes a message and signature, all as byte slices,
	// and determines whether the signature is valid for the given
	// key and message.
	Verify(msg, sig []byte) error
}

A Verifier verifies public key signatures.

func UnmarshalKey

func UnmarshalKey(key *data.Key) (Verifier, error)

UnmarshalKey takes key data to a working verifier implementation for the key type. This performs any validation over the data.PublicKey to ensure that the verifier is usable to verify signatures.

Jump to

Keyboard shortcuts

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