sqlitepib

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cert

type Cert interface {
	AsSigner() ndn.Signer
	Name() enc.Name
	Key() Key
	Data() []byte
	// KeyLocator is the name of the key/certificate which signs this certificate
	KeyLocator() enc.Name
}

Cert represents a certificate one owns

type FileTpm

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

func (*FileTpm) DeleteKey

func (tpm *FileTpm) DeleteKey(keyName enc.Name)

(AI GENERATED DESCRIPTION): Deletes the key identified by `keyName` from the file‑based TPM, removing its stored key material and associated metadata.

func (*FileTpm) GenerateKey

func (tpm *FileTpm) GenerateKey(keyName enc.Name, keyType string, keySize uint64) enc.Buffer

(AI GENERATED DESCRIPTION): Generates a new cryptographic key of the given type and size, stores it in the file‑based TPM under the specified name, and returns the key’s encoded representation as an `enc.Buffer`.

func (*FileTpm) GetSigner

func (tpm *FileTpm) GetSigner(keyName enc.Name, keyLocatorName enc.Name) ndn.Signer

(AI GENERATED DESCRIPTION): Retrieves a signer for a given key name by reading, base64‑decoding, and parsing the private key file stored on disk (returning an RSA or EC signer if recognized).

func (*FileTpm) KeyExist

func (tpm *FileTpm) KeyExist(keyName enc.Name) bool

(AI GENERATED DESCRIPTION): Checks whether a key with the specified name exists in the FileTpm’s storage by verifying the presence of the corresponding file.

func (*FileTpm) String added in v1.4.3

func (tpm *FileTpm) String() string

(AI GENERATED DESCRIPTION): Returns a human‑readable string describing the FileTpm, formatted as “file‑tpm (<path>)”.

func (*FileTpm) ToFileName

func (tpm *FileTpm) ToFileName(keyNameBytes []byte) string

(AI GENERATED DESCRIPTION): Generates a deterministic filename for a private key by hashing the supplied key name bytes with SHA‑256 and appending the “.privkey” extension.

type Identity

type Identity interface {
	Name() enc.Name
	GetKey(enc.Name) Key
	FindCert(func(Cert) bool) Cert
}

Identity represents an identity one owns

type Key

type Key interface {
	Name() enc.Name
	Identity() Identity
	KeyBits() []byte
	SelfSignedCert() Cert
	GetCert(enc.Name) Cert
	FindCert(func(Cert) bool) Cert
}

Key represents a key one owns (with both private and public keybits)

type Pib

type Pib interface {
	Tpm() Tpm
	GetIdentity(name enc.Name) Identity
}

Pib is a storage storing all owned identities, keys and certificates.

type SqliteCert

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

func (*SqliteCert) AsSigner

func (cert *SqliteCert) AsSigner() ndn.Signer

(AI GENERATED DESCRIPTION): Returns an ndn.Signer that signs packets using the private key associated with this certificate.

func (*SqliteCert) Data

func (cert *SqliteCert) Data() []byte

(AI GENERATED DESCRIPTION): Returns the raw certificate bits stored in the SqliteCert.

func (*SqliteCert) Key

func (cert *SqliteCert) Key() Key

(AI GENERATED DESCRIPTION): Retrieves the Key associated with this certificate by dropping the last two components of its name and looking up the resulting key name in the PIB, returning nil if the name is too short.

func (*SqliteCert) KeyLocator

func (cert *SqliteCert) KeyLocator() enc.Name

(AI GENERATED DESCRIPTION): Returns the key‑locator name associated with this certificate.

func (*SqliteCert) Name

func (cert *SqliteCert) Name() enc.Name

(AI GENERATED DESCRIPTION): Returns the Name of the certificate stored in this SqliteCert.

type SqliteIdent

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

func (*SqliteIdent) FindCert

func (iden *SqliteIdent) FindCert(check func(Cert) bool) Cert

(AI GENERATED DESCRIPTION): Finds and returns the first certificate belonging to this identity that satisfies a given condition, searching all of its keys and delegating to each key’s FindCert, or nil if no match is found.

func (*SqliteIdent) GetKey

func (iden *SqliteIdent) GetKey(keyName enc.Name) Key

(AI GENERATED DESCRIPTION): Retrieves the Key object identified by `keyName` from the SqliteIdent’s persistent identity base (PIB).

func (*SqliteIdent) Name

func (iden *SqliteIdent) Name() enc.Name

(AI GENERATED DESCRIPTION): Returns the name stored in the SqliteIdent instance.

type SqliteKey

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

func (*SqliteKey) FindCert

func (key *SqliteKey) FindCert(check func(Cert) bool) Cert

(AI GENERATED DESCRIPTION): FindCert returns the first certificate linked to the key that satisfies the supplied predicate, or nil if no matching certificate exists.

func (*SqliteKey) GetCert

func (key *SqliteKey) GetCert(certName enc.Name) Cert

(AI GENERATED DESCRIPTION): Retrieves and returns the certificate identified by the given name from the underlying persistent identity base (PIB).

func (*SqliteKey) Identity

func (key *SqliteKey) Identity() Identity

(AI GENERATED DESCRIPTION): Retrieves the owning Identity for the key by removing its two‑byte key‑ID suffix from the key’s name and looking up that identity in the PIB; returns nil if the key name is too short.

func (*SqliteKey) KeyBits

func (key *SqliteKey) KeyBits() []byte

(AI GENERATED DESCRIPTION): Returns the raw key bits of the SqliteKey as a byte slice.

func (*SqliteKey) Name

func (key *SqliteKey) Name() enc.Name

(AI GENERATED DESCRIPTION): Retrieves and returns the name associated with this SqliteKey instance.

func (*SqliteKey) SelfSignedCert

func (key *SqliteKey) SelfSignedCert() Cert

(AI GENERATED DESCRIPTION): Retrieves the first certificate stored under the key whose name contains the component “self” as the second‑to‑last component, indicating it is a self‑signed cert.

type SqlitePib

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

func NewSqlitePib

func NewSqlitePib(path string, tpm Tpm) *SqlitePib

(AI GENERATED DESCRIPTION): Initializes a new SqlitePib instance by opening the specified SQLite database and associating it with the provided TPM.

func (*SqlitePib) GetCert

func (pib *SqlitePib) GetCert(certName enc.Name) Cert

(AI GENERATED DESCRIPTION): Retrieves the certificate with the given name from the SQLite PIB database, parses its stored data to extract the certificate and signer key, and returns a Cert object populated with this information (or nil if not found or invalid).

func (*SqlitePib) GetIdentity

func (pib *SqlitePib) GetIdentity(name enc.Name) Identity

(AI GENERATED DESCRIPTION): Retrieves an identity from the PIB database by its name, returning a `SqliteIdent` instance if a matching record exists, otherwise nil.

func (*SqlitePib) GetKey

func (pib *SqlitePib) GetKey(keyName enc.Name) Key

(AI GENERATED DESCRIPTION): Retrieves a key from the SQLite PIB by name, returning a Key instance or nil if the key is missing or an error occurs.

func (*SqlitePib) GetSignerForCert

func (pib *SqlitePib) GetSignerForCert(certName enc.Name) ndn.Signer

(AI GENERATED DESCRIPTION): Retrieves a Signer for the given certificate name from the TPM, returning nil if the name has fewer than two components.

func (*SqlitePib) String added in v1.4.3

func (pib *SqlitePib) String() string

(AI GENERATED DESCRIPTION): Returns a string identifier for the SqlitePib implementation, i.e., `"sqlite-pib"`.

func (*SqlitePib) Tpm

func (pib *SqlitePib) Tpm() Tpm

(AI GENERATED DESCRIPTION): Returns the TPM instance used by the SqlitePib.

type Tpm

type Tpm interface {
	GetSigner(keyName enc.Name, keyLocatorName enc.Name) ndn.Signer
	GenerateKey(keyName enc.Name, keyType string, keySize uint64) enc.Buffer
	KeyExist(keyName enc.Name) bool
	DeleteKey(keyName enc.Name)
}

Tpm is a sceure storage that holds the private key

func NewFileTpm

func NewFileTpm(path string) Tpm

(AI GENERATED DESCRIPTION): Creates a new FileTpm instance initialized with the specified file path.

Jump to

Keyboard shortcuts

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