Skip to content

Commit

Permalink
Update code w.r.t. the addition of 'extensions' parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
liweitianux committed Jan 16, 2025
1 parent e1039f2 commit 1782a3b
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions ctutil/ctutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ func createLeaf(chain []*x509.Certificate, sct *ct.SignedCertificateTimestamp, e
var leaf *ct.MerkleTreeLeaf
var err error
if embedded {
leaf, err = ct.MerkleTreeLeafForEmbeddedSCT(chain, sct.Timestamp)
leaf, err = ct.MerkleTreeLeafForEmbeddedSCT(chain, sct.Timestamp, nil)
} else {
leaf, err = ct.MerkleTreeLeafFromChain(chain, certType, sct.Timestamp)
leaf, err = ct.MerkleTreeLeafFromChain(chain, certType, sct.Timestamp, nil)
}
if err != nil {
return nil, fmt.Errorf("error creating MerkleTreeLeaf: %s", err)
Expand Down
4 changes: 2 additions & 2 deletions ctutil/sctcheck/sctcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func checkChain(ctx context.Context, lf logInfoFactory, chain []*x509.Certificat

// Build a Merkle leaf that corresponds to the embedded SCTs. We can use the same
// leaf for all of the SCTs, as long as the timestamp field gets updated.
merkleLeaf, err := ct.MerkleTreeLeafForEmbeddedSCT([]*x509.Certificate{leaf, issuer}, 0)
merkleLeaf, err := ct.MerkleTreeLeafForEmbeddedSCT([]*x509.Certificate{leaf, issuer}, 0, nil)
if err != nil {
klog.Errorf("Failed to build Merkle leaf: %v", err)
return 0, len(leaf.SCTList.SCTList)
Expand Down Expand Up @@ -201,7 +201,7 @@ func getAndCheckSiteChain(ctx context.Context, lf logInfoFactory, target string,
var valid, invalid int
scts := conn.ConnectionState().SignedCertificateTimestamps
if len(scts) > 0 {
merkleLeaf, err := ct.MerkleTreeLeafFromChain(chain, ct.X509LogEntryType, 0 /* timestamp added later */)
merkleLeaf, err := ct.MerkleTreeLeafFromChain(chain, ct.X509LogEntryType, 0 /* timestamp added later */, nil)
if err != nil {
klog.Errorf("Failed to build Merkle tree leaf: %v", err)
return chain, 0, len(scts), nil
Expand Down
2 changes: 1 addition & 1 deletion ctutil/sctscan/sctscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func checkCertWithEmbeddedSCT(ctx context.Context, logsByKey map[[sha256.Size]by

// Build a Merkle leaf that corresponds to the embedded SCTs. We can use the same
// leaf for all of the SCTs, as long as the timestamp field gets updated.
merkleLeaf, err := ct.MerkleTreeLeafForEmbeddedSCT([]*x509.Certificate{leaf, issuer}, 0)
merkleLeaf, err := ct.MerkleTreeLeafForEmbeddedSCT([]*x509.Certificate{leaf, issuer}, 0, nil)
if err != nil {
klog.Errorf("[%d] Failed to build Merkle leaf: %v", entry.Index, err)
return
Expand Down
2 changes: 1 addition & 1 deletion trillian/ctfe/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ func addChainInternal(ctx context.Context, li *logInfo, w http.ResponseWriter, r
timeMillis := uint64(li.TimeSource.Now().UnixNano() / millisPerNano)

// Build the MerkleTreeLeaf that gets sent to the backend, and make a trillian.LogLeaf for it.
merkleLeaf, err := ct.MerkleTreeLeafFromChain(chain, etype, timeMillis)
merkleLeaf, err := ct.MerkleTreeLeafFromChain(chain, etype, timeMillis, nil)
if err != nil {
return http.StatusBadRequest, fmt.Errorf("failed to build MerkleTreeLeaf: %s", err)
}
Expand Down
6 changes: 3 additions & 3 deletions trillian/ctfe/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ func TestAddChainWhitespace(t *testing.T) {

// Which (if successful) produces a QueueLeaf response with a Merkle leaf:
pool := loadCertsIntoPoolOrDie(t, pemChain)
merkleLeaf, err := ct.MerkleTreeLeafFromChain(pool.RawCertificates(), ct.X509LogEntryType, fakeTimeMillis)
merkleLeaf, err := ct.MerkleTreeLeafFromChain(pool.RawCertificates(), ct.X509LogEntryType, fakeTimeMillis, nil)
if err != nil {
t.Fatalf("Unexpected error signing SCT: %v", err)
}
Expand Down Expand Up @@ -525,7 +525,7 @@ func TestAddChain(t *testing.T) {
chain := createJSONChain(t, *pool)
if len(test.toSign) > 0 {
root := info.roots.RawCertificates()[0]
merkleLeaf, err := ct.MerkleTreeLeafFromChain(pool.RawCertificates(), ct.X509LogEntryType, fakeTimeMillis)
merkleLeaf, err := ct.MerkleTreeLeafFromChain(pool.RawCertificates(), ct.X509LogEntryType, fakeTimeMillis, nil)
if err != nil {
t.Fatalf("Unexpected error signing SCT: %v", err)
}
Expand Down Expand Up @@ -647,7 +647,7 @@ func TestAddPrechain(t *testing.T) {
chain := createJSONChain(t, *pool)
if len(test.toSign) > 0 {
root := info.roots.RawCertificates()[0]
merkleLeaf, err := ct.MerkleTreeLeafFromChain([]*x509.Certificate{pool.RawCertificates()[0], root}, ct.PrecertLogEntryType, fakeTimeMillis)
merkleLeaf, err := ct.MerkleTreeLeafFromChain([]*x509.Certificate{pool.RawCertificates()[0], root}, ct.PrecertLogEntryType, fakeTimeMillis, nil)
if err != nil {
t.Fatalf("Unexpected error signing SCT: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions trillian/ctfe/serialize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestBuildV1MerkleTreeLeafForCert(t *testing.T) {
t.Fatalf("could not create signer: %v", err)
}

leaf, err := ct.MerkleTreeLeafFromChain([]*x509.Certificate{cert}, ct.X509LogEntryType, fixedTimeMillis)
leaf, err := ct.MerkleTreeLeafFromChain([]*x509.Certificate{cert}, ct.X509LogEntryType, fixedTimeMillis, nil)
if err != nil {
t.Fatalf("buildV1MerkleTreeLeafForCert()=nil,%v; want _,nil", err)
}
Expand Down Expand Up @@ -97,7 +97,7 @@ func TestSignV1SCTForPrecertificate(t *testing.T) {
}

// Use the same cert as the issuer for convenience.
leaf, err := ct.MerkleTreeLeafFromChain([]*x509.Certificate{cert, cert}, ct.PrecertLogEntryType, fixedTimeMillis)
leaf, err := ct.MerkleTreeLeafFromChain([]*x509.Certificate{cert, cert}, ct.PrecertLogEntryType, fixedTimeMillis, nil)
if err != nil {
t.Fatalf("buildV1MerkleTreeLeafForCert()=nil,%v; want _,nil", err)
}
Expand Down

0 comments on commit 1782a3b

Please sign in to comment.