sss

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PLUGIN_NAME = "SSS"
View Source
var PluginTerminalUIProxy = &plugin.ClientUI{
	DisplayMessage: func(name, message string) error {
		err := controller.SendCommand("msg", []byte(message), true)
		if err != nil {
			return err
		}

		return nil
	},
	RequestValue: func(name, message string, _ bool) (s string, err error) {
		defer func() {
			if err != nil {
				msg := fmt.Sprintf("warn: could not read value for age-plugin-%s: %v", name, err)
				controller.SendCommand("msg", []byte(msg), true)
			}
		}()

		return controller.RequestValue(message, true)
	},
	Confirm: func(name, message, yes, no string) (choseYes bool, err error) {
		defer func() {
			if err != nil {
				msg := fmt.Sprintf("could not read value for age-plugin-%s: %v", name, err)
				controller.SendCommand("msg", []byte(msg), true)
			}
		}()

		command := "confirm " + b64.EncodeToString([]byte(yes))
		if no != "" {
			command += " "
			command += b64.EncodeToString([]byte(no))
		}

		controller.SendCommand(command, []byte(message), false)
		scanner := bufio.NewScanner(os.Stdin)
		err = controller.ProtocolHandler(scanner, func(command string, args []string, body []byte) (done bool, err error) {
			switch command {
			case "ok":
				if args[0] == b64.EncodeToString([]byte("yes")) {
					choseYes = true
					return true, nil
				}
				if args[0] == b64.EncodeToString([]byte("no")) {
					choseYes = false
					return true, nil
				}
				return false, fmt.Errorf("invalid confirmation value %s", args[0])
			case "fail":
				return false, errors.New("controller error")
			}

			return false, errors.New("did not receive expected response")
		})

		if err != nil {
			return false, err
		}

		return
	},
	WaitTimer: func(name string) {

	},
}

this client UI acts as a proxy between the main controller (age process) and the plugin for which age-plugin-sss is the controller.

Functions

func EncodeIdentity

func EncodeIdentity(identity *SSSIdentity) (identityStr string, err error)

func EncodeRecipient

func EncodeRecipient(policy *SSS) (recipientStr string, err error)

func EncodeStanza

func EncodeStanza(stanza *SSSStanza) (data []byte, err error)

func IdentityV1

func IdentityV1() error

func InspectFileHeader

func InspectFileHeader(filePath string) error

func RecipientV1

func RecipientV1() error

Types

type PrintIdFunction

type PrintIdFunction func(shareId int) string

type SSS

type SSS struct {
	Threshold int    `yaml:"threshold,omitempty" json:"t,omitempty"`
	Shares    []*SSS `yaml:"shares,omitempty"    json:"s,omitempty"`
	Recipient string `yaml:"recipient,omitempty" json:"r,omitempty"`
}

func ParsePolicyFromYamlFile

func ParsePolicyFromYamlFile(filePath string) (policy *SSS, err error)

func ParseRecipient

func ParseRecipient(recipientString string) (policy *SSS, err error)

func (*SSS) UnmarshalYAML

func (policy *SSS) UnmarshalYAML(unmarshal func(interface{}) error) error

func (*SSS) Wrap

func (policy *SSS) Wrap(fileKey []byte) (stanza *SSSStanza, err error)

type SSSIdentity

type SSSIdentity struct {
	Identities []*SSSIdentityItem `yaml:"identities" json:"ids"`
}

func ParseIdentity

func ParseIdentity(identityString string) (identity *SSSIdentity, err error)

func ParseIdentityFromYamlFile

func ParseIdentityFromYamlFile(filePath string) (identity *SSSIdentity, err error)

type SSSIdentityItem

type SSSIdentityItem struct {
	ShareId     int          `yaml:"share_id,omitempty"  json:"sid,omitempty"`
	IdentityStr string       `yaml:"identity"            json:"i"`
	Identity    age.Identity `yaml:"-"                   json:"-"`
}

func (*SSSIdentityItem) UnmarshalYAML

func (identityItem *SSSIdentityItem) UnmarshalYAML(unmarshal func(interface{}) error) error

type SSSStanza

type SSSStanza struct {
	Version   int           `json:"v"`
	Threshold int           `json:"t,omitempty"`
	Shares    []*SSSStanza  `json:"s,omitempty"`
	Stanza    []*age.Stanza `json:"k,omitempty"`
	ShamirX   byte          `json:"x,omitempty"`

	// exclude from stanza data, only used for decryption
	ShareId  int    `json:"-"`
	KeyShare []byte `json:"-"`
}

func ParseStanza

func ParseStanza(stanzaData []byte) (stanza *SSSStanza, err error)

func (*SSSStanza) Marshal

func (stanza *SSSStanza) Marshal() (data []byte, err error)

func (*SSSStanza) PrintTree

func (stanza *SSSStanza) PrintTree()

func (*SSSStanza) Unwrap

func (stanza *SSSStanza) Unwrap(identity *SSSIdentity) (data []byte, err error)

Jump to

Keyboard shortcuts

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