Skip to content

PEM to vkey for MTC#1068

Merged
AlCutter merged 1 commit into
transparency-dev:mainfrom
AlCutter:pem_to_vkey
Jul 21, 2026
Merged

PEM to vkey for MTC#1068
AlCutter merged 1 commit into
transparency-dev:mainfrom
AlCutter:pem_to_vkey

Conversation

@AlCutter

@AlCutter AlCutter commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

This PR contains a quickly hacked-up tool for converting an X.509 PEM cert containing MTC CA IDs to a vkey for use with the mtc mirror.

Towards #945

@AlCutter
AlCutter requested a review from roger2hk July 21, 2026 14:34
@AlCutter
AlCutter requested a review from a team as a code owner July 21, 2026 14:34
@AlCutter
AlCutter force-pushed the pem_to_vkey branch 4 times, most recently from 9af51a0 to d565a32 Compare July 21, 2026 15:16
Comment thread cmd/mtc/pemtovkey/README.md Outdated
oid/1.3.6.1.4.1.44363.47.1.11129.11.99.1+f3cdeae8+BqEI2mLl390er8KhOhcQIXsl5MiNpfCY+J8pPHfWOSIKph/S87zYk9IwoM/T+z5Q0VNMHw1AZrluGTb1VAEPzzZhdl/M6hPaMv5YCOvvhk68C9eeFzyibqH/WppChBwnfKx3/8DwtEtsb6tL8V0QYdOnEg9h8F+HxIusAaL5zBLpagaswSM1gSzmNf8EYeFqGC21CtdJqIzXtDVmn448mt7ojrxjekR4p9EoLDT74l6Hm2ONdbeBf4SexYfiXkb9JV3VcCzWzCzcol5MrNwpbYj1XfruEFlFdI5vffpS9Kj3ZkFgX5yEEVPv+WHIn9nqrL1BgqagIUFlYZdnrS8gHBiyD2Dtk4IZ6JfZ9xcFrvahoduGqprhbrCME/1sl3gRpw0rsg6xEXjko3EcgmOF0iGz+6df/pNDcc+6/3DvIp82DxSfLmTuwVN7lY/C4HT1LY7cIg7DzIZq4Qk8okkEuNv6mdnWZohIT+c8EuwFr8IG1kZqAA8b1VUwOCxMRr2YnxW0kUHPUeEADRk5SchNlg3L1mz9JfNFGOSGtFweCYztKuEZdxKgZWQ3iY+fF97KryfqkvYTfEj2KiIWKOT1x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AQ44ygo2/W3Oq+IwCWvmle5YxiiYadblXy4R28oOIhpG4wHXMsCkaegT7O4Wf9jmcd5hrA2r4=
```

The `vkey` is the final (very long) line

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
The `vkey` is the final (very long) line
The `vkey` is the final (very long) line.

Comment thread cmd/mtc/pemtovkey/main.go Outdated
Comment on lines +86 to +89
pub := crt.RawSubjectPublicKeyInfo[22:]
if l := len(pub); l != 1312 {
exit("Invalid public key length %d, expected 1312", l)
}

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.

This is some magical code. We can either add some code comment to explain what it does or use the "encoding/asn1" or "golang.org/x/crypto/cryptobyte" package.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I did say it was hacky :)
Ok, parsed out the algo and verified that it's ML-DSA-44.

Comment thread cmd/mtc/pemtovkey/main.go
Comment on lines +63 to +64
der, _ := pem.Decode(c)
crt, err := x509.ParseCertificate(der.Bytes)

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.

If der from pem.Decode is nil, it will trigger a nil pointer dereference panic.

Comment thread cmd/mtc/pemtovkey/main.go Outdated
}

func exit(m string, a ...any) {
fmt.Printf(m, a...)

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.

The string printed here will get into the shell prompt line. Add a \n?

@AlCutter
AlCutter merged commit 0fbd302 into transparency-dev:main Jul 21, 2026
19 of 20 checks passed
@AlCutter
AlCutter deleted the pem_to_vkey branch July 21, 2026 17:31
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