ROOTPLOIT
Server: LiteSpeed
System: Linux in-mum-web1878.main-hosting.eu 5.14.0-570.21.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 11 07:22:35 EDT 2025 x86_64
User: u435929562 (435929562)
PHP: 7.4.33
Disabled: system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/go/pkg/mod/golang.org/x/[email protected]/sumdb/tlog/ct_test.go
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package tlog

import (
	"encoding/json"
	"fmt"
	"io"
	"net/http"
	"net/url"
	"os"
	"testing"
)

func TestCertificateTransparency(t *testing.T) {
	// Test that we can verify actual Certificate Transparency proofs.
	// (The other tests check that we can verify our own proofs;
	// this is a test that the two are compatible.)

	if testing.Short() {
		t.Skip("skipping in -short mode")
	}

	var root ctTree
	httpGET(t, "http://ct.googleapis.com/logs/argon2020/ct/v1/get-sth", &root)

	var leaf ctEntries
	httpGET(t, "http://ct.googleapis.com/logs/argon2020/ct/v1/get-entries?start=10000&end=10000", &leaf)
	hash := RecordHash(leaf.Entries[0].Data)

	var rp ctRecordProof
	httpGET(t, "http://ct.googleapis.com/logs/argon2020/ct/v1/get-proof-by-hash?tree_size="+fmt.Sprint(root.Size)+"&hash="+url.QueryEscape(hash.String()), &rp)

	err := CheckRecord(rp.Proof, root.Size, root.Hash, 10000, hash)
	if err != nil {
		t.Fatal(err)
	}

	var tp ctTreeProof
	httpGET(t, "http://ct.googleapis.com/logs/argon2020/ct/v1/get-sth-consistency?first=3654490&second="+fmt.Sprint(root.Size), &tp)

	oh, _ := ParseHash("AuIZ5V6sDUj1vn3Y1K85oOaQ7y+FJJKtyRTl1edIKBQ=")
	err = CheckTree(tp.Proof, root.Size, root.Hash, 3654490, oh)
	if err != nil {
		t.Fatal(err)
	}
}

type ctTree struct {
	Size int64 `json:"tree_size"`
	Hash Hash  `json:"sha256_root_hash"`
}

type ctEntries struct {
	Entries []*ctEntry
}

type ctEntry struct {
	Data []byte `json:"leaf_input"`
}

type ctRecordProof struct {
	Index int64       `json:"leaf_index"`
	Proof RecordProof `json:"audit_path"`
}

type ctTreeProof struct {
	Proof TreeProof `json:"consistency"`
}

func httpGET(t *testing.T, url string, targ interface{}) {
	if testing.Verbose() {
		println()
		println(url)
	}
	resp, err := http.Get(url)
	if err != nil {
		t.Fatal(err)
	}
	defer resp.Body.Close()
	data, err := io.ReadAll(resp.Body)
	if err != nil {
		t.Fatal(err)
	}
	if testing.Verbose() {
		os.Stdout.Write(data)
	}
	err = json.Unmarshal(data, targ)
	if err != nil {
		println(url)
		os.Stdout.Write(data)
		t.Fatal(err)
	}
}