manager

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 25 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PEMToPrivateKey

func PEMToPrivateKey(raw []byte, pwd []byte) (interface{}, error)

PEMToPrivateKey converts a PEM encoded private key to a *ecdsa.PrivateKey

func PullCrypto

func PullCrypto(manager *VaultManager, vaultPath string, keyname string) error

PullCrypto pulls crypto from Vault

func Reverse

func Reverse(s string) (result string)

Reverse reverses a string

Types

type CartridgeKey

type CartridgeKey struct {
	PrivKey *ecdsa.PrivateKey
	PubKey  *ecdsa.PublicKey
}

CartridgeKey is a core.Key wrapper for *ecdsa.PublicKey

func (*CartridgeKey) Bytes

func (k *CartridgeKey) Bytes() (raw []byte, err error)

Bytes converts this key to its byte representation.

func (*CartridgeKey) Private

func (k *CartridgeKey) Private() bool

Private returns true if this key is a private key, false otherwise.

func (*CartridgeKey) PublicKey

func (k *CartridgeKey) PublicKey() (core.Key, error)

PublicKey returns the corresponding public key part of an asymmetric public/private key pair.

func (*CartridgeKey) SKI

func (k *CartridgeKey) SKI() (ski []byte)

SKI returns the subject key identifier of this key.

func (*CartridgeKey) Symmetric

func (k *CartridgeKey) Symmetric() bool

Symmetric returns true if this key is a symmetric key, false otherwise.

type CartridgeSigningIdentity

type CartridgeSigningIdentity interface {
	Identifier() *msp.IdentityIdentifier
	Verify(msg []byte, sig []byte) error
	Serialize() ([]byte, error)
	EnrollmentCertificate() []byte
	Sign(msg []byte) ([]byte, error)
	PublicVersion() msp.Identity
	PrivateKey() core.Key
}

CartridgeSigningIdentity is an interface that provides access to the signing identity

type Manager

type Manager interface {
	Sign(digest []byte, ecdsaPrivateKey *ecdsa.PrivateKey, ecdsaPublicKey *ecdsa.PublicKey) ([]byte, error)
	Verify(digest, signature []byte, ecdsaPublicKey *ecdsa.PublicKey) error
	SigningIdentity() CartridgeSigningIdentity
	Cache() cryptocache.CryptoCache
}

Manager is responsible for sign/verify operations.

type Option

type Option func(c *VaultManager) error

Option is a function that configures a VaultManager

type SecretManager

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

SecretManager handles SecretManager operations

func NewSecretManager

func NewSecretManager(mspID, project, userCert, credsPath string) (*SecretManager, error)

func (*SecretManager) Cache

Cache returns cache

func (*SecretManager) Sign

func (sm *SecretManager) Sign(digest []byte, ecdsaPrivateKey *ecdsa.PrivateKey, ecdsaPublicKey *ecdsa.PublicKey) ([]byte, error)

Sign signs digest using ecdsaPrivateKey

func (*SecretManager) SigningIdentity

func (sm *SecretManager) SigningIdentity() CartridgeSigningIdentity

SigningIdentity returns signing identity

func (*SecretManager) Verify

func (sm *SecretManager) Verify(digest, signature []byte, ecdsaPublicKey *ecdsa.PublicKey) error

Verify verifies signature against digest using ecdsaPublicKey

type VaultIdentity

type VaultIdentity struct {
	MSPID   string        `protobuf:"bytes,1,opt,name=mspid,proto3" json:"mspid,omitempty"`
	IDBytes []byte        `protobuf:"bytes,2,opt,name=idBytes,proto3" json:"idBytes,omitempty"`
	Manager Manager       `json:"-"`
	Key     *CartridgeKey `json:"-"`
}

VaultIdentity is an interface that provides access to the identity

func (*VaultIdentity) EnrollmentCertificate

func (m *VaultIdentity) EnrollmentCertificate() []byte

EnrollmentCertificate Returns the underlying ECert representing this user’s identity.

func (*VaultIdentity) Identifier

func (m *VaultIdentity) Identifier() *msp.IdentityIdentifier

Identifier returns the identifier of that identity

func (*VaultIdentity) ProtoMessage

func (m *VaultIdentity) ProtoMessage()

ProtoMessage indicates the identity is Protobuf serializable

func (*VaultIdentity) Reset

func (m *VaultIdentity) Reset()

Reset resets struct

func (*VaultIdentity) Serialize

func (m *VaultIdentity) Serialize() ([]byte, error)

Serialize converts an identity to bytes

func (*VaultIdentity) String

func (m *VaultIdentity) String() string

String converts struct to string reprezentation

func (*VaultIdentity) Verify

func (m *VaultIdentity) Verify(msg []byte, sig []byte) error

Verify a signature over some message using this identity as reference

type VaultManager

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

VaultManager handles VaultManager operations

func NewVaultManager

func NewVaultManager(mspID, userCert, address, token, namespace string) (*VaultManager, error)

NewVaultManager gets new instance of VaultManager

func (*VaultManager) Cache

Cache returns the cache

func (*VaultManager) Sign

func (v *VaultManager) Sign(digest []byte, ecdsaPrivateKey *ecdsa.PrivateKey, ecdsaPublicKey *ecdsa.PublicKey) ([]byte, error)

Sign signs the digest

func (*VaultManager) SigningIdentity

func (v *VaultManager) SigningIdentity() CartridgeSigningIdentity

SigningIdentity returns the signing identity

func (*VaultManager) Verify

func (v *VaultManager) Verify(digest, signature []byte, ecdsaPublicKey *ecdsa.PublicKey) error

Verify verifies the signature

type VaultSigningIdentity

type VaultSigningIdentity struct {
	*VaultIdentity
}

VaultSigningIdentity represents singing identity using Manager

func NewVaultSigningIdentity

func NewVaultSigningIdentity(mspid, certname string, manager Manager) (*VaultSigningIdentity, error)

NewVaultSigningIdentity initializes VaultSigningIdentity

func (*VaultSigningIdentity) PrivateKey

func (m *VaultSigningIdentity) PrivateKey() core.Key

PrivateKey returns the crypto suite representation of the private key

func (*VaultSigningIdentity) PublicVersion

func (m *VaultSigningIdentity) PublicVersion() msp.Identity

PublicVersion returns the public parts of this identity

func (*VaultSigningIdentity) Sign

func (m *VaultSigningIdentity) Sign(msg []byte) ([]byte, error)

Sign the message

Jump to

Keyboard shortcuts

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