withdrawnSigningKeysFor method
- String enrollmentId
The public half of every signing keypair enrollmentId has
withdrawn from signing, strongest algorithm first, each with the status
the keyfile gives it — the entries an _apsk advertisement carries
alongside the active ones, so that envelopes signed before a key was
withdrawn still verify.
Public-only, deliberately. A retired key exists to verify what it already signed and must never sign again, so handing back its private half would only invite that. For the same reason the private half is not required to be present: a build that wipes a withdrawn key's private material is doing the hygienic thing, and dropping the advertisement entry when it does would retroactively unverify everything that key signed — the precise loss retention exists to prevent.
Selected on not active and not CryptographicMaterialStatus.dead, and the token
itself is carried out rather than replaced. dead material was never
adopted and has nothing to verify, so it stays out.
A status this build cannot read is advertised too, carrying the keyfile's own token. Skipping it is not the cautious option it looks like: the advertisement is rewritten whole on every publish, so an omitted entry is a withdrawal from the advertisement — it erases both the key that verifies what it signed and whatever its owner last said about it.
Same keyId shape and same unknown-algorithm skip as signingKeysFor; an
enrollment's other privateSigning material is not a signing key of its
own and is not advertised as one.
Implementation
List<
({
SigningAlgoType algorithm,
String publicKey,
CryptographicMaterialStatus status
})> withdrawnSigningKeysFor(String enrollmentId) {
final withdrawn = <({
SigningAlgoType algorithm,
String publicKey,
CryptographicMaterialStatus status
})>[];
for (final keyId in _enrollments[enrollmentId]?.materialsByKeyId.keys ??
const <String>[]) {
if (!isRoleKeyId(keyId, 'sign')) continue;
final public = getKey(
enrollmentId, keyId, CryptographicMaterialRole.publicVerification);
if (public == null ||
public.status == CryptographicMaterialStatus.active ||
public.status == CryptographicMaterialStatus.dead) {
continue;
}
final algorithm = SigningAlgoType.values
.where((a) => a.name == public.algorithm)
.firstOrNull;
if (algorithm == null) continue;
withdrawn.add((
algorithm: algorithm,
publicKey: public.bytes.toString(),
status: public.status,
));
}
withdrawn.sort((a, b) => _strongestFirst(a.algorithm, b.algorithm));
return withdrawn;
}