identity

package
v0.10.5 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: MIT Imports: 18 Imported by: 12

Documentation

Overview

Package access contains structs for storing chaincode access control information

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMSPIdentifierNotEqual occurs when msp id did not match
	ErrMSPIdentifierNotEqual = errors.New(`msp identifier not equal`)

	ErrSubjectNotEqual = errors.New(`certificate subject not equal`)
	ErrIssuerNotEqual  = errors.New(`certificate issuer not equal`)
)
View Source
var (
	ErrInvalidPEMStructure = errors.New(`invalid pem structure`)

	// ErrPemEncodedExpected pem format error
	ErrPemEncodedExpected = errors.New("expecting a PEM-encoded X509 certificate; PEM block not found")
)

Functions

func CertEqual added in v0.7.8

func CertEqual(cert1, cert2 SubjectIssuer) error

CertEqual checks certificate equality

func CertSubjEqual added in v0.6.4

func CertSubjEqual(a, b []byte) (bool, error)

func Certificate

func Certificate(c []byte) (cert *x509.Certificate, err error)

Certificate decode and parse .pem []byte x509 certificate structure

func Equal added in v0.8.2

func Equal(identity1, identity2 IdentityAttrs) error

Equal checks identity attributes (Msp id, cert subject and cert issuer) equality

func GetDN

func GetDN(name *pkix.Name) string

GetDN (distinguished name) associated with a pkix.Name. NOTE: This code is almost a direct copy of the String() function in https://go-review.googlesource.com/c/go/+/67270/1/src/crypto/x509/pkix/pkix.go#26 which returns a DN as defined by RFC 2253.

func ID

func ID(subject, issuer string) string

ID returns identifier from .509 certificate and base64 encode

func IDByCert

func IDByCert(cert *x509.Certificate) string

IDByCert returns id by certificate subject and issuer

func IDRaw

func IDRaw(subject, issuer string) string

IDRaw generates string identifier from .509 certificate

func MarshalPublicKey added in v0.10.5

func MarshalPublicKey(publicKey interface{}) []byte

func PrivateKey added in v0.6.4

func PrivateKey(keyBytes []byte) (*ecdsa.PrivateKey, error)

Types

type CertIdentity

type CertIdentity struct {
	MspID string
	Cert  *x509.Certificate
}

CertIdentity structs holds data of tx creator

func FromSerialized

func FromSerialized(s protomsp.SerializedIdentity) (ci *CertIdentity, err error)

FromSerialized converts msp.SerializedIdentity struct to Identity interface{}

func FromStub

func FromStub(stub shim.ChaincodeStubInterface) (*CertIdentity, error)

FromStub creates Identity interface from tx creator mspID and certificate (stub.GetCreator)

func New

func New(mspID string, certPEM []byte) (ci *CertIdentity, err error)

New creates CertIdentity struct from an mspID and certificate

func (CertIdentity) Anonymous added in v0.6.4

func (ci CertIdentity) Anonymous() bool

func (CertIdentity) ExpiresAt added in v0.6.4

func (ci CertIdentity) ExpiresAt() time.Time

func (CertIdentity) GetID

func (ci CertIdentity) GetID() string

GetID get id based in certificate subject and issuer

func (CertIdentity) GetIdentifier added in v0.6.4

func (ci CertIdentity) GetIdentifier() *msp.IdentityIdentifier

func (CertIdentity) GetIssuer

func (ci CertIdentity) GetIssuer() string

GetIssuer returns invoker's certificate issuer

func (CertIdentity) GetMSPIdentifier added in v0.6.4

func (ci CertIdentity) GetMSPIdentifier() string

func (CertIdentity) GetOrganizationalUnits added in v0.6.4

func (ci CertIdentity) GetOrganizationalUnits() []*msp.OUIdentifier

func (CertIdentity) GetPEM

func (ci CertIdentity) GetPEM() []byte

GetPEM certificate encoded to PEM

func (CertIdentity) GetPublicKey

func (ci CertIdentity) GetPublicKey() interface{}

func (CertIdentity) GetPublicVersion added in v0.6.4

func (ci CertIdentity) GetPublicVersion() msp.Identity

func (CertIdentity) GetSubject

func (ci CertIdentity) GetSubject() string

GetSubject returns invoker's certificate subject

func (CertIdentity) SatisfiesPrincipal added in v0.6.4

func (ci CertIdentity) SatisfiesPrincipal(principal *protomsp.MSPPrincipal) error

func (CertIdentity) Serialize added in v0.6.4

func (ci CertIdentity) Serialize() ([]byte, error)

func (CertIdentity) Sign added in v0.6.4

func (ci CertIdentity) Sign(msg []byte) ([]byte, error)

func (CertIdentity) ToBytes

func (ci CertIdentity) ToBytes() ([]byte, error)

ToBytes converts to serializedIdentity and then to json

func (CertIdentity) ToSerialized

func (ci CertIdentity) ToSerialized() *protomsp.SerializedIdentity

ToSerialized converts CertIdentity to *msp.SerializedIdentity

func (CertIdentity) Validate added in v0.6.4

func (ci CertIdentity) Validate() error

func (CertIdentity) Verify added in v0.6.4

func (ci CertIdentity) Verify(msg []byte, sig []byte) error

type Entry

type Entry struct {
	MSPId   string
	Subject string
	Issuer  string
	PEM     []byte
	Cert    *x509.Certificate `json:"-"` // temporary cert
}

Entry structure for storing identity information string representation certificate Subject and Issuer can be used for reach query searching

func CreateEntry

func CreateEntry(i Identity) (g *Entry, err error)

CreateEntry creates IdentityEntry structure from an identity interface

func EntryFromSerialized

func EntryFromSerialized(s protomsp.SerializedIdentity) (g *Entry, err error)

EntryFromSerialized creates Entry from SerializedEntry

func EntryFromStub

func EntryFromStub(stub shim.ChaincodeStubInterface) (g *Entry, err error)

func (Entry) GetID

func (e Entry) GetID() string

GetID identifier by certificate subject and issuer

func (Entry) GetIdentityEntry

func (e Entry) GetIdentityEntry() Entry

func (Entry) GetIssuer

func (e Entry) GetIssuer() string

GetIssuer certificate issuer

func (Entry) GetMSPID deprecated

func (e Entry) GetMSPID() string

Deprecated: use GetMSPIdentifier GetMSPID membership service provider identifier

func (Entry) GetMSPIdentifier added in v0.8.2

func (e Entry) GetMSPIdentifier() string

func (Entry) GetPEM

func (e Entry) GetPEM() []byte

GetPK certificate issuer

func (Entry) GetPublicKey

func (e Entry) GetPublicKey() interface{}

func (Entry) GetSubject

func (e Entry) GetSubject() string

GetSubject certificate subject

func (Entry) Is

func (e Entry) Is(id Identity) bool

Is checks IdentityEntry is equal to an other Identity

type Id

type Id struct {
	MSP  string
	Cert string
}

Id structure defines short id representation

type Identity

type Identity interface {
	msp.Identity

	// GetSubject string representation of X.509 cert subject
	GetSubject() string
	// GetIssuer string representation of X.509 cert issuer
	GetIssuer() string

	// GetPublicKey *rsa.PublicKey or *dsa.PublicKey or *ecdsa.PublicKey:
	GetPublicKey() interface{}
	GetPEM() []byte
}

Identity interface for invoker (tx creator) and grants, stored in chain code state

type IdentityAttrs added in v0.8.2

type IdentityAttrs interface {
	SubjectIssuer
	GetMSPIdentifier() string
}

type IdentityEntry

type IdentityEntry interface {
	GetIdentityEntry() Entry
}

IdentityEntry interface

type SubjectIssuer added in v0.7.8

type SubjectIssuer interface {
	GetSubject() string
	GetIssuer() string
}

Jump to

Keyboard shortcuts

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