aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd_snapshot.go38
-rw-r--r--utils_ct.go47
2 files changed, 47 insertions, 38 deletions
diff --git a/cmd_snapshot.go b/cmd_snapshot.go
index 5a9c50e..53923f2 100644
--- a/cmd_snapshot.go
+++ b/cmd_snapshot.go
@@ -123,41 +123,3 @@ func snapshot(opts options) error {
}
return nil
}
-
-// logs select logs that count towards CT-compliance checks. Logs that don't
-// have a description are skipped after printing a warning.
-func logs(md metadata.Metadata) (logs []metadata.Log) {
- for _, operators := range md.Operators {
- for _, log := range operators.Logs {
- if log.Description == nil {
- fmt.Fprintf(os.Stderr, "WARNING: skipping log without description")
- continue
- }
- if log.State == nil {
- continue // skip logs with unknown states
- }
- if log.State.Name == metadata.LogStatePending {
- continue // pending logs do not count towards CT-compliance
- }
- if log.State.Name == metadata.LogStateRetired {
- continue // retired logs are not necessarily reachable
- }
- if log.State.Name == metadata.LogStateRejected {
- continue // rejected logs do not count towards CT-compliance
- }
-
- logs = append(logs, log)
- }
- }
- return
-}
-
-// proof formats hashes so that they can be passed to the merkle package
-func proof(hashes [][]byte) (p [][sha256.Size]byte) {
- for _, hash := range hashes {
- var h [sha256.Size]byte
- copy(h[:], hash)
- p = append(p, h)
- }
- return
-}
diff --git a/utils_ct.go b/utils_ct.go
new file mode 100644
index 0000000..3c40ad0
--- /dev/null
+++ b/utils_ct.go
@@ -0,0 +1,47 @@
+package main
+
+import (
+ "crypto/sha256"
+ "fmt"
+ "os"
+
+ "gitlab.torproject.org/rgdd/ct/pkg/metadata"
+)
+
+// logs select logs that count towards CT-compliance checks. Logs that don't
+// have a description are skipped after printing a warning.
+func logs(md metadata.Metadata) (logs []metadata.Log) {
+ for _, operators := range md.Operators {
+ for _, log := range operators.Logs {
+ if log.Description == nil {
+ fmt.Fprintf(os.Stderr, "WARNING: skipping log without description")
+ continue
+ }
+ if log.State == nil {
+ continue // skip logs with unknown states
+ }
+ if log.State.Name == metadata.LogStatePending {
+ continue // pending logs do not count towards CT-compliance
+ }
+ if log.State.Name == metadata.LogStateRetired {
+ continue // retired logs are not necessarily reachable
+ }
+ if log.State.Name == metadata.LogStateRejected {
+ continue // rejected logs do not count towards CT-compliance
+ }
+
+ logs = append(logs, log)
+ }
+ }
+ return
+}
+
+// proof formats hashes so that they can be passed to the merkle package
+func proof(hashes [][]byte) (p [][sha256.Size]byte) {
+ for _, hash := range hashes {
+ var h [sha256.Size]byte
+ copy(h[:], hash)
+ p = append(p, h)
+ }
+ return
+}