mirror of https://github.com/docker/docs.git
Merge pull request #578 from endophage/go1.6
updates and bugfixes for go 1.6
This commit is contained in:
commit
332fc35dc5
22
Makefile
22
Makefile
|
@ -42,14 +42,6 @@ GO_VERSION = $(shell go version | awk '{print $$3}')
|
||||||
.DELETE_ON_ERROR: cover
|
.DELETE_ON_ERROR: cover
|
||||||
.DEFAULT: default
|
.DEFAULT: default
|
||||||
|
|
||||||
go_version:
|
|
||||||
ifeq (,$(findstring go1.5.,$(GO_VERSION)))
|
|
||||||
$(error Requires go version 1.5.x - found $(GO_VERSION))
|
|
||||||
else
|
|
||||||
@echo
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
all: AUTHORS clean fmt vet fmt lint build test binaries
|
all: AUTHORS clean fmt vet fmt lint build test binaries
|
||||||
|
|
||||||
AUTHORS: .git/HEAD
|
AUTHORS: .git/HEAD
|
||||||
|
@ -87,7 +79,7 @@ ${PREFIX}/bin/static/notary-signer: NOTARY_VERSION $(shell find . -type f -name
|
||||||
@godep go build -tags ${NOTARY_BUILDTAGS} -o $@ ${GO_LDFLAGS_STATIC} ./cmd/notary-signer
|
@godep go build -tags ${NOTARY_BUILDTAGS} -o $@ ${GO_LDFLAGS_STATIC} ./cmd/notary-signer
|
||||||
endif
|
endif
|
||||||
|
|
||||||
vet: go_version
|
vet:
|
||||||
@echo "+ $@"
|
@echo "+ $@"
|
||||||
ifeq ($(shell uname -s), Darwin)
|
ifeq ($(shell uname -s), Darwin)
|
||||||
@test -z "$(shell find . -iname *test*.go | grep -v _test.go | grep -v Godeps | xargs echo "This file should end with '_test':" | tee /dev/stderr)"
|
@test -z "$(shell find . -iname *test*.go | grep -v _test.go | grep -v Godeps | xargs echo "This file should end with '_test':" | tee /dev/stderr)"
|
||||||
|
@ -114,14 +106,14 @@ misspell:
|
||||||
@echo "+ $@"
|
@echo "+ $@"
|
||||||
@test -z "$$(find . -name '*' | grep -v Godeps/_workspace/src/ | grep -v bin/ | grep -v misc/ | grep -v .git/ | xargs misspell | tee /dev/stderr)"
|
@test -z "$$(find . -name '*' | grep -v Godeps/_workspace/src/ | grep -v bin/ | grep -v misc/ | grep -v .git/ | xargs misspell | tee /dev/stderr)"
|
||||||
|
|
||||||
build: go_version
|
build:
|
||||||
@echo "+ $@"
|
@echo "+ $@"
|
||||||
@go build -tags "${NOTARY_BUILDTAGS}" -v ${GO_LDFLAGS} ./...
|
@go build -tags "${NOTARY_BUILDTAGS}" -v ${GO_LDFLAGS} ./...
|
||||||
|
|
||||||
# When running `go test ./...`, it runs all the suites in parallel, which causes
|
# When running `go test ./...`, it runs all the suites in parallel, which causes
|
||||||
# problems when running with a yubikey
|
# problems when running with a yubikey
|
||||||
test: TESTOPTS =
|
test: TESTOPTS =
|
||||||
test: go_version
|
test:
|
||||||
@echo Note: when testing with a yubikey plugged in, make sure to include 'TESTOPTS="-p 1"'
|
@echo Note: when testing with a yubikey plugged in, make sure to include 'TESTOPTS="-p 1"'
|
||||||
@echo "+ $@ $(TESTOPTS)"
|
@echo "+ $@ $(TESTOPTS)"
|
||||||
@echo
|
@echo
|
||||||
|
@ -147,7 +139,7 @@ define gocover
|
||||||
$(GO_EXC) test $(OPTS) $(TESTOPTS) -covermode="$(COVERMODE)" -coverprofile="$(COVERDIR)/$(subst /,-,$(1)).$(subst $(_space),.,$(NOTARY_BUILDTAGS)).coverage.txt" "$(1)" || exit 1;
|
$(GO_EXC) test $(OPTS) $(TESTOPTS) -covermode="$(COVERMODE)" -coverprofile="$(COVERDIR)/$(subst /,-,$(1)).$(subst $(_space),.,$(NOTARY_BUILDTAGS)).coverage.txt" "$(1)" || exit 1;
|
||||||
endef
|
endef
|
||||||
|
|
||||||
gen-cover: go_version
|
gen-cover:
|
||||||
@mkdir -p "$(COVERDIR)"
|
@mkdir -p "$(COVERDIR)"
|
||||||
$(foreach PKG,$(PKGS),$(call gocover,$(PKG)))
|
$(foreach PKG,$(PKGS),$(call gocover,$(PKG)))
|
||||||
rm -f "$(COVERDIR)"/*testutils*.coverage.txt
|
rm -f "$(COVERDIR)"/*testutils*.coverage.txt
|
||||||
|
@ -176,10 +168,10 @@ covmerge:
|
||||||
clean-protos:
|
clean-protos:
|
||||||
@rm proto/*.pb.go
|
@rm proto/*.pb.go
|
||||||
|
|
||||||
binaries: go_version ${PREFIX}/bin/notary-server ${PREFIX}/bin/notary ${PREFIX}/bin/notary-signer
|
binaries: ${PREFIX}/bin/notary-server ${PREFIX}/bin/notary ${PREFIX}/bin/notary-signer
|
||||||
@echo "+ $@"
|
@echo "+ $@"
|
||||||
|
|
||||||
static: go_version ${PREFIX}/bin/static/notary-server ${PREFIX}/bin/static/notary-signer
|
static: ${PREFIX}/bin/static/notary-server ${PREFIX}/bin/static/notary-signer
|
||||||
@echo "+ $@"
|
@echo "+ $@"
|
||||||
|
|
||||||
define template
|
define template
|
||||||
|
@ -187,7 +179,7 @@ mkdir -p ${PREFIX}/cross/$(1)/$(2);
|
||||||
GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build -o ${PREFIX}/cross/$(1)/$(2)/notary -a -tags "static_build netgo" -installsuffix netgo ${GO_LDFLAGS_STATIC} ./cmd/notary;
|
GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build -o ${PREFIX}/cross/$(1)/$(2)/notary -a -tags "static_build netgo" -installsuffix netgo ${GO_LDFLAGS_STATIC} ./cmd/notary;
|
||||||
endef
|
endef
|
||||||
|
|
||||||
cross: go_version
|
cross:
|
||||||
$(foreach GOARCH,$(GOARCHS),$(foreach GOOS,$(GOOSES),$(call template,$(GOOS),$(GOARCH))))
|
$(foreach GOARCH,$(GOARCHS),$(foreach GOOS,$(GOOSES),$(call template,$(GOOS),$(GOARCH))))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ machine:
|
||||||
|
|
||||||
post:
|
post:
|
||||||
# Install many go versions
|
# Install many go versions
|
||||||
- gvm install go1.5.1 -B --name=stable
|
- gvm install go1.6 -B --name=stable
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
# Convenient shortcuts to "common" locations
|
# Convenient shortcuts to "common" locations
|
||||||
|
|
|
@ -46,7 +46,7 @@ type Keys map[string]PublicKey
|
||||||
|
|
||||||
// UnmarshalJSON implements the json.Unmarshaller interface
|
// UnmarshalJSON implements the json.Unmarshaller interface
|
||||||
func (ks *Keys) UnmarshalJSON(data []byte) error {
|
func (ks *Keys) UnmarshalJSON(data []byte) error {
|
||||||
parsed := make(map[string]tufKey)
|
parsed := make(map[string]TUFKey)
|
||||||
err := json.Unmarshal(data, &parsed)
|
err := json.Unmarshal(data, &parsed)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -64,7 +64,7 @@ type KeyList []PublicKey
|
||||||
|
|
||||||
// UnmarshalJSON implements the json.Unmarshaller interface
|
// UnmarshalJSON implements the json.Unmarshaller interface
|
||||||
func (ks *KeyList) UnmarshalJSON(data []byte) error {
|
func (ks *KeyList) UnmarshalJSON(data []byte) error {
|
||||||
parsed := make([]tufKey, 0, 1)
|
parsed := make([]TUFKey, 0, 1)
|
||||||
err := json.Unmarshal(data, &parsed)
|
err := json.Unmarshal(data, &parsed)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -86,64 +86,64 @@ func (ks KeyList) IDs() []string {
|
||||||
return keyIDs
|
return keyIDs
|
||||||
}
|
}
|
||||||
|
|
||||||
func typedPublicKey(tk tufKey) PublicKey {
|
func typedPublicKey(tk TUFKey) PublicKey {
|
||||||
switch tk.Algorithm() {
|
switch tk.Algorithm() {
|
||||||
case ECDSAKey:
|
case ECDSAKey:
|
||||||
return &ECDSAPublicKey{tufKey: tk}
|
return &ECDSAPublicKey{TUFKey: tk}
|
||||||
case ECDSAx509Key:
|
case ECDSAx509Key:
|
||||||
return &ECDSAx509PublicKey{tufKey: tk}
|
return &ECDSAx509PublicKey{TUFKey: tk}
|
||||||
case RSAKey:
|
case RSAKey:
|
||||||
return &RSAPublicKey{tufKey: tk}
|
return &RSAPublicKey{TUFKey: tk}
|
||||||
case RSAx509Key:
|
case RSAx509Key:
|
||||||
return &RSAx509PublicKey{tufKey: tk}
|
return &RSAx509PublicKey{TUFKey: tk}
|
||||||
case ED25519Key:
|
case ED25519Key:
|
||||||
return &ED25519PublicKey{tufKey: tk}
|
return &ED25519PublicKey{TUFKey: tk}
|
||||||
}
|
}
|
||||||
return &UnknownPublicKey{tufKey: tk}
|
return &UnknownPublicKey{TUFKey: tk}
|
||||||
}
|
}
|
||||||
|
|
||||||
func typedPrivateKey(tk tufKey) (PrivateKey, error) {
|
func typedPrivateKey(tk TUFKey) (PrivateKey, error) {
|
||||||
private := tk.Value.Private
|
private := tk.Value.Private
|
||||||
tk.Value.Private = nil
|
tk.Value.Private = nil
|
||||||
switch tk.Algorithm() {
|
switch tk.Algorithm() {
|
||||||
case ECDSAKey:
|
case ECDSAKey:
|
||||||
return NewECDSAPrivateKey(
|
return NewECDSAPrivateKey(
|
||||||
&ECDSAPublicKey{
|
&ECDSAPublicKey{
|
||||||
tufKey: tk,
|
TUFKey: tk,
|
||||||
},
|
},
|
||||||
private,
|
private,
|
||||||
)
|
)
|
||||||
case ECDSAx509Key:
|
case ECDSAx509Key:
|
||||||
return NewECDSAPrivateKey(
|
return NewECDSAPrivateKey(
|
||||||
&ECDSAx509PublicKey{
|
&ECDSAx509PublicKey{
|
||||||
tufKey: tk,
|
TUFKey: tk,
|
||||||
},
|
},
|
||||||
private,
|
private,
|
||||||
)
|
)
|
||||||
case RSAKey:
|
case RSAKey:
|
||||||
return NewRSAPrivateKey(
|
return NewRSAPrivateKey(
|
||||||
&RSAPublicKey{
|
&RSAPublicKey{
|
||||||
tufKey: tk,
|
TUFKey: tk,
|
||||||
},
|
},
|
||||||
private,
|
private,
|
||||||
)
|
)
|
||||||
case RSAx509Key:
|
case RSAx509Key:
|
||||||
return NewRSAPrivateKey(
|
return NewRSAPrivateKey(
|
||||||
&RSAx509PublicKey{
|
&RSAx509PublicKey{
|
||||||
tufKey: tk,
|
TUFKey: tk,
|
||||||
},
|
},
|
||||||
private,
|
private,
|
||||||
)
|
)
|
||||||
case ED25519Key:
|
case ED25519Key:
|
||||||
return NewED25519PrivateKey(
|
return NewED25519PrivateKey(
|
||||||
ED25519PublicKey{
|
ED25519PublicKey{
|
||||||
tufKey: tk,
|
TUFKey: tk,
|
||||||
},
|
},
|
||||||
private,
|
private,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return &UnknownPrivateKey{
|
return &UnknownPrivateKey{
|
||||||
tufKey: tk,
|
TUFKey: tk,
|
||||||
privateKey: privateKey{private: private},
|
privateKey: privateKey{private: private},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ func typedPrivateKey(tk tufKey) (PrivateKey, error) {
|
||||||
// NewPublicKey creates a new, correctly typed PublicKey, using the
|
// NewPublicKey creates a new, correctly typed PublicKey, using the
|
||||||
// UnknownPublicKey catchall for unsupported ciphers
|
// UnknownPublicKey catchall for unsupported ciphers
|
||||||
func NewPublicKey(alg string, public []byte) PublicKey {
|
func NewPublicKey(alg string, public []byte) PublicKey {
|
||||||
tk := tufKey{
|
tk := TUFKey{
|
||||||
Type: alg,
|
Type: alg,
|
||||||
Value: KeyPair{
|
Value: KeyPair{
|
||||||
Public: public,
|
Public: public,
|
||||||
|
@ -163,7 +163,7 @@ func NewPublicKey(alg string, public []byte) PublicKey {
|
||||||
// NewPrivateKey creates a new, correctly typed PrivateKey, using the
|
// NewPrivateKey creates a new, correctly typed PrivateKey, using the
|
||||||
// UnknownPrivateKey catchall for unsupported ciphers
|
// UnknownPrivateKey catchall for unsupported ciphers
|
||||||
func NewPrivateKey(pubKey PublicKey, private []byte) (PrivateKey, error) {
|
func NewPrivateKey(pubKey PublicKey, private []byte) (PrivateKey, error) {
|
||||||
tk := tufKey{
|
tk := TUFKey{
|
||||||
Type: pubKey.Algorithm(),
|
Type: pubKey.Algorithm(),
|
||||||
Value: KeyPair{
|
Value: KeyPair{
|
||||||
Public: pubKey.Public(),
|
Public: pubKey.Public(),
|
||||||
|
@ -175,7 +175,7 @@ func NewPrivateKey(pubKey PublicKey, private []byte) (PrivateKey, error) {
|
||||||
|
|
||||||
// UnmarshalPublicKey is used to parse individual public keys in JSON
|
// UnmarshalPublicKey is used to parse individual public keys in JSON
|
||||||
func UnmarshalPublicKey(data []byte) (PublicKey, error) {
|
func UnmarshalPublicKey(data []byte) (PublicKey, error) {
|
||||||
var parsed tufKey
|
var parsed TUFKey
|
||||||
err := json.Unmarshal(data, &parsed)
|
err := json.Unmarshal(data, &parsed)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -185,7 +185,7 @@ func UnmarshalPublicKey(data []byte) (PublicKey, error) {
|
||||||
|
|
||||||
// UnmarshalPrivateKey is used to parse individual private keys in JSON
|
// UnmarshalPrivateKey is used to parse individual private keys in JSON
|
||||||
func UnmarshalPrivateKey(data []byte) (PrivateKey, error) {
|
func UnmarshalPrivateKey(data []byte) (PrivateKey, error) {
|
||||||
var parsed tufKey
|
var parsed TUFKey
|
||||||
err := json.Unmarshal(data, &parsed)
|
err := json.Unmarshal(data, &parsed)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -193,26 +193,26 @@ func UnmarshalPrivateKey(data []byte) (PrivateKey, error) {
|
||||||
return typedPrivateKey(parsed)
|
return typedPrivateKey(parsed)
|
||||||
}
|
}
|
||||||
|
|
||||||
// tufKey is the structure used for both public and private keys in TUF.
|
// TUFKey is the structure used for both public and private keys in TUF.
|
||||||
// Normally it would make sense to use a different structures for public and
|
// Normally it would make sense to use a different structures for public and
|
||||||
// private keys, but that would change the key ID algorithm (since the canonical
|
// private keys, but that would change the key ID algorithm (since the canonical
|
||||||
// JSON would be different). This structure should normally be accessed through
|
// JSON would be different). This structure should normally be accessed through
|
||||||
// the PublicKey or PrivateKey interfaces.
|
// the PublicKey or PrivateKey interfaces.
|
||||||
type tufKey struct {
|
type TUFKey struct {
|
||||||
id string
|
id string
|
||||||
Type string `json:"keytype"`
|
Type string `json:"keytype"`
|
||||||
Value KeyPair `json:"keyval"`
|
Value KeyPair `json:"keyval"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Algorithm returns the algorithm of the key
|
// Algorithm returns the algorithm of the key
|
||||||
func (k tufKey) Algorithm() string {
|
func (k TUFKey) Algorithm() string {
|
||||||
return k.Type
|
return k.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
// ID efficiently generates if necessary, and caches the ID of the key
|
// ID efficiently generates if necessary, and caches the ID of the key
|
||||||
func (k *tufKey) ID() string {
|
func (k *TUFKey) ID() string {
|
||||||
if k.id == "" {
|
if k.id == "" {
|
||||||
pubK := tufKey{
|
pubK := TUFKey{
|
||||||
Type: k.Algorithm(),
|
Type: k.Algorithm(),
|
||||||
Value: KeyPair{
|
Value: KeyPair{
|
||||||
Public: k.Public(),
|
Public: k.Public(),
|
||||||
|
@ -230,7 +230,7 @@ func (k *tufKey) ID() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Public returns the public bytes
|
// Public returns the public bytes
|
||||||
func (k tufKey) Public() []byte {
|
func (k TUFKey) Public() []byte {
|
||||||
return k.Value.Public
|
return k.Value.Public
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,42 +239,42 @@ func (k tufKey) Public() []byte {
|
||||||
// ECDSAPublicKey represents an ECDSA key using a raw serialization
|
// ECDSAPublicKey represents an ECDSA key using a raw serialization
|
||||||
// of the public key
|
// of the public key
|
||||||
type ECDSAPublicKey struct {
|
type ECDSAPublicKey struct {
|
||||||
tufKey
|
TUFKey
|
||||||
}
|
}
|
||||||
|
|
||||||
// ECDSAx509PublicKey represents an ECDSA key using an x509 cert
|
// ECDSAx509PublicKey represents an ECDSA key using an x509 cert
|
||||||
// as the serialized format of the public key
|
// as the serialized format of the public key
|
||||||
type ECDSAx509PublicKey struct {
|
type ECDSAx509PublicKey struct {
|
||||||
tufKey
|
TUFKey
|
||||||
}
|
}
|
||||||
|
|
||||||
// RSAPublicKey represents an RSA key using a raw serialization
|
// RSAPublicKey represents an RSA key using a raw serialization
|
||||||
// of the public key
|
// of the public key
|
||||||
type RSAPublicKey struct {
|
type RSAPublicKey struct {
|
||||||
tufKey
|
TUFKey
|
||||||
}
|
}
|
||||||
|
|
||||||
// RSAx509PublicKey represents an RSA key using an x509 cert
|
// RSAx509PublicKey represents an RSA key using an x509 cert
|
||||||
// as the serialized format of the public key
|
// as the serialized format of the public key
|
||||||
type RSAx509PublicKey struct {
|
type RSAx509PublicKey struct {
|
||||||
tufKey
|
TUFKey
|
||||||
}
|
}
|
||||||
|
|
||||||
// ED25519PublicKey represents an ED25519 key using a raw serialization
|
// ED25519PublicKey represents an ED25519 key using a raw serialization
|
||||||
// of the public key
|
// of the public key
|
||||||
type ED25519PublicKey struct {
|
type ED25519PublicKey struct {
|
||||||
tufKey
|
TUFKey
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnknownPublicKey is a catchall for key types that are not supported
|
// UnknownPublicKey is a catchall for key types that are not supported
|
||||||
type UnknownPublicKey struct {
|
type UnknownPublicKey struct {
|
||||||
tufKey
|
TUFKey
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewECDSAPublicKey initializes a new public key with the ECDSAKey type
|
// NewECDSAPublicKey initializes a new public key with the ECDSAKey type
|
||||||
func NewECDSAPublicKey(public []byte) *ECDSAPublicKey {
|
func NewECDSAPublicKey(public []byte) *ECDSAPublicKey {
|
||||||
return &ECDSAPublicKey{
|
return &ECDSAPublicKey{
|
||||||
tufKey: tufKey{
|
TUFKey: TUFKey{
|
||||||
Type: ECDSAKey,
|
Type: ECDSAKey,
|
||||||
Value: KeyPair{
|
Value: KeyPair{
|
||||||
Public: public,
|
Public: public,
|
||||||
|
@ -287,7 +287,7 @@ func NewECDSAPublicKey(public []byte) *ECDSAPublicKey {
|
||||||
// NewECDSAx509PublicKey initializes a new public key with the ECDSAx509Key type
|
// NewECDSAx509PublicKey initializes a new public key with the ECDSAx509Key type
|
||||||
func NewECDSAx509PublicKey(public []byte) *ECDSAx509PublicKey {
|
func NewECDSAx509PublicKey(public []byte) *ECDSAx509PublicKey {
|
||||||
return &ECDSAx509PublicKey{
|
return &ECDSAx509PublicKey{
|
||||||
tufKey: tufKey{
|
TUFKey: TUFKey{
|
||||||
Type: ECDSAx509Key,
|
Type: ECDSAx509Key,
|
||||||
Value: KeyPair{
|
Value: KeyPair{
|
||||||
Public: public,
|
Public: public,
|
||||||
|
@ -300,7 +300,7 @@ func NewECDSAx509PublicKey(public []byte) *ECDSAx509PublicKey {
|
||||||
// NewRSAPublicKey initializes a new public key with the RSA type
|
// NewRSAPublicKey initializes a new public key with the RSA type
|
||||||
func NewRSAPublicKey(public []byte) *RSAPublicKey {
|
func NewRSAPublicKey(public []byte) *RSAPublicKey {
|
||||||
return &RSAPublicKey{
|
return &RSAPublicKey{
|
||||||
tufKey: tufKey{
|
TUFKey: TUFKey{
|
||||||
Type: RSAKey,
|
Type: RSAKey,
|
||||||
Value: KeyPair{
|
Value: KeyPair{
|
||||||
Public: public,
|
Public: public,
|
||||||
|
@ -313,7 +313,7 @@ func NewRSAPublicKey(public []byte) *RSAPublicKey {
|
||||||
// NewRSAx509PublicKey initializes a new public key with the RSAx509Key type
|
// NewRSAx509PublicKey initializes a new public key with the RSAx509Key type
|
||||||
func NewRSAx509PublicKey(public []byte) *RSAx509PublicKey {
|
func NewRSAx509PublicKey(public []byte) *RSAx509PublicKey {
|
||||||
return &RSAx509PublicKey{
|
return &RSAx509PublicKey{
|
||||||
tufKey: tufKey{
|
TUFKey: TUFKey{
|
||||||
Type: RSAx509Key,
|
Type: RSAx509Key,
|
||||||
Value: KeyPair{
|
Value: KeyPair{
|
||||||
Public: public,
|
Public: public,
|
||||||
|
@ -326,7 +326,7 @@ func NewRSAx509PublicKey(public []byte) *RSAx509PublicKey {
|
||||||
// NewED25519PublicKey initializes a new public key with the ED25519Key type
|
// NewED25519PublicKey initializes a new public key with the ED25519Key type
|
||||||
func NewED25519PublicKey(public []byte) *ED25519PublicKey {
|
func NewED25519PublicKey(public []byte) *ED25519PublicKey {
|
||||||
return &ED25519PublicKey{
|
return &ED25519PublicKey{
|
||||||
tufKey: tufKey{
|
TUFKey: TUFKey{
|
||||||
Type: ED25519Key,
|
Type: ED25519Key,
|
||||||
Value: KeyPair{
|
Value: KeyPair{
|
||||||
Public: public,
|
Public: public,
|
||||||
|
@ -367,7 +367,7 @@ type ED25519PrivateKey struct {
|
||||||
|
|
||||||
// UnknownPrivateKey is a catchall for unsupported key types
|
// UnknownPrivateKey is a catchall for unsupported key types
|
||||||
type UnknownPrivateKey struct {
|
type UnknownPrivateKey struct {
|
||||||
tufKey
|
TUFKey
|
||||||
privateKey
|
privateKey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,10 +515,10 @@ func (k UnknownPrivateKey) SignatureAlgorithm() SigAlgorithm {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// PublicKeyFromPrivate returns a new tufKey based on a private key, with
|
// PublicKeyFromPrivate returns a new TUFKey based on a private key, with
|
||||||
// the private key bytes guaranteed to be nil.
|
// the private key bytes guaranteed to be nil.
|
||||||
func PublicKeyFromPrivate(pk PrivateKey) PublicKey {
|
func PublicKeyFromPrivate(pk PrivateKey) PublicKey {
|
||||||
return typedPublicKey(tufKey{
|
return typedPublicKey(TUFKey{
|
||||||
Type: pk.Algorithm(),
|
Type: pk.Algorithm(),
|
||||||
Value: KeyPair{
|
Value: KeyPair{
|
||||||
Public: pk.Public(),
|
Public: pk.Public(),
|
||||||
|
|
Loading…
Reference in New Issue