From 989bb27f06a7d22e9829d3565976d0ef8d310b4d Mon Sep 17 00:00:00 2001 From: Jarek Kowalski Date: Tue, 18 Jul 2017 10:07:51 +0200 Subject: [PATCH] renamed vault.Format to vault.VaultFormat in preparation for merging with repo --- cli/command_create.go | 4 ++-- vault/creds.go | 9 ++++----- vault/format.go | 2 +- vault/vault.go | 5 ++--- vault/vault_test.go | 2 +- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/cli/command_create.go b/cli/command_create.go index fd912d29e..86012bb89 100644 --- a/cli/command_create.go +++ b/cli/command_create.go @@ -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) diff --git a/vault/creds.go b/vault/creds.go index 7f364be45..426130d45 100644 --- a/vault/creds.go +++ b/vault/creds.go @@ -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 diff --git a/vault/format.go b/vault/format.go index 2d4cfecfd..6b999dafe 100644 --- a/vault/format.go +++ b/vault/format.go @@ -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"` diff --git a/vault/vault.go b/vault/vault.go index 7fd1bd0b5..6b3dc4624 100644 --- a/vault/vault.go +++ b/vault/vault.go @@ -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{ diff --git a/vault/vault_test.go b/vault/vault_test.go index 140f4c9eb..bd68770c7 100644 --- a/vault/vault_test.go +++ b/vault/vault_test.go @@ -56,7 +56,7 @@ func verifyVault(t *testing.T, vaultPath string, repoPath string) { return } - vaultFormat := &Format{ + vaultFormat := &VaultFormat{ EncryptionAlgorithm: "AES256_GCM", }