secrets

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package secrets manages secret keys used in onion clients and servers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientKeyPair

type ClientKeyPair struct {
	Public  []byte `json:"public"`
	Private []byte `json:"private"`
}

ClientKeyPair represents an x25519 key pair used for client authorization.

type ClientPublic

type ClientPublic struct {
	Identity string `json:"identity"`
}

ClientPublic represents a client public key identity, that can be authorized to access onion services.

type ClientsPublic

type ClientsPublic map[string]ClientPublic

ClientsPublic represent client public key identities that can be authorized to access onion services.

type Secrets

type Secrets struct {
	Version     string                   `json:"version"`
	ServiceKeys map[string][]byte        `json:"serviceKeys"`
	ClientKeys  map[string]ClientKeyPair `json:"clientKeys"`
	// contains filtered or unexported fields
}

Secrets represents the format for storing onionpipe secret keys.

func ReadFile

func ReadFile(path string) (*Secrets, error)

ReadFile reads secrets from the given path.

func (*Secrets) ClientsPublic

func (s *Secrets) ClientsPublic() ClientsPublic

ClientsPublic returns public key information about the client identities held in this secret store. Clients' public keys would be shared with the operator of an authenticated onion service, for granting exclusive access to these key identities.

func (*Secrets) EnsureClientKey

func (s *Secrets) EnsureClientKey(name string) (ClientKeyPair, error)

EnsureClientKey returns the client private key for the given alias name, generating a new one if it did not exist.

func (*Secrets) EnsureServiceKey

func (s *Secrets) EnsureServiceKey(name string) ([]byte, error)

EnsureServiceKey returns the service private key for the given alias name, generating a new one if it did not exist.

func (*Secrets) RemoveClientKey

func (s *Secrets) RemoveClientKey(name string) error

RemoveClientKey removes the client private key for the given alias name.

func (*Secrets) RemoveServiceKey

func (s *Secrets) RemoveServiceKey(name string) error

RemoveServiceKey removes the service private key for the given alias name.

func (*Secrets) ResolveClientPrivateKey

func (s *Secrets) ResolveClientPrivateKey(nameOrKey string) ([]byte, error)

ResolveClientPrivateKey returns the x25519 client authorization private key for the given identity name, or base32-encoded private key representation.

func (*Secrets) ServicesPublic

func (s *Secrets) ServicesPublic() ServicesPublic

ServicesPublic returns public key information about the service keys.

func (*Secrets) WriteFile

func (s *Secrets) WriteFile() error

WriteFile writes the secrets to the path from where they were read from, if they have changed.

type ServicePublic

type ServicePublic struct {
	Address string `json:"address"`
}

ServicePublic represents public key information about a service.

type ServicesPublic

type ServicesPublic map[string]ServicePublic

ServicesPublic represent public key information about services.

Jump to

Keyboard shortcuts

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