go-pkcs11uri – github.com/stefanberger/go-pkcs11uri Index | Files

package pkcs11uri

import "github.com/stefanberger/go-pkcs11uri"

Index

Types

type Pkcs11URI

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

Pkcs11URI holds a pkcs11 URI object

func New

func New() *Pkcs11URI

New creates a new Pkcs11URI object

func (*Pkcs11URI) AddEnv

func (uri *Pkcs11URI) AddEnv(name, value string)

AddEnv adds an environment variable for the pkcs11 module

func (*Pkcs11URI) AddPathAttribute

func (uri *Pkcs11URI) AddPathAttribute(name, value string) error

AddPathAttribute adds a path attribute; it returns an error if an attribute with the same name already existed or if the given value cannot be pct-unescaped

func (*Pkcs11URI) AddPathAttributeUnencoded

func (uri *Pkcs11URI) AddPathAttributeUnencoded(name string, value []byte) error

AddPathAttributeUnencoded adds a path attribute given as byte[] which must not already be pct-encoded; it returns an error if an attribute with the same name already existed

func (*Pkcs11URI) AddQueryAttribute

func (uri *Pkcs11URI) AddQueryAttribute(name, value string) error

AddQueryAttribute adds a query attribute; it returns an error if an attribute with the same name already existed or if the given value cannot be pct-unescaped

func (*Pkcs11URI) AddQueryAttributeUnencoded

func (uri *Pkcs11URI) AddQueryAttributeUnencoded(name string, value []byte) error

AddQueryAttributeUnencoded adds a query attribute given as byte[] which must not already be pct-encoded; it returns an error if an attribute with the same name already existed

func (*Pkcs11URI) Format

func (uri *Pkcs11URI) Format() (string, error)

Format formats a Pkcs11URI to it string representaion

func (*Pkcs11URI) GetEnvMap

func (uri *Pkcs11URI) GetEnvMap() map[string]string

GetEnvMap returns the map of environment variables

func (*Pkcs11URI) GetModule

func (uri *Pkcs11URI) GetModule() (string, error)

GetModule returns the module to use or an error in case no module could be found. First the module-path is checked for whether it holds an absolute that can be read by the current user. If this is the case the module is returned. Otherwise either the module-path is used or the user-provided module path is used to match a module containing what is set in the attribute module-name.

func (*Pkcs11URI) GetModuleDirectories

func (uri *Pkcs11URI) GetModuleDirectories() []string

GetModuleDirectories gets the search directories for pkcs11 modules

func (*Pkcs11URI) GetPIN

func (uri *Pkcs11URI) GetPIN() (string, error)

GetPIN gets the PIN from either the pin-value or pin-source attribute; a user may want to call HasPIN() before calling this function to determine whether a PIN has been provided at all so that an error code returned by this function indicates that the PIN value could not be retrieved.

func (*Pkcs11URI) GetPathAttribute

func (uri *Pkcs11URI) GetPathAttribute(name string, pctencode bool) (string, bool)

GetPathAttribute returns the value of a path attribute in unescaped form or pct-encoded form

func (*Pkcs11URI) GetQueryAttribute

func (uri *Pkcs11URI) GetQueryAttribute(name string, pctencode bool) (string, bool)

GetQueryAttribute returns the value of a query attribute in unescaped or pct-encoded form

func (*Pkcs11URI) HasPIN

func (uri *Pkcs11URI) HasPIN() bool

HasPIN allows the user to check whether a PIN has been provided either by the pin-value or the pin-source attributes. It should be called before GetPIN(), which may still fail getting the PIN from a file for example.

func (*Pkcs11URI) Parse

func (uri *Pkcs11URI) Parse(uristring string) error

Parse parses a pkcs11: URI string

func (*Pkcs11URI) RemovePathAttribute

func (uri *Pkcs11URI) RemovePathAttribute(name string)

RemovePathAttribute removes a path attribute

func (*Pkcs11URI) RemoveQueryAttribute

func (uri *Pkcs11URI) RemoveQueryAttribute(name string)

RemoveQueryAttribute removes a path attribute

func (*Pkcs11URI) SetAllowAnyModule

func (uri *Pkcs11URI) SetAllowAnyModule(allowAnyModule bool)

SetAllowAnyModule allows any module to be loaded; by default this is not allowed

func (*Pkcs11URI) SetAllowedModulePaths

func (uri *Pkcs11URI) SetAllowedModulePaths(allowedModulePaths []string)

SetAllowedModulePaths sets allowed module paths to restrict access to modules. Directory entries must end with a '/', all other ones are assumed to be file entries. Allowed modules are filtered by string matching.

func (*Pkcs11URI) SetEnvMap

func (uri *Pkcs11URI) SetEnvMap(env map[string]string)

SetEnvMap sets the environment variables for the pkcs11 module

func (*Pkcs11URI) SetModuleDirectories

func (uri *Pkcs11URI) SetModuleDirectories(moduleDirectories []string)

SetModuleDirectories sets the search directories for pkcs11 modules

func (*Pkcs11URI) SetPathAttribute

func (uri *Pkcs11URI) SetPathAttribute(name, value string) error

SetPathAttribute sets the value for a path attribute; this function may return an error if the given value cannot be pct-unescaped

func (*Pkcs11URI) SetPathAttributeUnencoded

func (uri *Pkcs11URI) SetPathAttributeUnencoded(name string, value []byte)

SetPathAttributeUnencoded sets the value for a path attribute given as byte[]. The value must not have been pct-encoded already.

func (*Pkcs11URI) SetQueryAttribute

func (uri *Pkcs11URI) SetQueryAttribute(name, value string) error

SetQueryAttribute sets the value for a query attribute; this function may return an error if the given value cannot pct-unescaped

func (*Pkcs11URI) SetQueryAttributeUnencoded

func (uri *Pkcs11URI) SetQueryAttributeUnencoded(name string, value []byte)

SetQueryAttributeUnencoded sets the value for a quiery attribute given as byte[]. The value must not have been pct-encoded already.

func (*Pkcs11URI) Validate

func (uri *Pkcs11URI) Validate() error

Validate validates a Pkcs11URI object's attributes following RFC 7512 rules and proper formatting of their values

Source Files

pkcs11uri.go

Version
v0.0.0-20230803200340-78284954bff6 (latest)
Published
Aug 3, 2023
Platform
js/wasm
Imports
8 packages
Last checked
4 days ago

Tools for package owners.