common

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package common implements the factories of the crypto primitives to allow the use of multiple algorithms over the same communication channel.

Documentation Last Review: 05.10.2020

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterAlgorithmFormat

func RegisterAlgorithmFormat(c serde.Format, f serde.FormatEngine)

RegisterAlgorithmFormat registers the engine for the provided format.

Types

type Algorithm

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

Algorithm contains information about a signature algorithm.

- implements serde.Message

func NewAlgorithm

func NewAlgorithm(name string) Algorithm

NewAlgorithm returns a new algorithm from the provided name.

func (Algorithm) GetName

func (alg Algorithm) GetName() string

GetName returns the name of the algorithm.

func (Algorithm) Serialize

func (alg Algorithm) Serialize(ctx serde.Context) ([]byte, error)

Serialize implements serde.Message. It returns the serialized for the algorithm.

type PublicKeyFac

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

PublicKeyFac is a public key factory for commonly known algorithms.

- implements common.PublicKeyFactory

func NewPublicKeyFactory

func NewPublicKeyFactory() PublicKeyFac

NewPublicKeyFactory returns a new instance of the common public key factory.

func (PublicKeyFac) Deserialize

func (f PublicKeyFac) Deserialize(ctx serde.Context, data []byte) (serde.Message, error)

Deserialize implements serde.Factory. It looks up the format and returns the public key of the data if appropriate, otherwise an error.

func (PublicKeyFac) PublicKeyOf

func (f PublicKeyFac) PublicKeyOf(ctx serde.Context, data []byte) (crypto.PublicKey, error)

PublicKeyOf implements crypto.PublicKeyFactory. It returns the public key of the data if appropriate, otherwise an error.

func (PublicKeyFac) RegisterAlgorithm

func (f PublicKeyFac) RegisterAlgorithm(algo string, factory crypto.PublicKeyFactory)

RegisterAlgorithm registers the factory for the algorithm. It will override an already existing key.

type PublicKeyFactory

type PublicKeyFactory interface {
	serde.Factory

	// PublicKeyOf returns the public key associated to the data if appropriate,
	// otherwise an error.
	PublicKeyOf(serde.Context, []byte) (crypto.PublicKey, error)
}

PublicKeyFactory is a redefinition of the crypto public key factory to exclude some functions that are incompatible with the logic of a common factory which requires specific serialization.

type SignatureFactory

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

SignatureFactory is a factory for commonly known algorithms.

- implements crypto.SignatureFactory

func NewSignatureFactory

func NewSignatureFactory() SignatureFactory

NewSignatureFactory returns a new instance of the common signature factory. It registers the BLS algorithm by default.

func (SignatureFactory) Deserialize

func (f SignatureFactory) Deserialize(ctx serde.Context, data []byte) (serde.Message, error)

Deserialize implements serde.Factory. It returns the signature associated to the data if appropriate, otherwise it returns an error.

func (SignatureFactory) RegisterAlgorithm

func (f SignatureFactory) RegisterAlgorithm(name string, factory crypto.SignatureFactory)

RegisterAlgorithm register the factory for the algorithm.

func (SignatureFactory) SignatureOf

func (f SignatureFactory) SignatureOf(ctx serde.Context, data []byte) (crypto.Signature, error)

SignatureOf implements crypto.SignatureFactory. It returns the signature associated to the data if appropriate, otherwise it returns an error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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