Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | model: improved documentation |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
8618055a5e4a7220ffce79dc00cc1ec1 |
User & Date: | dnc 2019-05-27 13:54:17 |
Context
2019-05-27
| ||
13:54 | model: generated implementation of Stringer check-in: a85969401a user: dnc tags: trunk | |
13:54 | model: improved documentation check-in: 8618055a5e user: dnc tags: trunk | |
13:33 | add role to file manifest testimony signed by author, or auditor, etc. check-in: a330762664 user: dnc tags: trunk | |
Changes
Changes to model/index.go.
1 2 3 4 5 6 7 |
// Index // // Provides a consistent naming convention for index files. Multiple // commands may create and inspect indexes, so we define the common // conventions in this package. package model |
> > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
// Copyright (C) 2019 David N. Cohen // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // Index // // Provides a consistent naming convention for index files. Multiple // commands may create and inspect indexes, so we define the common // conventions in this package. package model |
Changes to model/manifest.go.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. package model import ( "encoding/json" "io" "os" "time" ................................................................................ // How many roles? RoleCount int = iota ) //go:generate stringer -type=Role type FileManifest struct { CID CID `json:"cid"` Path string `json:"path,omitempty"` Role Role `json:"role"` Time int64 `json:"timestamp"` } func NewFileManifest(path string) (*FileManifest, error) { f, err := os.Open(path) if err != nil { return nil, err } |
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
|
>
>
>
|
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
..
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. // Manifest // // A file manifest is a description of a source file, produced by an // authority who signs the manifest to produce testimony. package model import ( "encoding/json" "io" "os" "time" ................................................................................ // How many roles? RoleCount int = iota ) //go:generate stringer -type=Role // 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"` // The Role of the authority producing testimony. I.e. the file's // author, or a third-party auditor. Role Role `json:"role"` // Timestamp indicates when manifest was produced. This does not // indicated the age of the file, or when testimony was signed. Time int64 `json:"timestamp"` } func NewFileManifest(path string) (*FileManifest, error) { f, err := os.Open(path) if err != nil { return nil, err } |
Changes to model/testimony.go.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. package model import "golang.org/x/crypto/ssh" type Testimony struct { Public string `json:"public"` // the signing public key Encoded []byte `json:"encoded"` // the encoded bytes that are signed Signature ssh.Signature `json:"signature"` // the signature publicKey ssh.PublicKey // cache to avoid redundant parsing } // 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 { public, err := this.PublicKey() |
> > > > > > < < > > > > > > > | > | |
9 10 11 12 13 14 15 16 17 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 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. // Testmimony // // Testimony is an attestation by an authority regarding the status of // a source file. package model import "golang.org/x/crypto/ssh" // Type Testimony, when produced by a trusted authority, allows a // verifier to authenticate a source file. type Testimony struct { // The signer's public key. Public string `json:"public"` // The encoded bytes that were signed. May be decoded into a manifest. Encoded []byte `json:"encoded"` // Signature of Encoded bytes. Signature ssh.Signature `json:"signature"` // internal cache, to avoid redundant parsing of Public field. 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 { public, err := this.PublicKey() |