diff --git a/proto/signer.pb.go b/proto/signer.pb.go index ce30950610..c7ccd824ff 100644 --- a/proto/signer.pb.go +++ b/proto/signer.pb.go @@ -94,8 +94,9 @@ func (m *PublicKey) GetKeyInfo() *KeyInfo { // Signature specifies a KeyInfo that was used for signing and signed content type Signature struct { - KeyInfo *KeyInfo `protobuf:"bytes,1,opt,name=keyInfo" json:"keyInfo,omitempty"` - Content []byte `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` + KeyInfo *KeyInfo `protobuf:"bytes,1,opt,name=keyInfo" json:"keyInfo,omitempty"` + Algorithm *Algorithm `protobuf:"bytes,2,opt,name=algorithm" json:"algorithm,omitempty"` + Content []byte `protobuf:"bytes,3,opt,name=content,proto3" json:"content,omitempty"` } func (m *Signature) Reset() { *m = Signature{} } @@ -109,6 +110,13 @@ func (m *Signature) GetKeyInfo() *KeyInfo { return nil } +func (m *Signature) GetAlgorithm() *Algorithm { + if m != nil { + return m.Algorithm + } + return nil +} + // SignatureRequests specifies a KeyInfo, and content to be signed type SignatureRequest struct { KeyID *KeyID `protobuf:"bytes,1,opt,name=keyID" json:"keyID,omitempty"` diff --git a/proto/signer.proto b/proto/signer.proto index 65ae950ff8..5278bc26cb 100644 --- a/proto/signer.proto +++ b/proto/signer.proto @@ -46,7 +46,8 @@ message PublicKey { // Signature specifies a KeyInfo that was used for signing and signed content message Signature { KeyInfo keyInfo = 1; - bytes content = 2; + Algorithm algorithm = 2; + bytes content = 3; } // SignatureRequests specifies a KeyInfo, and content to be signed diff --git a/signer/api/rpc_api.go b/signer/api/rpc_api.go index af72f62933..49f31b1953 100644 --- a/signer/api/rpc_api.go +++ b/signer/api/rpc_api.go @@ -113,7 +113,8 @@ func (s *SignerServer) Sign(ctx context.Context, sr *pb.SignatureRequest) (*pb.S KeyID: &pb.KeyID{ID: tufKey.ID()}, Algorithm: &pb.Algorithm{Algorithm: tufKey.Algorithm().String()}, }, - Content: signatures[0].Signature, + Algorithm: &pb.Algorithm{Algorithm: signatures[0].Method.String()}, + Content: signatures[0].Signature, } return signature, nil diff --git a/signer/api/rsa_hardware_crypto_service.go b/signer/api/rsa_hardware_crypto_service.go index c0355ae0b5..177695b63e 100644 --- a/signer/api/rsa_hardware_crypto_service.go +++ b/signer/api/rsa_hardware_crypto_service.go @@ -113,7 +113,11 @@ func (s *RSAHardwareCryptoService) RemoveKey(keyID string) error { // GetKey returns the public components of a particular key func (s *RSAHardwareCryptoService) GetKey(keyID string) data.PublicKey { - return s.keys[keyID] + key, ok := s.keys[keyID] + if !ok { + return nil + } + return key } // Sign returns a signature for a given signature request diff --git a/signer/signer_trust.go b/signer/signer_trust.go index d5856c1de3..5824b299c2 100644 --- a/signer/signer_trust.go +++ b/signer/signer_trust.go @@ -54,7 +54,7 @@ func (trust *NotarySigner) Sign(keyIDs []string, toSign []byte) ([]data.Signatur } signatures = append(signatures, data.Signature{ KeyID: sig.KeyInfo.KeyID.ID, - Method: data.SigAlgorithm(sig.KeyInfo.Algorithm.Algorithm), + Method: data.SigAlgorithm(sig.Algorithm.Algorithm), Signature: sig.Content, }) } diff --git a/trustmanager/x509utils.go b/trustmanager/x509utils.go index 5c2f5908b5..396bd052e0 100644 --- a/trustmanager/x509utils.go +++ b/trustmanager/x509utils.go @@ -365,7 +365,7 @@ func GenerateED25519Key(random io.Reader) (data.PrivateKey, error) { return nil, err } - logrus.Debugf("generated EDDSA key with keyID: %s", tufPrivKey.ID()) + logrus.Debugf("generated ED25519 key with keyID: %s", tufPrivKey.ID()) return tufPrivKey, nil }