syntax = "proto3"; package cald.core.v1; // If false, all generated code goes in a single java file option java_multiple_files = true; option java_package = "nexus.cald.api.core"; // Signing contexts. Every signature a CaLD message carries in a signature field is made, and // checked, over a context label followed by the signed bytes exactly as sent, never over the bytes // alone (a certificate's own signature is plain X.509): the label's length in bytes as two // bytes, big-endian, then the label in ASCII, then the signed bytes. So `cald/lookup/read/v1` (19 // characters) puts 0x00 0x13 and those 19 bytes ahead of a Lookup read's signed bytes. The label // says what kind of content a signature is for, so a signature made for one kind never verifies as // another, whatever its bytes happen to decode as. It is never sent: each signature field names the // label its verifier expects, and each kind of signed content has its own. // A phone number in E.164 form: "+", the country's dialing code, // then the national significant number, digits only, at most 15 digits in all, no spaces or other // formatting -- US +1 613 555 0142 is {e164: "+16135550142"}. The country is read from the dialing // code; there is no separate country field, so none can default. A receiver refuses a value that // isn't E.164 or whose dialing code it doesn't support. A certificate's subject names the same // number (CN=+16135550142). It stays a message, never a bare string field, so every phone number on // the wire has one type. message PhoneNumber { string e164 = 1; } // Plain days, no unit: MONTHS/YEARS would only ever be an approximate day count anyway (this // project doesn't do calendar-exact validity math), so a unit enum bought no real precision -- // just complexity the client would still have to convert away from. message ValidityPeriod { int32 days = 1; } // A network endpoint. `scheme` is the URL scheme (`http` / `https` for now) -- a plain string, // not an enum, since it's unclear whether other schemes will ever be needed. Field order matches // the URL string form this is written into a certificate as, `://:`. message WebAddress { string scheme = 1; string hostname = 2; // Always explicit, 1-65535. There is no "scheme default": 0 (the unset value) or // anything out of range makes the address unusable, never port 80 / 443. int32 port = 3; string path = 4; } // A digest and the algorithm that made it: the one shape every hash on the wire is meant to take, // so a reader always computes with the algorithm the hash names rather than a house convention, and a // second algorithm (SHA-512, say) is additive. `digest` is the raw digest bytes. message Hash { HashAlgorithm algorithm = 1; bytes digest = 2; } // HASH_ALGORITHM_UNSPECIFIED (an omitted algorithm) is refused, never read as SHA-256, and so is a // value this build doesn't know. Over protobuf-JSON an unknown name fails a strict parser's whole // message; a parser ignoring unknown fields reads it as unspecified, which is refused too. enum HashAlgorithm { HASH_ALGORITHM_UNSPECIFIED = 0; SHA_256 = 1; } enum CertificateAlgo { RSA = 0; ECC = 1; ML = 2; } // A CaLD Certificate Pair (both leaves) plus the issuing-chain material that accompanies it. // Shared by the CA (returned from a successful registration) and the Lookup Service (returned // from a read). All certificates are DER, `X509Certificate.getEncoded()`. How much chain // material is populated is context-dependent: the CA sends the full chain on issuance; a Lookup // read populates it per the request's `ChainDetail`. Not named `...Pair` because the glossary // reserves "CaLD Certificate Pair" for the two leaves alone. message CertificateBundle { bytes encodedSigningCertificate = 1; bytes encodedEncryptionCertificate = 2; // The CA certificates between the leaves and the root, nearest issuer first: the certificate // that issued the leaves, then its issuer, and so on toward the root. Senders leave the root // out (it goes in `rootCACertificate`). Where the list is used, both leaves are validated // through it, so both must have been issued by its first certificate, and a list in another // order does not validate. CaLD's own chains carry exactly one, since its intermediates are // issued by the root with a path length of 0. May be empty when only the leaves were // requested; a message carrying a bundle may say it never uses this field // (`SignedMessage.signerCertificates`). repeated bytes intermediateCACertificates = 3; // The trusted root. May be empty when it was not requested. bytes rootCACertificate = 4; }