renamed vault.Format to vault.VaultFormat in preparation for merging with repo

This commit is contained in:
Jarek Kowalski committed 2017-08-01 08:29:41 +02:00
1 parent dd7f78468d
commit 989bb27f06
5 files changed
+10 -12

No files matched your search

+2 -2
View File
@@ -30,8 +30,8 @@ func init() {
createCommand.Action(runCreateCommand)
}
func vaultFormat() (*vault.Format, error) {
f := &vault.Format{
func vaultFormat() (*vault.VaultFormat, error) {
f := &vault.VaultFormat{
Version: "1",
}
f.UniqueID = make([]byte, 32)
+4 -5
View File
@@ -4,9 +4,8 @@ import (
"crypto/sha256"
"fmt"
"golang.org/x/crypto/scrypt"
"golang.org/x/crypto/pbkdf2"
"golang.org/x/crypto/scrypt"
)
const (
@@ -29,14 +28,14 @@ var SupportedKeyAlgorithms = []string{
// Credentials encapsulates credentials used to encrypt a Vault.
type Credentials interface {
getMasterKey(f *Format) ([]byte, error)
getMasterKey(f *VaultFormat) ([]byte, error)
}
type masterKeyCredentials struct {
key []byte
}
func (mkc *masterKeyCredentials) getMasterKey(f *Format) ([]byte, error) {
func (mkc *masterKeyCredentials) getMasterKey(f *VaultFormat) ([]byte, error) {
return mkc.key, nil
}
@@ -53,7 +52,7 @@ type passwordCredentials struct {
password string
}
func (pc *passwordCredentials) getMasterKey(f *Format) ([]byte, error) {
func (pc *passwordCredentials) getMasterKey(f *VaultFormat) ([]byte, error) {
switch f.KeyAlgorithm {
case "pbkdf2-sha256-100000":
return pbkdf2.Key([]byte(pc.password), f.UniqueID, 100000, passwordBasedKeySize, sha256.New), nil
+1 -1
View File
@@ -2,7 +2,7 @@ package vault
// Format describes the format of a Vault.
// Contents of this structure are serialized in plain text in the Vault storage.
type Format struct {
type VaultFormat struct {
Version string `json:"version"`
UniqueID []byte `json:"uniqueID"`
KeyAlgorithm string `json:"keyAlgo"`
+2 -3
View File
@@ -45,7 +45,7 @@ var SupportedEncryptionAlgorithms = []string{
// Vault is a secure storage for secrets such as repository object identifiers.
type Vault struct {
storage blob.Storage
format Format
format VaultFormat
RepoConfig RepositoryConfig
masterKey []byte
@@ -236,8 +236,7 @@ func (v *Vault) RemoveMany(itemIDs []string) error {
// Create initializes a Vault attached to the specified repository.
func Create(
vaultStorage blob.Storage,
vaultFormat *Format,
vaultCreds Credentials,
vaultFormat *VaultFormat, vaultCreds Credentials,
repoFormat *repo.Format,
) (*Vault, error) {
v := Vault{
+1 -1
View File
@@ -56,7 +56,7 @@ func verifyVault(t *testing.T, vaultPath string, repoPath string) {
return
}
vaultFormat := &Format{
vaultFormat := &VaultFormat{
EncryptionAlgorithm: "AES256_GCM",
}