Esempio n. 1
0
func getEncrypted(key, keyring string, store backend.Store) ([]byte, error) {
	var (
		value    []byte
		passring keyctl.Keyring
		pkr      prompt.PassphraseKeyring
	)
	kr, err := os.Open(secretKeyring)
	if err != nil {
		return value, err
	}
	defer kr.Close()
	data, err := store.Get(key)
	if err != nil {
		return value, err
	}
	if passring, err = SessionKeyring(); err == nil {
		pkr = prompt.PassphraseKeyring{Keyring: passring}
	}

	if passring != nil {
		pkr.Prompt = prompt.NewPrompter(prompt.PassphrasePrompt)
		value, err = secconf.DecodeVia(data, kr, pkr)
	} else {
		value, err = secconf.Decode(data, kr)
	}
	if err != nil {
		return value, err
	}
	return value, err

}
Esempio n. 2
0
func getPlain(key string, store backend.Store) ([]byte, error) {
	var value []byte
	data, err := store.Get(key)
	if err != nil {
		return value, err
	}
	return data, err
}