syntax = "proto3";
package cald.ca.v1;
import "Core.proto";
// If false, all generated code goes in a single java file
option java_multiple_files = true;
option java_package = "nexus.cald.api.ca";
// Calling this service: each rpc in CaService, at the end of this file, is an HTTP POST to
// //. is the name between "cald." and ".v1" in this file's package
// (cald.ca.v1, so "ca"), and is the rpc's name in kebab-case: the CA at
// https://example.com/cald takes startRegistration at
// https://example.com/cald/ca/start-registration. The body is the request message in protobuf's
// standard JSON encoding (Content-Type: application/json), and a 200 answer's body is the response
// message, encoded the same way. Every outcome the service decides, refusals included, is a 200
// whose status field says which; any other HTTP status means the call didn't go through. A server
// that doesn't offer an rpc has no route for it.
// ---------------------------------------------------------------------------
// Shared types
// ---------------------------------------------------------------------------
// How a registrant proves control of the number in basic registration. A new method (voice, say)
// is a new value here with its own challenger at the CA. Delayed re-registration is not one: it
// has its own requests below and no challenge.
enum VerificationMethod {
TEXT_MESSAGE = 0;
}
// ---------------------------------------------------------------------------
// Basic registration -- start, then verify with the code
// ---------------------------------------------------------------------------
/**
* The initial request sent to the Certificate Authority Server
*/
message ClientCertificateRequest {
cald.core.v1.PhoneNumber phoneNumber = 1;
// Both encoded in ASN.1 DER via the Java PublicKey.getEncoded() method (X.509 SubjectPublicKeyInfo).
// Two keys, not one: CaLD issues a signing cert and a separate encryption cert per user, which
// are different keys entirely for ECC/ML (e.g. Ed25519 vs. X25519). The CA only
// ever signs these -- it never generates or sees a user's private key.
bytes encodedSigningPublicKey = 2;
bytes encodedEncryptionPublicKey = 3;
cald.core.v1.ValidityPeriod validityPeriod = 4;
// The Relay Server endpoint through which this number is to be reachable. The CA binds it into
// both issued certificates (a dedicated extension) and never defaults it: proto3 has no
// `required`, so a missing or incomplete address is rejected by the CA.
cald.core.v1.WebAddress relayServerAddress = 5;
VerificationMethod verificationMethod = 6;
}
/**
* The follow-up request sent to the Certificate Authority Server
*/
message VerificationRequest {
cald.core.v1.PhoneNumber phoneNumber = 1;
string verificationCode = 2;
// The same two public keys the initial ClientCertificateRequest carried. A challenge is scoped
// to (phone number + these keys), so several registrations for one number can be outstanding
// at once and a correct code only ever issues the certificate that was actually requested.
bytes encodedSigningPublicKey = 3;
bytes encodedEncryptionPublicKey = 4;
}
message ClientCertificateResponse {
Status status = 1;
enum Status {
// Never sent: an empty or missing status must not read as a challenge sent.
STATUS_UNSPECIFIED = 0;
CHALLENGE_SENT = 1;
// Every refusal the CA makes, deliberately not distinguished.
REFUSED = 2;
// The requesting source is over the route's per-source limit; nothing was
// checked, so it says nothing about the number. Try again later.
RATE_LIMITED = 3;
}
}
message VerificationResponse {
Status status = 1;
// The issued pair and its full chain, set only when the status is ISSUED. Shared shape with the
// Lookup Service's read responses -- see Core.proto CertificateBundle.
cald.core.v1.CertificateBundle certificateBundle = 2;
enum Status {
// Never sent: an empty or missing status must not read as success.
STATUS_UNSPECIFIED = 0;
ISSUED = 1;
// Every refusal the CA makes, deliberately not distinguished.
REFUSED = 2;
// The requesting source is over the route's per-source limit; the code was not
// checked and no try of it was used. Try again later.
RATE_LIMITED = 3;
}
}
// ---------------------------------------------------------------------------
// Delayed re-registration
// ---------------------------------------------------------------------------
// Delayed re-registration is a two-step, challenge-less flow gated by proof of possession of the
// current pair's signing key.
// Step 1: reserve a replacement pair. The CA returns a signed authorization letter and creates no
// certificate.
//
// signedReservationRequestBody is a serialized ReservationRequestBody (below), transmitted
// verbatim. The CA verifies proofSignature against these exact bytes and only then decodes them,
// rather than reconstructing them from an already-parsed message field.
message ReregistrationReservationRequest {
bytes signedReservationRequestBody = 1;
// Signature by the authorizing certificate's signing private key over
// signedReservationRequestBody, under signing context `cald/ca/reservation-request/v1`
// (Core.proto).
bytes proofSignature = 2;
}
message ReservationRequestBody {
cald.core.v1.PhoneNumber phoneNumber = 1;
// The committed replacement keys (DER SubjectPublicKeyInfo), algorithm family derived from
// them as in basic registration.
bytes replacementSigningPublicKey = 2;
bytes replacementEncryptionPublicKey = 3;
cald.core.v1.ValidityPeriod validityPeriod = 4;
// Required, never defaulted or carried over from the current pair.
cald.core.v1.WebAddress relayServerAddress = 5;
// DER of the current Current Certificate whose signing key signs this request.
bytes authorizingCertificate = 6;
}
// The outcome is the status alone; a reader treats anything but RESERVED
// (STATUS_UNSPECIFIED, an unknown value) as a failure.
message ReregistrationReservationResponse {
Status status = 1;
AuthorizationLetter letter = 2; // set only when the status is RESERVED
enum Status {
// Never sent: an empty or missing status must not read as success.
STATUS_UNSPECIFIED = 0;
RESERVED = 1;
// Every refusal the CA makes, deliberately not distinguished.
REFUSED = 2;
// The requesting source is over the route's per-source limit; nothing was
// checked, so it says nothing about the request. Try again later.
RATE_LIMITED = 3;
}
}
// Self-contained: everything the CA needs to confirm and issue the replacement at redemption,
// signed with the CA intermediate key with the intermediate->root chain embedded so the signature
// validates to the CaLD root.
//
// signedAuthorizationLetterBody is a serialized AuthorizationLetterBody (below), transmitted
// verbatim. Redemption verifies signature against these exact bytes and only then decodes them,
// rather than reconstructing them from an already-parsed message field -- the letter travels
// through the holder between mint and redemption, so this matters even though the CA is both
// signer and verifier.
message AuthorizationLetter {
bytes signedAuthorizationLetterBody = 1;
// CA signature over signedAuthorizationLetterBody, by the intermediate key, under signing context
// `cald/ca/authorization-letter/v1` (Core.proto).
bytes signature = 2;
// The signer first -- the intermediate whose key made `signature` -- then its issuers toward
// the root, the root left out (it goes in `rootCACertificate`), as in `CertificateBundle`.
repeated bytes intermediateCACertificates = 3;
bytes rootCACertificate = 4;
}
message AuthorizationLetterBody {
cald.core.v1.PhoneNumber phoneNumber = 1;
bytes replacementSigningPublicKey = 2;
bytes replacementEncryptionPublicKey = 3;
cald.core.v1.ValidityPeriod validityPeriod = 4;
cald.core.v1.WebAddress relayServerAddress = 5;
bytes authorizingCertificate = 6;
// Epoch millis. Becomes the replacement pair's notBefore -- the pair is back-dated to the
// reservation.
int64 issuedAtEpochMillis = 7;
// Epoch millis. The letter's redemption deadline, not a certificate's notAfter: a redemption
// after this is rejected. The CA sets it no later than the authorizing certificate's
// own notAfter.
int64 redeemByEpochMillis = 8;
}
// Step 2: redeem the letter for the issued, back-dated replacement pair.
//
// proofSignature proves possession of the authorizing certificate's signing key, so a letter alone
// redeems nothing. It covers letter.signedAuthorizationLetterBody exactly as transmitted, under
// signing context `cald/ca/letter-redemption-proof/v1` (Core.proto).
message ReregistrationRedemptionRequest {
AuthorizationLetter letter = 1;
bytes proofSignature = 2;
}
// As ReregistrationReservationResponse, anything but REDEEMED is a failure.
message ReregistrationRedemptionResponse {
Status status = 1;
cald.core.v1.CertificateBundle certificateBundle = 2; // set only when the status is REDEEMED
enum Status {
// Never sent: an empty or missing status must not read as success.
STATUS_UNSPECIFIED = 0;
REDEEMED = 1;
// Every refusal the CA makes, deliberately not distinguished.
REFUSED = 2;
// The requesting source is over the route's per-source limit; nothing was
// checked, so the letter is still good. Try again later.
RATE_LIMITED = 3;
}
}
// ---------------------------------------------------------------------------
// Stored records (not exchanged on the wire)
// ---------------------------------------------------------------------------
/**
* The CA's permanent record of one issuance -- a pair issued by basic
* registration or by a redeemed re-registration. Written before the pair is published to the Lookup
* Service and kept forever, so "which certificate did the CA issue to this number, and when?" has an
* answer after the pair is superseded.
*/
message IssuanceRecord {
int64 issuedAtEpochMillis = 1;
cald.core.v1.PhoneNumber phoneNumber = 2;
IssuedCertificate signingCertificate = 3;
IssuedCertificate encryptionCertificate = 4;
// The intermediate that signed both certificates (DER).
bytes issuingIntermediateCertificate = 5;
// How the number was verified.
oneof verification {
// Basic registration: the challenge the registrant answered.
VerificationMethod verificationMethod = 6;
// Re-registration: the authorization letter redeemed, exactly as submitted.
AuthorizationLetter redeemedLetter = 7;
}
}
message IssuedCertificate {
bytes certificate = 1; // DER, in full
bytes serialNumber = 2; // two's-complement big-endian, as BigInteger.toByteArray()
cald.core.v1.Hash fingerprint = 3; // of the full DER (SHA-256 today)
cald.core.v1.CertificateAlgo keyFamily = 4; // the certified key's family
}
/**
* A registration the CA has sent a challenge for and is waiting to complete: the start request as
* last received, and when its challenge was sent, so a completion can say how long the registrant
* took (the `ca.registration.elapsed` metric). Kept only until
* it completes, its challenge expires or it is swept.
*/
message PendingRegistration {
ClientCertificateRequest request = 1;
// When the challenge that is still live was sent; 0 when not known.
int64 challengeSentAtEpochMillis = 2;
}
// ---------------------------------------------------------------------------
// Service
// ---------------------------------------------------------------------------
// The Certificate Authority's operations, each request message with the response that answers it:
// basic registration and delayed re-registration. Carried as HTTP POST with
// protobuf-JSON bodies; this block documents the exchanges and generates no gRPC code.
service CaService {
// Anyone: start registering a number. The CA stores the pending request and sends a challenge
// to the number by the requested verification method. A live challenge for the same request is
// reused, and one that can't be delivered leaves nothing behind. Challenges are capped per
// number and by a global send budget, which a request can be refused for.
rpc startRegistration(ClientCertificateRequest) returns (ClientCertificateResponse);
// The registrant: answer the challenge. A correct code for the same number and keys issues the
// signing and encryption pair, publishes it to the Lookup Service and returns it with its chain.
// Every failure looks the same from outside.
rpc completeRegistration(VerificationRequest) returns (VerificationResponse);
// The holder of a number's current pair, proving possession of its signing key: reserve a
// replacement pair. Returns a CA-signed authorization letter and issues no certificate.
rpc reserveReregistration(ReregistrationReservationRequest) returns (ReregistrationReservationResponse);
// The same holder, later: redeem the letter. The CA confirms the authorizing pair is still
// current, then issues and publishes the replacement pair back-dated to the reservation.
rpc redeemReregistration(ReregistrationRedemptionRequest) returns (ReregistrationRedemptionResponse);
}