aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus@rgdd.se>2023-03-18 13:17:40 +0100
committerRasmus Dahlberg <rasmus@rgdd.se>2023-03-18 13:17:40 +0100
commit15ffe76847c4c0383c4d0c0a35fb29d5031d093b (patch)
tree73001d637ef722bcf11562cdc9b10c809d09a66c /internal
parentc96dabe39386d008985566bf689a3735d0a8f1c8 (diff)
more light refactoring
Diffstat (limited to 'internal')
-rw-r--r--internal/utils/utils.go47
-rw-r--r--internal/x509/x509.go (renamed from internal/utils/x509.go)19
2 files changed, 9 insertions, 57 deletions
diff --git a/internal/utils/utils.go b/internal/utils/utils.go
deleted file mode 100644
index 5b27868..0000000
--- a/internal/utils/utils.go
+++ /dev/null
@@ -1,47 +0,0 @@
-package utils
-
-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
-}
diff --git a/internal/utils/x509.go b/internal/x509/x509.go
index bf99334..949199d 100644
--- a/internal/utils/x509.go
+++ b/internal/x509/x509.go
@@ -1,13 +1,3 @@
-package utils
-
-import (
- "fmt"
-
- ct "github.com/google/certificate-transparency-go"
- "github.com/google/certificate-transparency-go/asn1"
- "github.com/google/certificate-transparency-go/x509/pkix"
-)
-
// Mozilla Public License Version 2.0
// ==================================
//
@@ -407,6 +397,15 @@ import (
// https://gitlab.torproject.org/tpo/onion-services/sauteed-onions/monitor/-/blob/main/follow-go/main.go#L115-124
// https://gitlab.torproject.org/tpo/onion-services/sauteed-onions/monitor/-/blob/main/follow-go/x509.go
// https://github.com/SSLMate/certspotter/blob/54f34077d3bebe8aafce07dcfbffeb928c6e1d04/x509.go#L380
+package x509
+
+import (
+ "fmt"
+
+ ct "github.com/google/certificate-transparency-go"
+ "github.com/google/certificate-transparency-go/asn1"
+ "github.com/google/certificate-transparency-go/x509/pkix"
+)
func SANsFromLeafEntries(startIndex int64, leafEntries []ct.LeafEntry) (sans []string, errs []error) {
for offset, leafEntry := range leafEntries {