...

Package ctutil

import "github.com/google/certificate-transparency-go/ctutil"
Overview
Index
Subdirectories

Overview ▾

Package ctutil contains utilities for Certificate Transparency.

func ContainsSCT

func ContainsSCT(cert *x509.Certificate, sct *ct.SignedCertificateTimestamp) (bool, error)

ContainsSCT checks to see whether the given SCT is embedded within the given certificate.

func LeafHash

func LeafHash(chain []*x509.Certificate, sct *ct.SignedCertificateTimestamp, embedded bool) ([sha256.Size]byte, error)

LeafHash calculates the leaf hash of the certificate or precertificate at chain[0] that sct was issued for.

sct is required because the SCT timestamp is used to calculate the leaf hash. Leaf hashes are unique to (pre)certificate-SCT pairs.

This function can be used with three different types of leaf certificate:

Note: LeafHash doesn't check that the provided SCT verifies for the given chain. It simply calculates what the leaf hash would be for the given (pre)certificate-SCT pair.

func LeafHashB64

func LeafHashB64(chain []*x509.Certificate, sct *ct.SignedCertificateTimestamp, embedded bool) (string, error)

LeafHashB64 does as LeafHash does, but returns the leaf hash base64-encoded. The base64-encoded leaf hash returned by B64LeafHash can be used with the get-proof-by-hash API endpoint of Certificate Transparency Logs.

func VerifySCT

func VerifySCT(pubKey crypto.PublicKey, chain []*x509.Certificate, sct *ct.SignedCertificateTimestamp, embedded bool) error

VerifySCT takes the public key of a Certificate Transparency Log, a certificate chain, and an SCT and verifies whether the SCT is a valid SCT for the certificate at chain[0], signed by the Log that the public key belongs to. If the SCT does not verify, an error will be returned.

This function can be used with three different types of leaf certificate:

func VerifySCTWithVerifier

func VerifySCTWithVerifier(sv *ct.SignatureVerifier, chain []*x509.Certificate, sct *ct.SignedCertificateTimestamp, embedded bool) error

VerifySCTWithVerifier takes a ct.SignatureVerifier, a certificate chain, and an SCT and verifies whether the SCT is a valid SCT for the certificate at chain[0], signed by the Log whose public key was used to set up the ct.SignatureVerifier. If the SCT does not verify, an error will be returned.

This function can be used with three different types of leaf certificate:

type LogInfo

LogInfo holds the objects needed to perform per-log verification and validation of SCTs.

type LogInfo struct {
    Description string
    Client      client.CheckLogClient
    MMD         time.Duration
    Verifier    *ct.SignatureVerifier
    PublicKey   []byte
    // contains filtered or unexported fields
}

func NewLogInfo

func NewLogInfo(log *loglist3.Log, hc *http.Client) (*LogInfo, error)

NewLogInfo builds a LogInfo object based on a log list entry.

func (*LogInfo) LastSTH

func (li *LogInfo) LastSTH() *ct.SignedTreeHead

LastSTH returns the last STH known for the log.

func (*LogInfo) SetSTH

func (li *LogInfo) SetSTH(sth *ct.SignedTreeHead)

SetSTH sets the last STH known for the log.

func (*LogInfo) VerifyInclusion

func (li *LogInfo) VerifyInclusion(ctx context.Context, leaf ct.MerkleTreeLeaf, timestamp uint64) (int64, error)

VerifyInclusion checks that the given Merkle tree leaf, adjusted for the provided timestamp, is present in the current tree size of the log. On success, returns the index of the leaf in the log.

func (*LogInfo) VerifyInclusionAt

func (li *LogInfo) VerifyInclusionAt(ctx context.Context, leaf ct.MerkleTreeLeaf, timestamp, treeSize uint64, rootHash []byte) (int64, error)

VerifyInclusionAt checks that the given Merkle tree leaf, adjusted for the provided timestamp, is present in the given tree size & root hash of the log. On success, returns the index of the leaf in the log.

func (*LogInfo) VerifyInclusionLatest

func (li *LogInfo) VerifyInclusionLatest(ctx context.Context, leaf ct.MerkleTreeLeaf, timestamp uint64) (int64, error)

VerifyInclusionLatest checks that the given Merkle tree leaf, adjusted for the provided timestamp, is present in the latest known tree size of the log. If no tree size for the log is known, it will be queried. On success, returns the index of the leaf in the log.

func (*LogInfo) VerifySCTSignature

func (li *LogInfo) VerifySCTSignature(sct ct.SignedCertificateTimestamp, leaf ct.MerkleTreeLeaf) error

VerifySCTSignature checks the signature in the SCT matches the given leaf (adjusted for the timestamp in the SCT) and log.

type LogInfoByHash

LogInfoByHash holds LogInfo objects index by the SHA-256 hash of the log's public key.

type LogInfoByHash map[[sha256.Size]byte]*LogInfo

func LogInfoByKeyHash

func LogInfoByKeyHash(ll *loglist3.LogList, hc *http.Client) (LogInfoByHash, error)

LogInfoByKeyHash builds a map of LogInfo objects indexed by their key hashes.

Subdirectories

Name Synopsis
..
sctcheck sctcheck is a utility to show and check embedded SCTs (Signed Certificate Timestamps) in certificates.
sctscan sctscan is a utility to scan a CT log and check embedded SCTs (Signed Certificate Timestamps) in certificates in the log.