[vault] Android: the android key kind (RSA-4096, self-signed, 100 years) and the apk sign kind (1-4 SHA-512 digests, PKCS#1 v1.5), never unattended; v0.14.0
This commit is contained in:
+43
-2
@@ -1,4 +1,4 @@
|
||||
# Signing keys (core 0.9.0; deploy approvals 0.12.0)
|
||||
# Signing keys (core 0.9.0; deploy approvals 0.12.0; Android APKs 0.14.0)
|
||||
|
||||
Custos signs releases for Fabrica Domi · Artifex without a private key ever leaving the vault. A build asks for a
|
||||
signature over a **digest**; Custos checks who may ask, Mark approves with a match code, and the vault signs and
|
||||
@@ -46,6 +46,7 @@ vault must be 0.9.0 or later. There is no mnemonic for these keys: back the vaul
|
||||
| `ed25519` | Ed25519; `secret` is the 32-byte seed, `public` the 32-byte key, `keyId` minisign's 8-byte key id | `minisign`, `manifest`; `domi-approve` only `approval` | random |
|
||||
| `root-ca` | RSA-3072; `secret` is PKCS#8 DER; `cert` a self-signed X.509 v3 CA certificate, valid 10 years | only the leaf it issues, at creation; never a request | random |
|
||||
| `code-signing` | RSA-3072; `secret` PKCS#8 DER; `cert` an X.509 v3 leaf issued by `issuer`, valid 2 years, EKU code signing | `authenticode` | random |
|
||||
| `android` (core 0.14.0) | RSA-4096; `secret` PKCS#8 DER; `cert` a self-signed X.509 v3 certificate, valid 100 years, no EKU, under no root | only `apk` | random |
|
||||
|
||||
`role` is `release` or `test`. *Create release keys* makes `domi-release`, `domi-root`, `domi-code-signing` and
|
||||
(since core 0.12.0) `domi-approve` ("Domi deploy approval"), the Ed25519 key that signs deploy approvals, with the
|
||||
@@ -55,6 +56,15 @@ release keys' scope. A vault whose release keys were made by an older core gets
|
||||
`domi-test-root`: a test certificate never chains to the household root, so an automatically approved signature is
|
||||
never trusted by Mark's PCs.
|
||||
|
||||
*Create Android key* (`signing_create_android`, core 0.14.0) makes one Android app signing key at a time, with the
|
||||
id, name, certificate subject (`CN`, `O`, a two-letter `C`), role and scope the app gives it; an id is used once.
|
||||
The app makes `postea-android` (`CN=Postea, O=Marek Novak, C=CZ`, release, pipeline `release`, repo
|
||||
`mnovak/Postea`) and its test twin `domi-test-android` (`CN=Domi Test Android, O=Domi, C=CZ`, test). An Android
|
||||
key's certificate *is* the app's identity: Android accepts an update only when it is signed by the same certificate,
|
||||
for the app's whole life. Its loss ends the app's updates for good, and there is no phrase to recover it from (the
|
||||
vault has none), so **the vault must have two backups off the PC before the first real signature**. Its public
|
||||
half is the certificate (`signing_export_cert`).
|
||||
|
||||
`pipelines` and `repos` list who may ask (pipeline names, repository folder names; `*` means any). A request from
|
||||
a pipeline or repo not on its key's lists is refused **even when approved**. Release keys always need approval.
|
||||
Test keys are approved automatically, but only for requests whose `trigger` is not `tag` (a manual run, a push).
|
||||
@@ -66,6 +76,9 @@ Certificates:
|
||||
`extKeyUsage` codeSigning, subject and authority key identifiers; both signed with sha256WithRSAEncryption.
|
||||
The root's certificate (public part only) is exported as DER (`.cer`) to install as Trusted Root and Trusted
|
||||
Publisher.
|
||||
- android: subject and issuer `CN=<cn>, O=<o>, C=<c>` (encoded C, O, CN; `C` a PrintableString), validity 100 × 365
|
||||
days, `basicConstraints` not a CA, `keyUsage` digitalSignature + nonRepudiation, subject and authority key
|
||||
identifiers (both of its own key), no `extKeyUsage`; sha256WithRSAEncryption by its own key.
|
||||
|
||||
## Signature kinds
|
||||
|
||||
@@ -77,6 +90,7 @@ A request names a key, a kind and what to sign. Custos never receives the file.
|
||||
| `manifest` | `manifest`: the `SHA256SUMS` text itself (≤ 32 KiB, canonical, see below) | a `.minisig` file over it |
|
||||
| `authenticode` | `digest`: the 32-byte SHA-256 in signtool's `.dig` | the RSA PKCS#1 v1.5 signature (384 bytes) for `.dig.signed` |
|
||||
| `approval` | `approval`: a deploy approval's canonical JSON (at most 8 KiB, see below), and `run` | a `.minisig` file over it |
|
||||
| `apk` (core 0.14.0) | `digest`: 1 to 4 SHA-512 digests of APK Signature Scheme signed data, concatenated (64·n bytes) | the n RSA PKCS#1 v1.5 signatures (512 bytes each), concatenated in the same order |
|
||||
|
||||
Any request may carry a `run` (`[A-Za-z0-9._-]{1,64}`, core 0.12.0): the build's run id, so the app can show every
|
||||
request of one run on one card. It is kept in the audit entry. A malformed `run` is `invalid`; `approval` text on a
|
||||
@@ -158,6 +172,28 @@ Checked on 2026-11-04 with signtool 10.0.26100 and a throwaway RSA-3072 key: the
|
||||
with "terminated in a root certificate which is not trusted", and a wrong signature gives "No signature found".
|
||||
`signtool verify /pa` on a machine that trusts the root is the last check, done where the root is installed.
|
||||
|
||||
### apk (core 0.14.0)
|
||||
|
||||
An APK is signed by Google's apksig (`apksigner.jar` from the Android SDK build-tools) on the build's side; Custos
|
||||
signs only what apksig's signer would sign. APK Signature Scheme v2 and v3 each sign one *signed data* block (the
|
||||
APK's content digests, the certificate, attributes; v3 adds the SDK range), so a v2+v3 APK needs two signatures.
|
||||
apksig picks `RSA_PKCS1_V1_5_WITH_SHA512` (`SHA512withRSA`) for every RSA key over 3072 bits and has no way to
|
||||
choose otherwise, so the kind takes **SHA-512** digests and signs each with the SHA-512 DigestInfo:
|
||||
|
||||
- `digest` is 64·n bytes, n from 1 to 4: the SHA-512 of each signed data block, in the order the build wants the
|
||||
signatures back. Anything else is `invalid`. The context's `file` (the APK's name) is required, as for minisign.
|
||||
- The answer is the n signatures concatenated, 512 bytes each for RSA-4096. One request, one card line, one audit
|
||||
entry (its `signature` is the SHA-256 of all of them), so a release run raises **one** card for its APK.
|
||||
- `apk` is signed only by an `android` key, and an `android` key signs nothing else: an Authenticode key cannot sign
|
||||
an APK and an Android key cannot sign an exe (`invalid`).
|
||||
- `apk` is not one of the kinds the hands-off vault may sign without a card (FORMAT.md, `unattended_sign`): an
|
||||
Android key cannot be revoked or replaced, so its signatures always ask.
|
||||
|
||||
The client (`custos-sign apk`, in the app's repository) runs apksig twice: once with a stand-in signer that records
|
||||
the digests and answers with placeholder signatures (the signed data does not depend on the signatures), then, with
|
||||
Custos's answer, again with a signer that hands each recorded digest its signature, and refuses any digest it did
|
||||
not record. It verifies the result with apksig's verifier before it writes the APK.
|
||||
|
||||
## The audit log
|
||||
|
||||
`audit` is append-only: there is no function that edits or removes an entry. Every request a key is named in gets
|
||||
@@ -177,7 +213,11 @@ one entry, whatever happened:
|
||||
(core 0.12.0) is the context's version, absent when empty. The entry is part of the vault, so it survives a reopen
|
||||
and travels with it.
|
||||
|
||||
**Compatibility.** Older cores ignore `run`, `version` and the `domi-approve` key. An audit entry of kind
|
||||
**Compatibility.** A key of kind `android` and an audit entry of kind `apk` (core 0.14.0) are values a core
|
||||
before 0.14.0 does not know: once the vault holds an Android key, every Custos that opens it must be on core 0.14.0
|
||||
or later (an older one refuses the vault as `Corrupted`; the web vault, which never reads `signing`, is unaffected).
|
||||
|
||||
Older cores ignore `run`, `version` and the `domi-approve` key. An audit entry of kind
|
||||
`approval` is a value they do not know, so a core before 0.12.0 refuses a vault that holds one (`Corrupted`): once a
|
||||
vault has recorded an approval request, every Custos that opens it must be on core 0.12.0 or later.
|
||||
|
||||
@@ -186,6 +226,7 @@ vault has recorded an approval request, every Custos that opens it must be on co
|
||||
```
|
||||
Vault::signing_create(role, pipelines, repos, now) -> ids // release (with domi-approve) or test set
|
||||
Vault::signing_add_approve(now) -> "domi-approve" // for release keys made before 0.12.0
|
||||
Vault::signing_create_android(&AndroidKey, now) -> id // one Android key (core 0.14.0)
|
||||
Vault::signing_keys() -> [SigningKeyView] // public parts only
|
||||
Vault::signing_set_scope(id, pipelines, repos)
|
||||
Vault::signing_export_cert(id) -> DER // a certificate, never a key
|
||||
|
||||
Reference in New Issue
Block a user