From 486824325919716b6a09bcac5a540e624951e982 Mon Sep 17 00:00:00 2001 From: Andrew Ayer Date: Sat, 26 Nov 2016 17:48:15 -0800 Subject: [PATCH] Add ID function to LogInfo to return log ID --- logs.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/logs.go b/logs.go index 31ffd39..0746827 100644 --- a/logs.go +++ b/logs.go @@ -11,6 +11,7 @@ package certspotter import ( "crypto" + "crypto/sha256" "crypto/x509" "encoding/base64" ) @@ -37,6 +38,11 @@ func (info *LogInfo) ParsedPublicKey() (crypto.PublicKey, error) { } } +func (info *LogInfo) ID() []byte { + sum := sha256.Sum256(info.Key) + return sum[:] +} + var DefaultLogs = []LogInfo{ { // a4b90990b418581487bb13a2cc67700a3c359804f91bdfb8e377cd0ec80ddc10