Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | model: rename manifest "Content" field (was "CID") |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
da5f7ebb26ab9a08a6b39e82454b0dda |
| User & Date: | dnc 2019-11-03 11:59:30 |
Context
|
2019-11-03
| ||
| 12:01 | hancock: call new server interface previously: seperate index and testimony on IPFS now: hancockd server acts as key/value store check-in: 99044d8f59 user: dnc tags: trunk | |
| 11:59 | model: rename manifest "Content" field (was "CID") check-in: da5f7ebb26 user: dnc tags: trunk | |
| 11:58 | model: prefer model.Authority (to string) for type safety check-in: 99cee0289a user: dnc tags: trunk | |
Changes
Changes to model/manifest.go.
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
...
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
}
// Type FileManifest includes information about a file. A signed
// manifest becomes testimony used to authenticate the file.
type FileManifest struct {
// Content Identifier is derived from a cryptographically strong
// hash of the file content.
CID CID `json:"cid"`
// Path indicates the relative path of the file when manifest was
// produced. It may have a different path when verified.
Path string `json:"path,omitempty"`
// Quality allows testimony to serve as either endorsement or
// repudiation of source.
................................................................................
cid := NewSha256CID(nil)
_, err := io.Copy(cid, f)
if err != nil {
return nil, err
}
return &FileManifest{
Time: time.Now().Unix(),
CID: cid.Encode(), // TODO(dnc): avoid unnecessary encodes/decodes, for performance
}, nil
}
// Enforce limitations on manifest data.
func (this FileManifest) Check() error {
const messageCount = 8
const messageLength = 128
|
|
|
|
|
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
...
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
}
// Type FileManifest includes information about a file. A signed
// manifest becomes testimony used to authenticate the file.
type FileManifest struct {
// Content Identifier is derived from a cryptographically strong
// hash of the file content.
Content CID `json:"cid"`
// Path indicates the relative path of the file when manifest was
// produced. It may have a different path when verified.
Path string `json:"path,omitempty"`
// Quality allows testimony to serve as either endorsement or
// repudiation of source.
................................................................................
cid := NewSha256CID(nil)
_, err := io.Copy(cid, f)
if err != nil {
return nil, err
}
return &FileManifest{
Time: time.Now().Unix(),
Content: cid.Encode(), // TODO(dnc): avoid unnecessary encodes/decodes, for performance
}, nil
}
// Enforce limitations on manifest data.
func (this FileManifest) Check() error {
const messageCount = 8
const messageLength = 128
|
Changes to model/testimony.go.
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
..
68
69
70
71
72
73
74
75
76
77
78
79
|
publicKey ssh.PublicKey
}
// Verify returns nil when the manifest, signature, and public key are
// consistent. This checks only the tag data, and does not check that
// the key corresponds to an authorized entity.
func (this *Testimony) Verify() error {
if this.Authority == "" {
return errors.New("testimony without public key")
}
public, err := this.PublicKey()
if err != nil {
return err
}
err = public.Verify(this.Encoded, &this.Signature)
return err
}
................................................................................
if this.publicKey == nil {
this.publicKey, _, _, _, err = ssh.ParseAuthorizedKey([]byte(this.Authority))
}
return this.publicKey, err
}
func (this *Testimony) Key() *TestimonyKey {
if this.Authority == "" {
log.Panic("testimony not initialized, missing authority")
}
return &TestimonyKey{Authority: this.Authority, Content: this.Content}
}
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
<
>
<
>
>
|
>
>
|
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
..
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
publicKey ssh.PublicKey
}
// Verify returns nil when the manifest, signature, and public key are
// consistent. This checks only the tag data, and does not check that
// the key corresponds to an authorized entity.
func (this *Testimony) Verify() error {
err := this.Check()
if err != nil {
return err
}
public, err := this.PublicKey()
if err != nil {
return err
}
err = public.Verify(this.Encoded, &this.Signature)
return err
}
................................................................................
if this.publicKey == nil {
this.publicKey, _, _, _, err = ssh.ParseAuthorizedKey([]byte(this.Authority))
}
return this.publicKey, err
}
func (this *Testimony) Key() *TestimonyKey {
key := &TestimonyKey{Authority: this.Authority, Content: this.Content}
// sanity check; TODO(dnc): remove when not needed
err := key.Check()
if err != nil {
log.Panicf("failed to generate testimony key: %s", err)
}
return key
}
func (this *Testimony) Check() error {
if this.Authority == "" {
return errors.New("testimony missing authority field")
}
if this.Content.String() == "" {
return errors.New("testimony missing content field")
}
return nil
}
|