crypto

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SignCertsDirName = "signcerts"
	KeyStoreDirName  = "keystore"
	PrivSKFileName   = "priv_sk"

	ProtobufProtocolVersionV1 uint64 = 1
)

Variables

This section is empty.

Functions

func DeserializeVerifier

func DeserializeVerifier(id driver.Identity) (driver.Verifier, error)

func GetBCCSPFromConf

func GetBCCSPFromConf(conf *BCCSP, keyStore bccsp.KeyStore) (bccsp.BCCSP, error)

GetBCCSPFromConf returns a BCCSP instance and its relative key store from the passed configuration. If no configuration is passed, the default one is used, namely the `SW` provider.

func GetDefaultBCCSP

func GetDefaultBCCSP(keyStore bccsp.KeyStore) (bccsp.BCCSP, error)

GetDefaultBCCSP returns a new instance of the software-based BCCSP

func GetEnrollmentID

func GetEnrollmentID(id []byte) (string, error)

func GetPKCS11BCCSP

func GetPKCS11BCCSP(conf *BCCSP, keyStore bccsp.KeyStore) (bccsp.BCCSP, error)

GetPKCS11BCCSP returns a new instance of the HSM-based BCCSP

func GetRevocationHandle

func GetRevocationHandle(id []byte) ([]byte, error)

func GetSigningIdentity

func GetSigningIdentity(conf *Config, bccspConfig *BCCSP, keyStore bccsp.KeyStore) (driver.FullIdentity, error)

GetSigningIdentity retrieves a signing identity from the passed arguments. If keyStorePath is empty, then it is assumed that the key is at configPath/keystore

func Info

func Info(raw []byte) (string, error)

func IsLowS

func IsLowS(k *ecdsa.PublicKey, s *big.Int) (bool, error)

IsLowS checks that s is a low-S

func MarshalConfig

func MarshalConfig(config *Config) ([]byte, error)

func NewECDSAVerifier

func NewECDSAVerifier(pk *ecdsa.PublicKey) *ecdsaVerifier

func NewSKIBasedSigner

func NewSKIBasedSigner(csp bccsp.BCCSP, ski []byte, pk crypto.PublicKey) (crypto.Signer, error)

NewSKIBasedSigner returns a new SKIBasedSigner

func PemDecodeCert

func PemDecodeCert(pemBytes []byte) (*x509.Certificate, error)

func PemDecodeKey

func PemDecodeKey(keyBytes []byte) (interface{}, error)

PemDecodeKey takes bytes and returns a Go key

func SerializeIdentity

func SerializeIdentity(conf *Config) ([]byte, error)

func ToPKCS11OptsOpts

func ToPKCS11OptsOpts(o *PKCS11) *pkcs11.PKCS11Opts

Types

type BCCSP

type BCCSP struct {
	Default string            `yaml:"Default,omitempty"`
	SW      *SoftwareProvider `yaml:"SW,omitempty"`
	PKCS11  *PKCS11           `yaml:"PKCS11,omitempty"`
}

func BCCSPOpts

func BCCSPOpts(defaultProvider string) (*BCCSP, error)

BCCSPOpts returns a `BCCSP` instance. `defaultProvider` sets the `Default` value of the BCCSP, that is denoting the which provider impl is used. `defaultProvider` currently supports `SW` and `PKCS11`.

func ToBCCSPOpts

func ToBCCSPOpts(boxed interface{}) (*BCCSP, error)

ToBCCSPOpts converts the passed opts to `config.BCCSP`

type Config

type Config = config.Config

func LoadConfig

func LoadConfig(dir string, keyStoreDirName string) (*Config, error)

func LoadConfigWithIdentityInfo

func LoadConfigWithIdentityInfo(signingIdentityInfo *SigningIdentityInfo) (*Config, error)

func RemovePrivateSigner

func RemovePrivateSigner(c *Config) (*Config, error)

func UnmarshalConfig

func UnmarshalConfig(data []byte) (*Config, error)

type CryptoConfig

type CryptoConfig = config.CryptoConfig

type ECDSASignature

type ECDSASignature struct {
	R, S *big.Int
}

type IdentityFactory

type IdentityFactory struct {
	SignatureHashFamily string
	// contains filtered or unexported fields
}

func NewIdentityFactory

func NewIdentityFactory(bccsp bccsp.BCCSP, signatureHashFamily string) *IdentityFactory

func (*IdentityFactory) GetFullIdentity

func (f *IdentityFactory) GetFullIdentity(sidInfo *SigningIdentityInfo) (*fullIdentity, error)

func (*IdentityFactory) GetIdentity

func (f *IdentityFactory) GetIdentity(sidInfo *SigningIdentityInfo) (*verifyingIdentity, error)

type KeyIDMapping

type KeyIDMapping struct {
	SKI string `yaml:"SKI,omitempty"`
	ID  string `yaml:"ID,omitempty"`
}

type KeyInfo

type KeyInfo = config.KeyInfo

type KeyStore

type KeyStore = bccsp.KeyStore

type Opts

type Opts struct {
	BCCSP *BCCSP `yaml:"BCCSP,omitempty"`
}

type PKCS11

type PKCS11 struct {
	// Default algorithms when not specified (Deprecated?)
	Security int    `yaml:"Security"`
	Hash     string `yaml:"Hash"`

	// PKCS11 options
	Library        string         `yaml:"Library"`
	Label          string         `yaml:"Label"`
	Pin            string         `yaml:"Pin"`
	SoftwareVerify bool           `yaml:"SoftwareVerify,omitempty"`
	Immutable      bool           `yaml:"Immutable,omitempty"`
	AltID          string         `yaml:"AltId,omitempty"`
	KeyIDs         []KeyIDMapping `yaml:"KeyIds,omitempty" mapstructure:"KeyIds"`
}

type SKIBasedSigner

type SKIBasedSigner struct {
	SKI []byte
	// contains filtered or unexported fields
}

SKIBasedSigner implements a crypto.Signer based on the bccsp

func (*SKIBasedSigner) Public

func (s *SKIBasedSigner) Public() crypto.PublicKey

Public returns the public key corresponding to the opaque, private key.

func (*SKIBasedSigner) Sign

func (s *SKIBasedSigner) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error)

Sign signs digest with the private key, possibly using entropy from rand. For an (EC)DSA key, it should be a DER-serialised, ASN.1 signature structure.

Hash implements the SignerOpts interface and, in most cases, one can simply pass in the hash function used as opts. Sign may also attempt to type assert opts to other types in order to obtain algorithm specific values. See the documentation in each package for details.

Note that when a signature of a hash of a larger message is needed, the caller is responsible for hashing the larger message and passing the hash (as digest) and the hash function (as opts) to Sign.

type SigningIdentityInfo

type SigningIdentityInfo = config.SigningIdentityInfo

type SoftwareProvider

type SoftwareProvider struct {
	Hash     string `yaml:"Hash,omitempty"`
	Security int    `yaml:"Security,omitempty"`
}

Directories

Path Synopsis
protos-go

Jump to

Keyboard shortcuts

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