config

package
v0.0.0-...-0b3308b Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2017 License: MPL-2.0 Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

Cryptographic configuration file

func (*File) GenKey

func (f *File) GenKey(keys *Keys, suite abstract.Suite) (KeyPair, error)

Generate a new public/private keypair with the given ciphersuite and Save it to the application's previously-loaded configuration.

func (*File) Key

func (f *File) Key(key *KeyInfo, suites map[string]abstract.Suite) (KeyPair, error)

Retrieve a public/private keypair for a given KeyInfo configuration record.

func (*File) Keys

func (f *File) Keys(keys *Keys, suites map[string]abstract.Suite,
	defaultSuite abstract.Suite) ([]KeyPair, error)

Retrieve a set of public/private keypairs configured for this application. The caller must provide a pointer to an instance of the Keys struct, which should be embedded in the configData object that was passed to Load. If the provided defaultSuite is non-nil and no keypairs are configured yet, automatically creates and saves a keypair with the specified defaultSuite.

If any of the configured public keys cannot be loaded for whatever reason, such as a key's ciphersuite becoming no-longer-supported for example, logs a warning but continues to load any other configured keys.

func (*File) Load

func (f *File) Load(appName string, configData interface{}) error

Load a TOML-format config file for an application with the given name. The provided configData object will contain the loaded config data; its reflective Go structure defines the TOML format it expects.

func (*File) Save

func (f *File) Save() error

Re-save the (modified) configData loaded earlier with Load(). Takes precautions to replace the old config file atomically to avoid config file corruption due to write errors or races.

type KeyInfo

type KeyInfo struct {
	Suite string // Name of this key's ciphersuite
	PubId string // Public key's base64-encoded hash-ID
}

KeyInfo represents configuration data for a particular public key, consisting of the name of the ciphersuite the public key was generated from and the unpadded, base64-encoded Hash-Id of the public key itself using the appropriate ciphersuite's hash function. The corresponding private key is stored separately for security.

type KeyPair

type KeyPair struct {
	Suite  abstract.Suite  // Ciphersuite this keypair is for
	Public abstract.Point  // Public key
	Secret abstract.Scalar // Secret key
}

KeyPair represents a public/private keypair together with the ciphersuite the key was generated from.

func NewKeyPair

func NewKeyPair(suite abstract.Suite) *KeyPair

NewKeyPair directly creates a secret/public key pair

func (*KeyPair) Gen

func (p *KeyPair) Gen(suite abstract.Suite, random cipher.Stream)

Generate a fresh public/private keypair with the given ciphersuite, using a given source of cryptographic randomness.

func (*KeyPair) PubId

func (p *KeyPair) PubId() string

PubId returns the base64-encoded HashId for this KeyPair's public key.

type Keys

type Keys []KeyInfo

Keys represents a set of public/private keypairs an application is configured to use to identify itself. The caller should embed an instance of Keys in its application-specific configData struct.

Jump to

Keyboard shortcuts

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