fixes for Diogo's comments

Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
This commit is contained in:
David Lawrence 2015-10-28 19:24:51 -07:00
parent ca7988d642
commit b7ce16ab6f
7 changed files with 9 additions and 9 deletions

View File

@ -33,7 +33,7 @@ func NewCryptoService(gun string, keyStore trustmanager.KeyStore) *CryptoService
} }
// Create is used to generate keys for targets, snapshots and timestamps // Create is used to generate keys for targets, snapshots and timestamps
func (ccs *CryptoService) Create(role string, algorithm string) (data.PublicKey, error) { func (ccs *CryptoService) Create(role, algorithm string) (data.PublicKey, error) {
var privKey data.PrivateKey var privKey data.PrivateKey
var err error var err error

View File

@ -220,7 +220,7 @@ func TestValidateSuccessfulRootRotation(t *testing.T) {
} }
} }
func testValidateSuccessfulRootRotation(t *testing.T, keyAlg string, rootKeyType string) { func testValidateSuccessfulRootRotation(t *testing.T, keyAlg, rootKeyType string) {
// Temporary directory where test files will be created // Temporary directory where test files will be created
tempBaseDir, err := ioutil.TempDir("", "notary-test-") tempBaseDir, err := ioutil.TempDir("", "notary-test-")
defer os.RemoveAll(tempBaseDir) defer os.RemoveAll(tempBaseDir)
@ -306,7 +306,7 @@ func TestValidateRootRotationMissingOrigSig(t *testing.T) {
} }
} }
func testValidateRootRotationMissingOrigSig(t *testing.T, keyAlg string, rootKeyType string) { func testValidateRootRotationMissingOrigSig(t *testing.T, keyAlg, rootKeyType string) {
// Temporary directory where test files will be created // Temporary directory where test files will be created
tempBaseDir, err := ioutil.TempDir("", "notary-test-") tempBaseDir, err := ioutil.TempDir("", "notary-test-")
defer os.RemoveAll(tempBaseDir) defer os.RemoveAll(tempBaseDir)
@ -389,7 +389,7 @@ func TestValidateRootRotationMissingNewSig(t *testing.T) {
} }
} }
func testValidateRootRotationMissingNewSig(t *testing.T, keyAlg string, rootKeyType string) { func testValidateRootRotationMissingNewSig(t *testing.T, keyAlg, rootKeyType string) {
// Temporary directory where test files will be created // Temporary directory where test files will be created
tempBaseDir, err := ioutil.TempDir("", "notary-test-") tempBaseDir, err := ioutil.TempDir("", "notary-test-")
defer os.RemoveAll(tempBaseDir) defer os.RemoveAll(tempBaseDir)

View File

@ -23,7 +23,7 @@ type RSAHardwareCryptoService struct {
} }
// Create creates a key and returns its public components // Create creates a key and returns its public components
func (s *RSAHardwareCryptoService) Create(role string, algo string) (data.PublicKey, error) { func (s *RSAHardwareCryptoService) Create(role, algo string) (data.PublicKey, error) {
// For now generate random labels for keys // For now generate random labels for keys
// (diogo): add link between keyID and label in database so we can support multiple keys // (diogo): add link between keyID and label in database so we can support multiple keys
randomLabel := make([]byte, 32) randomLabel := make([]byte, 32)

View File

@ -77,7 +77,7 @@ func (trust *NotarySigner) Sign(keyIDs []string, toSign []byte) ([]data.Signatur
} }
// Create creates a remote key and returns the PublicKey associated with the remote private key // Create creates a remote key and returns the PublicKey associated with the remote private key
func (trust *NotarySigner) Create(role string, algorithm string) (data.PublicKey, error) { func (trust *NotarySigner) Create(role, algorithm string) (data.PublicKey, error) {
publicKey, err := trust.kmClient.CreateKey(context.Background(), &pb.Algorithm{Algorithm: algorithm}) publicKey, err := trust.kmClient.CreateKey(context.Background(), &pb.Algorithm{Algorithm: algorithm})
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -50,7 +50,7 @@ func (e *Ed25519) Sign(keyIDs []string, toSign []byte) ([]data.Signature, error)
} }
// Create generates a new key and returns the public part // Create generates a new key and returns the public part
func (e *Ed25519) Create(role string, algorithm string) (data.PublicKey, error) { func (e *Ed25519) Create(role, algorithm string) (data.PublicKey, error) {
if algorithm != data.ED25519Key { if algorithm != data.ED25519Key {
return nil, errors.New("only ED25519 supported by this cryptoservice") return nil, errors.New("only ED25519 supported by this cryptoservice")
} }

View File

@ -20,7 +20,7 @@ type KeyService interface {
// the private key into the appropriate signing service. // the private key into the appropriate signing service.
// The role isn't currently used for anything, but it's here to support // The role isn't currently used for anything, but it's here to support
// future features // future features
Create(role string, algorithm string) (data.PublicKey, error) Create(role, algorithm string) (data.PublicKey, error)
// GetKey retrieves the public key if present, otherwise it returns nil // GetKey retrieves the public key if present, otherwise it returns nil
GetKey(keyID string) data.PublicKey GetKey(keyID string) data.PublicKey

View File

@ -29,7 +29,7 @@ func (mts *FailingCryptoService) Sign(keyIDs []string, _ []byte) ([]data.Signatu
return sigs, nil return sigs, nil
} }
func (mts *FailingCryptoService) Create(_ string, _ string) (data.PublicKey, error) { func (mts *FailingCryptoService) Create(_, _ string) (data.PublicKey, error) {
return mts.testKey, nil return mts.testKey, nil
} }