Skip to content

Add new MTCB service to build MTCs from db and tree - #8986

Draft
aarongable wants to merge 1 commit into
mainfrom
mtcb
Draft

Add new MTCB service to build MTCs from db and tree#8986
aarongable wants to merge 1 commit into
mainfrom
mtcb

Conversation

@aarongable

@aarongable aarongable commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Note

This is very much a draft. It is based on top of #8958, should incorporate #8971 and #8968 before merging, and would benefit greatly from the work that @jsha is doing to factor out the database interface for tests and readability. Also, it doesn't have tests yet.

That said, the main-line logic is reviewable, so take a look at that if you're curious!

Fixes #8914
Fixes #8918

Base automatically changed from ezekiel/pubkeys-as-tiles to main August 31, 2026 22:02
Comment thread mtcb/proto/mtcb.proto
Comment on lines +8 to +9
// GetStandalone requests that the MTCB return the standalone version of the
// certificate with the given serial number issued by the given MTCA.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// GetStandalone requests that the MTCB return the standalone version of the
// certificate with the given serial number issued by the given MTCA.
// GetStandalone returns a standalone certificate.

"requests that the MTCB return" is redundant when defining an RPC service. "Returns" is simpler.

"given serial number issued by the given MTCA" restates the parameters; better to leave those defined in the StandaloneRequest so they don't drift.

Comment thread mtcb/proto/mtcb.proto

message StandaloneRequest {
// Next unused field number: 3
string mtcaID = 1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In many places we have a choice of what to store and pass:

  1. mtcaID, serial
  2. mtcLogID, entryIndex
  3. mtcLogID, serial

FWIW in #8912 I proposed (mtcLogID, entryIndex). This PR currently uses (mtcaID, serial) for this request.

Rethinking #8912 I maybe want to settle on (mtcLogID, serial). It's slightly redundant (log number is carried in two places), but:

  • Redundancy can be good, it gives us a cross-check.
  • CRLs care about serials (not entryIndexes).
  • Tlogs care about MTC log IDs (not CA IDs).

WDYT?

Comment thread mtcb/mtcb.go
Bucket() string
}

func getCAID(issuerCert *x509.Certificate) (string, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should factor this out from mtca, probably into the issuance package as an accessor on Issuer.

Comment thread mtcb/mtcb.go
Comment on lines +119 to +123
// The serial is always a 64-bit int. However, there might be many leading
// zeroes which aren't represented in the hex string, so it needs to be
// left-padded with zeroes out to 64 bits.
var paddedSerialBytes [8]byte
copy(paddedSerialBytes[8-len(serialBytes):8], serialBytes)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably express this a little more simply with strconv.ParseUint with a base of 16 and then some bit math based on the resulting uint64.

Comment thread mtcb/mtcb.go
Comment on lines +248 to +250
b.AddASN1(asn1.TagSequence, func(b *cryptobyte.Builder) {
b.AddBytes(proof.SigAlgEncoded())
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since SigAlgEncoded() includes the wrapping SEQUENCE, this should just be:

Suggested change
b.AddASN1(asn1.TagSequence, func(b *cryptobyte.Builder) {
b.AddBytes(proof.SigAlgEncoded())
})
b.AddBytes(proof.SigAlgEncoded())

Also, minor refactoring: I expect that GetLandmarkRelative() will also need this code (serialize an MTCProof and put it into an RFC 5280 Certificate), so we'll want to factor it out either now or later. One argument in favor of "now": this is a nice-sized chunk to test on its own, for instance checking that the result parses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants