updating wo make notary work with rufus again

Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
This commit is contained in:
David Lawrence 2015-07-08 09:36:22 -07:00 committed by Diogo Monica
parent 1d163650a3
commit 3bcc0e1d4d
4 changed files with 61 additions and 19 deletions

2
Godeps/Godeps.json generated
View File

@ -43,7 +43,7 @@
},
{
"ImportPath": "github.com/docker/rufus/proto",
"Rev": "61b53384b24bfa83e8e0a5f11f28ae83457fd80c"
"Rev": "7f61f678c264ae0a329f25cbaa8af6fd55ada7b6"
},
{
"ImportPath": "github.com/endophage/gotuf",

View File

@ -10,6 +10,7 @@ It is generated from these files:
It has these top-level messages:
KeyID
Algorithm
PublicKey
Signature
SignatureRequest
@ -40,10 +41,20 @@ func (m *KeyID) Reset() { *m = KeyID{} }
func (m *KeyID) String() string { return proto1.CompactTextString(m) }
func (*KeyID) ProtoMessage() {}
// PublicKey has a KeyID that is used to reference the key and opaque bytes of a publicKey
// Type holds the type of crypto algorithm used
type Algorithm struct {
Algorithm string `protobuf:"bytes,1,opt,name=algorithm" json:"algorithm,omitempty"`
}
func (m *Algorithm) Reset() { *m = Algorithm{} }
func (m *Algorithm) String() string { return proto1.CompactTextString(m) }
func (*Algorithm) ProtoMessage() {}
// PublicKey has a KeyID that is used to reference the key, the key type, and opaque bytes of a publicKey
type PublicKey struct {
KeyID *KeyID `protobuf:"bytes,1,opt,name=keyID" json:"keyID,omitempty"`
PublicKey []byte `protobuf:"bytes,2,opt,name=publicKey,proto3" json:"publicKey,omitempty"`
KeyID *KeyID `protobuf:"bytes,1,opt,name=keyID" json:"keyID,omitempty"`
Algorithm *Algorithm `protobuf:"bytes,2,opt,name=algorithm" json:"algorithm,omitempty"`
PublicKey []byte `protobuf:"bytes,3,opt,name=publicKey,proto3" json:"publicKey,omitempty"`
}
func (m *PublicKey) Reset() { *m = PublicKey{} }
@ -57,10 +68,18 @@ func (m *PublicKey) GetKeyID() *KeyID {
return nil
}
// Signature specifies a KeyID that was used for signing and signed content
func (m *PublicKey) GetAlgorithm() *Algorithm {
if m != nil {
return m.Algorithm
}
return nil
}
// Signature specifies a KeyID that was used for signing, the key type, and signed content
type Signature struct {
KeyID *KeyID `protobuf:"bytes,1,opt,name=keyID" json:"keyID,omitempty"`
Content []byte `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"`
KeyID *KeyID `protobuf:"bytes,1,opt,name=keyID" json:"keyID,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{} }
@ -74,10 +93,18 @@ func (m *Signature) GetKeyID() *KeyID {
return nil
}
// SignatureRequests specifies a KeyID for signing and content to be signed
func (m *Signature) GetAlgorithm() *Algorithm {
if m != nil {
return m.Algorithm
}
return nil
}
// SignatureRequests specifies a KeyID for signing, the type of signature requested, and content to be signed
type SignatureRequest struct {
KeyID *KeyID `protobuf:"bytes,1,opt,name=keyID" json:"keyID,omitempty"`
Content []byte `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"`
KeyID *KeyID `protobuf:"bytes,1,opt,name=keyID" json:"keyID,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 *SignatureRequest) Reset() { *m = SignatureRequest{} }
@ -91,6 +118,13 @@ func (m *SignatureRequest) GetKeyID() *KeyID {
return nil
}
func (m *SignatureRequest) GetAlgorithm() *Algorithm {
if m != nil {
return m.Algorithm
}
return nil
}
// Void represents an empty message type
type Void struct {
}

View File

@ -26,22 +26,30 @@ message KeyID {
string ID = 1;
}
// PublicKey has a KeyID that is used to reference the key and opaque bytes of a publicKey
// Type holds the type of crypto algorithm used
message Algorithm {
string algorithm = 1;
}
// PublicKey has a KeyID that is used to reference the key, the key type, and opaque bytes of a publicKey
message PublicKey {
KeyID keyID = 1;
bytes publicKey = 2;
Algorithm algorithm = 2;
bytes publicKey = 3;
}
// Signature specifies a KeyID that was used for signing and signed content
// Signature specifies a KeyID that was used for signing, the key type, and signed content
message Signature {
KeyID keyID = 1;
bytes content = 2;
Algorithm algorithm = 2;
bytes content = 3;
}
// SignatureRequests specifies a KeyID for signing and content to be signed
// SignatureRequests specifies a KeyID for signing, the type of signature requested, and content to be signed
message SignatureRequest {
KeyID keyID = 1;
bytes content = 2;
Algorithm algorithm = 2;
bytes content = 3;
}
// Void represents an empty message type

View File

@ -53,7 +53,7 @@ func (trust *RufusSigner) Sign(keyIDs []string, toSign []byte) ([]data.Signature
}
signatures = append(signatures, data.Signature{
KeyID: sig.KeyID.ID,
Method: sig.Algorithm,
Method: sig.Algorithm.Algorithm,
Signature: sig.Content,
})
}
@ -67,7 +67,7 @@ func (trust *RufusSigner) Create(role string) (*data.PublicKey, error) {
return nil, err
}
//TODO(mccauley): Update API to return algorithm and/or take it as a param
public := data.NewPublicKey(publicKey.Algorithm, publicKey.PublicKey)
public := data.NewPublicKey(publicKey.Algorithm.Algorithm, publicKey.PublicKey)
return public, nil
}
@ -81,7 +81,7 @@ func (trust *RufusSigner) PublicKeys(keyIDs ...string) (map[string]*data.PublicK
return nil, err
}
publicKeys[public.KeyID.ID] =
data.NewPublicKey(public.Algorithm, public.PublicKey)
data.NewPublicKey(public.Algorithm.Algorithm, public.PublicKey)
}
return publicKeys, nil
}