Class LicenseSigner
java.lang.Object
com.iizix.license.v2.LicenseSigner
The issuing half of
LICENSE-V2-DESIGN.md sections 2.2 and 2.4: the canonical payload bytes, the envelope and the Ed25519 signature. Two roles, told apart by the constructor:- A root (
LicenseSigner(String, PrivateKey)) signs key certificates (signCertificate(String, PublicKey, Instant, Instant)) at the ceremony of LV-4, offline. It signs no document. - The MLS signing key (
LicenseSigner(PrivateKey, KeyCertificate)) signs licence documents (signDocument(Map)) and the MLS's hello proof (sign(byte[])overHello.mlsHello(byte[], byte[], UUID)). Its certificate, verified under the pinned roots byLicenseVerifier.verifyCertificate(byte[]), travels in every document'scertline, and the constructor proves the private key is the one the certificate certifies - a wrong file on the MLS host fails at startup, not at the first client.
The signer takes a PrivateKey and loads nothing: where the key comes from (the PKCS#8 file under /etc/iizi/mls/, the refusal of a file open to group or others) is the MLS's business in B-5b. An installation's own proofs (5.2, 5.4) need no signer: they are Ed25519.sign(PrivateKey, byte[]) over the bytes of Hello.
What the verifier's step 3 would refuse is refused here before it is signed: a payload with an unknown key, a missing required key or a value in another spelling is an IllegalArgumentException naming the rule.
- Author:
- Christopher Mindus
Constructor Summary
ConstructorsConstructorDescriptionLicenseSigner(String kid, PrivateKey key) Constructor for a root, or for a key whose certificate is not at hand: signs certificates and raw bytes, never a document.LicenseSigner(PrivateKey key, KeyCertificate certificate) Constructor for the MLS signing key: signs documents with its certificate in them.Method Summary
Modifier and TypeMethodDescriptionGets the certificate.getKeyID()Gets this key's ID.byte[]sign(byte[] bytes) Signs bytes: the MLS's hello proof overHello.mlsHello(byte[], byte[], UUID).byte[]signCertificate(String keyID, PublicKey certified, Instant notBefore, Instant notAfter) Signs a key certificate: this key is the root, thekidline of the envelope.byte[]signDocument(Map<String, String> payload) Signs a licence document: the payload in its one byte form, this key's signature over it, this key's certificate.
Constructor Details
LicenseSigner
Constructor for a root, or for a key whose certificate is not at hand: signs certificates and raw bytes, never a document.- Parameters:
kid- This key's ID, thekidline of what it signs.key- The Ed25519 private key.- Throws:
IllegalArgumentException- If the key ID is malformed or the key is not an Ed25519 key.
LicenseSigner
Constructor for the MLS signing key: signs documents with its certificate in them.- Parameters:
key- The Ed25519 private key.certificate- Its certificate, verified under the pinned roots.- Throws:
IllegalArgumentException- If the key is not an Ed25519 key, or the certificate does not certify this key (a signature made here does not verify under the certified key).
Method Details
getKeyID
getCertificate
Gets the certificate.- Returns:
- The certificate, or null for a root.
sign
public byte[] sign(byte[] bytes) Signs bytes: the MLS's hello proof overHello.mlsHello(byte[], byte[], UUID).- Parameters:
bytes- The bytes.- Returns:
- The 64-byte signature.
signCertificate
public byte[] signCertificate(String keyID, PublicKey certified, Instant notBefore, Instant notAfter) Signs a key certificate: this key is the root, thekidline of the envelope.- Parameters:
keyID- The certified key's ID.certified- The certified Ed25519 public key.notBefore- The first instant the certificate is valid.notAfter- The last instant the certificate is valid; a year afternotBeforefor an MLS signing key (2.4).- Returns:
- The
IIZI-KEYCERT/1envelope bytes. - Throws:
IllegalArgumentException- If the key ID is malformed, the key is not an Ed25519 key on the curve, ornotBeforeis afternotAfter.
signDocument
Signs a licence document: the payload in its one byte form, this key's signature over it, this key's certificate.- Parameters:
payload- The keys and values ofLicenseDocument;vmay be absent and is then written as 2.- Returns:
- The
IIZI-LICENSE/2envelope bytes. - Throws:
IllegalStateException- If this signer has no certificate (a root).IllegalArgumentException- Ifvis present and not 2, or the payload is not one the verifier's step 3 accepts: the message names the rule.