factory

package
v0.0.0-...-b544036 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Copyright hechain. 2022 All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	// SoftwareBasedFactoryName is the name of the factory of the software-based BCCSP implementation
	SoftwareBasedFactoryName = "SW"
)

Variables

This section is empty.

Functions

func GetBCCSPFromOpts

func GetBCCSPFromOpts(config *FactoryOpts) (bccsp.BCCSP, error)

GetBCCSPFromOpts returns a BCCSP created according to the options passed in input.

func GetDefault

func GetDefault() bccsp.BCCSP

GetDefault returns a non-ephemeral (long-term) BCCSP

func InitFactories

func InitFactories(config *FactoryOpts) error

InitFactories must be called before using factory interfaces It is acceptable to call with config = nil, in which case some defaults will get used Error is returned only if defaultBCCSP cannot be found

Types

type BCCSPFactory

type BCCSPFactory interface {

	// Name returns the name of this factory
	Name() string

	// Get returns an instance of BCCSP using opts.
	Get(opts *FactoryOpts) (bccsp.BCCSP, error)
}

BCCSPFactory is used to get instances of the BCCSP interface. A Factory has name used to address it.

type FactoryOpts

type FactoryOpts struct {
	Default string  `json:"default" yaml:"Default"`
	SW      *SwOpts `json:"SW,omitempty" yaml:"SW,omitempty"`
}

FactoryOpts holds configuration information used to initialize factory implementations

func GetDefaultOpts

func GetDefaultOpts() *FactoryOpts

GetDefaultOpts offers a default implementation for Opts returns a new instance every time

func (*FactoryOpts) FactoryName

func (o *FactoryOpts) FactoryName() string

FactoryName returns the name of the provider

type FileKeystoreOpts

type FileKeystoreOpts struct {
	KeyStorePath string `yaml:"KeyStore"`
}

Pluggable Keystores, could add JKS, P12, etc..

type SWFactory

type SWFactory struct{}

SWFactory is the factory of the software-based BCCSP.

func (*SWFactory) Get

func (f *SWFactory) Get(config *FactoryOpts) (bccsp.BCCSP, error)

Get returns an instance of BCCSP using Opts.

func (*SWFactory) Name

func (f *SWFactory) Name() string

Name returns the name of this factory

type SwOpts

type SwOpts struct {
	// Default algorithms when not specified (Deprecated?)
	Security     int               `json:"security" yaml:"Security"`
	Hash         string            `json:"hash" yaml:"Hash"`
	FileKeystore *FileKeystoreOpts `json:"filekeystore,omitempty" yaml:"FileKeyStore,omitempty"`
}

SwOpts contains options for the SWFactory

Jump to

Keyboard shortcuts

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