hancock

Check-in [e0fadea8cc]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:model: NewAuthority helper formats authority string consistently
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e0fadea8cc73ee84cb2e5da771ad9e514b3cc0f90b6b3bb3d3d6f493c1006892
User & Date: dnc 2019-12-13 04:19:32
Context
2019-12-13
04:22
cmd/hancock: refactor to use Store interface check-in: ef3dc07f7e user: dnc tags: trunk
04:19
model: NewAuthority helper formats authority string consistently check-in: e0fadea8cc user: dnc tags: trunk
2019-12-11
20:21
store: put/get testimony via consistent interface; file system and bolt implementation check-in: 4950d4133b user: dnc tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to model/testimony.go.

18
19
20
21
22
23
24

25
26
27
28
29
30











31
32
33
34
35
36
37
// Testimony is an attestation by an authority regarding the status of
// a source file.
package model

import (
	"errors"
	"log"


	"golang.org/x/crypto/ssh"
)

// An Authority is public key, encoded as a string (see ssh.ParseAuthorizedKey)
type Authority string












func (this Authority) String() string { return string(this) }

// Type Testimony, when produced by a trusted authority, allows a
// verifier to authenticate a source file.
type Testimony struct {
	// The signer's public key.







>






>
>
>
>
>
>
>
>
>
>
>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Testimony is an attestation by an authority regarding the status of
// a source file.
package model

import (
	"errors"
	"log"
	"strings"

	"golang.org/x/crypto/ssh"
)

// An Authority is public key, encoded as a string (see ssh.ParseAuthorizedKey)
type Authority string

// NewAuthority acceps as input a public key in SSH authorized key
// format.  Returns non-nil error if the incoming key cannot be
// parsed.
func NewAuthority(str string) (Authority, error) {
	public, _, _, _, err := ssh.ParseAuthorizedKey([]byte(str))

	// re-marshal to get consistent format, i.e. without comments, trailing newline
	clean := strings.TrimSpace(string(ssh.MarshalAuthorizedKey(public)))
	return Authority(clean), err
}

func (this Authority) String() string { return string(this) }

// Type Testimony, when produced by a trusted authority, allows a
// verifier to authenticate a source file.
type Testimony struct {
	// The signer's public key.