Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f622bd283c | |||
| 022b5da454 | |||
| 553f13b265 | |||
| bf5becdc32 | |||
| 44452e3815 | |||
| 987d49c116 | |||
| b942c24077 | |||
| a3b3a32745 | |||
| 0eee7632ae | |||
| 6588461438 | |||
| e533a38883 |
@@ -1,7 +1,7 @@
|
|||||||
# Custos Domi — core (public)
|
# Custos Domi — core (public)
|
||||||
|
|
||||||
Custos (Latin: guardian) is a local-first password and secret manager in the Domi ecosystem.
|
Custos (Latin: guardian) is a local-first password and secret manager in the Domi ecosystem.
|
||||||
This repository is the **public, MPL-2.0 core**: everything that touches plaintext or keys.
|
This repository is the **public, CPAL-1.0 core** (MPL-2.0 before v0.20.0): everything that touches plaintext or keys.
|
||||||
The Windows app lives in the private `Custos` repo and depends on this one by git tag.
|
The Windows app lives in the private `Custos` repo and depends on this one by git tag.
|
||||||
|
|
||||||
## Layout
|
## Layout
|
||||||
|
|||||||
Generated
+13
-13
@@ -329,14 +329,14 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-browser"
|
name = "custos-browser"
|
||||||
version = "0.18.1"
|
version = "0.21.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-gen"
|
name = "custos-gen"
|
||||||
version = "0.18.1"
|
version = "0.21.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"custos-vault",
|
"custos-vault",
|
||||||
"data-encoding",
|
"data-encoding",
|
||||||
@@ -348,7 +348,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-kdbx"
|
name = "custos-kdbx"
|
||||||
version = "0.18.1"
|
version = "0.21.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes",
|
"aes",
|
||||||
"argon2",
|
"argon2",
|
||||||
@@ -369,7 +369,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-keys"
|
name = "custos-keys"
|
||||||
version = "0.18.1"
|
version = "0.21.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"custos-vault",
|
"custos-vault",
|
||||||
"ed25519-dalek",
|
"ed25519-dalek",
|
||||||
@@ -382,7 +382,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-native"
|
name = "custos-native"
|
||||||
version = "0.18.1"
|
version = "0.21.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"custos-browser",
|
"custos-browser",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@@ -392,11 +392,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-qr"
|
name = "custos-qr"
|
||||||
version = "0.18.1"
|
version = "0.21.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-seal"
|
name = "custos-seal"
|
||||||
version = "0.18.1"
|
version = "0.21.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chacha20poly1305",
|
"chacha20poly1305",
|
||||||
"hkdf",
|
"hkdf",
|
||||||
@@ -409,7 +409,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-share"
|
name = "custos-share"
|
||||||
version = "0.18.1"
|
version = "0.21.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"argon2",
|
"argon2",
|
||||||
"chacha20poly1305",
|
"chacha20poly1305",
|
||||||
@@ -426,7 +426,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-sign"
|
name = "custos-sign"
|
||||||
version = "0.18.1"
|
version = "0.21.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"blake2 0.10.6",
|
"blake2 0.10.6",
|
||||||
"data-encoding",
|
"data-encoding",
|
||||||
@@ -446,7 +446,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-team"
|
name = "custos-team"
|
||||||
version = "0.18.1"
|
version = "0.21.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"custos-seal",
|
"custos-seal",
|
||||||
"custos-sign",
|
"custos-sign",
|
||||||
@@ -464,7 +464,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-totp"
|
name = "custos-totp"
|
||||||
version = "0.18.1"
|
version = "0.21.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"custos-vault",
|
"custos-vault",
|
||||||
"data-encoding",
|
"data-encoding",
|
||||||
@@ -477,7 +477,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-vault"
|
name = "custos-vault"
|
||||||
version = "0.18.1"
|
version = "0.21.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"argon2",
|
"argon2",
|
||||||
"bip39",
|
"bip39",
|
||||||
@@ -503,7 +503,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-wasm"
|
name = "custos-wasm"
|
||||||
version = "0.18.1"
|
version = "0.21.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"custos-qr",
|
"custos-qr",
|
||||||
"custos-seal",
|
"custos-seal",
|
||||||
|
|||||||
+2
-2
@@ -3,9 +3,9 @@ resolver = "3"
|
|||||||
members = ["crates/*"]
|
members = ["crates/*"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.18.1"
|
version = "0.21.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
license = "MPL-2.0"
|
license = "CPAL-1.0"
|
||||||
repository = "https://gitea.marek-novak.cz/mnovak/CustosPublic"
|
repository = "https://gitea.marek-novak.cz/mnovak/CustosPublic"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
|
|||||||
@@ -1,373 +1,168 @@
|
|||||||
Mozilla Public License Version 2.0
|
Common Public Attribution License Version 1.0 (CPAL)
|
||||||
==================================
|
|
||||||
|
|
||||||
1. Definitions
|
1. “Definitions”
|
||||||
--------------
|
|
||||||
|
|
||||||
1.1. "Contributor"
|
1.0.1 “Commercial Use” means distribution or otherwise making the Covered Code available to a third party.
|
||||||
means each individual or legal entity that creates, contributes to
|
|
||||||
the creation of, or owns Covered Software.
|
|
||||||
|
|
||||||
1.2. "Contributor Version"
|
1.1 “Contributor” means each entity that creates or contributes to the creation of Modifications.
|
||||||
means the combination of the Contributions of others (if any) used
|
|
||||||
by a Contributor and that particular Contributor's Contribution.
|
|
||||||
|
|
||||||
1.3. "Contribution"
|
1.2 “Contributor Version” means the combination of the Original Code, prior Modifications used by a Contributor, and the Modifications made by that particular Contributor.
|
||||||
means Covered Software of a particular Contributor.
|
|
||||||
|
|
||||||
1.4. "Covered Software"
|
1.3 “Covered Code” means the Original Code or Modifications or the combination of the Original Code and Modifications, in each case including portions thereof.
|
||||||
means Source Code Form to which the initial Contributor has attached
|
|
||||||
the notice in Exhibit A, the Executable Form of such Source Code
|
|
||||||
Form, and Modifications of such Source Code Form, in each case
|
|
||||||
including portions thereof.
|
|
||||||
|
|
||||||
1.5. "Incompatible With Secondary Licenses"
|
1.4 “Electronic Distribution Mechanism” means a mechanism generally accepted in the software development community for the electronic transfer of data.
|
||||||
means
|
|
||||||
|
|
||||||
(a) that the initial Contributor has attached the notice described
|
1.5 “Executable” means Covered Code in any form other than Source Code.
|
||||||
in Exhibit B to the Covered Software; or
|
|
||||||
|
|
||||||
(b) that the Covered Software was made available under the terms of
|
1.6 “Initial Developer” means the individual or entity identified as the Initial Developer in the Source Code notice required by Exhibit A.
|
||||||
version 1.1 or earlier of the License, but not also under the
|
|
||||||
terms of a Secondary License.
|
|
||||||
|
|
||||||
1.6. "Executable Form"
|
1.7 “Larger Work” means a work which combines Covered Code or portions thereof with code not governed by the terms of this License.
|
||||||
means any form of the work other than Source Code Form.
|
|
||||||
|
|
||||||
1.7. "Larger Work"
|
1.8 “License” means this document.
|
||||||
means a work that combines Covered Software with other material, in
|
|
||||||
a separate file or files, that is not Covered Software.
|
|
||||||
|
|
||||||
1.8. "License"
|
1.8.1 “Licensable” means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein.
|
||||||
means this document.
|
|
||||||
|
|
||||||
1.9. "Licensable"
|
1.9 “Modifications” means any addition to or deletion from the substance or structure of either the Original Code or any previous Modifications. When Covered Code is released as a series of files, a Modification is:
|
||||||
means having the right to grant, to the maximum extent possible,
|
|
||||||
whether at the time of the initial grant or subsequently, any and
|
|
||||||
all of the rights conveyed by this License.
|
|
||||||
|
|
||||||
1.10. "Modifications"
|
A. Any addition to or deletion from the contents of a file containing Original Code or previous Modifications.
|
||||||
means any of the following:
|
|
||||||
|
|
||||||
(a) any file in Source Code Form that results from an addition to,
|
B. Any new file that contains any part of the Original Code or previous Modifications.
|
||||||
deletion from, or modification of the contents of Covered
|
|
||||||
Software; or
|
|
||||||
|
|
||||||
(b) any new file in Source Code Form that contains any Covered
|
1.10 “Original Code” means Source Code of computer software code which is described in the Source Code notice required by Exhibit A as Original Code, and which, at the time of its release under this License is not already Covered Code governed by this License.
|
||||||
Software.
|
|
||||||
|
|
||||||
1.11. "Patent Claims" of a Contributor
|
1.10.1 “Patent Claims” means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor.
|
||||||
means any patent claim(s), including without limitation, method,
|
|
||||||
process, and apparatus claims, in any patent Licensable by such
|
|
||||||
Contributor that would be infringed, but for the grant of the
|
|
||||||
License, by the making, using, selling, offering for sale, having
|
|
||||||
made, import, or transfer of either its Contributions or its
|
|
||||||
Contributor Version.
|
|
||||||
|
|
||||||
1.12. "Secondary License"
|
1.11 “Source Code” means the preferred form of the Covered Code for making modifications to it, including all modules it contains, plus any associated interface definition files, scripts used to control compilation and installation of an Executable, or source code differential comparisons against either the Original Code or another well known, available Covered Code of the Contributor’s choice. The Source Code can be in a compressed or archival form, provided the appropriate decompression or de-archiving software is widely available for no charge.
|
||||||
means either the GNU General Public License, Version 2.0, the GNU
|
|
||||||
Lesser General Public License, Version 2.1, the GNU Affero General
|
|
||||||
Public License, Version 3.0, or any later versions of those
|
|
||||||
licenses.
|
|
||||||
|
|
||||||
1.13. "Source Code Form"
|
1.12 “You” (or “Your”) means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License or a future version of this License issued under Section 6.1. For legal entities, “You” includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
|
||||||
means the form of the work preferred for making modifications.
|
|
||||||
|
|
||||||
1.14. "You" (or "Your")
|
2. Source Code License.
|
||||||
means an individual or a legal entity exercising rights under this
|
|
||||||
License. For legal entities, "You" includes any entity that
|
|
||||||
controls, is controlled by, or is under common control with You. For
|
|
||||||
purposes of this definition, "control" means (a) the power, direct
|
|
||||||
or indirect, to cause the direction or management of such entity,
|
|
||||||
whether by contract or otherwise, or (b) ownership of more than
|
|
||||||
fifty percent (50%) of the outstanding shares or beneficial
|
|
||||||
ownership of such entity.
|
|
||||||
|
|
||||||
2. License Grants and Conditions
|
2.1 The Initial Developer Grant.
|
||||||
--------------------------------
|
The Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims:
|
||||||
|
|
||||||
2.1. Grants
|
(a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer to use, reproduce, modify, display, perform, sublicense and distribute the Original Code (or portions thereof) with or without Modifications, and/or as part of a Larger Work; and
|
||||||
|
|
||||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
(b) under Patents Claims infringed by the making, using or selling of Original Code, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Code (or portions thereof).
|
||||||
non-exclusive license:
|
|
||||||
|
|
||||||
(a) under intellectual property rights (other than patent or trademark)
|
(c) the licenses granted in this Section 2.1(a) and (b) are effective on the date Initial Developer first distributes Original Code under the terms of this License.
|
||||||
Licensable by such Contributor to use, reproduce, make available,
|
|
||||||
modify, display, perform, distribute, and otherwise exploit its
|
|
||||||
Contributions, either on an unmodified basis, with Modifications, or
|
|
||||||
as part of a Larger Work; and
|
|
||||||
|
|
||||||
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
(d) Notwithstanding Section 2.1(b) above, no patent license is granted: 1) for code that You delete from the Original Code; 2) separate from the Original Code; or 3) for infringements caused by: i) the modification of the Original Code or ii) the combination of the Original Code with other software or devices.
|
||||||
for sale, have made, import, and otherwise transfer either its
|
|
||||||
Contributions or its Contributor Version.
|
|
||||||
|
|
||||||
2.2. Effective Date
|
2.2 Contributor Grant.
|
||||||
|
Subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license
|
||||||
|
|
||||||
The licenses granted in Section 2.1 with respect to any Contribution
|
(a) under intellectual property rights (other than patent or trademark) Licensable by Contributor, to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof) either on an unmodified basis, with other Modifications, as Covered Code and/or as part of a Larger Work; and
|
||||||
become effective for each Contribution on the date the Contributor first
|
|
||||||
distributes such Contribution.
|
|
||||||
|
|
||||||
2.3. Limitations on Grant Scope
|
(b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications made by that Contributor (or portions thereof); and 2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination).
|
||||||
|
|
||||||
The licenses granted in this Section 2 are the only rights granted under
|
(c) the licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first makes Commercial Use of the Covered Code.
|
||||||
this License. No additional rights or licenses will be implied from the
|
|
||||||
distribution or licensing of Covered Software under this License.
|
(d) Notwithstanding Section 2.2(b) above, no patent license is granted: 1) for any code that Contributor has deleted from the Contributor Version; 2) separate from the Contributor Version; 3) for infringements caused by: i) third party modifications of Contributor Version or ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or 4) under Patent Claims infringed by Covered Code in the absence of Modifications made by that Contributor.
|
||||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
|
||||||
Contributor:
|
3. Distribution Obligations.
|
||||||
|
|
||||||
(a) for any code that a Contributor has removed from Covered Software;
|
3.1 Application of License.
|
||||||
or
|
The Modifications which You create or to which You contribute are governed by the terms of this License, including without limitation Section 2.2. The Source Code version of Covered Code may be distributed only under the terms of this License or a future version of this License released under Section 6.1, and You must include a copy of this License with every copy of the Source Code You distribute. You may not offer or impose any terms on any Source Code version that alters or restricts the applicable version of this License or the recipients’ rights hereunder. However, You may include an additional document offering the additional rights described in Section 3.5.
|
||||||
|
|
||||||
(b) for infringements caused by: (i) Your and any other third party's
|
3.2 Availability of Source Code.
|
||||||
modifications of Covered Software, or (ii) the combination of its
|
Any Modification which You create or to which You contribute must be made available in Source Code form under the terms of this License either on the same media as an Executable version or via an accepted Electronic Distribution Mechanism to anyone to whom you made an Executable version available; and if made available via Electronic Distribution Mechanism, must remain available for at least twelve (12) months after the date it initially became available, or at least six (6) months after a subsequent version of that particular Modification has been made available to such recipients. You are responsible for ensuring that the Source Code version remains available even if the Electronic Distribution Mechanism is maintained by a third party.
|
||||||
Contributions with other software (except as part of its Contributor
|
|
||||||
Version); or
|
3.3 Description of Modifications.
|
||||||
|
You must cause all Covered Code to which You contribute to contain a file documenting the changes You made to create that Covered Code and the date of any change. You must include a prominent statement that the Modification is derived, directly or indirectly, from Original Code provided by the Initial Developer and including the name of the Initial Developer in (a) the Source Code, and (b) in any notice in an Executable version or related documentation in which You describe the origin or ownership of the Covered Code.
|
||||||
(c) under Patent Claims infringed by Covered Software in the absence of
|
|
||||||
its Contributions.
|
3.4 Intellectual Property Matters
|
||||||
|
|
||||||
This License does not grant any rights in the trademarks, service marks,
|
(a) Third Party Claims. If Contributor has knowledge that a license under a third party’s intellectual property rights is required to exercise the rights granted by such Contributor under Sections 2.1 or 2.2, Contributor must include a text file with the Source Code distribution titled “LEGAL” which describes the claim and the party making the claim in sufficient detail that a recipient will know whom to contact. If Contributor obtains such knowledge after the Modification is made available as described in Section 3.2, Contributor shall promptly modify the LEGAL file in all copies Contributor makes available thereafter and shall take other steps (such as notifying appropriate mailing lists or newsgroups) reasonably calculated to inform those who received the Covered Code that new knowledge has been obtained.
|
||||||
or logos of any Contributor (except as may be necessary to comply with
|
|
||||||
the notice requirements in Section 3.4).
|
(b) Contributor APIs. If Contributor’s Modifications include an application programming interface and Contributor has knowledge of patent licenses which are reasonably necessary to implement that API, Contributor must also include this information in the LEGAL file.
|
||||||
|
|
||||||
2.4. Subsequent Licenses
|
(c) Representations. Contributor represents that, except as disclosed pursuant to Section 3.4(a) above, Contributor believes that Contributor’s Modifications are Contributor’s original creation(s) and/or Contributor has sufficient rights to grant the rights conveyed by this License.
|
||||||
|
|
||||||
No Contributor makes additional grants as a result of Your choice to
|
3.5 Required Notices.
|
||||||
distribute the Covered Software under a subsequent version of this
|
You must duplicate the notice in Exhibit A in each file of the Source Code. If it is not possible to put such notice in a particular Source Code file due to its structure, then You must include such notice in a location (such as a relevant directory) where a user would be likely to look for such a notice. If You created one or more Modification(s) You may add your name as a Contributor to the notice described in Exhibit A. You must also duplicate this License in any documentation for the Source Code where You describe recipients’ rights or ownership rights relating to Covered Code. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Code. However, You may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear than any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer.
|
||||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
|
||||||
permitted under the terms of Section 3.3).
|
3.6 Distribution of Executable Versions.
|
||||||
|
You may distribute Covered Code in Executable form only if the requirements of Section 3.1-3.5 have been met for that Covered Code, and if You include a notice stating that the Source Code version of the Covered Code is available under the terms of this License, including a description of how and where You have fulfilled the obligations of Section 3.2. The notice must be conspicuously included in any notice in an Executable version, related documentation or collateral in which You describe recipients’ rights relating to the Covered Code. You may distribute the Executable version of Covered Code or ownership rights under a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable version does not attempt to limit or alter the recipient’s rights in the Source Code version from the rights set forth in this License. If You distribute the Executable version under a different license You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer, Original Developer or any Contributor. You hereby agree to indemnify the Initial Developer, Original Developer and every Contributor for any liability incurred by the Initial Developer, Original Developer or such Contributor as a result of any such terms You offer.
|
||||||
2.5. Representation
|
|
||||||
|
3.7 Larger Works.
|
||||||
Each Contributor represents that the Contributor believes its
|
You may create a Larger Work by combining Covered Code with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Code.
|
||||||
Contributions are its original creation(s) or it has sufficient rights
|
|
||||||
to grant the rights to its Contributions conveyed by this License.
|
4. Inability to Comply Due to Statute or Regulation.
|
||||||
|
If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Code due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be included in the LEGAL file described in Section 3.4 and must be included with all distributions of the Source Code. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it.
|
||||||
2.6. Fair Use
|
|
||||||
|
5. Application of this License.
|
||||||
This License is not intended to limit any rights You have under
|
This License applies to code to which the Initial Developer has attached the notice in Exhibit A and to related Covered Code.
|
||||||
applicable copyright doctrines of fair use, fair dealing, or other
|
|
||||||
equivalents.
|
6. Versions of the License.
|
||||||
|
|
||||||
2.7. Conditions
|
6.1 New Versions.
|
||||||
|
Socialtext, Inc. (“Socialtext”) may publish revised and/or new versions of the License from time to time. Each version will be given a distinguishing version number.
|
||||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
|
||||||
in Section 2.1.
|
6.2 Effect of New Versions.
|
||||||
|
Once Covered Code has been published under a particular version of the License, You may always continue to use it under the terms of that version. You may also choose to use such Covered Code under the terms of any subsequent version of the License published by Socialtext. No one other than Socialtext has the right to modify the terms applicable to Covered Code created under this License.
|
||||||
3. Responsibilities
|
|
||||||
-------------------
|
6.3 Derivative Works.
|
||||||
|
If You create or use a modified version of this License (which you may only do in order to apply it to code which is not already Covered Code governed by this License), You must (a) rename Your license so that the phrases “Socialtext”, “CPAL” or any confusingly similar phrase do not appear in your license (except to note that your license differs from this License) and (b) otherwise make it clear that Your version of the license contains terms which differ from the CPAL. (Filling in the name of the Initial Developer, Original Developer, Original Code or Contributor in the notice described in Exhibit A shall not of themselves be deemed to be modifications of this License.)
|
||||||
3.1. Distribution of Source Form
|
|
||||||
|
7. DISCLAIMER OF WARRANTY.
|
||||||
All distribution of Covered Software in Source Code Form, including any
|
COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN “AS IS” BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER, ORIGINAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
|
||||||
Modifications that You create or to which You contribute, must be under
|
|
||||||
the terms of this License. You must inform recipients that the Source
|
8. TERMINATION.
|
||||||
Code Form of the Covered Software is governed by the terms of this
|
|
||||||
License, and how they can obtain a copy of this License. You may not
|
8.1 This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. All sublicenses to the Covered Code which are properly granted shall survive any termination of this License. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive.
|
||||||
attempt to alter or restrict the recipients' rights in the Source Code
|
|
||||||
Form.
|
8.2 If You initiate litigation by asserting a patent infringement claim (excluding declatory judgment actions) against Initial Developer, Original Developer or a Contributor (the Initial Developer, Original Developer or Contributor against whom You file such action is referred to as “Participant”) alleging that:
|
||||||
|
|
||||||
3.2. Distribution of Executable Form
|
(a) such Participant’s Contributor Version directly or indirectly infringes any patent, then any and all rights granted by such Participant to You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively, unless if within 60 days after receipt of notice You either: (i) agree in writing to pay Participant a mutually agreeable reasonable royalty for Your past and future use of Modifications made by such Participant, or (ii) withdraw Your litigation claim with respect to the Contributor Version against such Participant. If within 60 days of notice, a reasonable royalty and payment arrangement are not mutually agreed upon in writing by the parties or the litigation claim is not withdrawn, the rights granted by Participant to You under Sections 2.1 and/or 2.2 automatically terminate at the expiration of the 60 day notice period specified above.
|
||||||
|
|
||||||
If You distribute Covered Software in Executable Form then:
|
(b) any software, hardware, or device, other than such Participant’s Contributor Version, directly or indirectly infringes any patent, then any rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are revoked effective as of the date You first made, used, sold, distributed, or had made, Modifications made by that Participant.
|
||||||
|
|
||||||
(a) such Covered Software must also be made available in Source Code
|
8.3 If You assert a patent infringement claim against Participant alleging that such Participant’s Contributor Version directly or indirectly infringes any patent where such claim is resolved (such as by license or settlement) prior to the initiation of patent infringement litigation, then the reasonable value of the licenses granted by such Participant under Sections 2.1 or 2.2 shall be taken into account in determining the amount or value of any payment or license.
|
||||||
Form, as described in Section 3.1, and You must inform recipients of
|
|
||||||
the Executable Form how they can obtain a copy of such Source Code
|
8.4 In the event of termination under Sections 8.1 or 8.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or any distributor hereunder prior to termination shall survive termination.
|
||||||
Form by reasonable means in a timely manner, at a charge no more
|
|
||||||
than the cost of distribution to the recipient; and
|
9. LIMITATION OF LIABILITY.
|
||||||
|
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ORIGINAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY’S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
|
||||||
(b) You may distribute such Executable Form under the terms of this
|
|
||||||
License, or sublicense it under different terms, provided that the
|
10. U.S. GOVERNMENT END USERS.
|
||||||
license for the Executable Form does not attempt to limit or alter
|
The Covered Code is a “commercial item,” as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of “commercial computer software” and “commercial computer software documentation,” as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Code with only those rights set forth herein.
|
||||||
the recipients' rights in the Source Code Form under this License.
|
|
||||||
|
11. MISCELLANEOUS.
|
||||||
3.3. Distribution of a Larger Work
|
This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by California law provisions (except to the extent applicable law, if any, provides otherwise), excluding its conflict-of-law provisions. With respect to disputes in which at least one party is a citizen of, or an entity chartered or registered to do business in the United States of America, any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California, with venue lying in Santa Clara County, California, with the losing party responsible for costs, including without limitation, court costs and reasonable attorneys’ fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License.
|
||||||
|
|
||||||
You may create and distribute a Larger Work under terms of Your choice,
|
12. RESPONSIBILITY FOR CLAIMS.
|
||||||
provided that You also comply with the requirements of this License for
|
As between Initial Developer, Original Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer, Original Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability.
|
||||||
the Covered Software. If the Larger Work is a combination of Covered
|
|
||||||
Software with a work governed by one or more Secondary Licenses, and the
|
13. MULTIPLE-LICENSED CODE.
|
||||||
Covered Software is not Incompatible With Secondary Licenses, this
|
Initial Developer may designate portions of the Covered Code as Multiple-Licensed. Multiple-Licensed means that the Initial Developer permits you to utilize portions of the Covered Code under Your choice of the CPAL or the alternative licenses, if any, specified by the Initial Developer in the file described in Exhibit A.
|
||||||
License permits You to additionally distribute such Covered Software
|
|
||||||
under the terms of such Secondary License(s), so that the recipient of
|
14. ADDITIONAL TERM: ATTRIBUTION
|
||||||
the Larger Work may, at their option, further distribute the Covered
|
|
||||||
Software under the terms of either this License or such Secondary
|
(a) As a modest attribution to the organizer of the development of the Original Code (“Original Developer”), in the hope that its promotional value may help justify the time, money and effort invested in writing the Original Code, the Original Developer may include in Exhibit B (“Attribution Information”) a requirement that each time an Executable and Source Code or a Larger Work is launched or initially run (which includes initiating a session), a prominent display of the Original Developer’s Attribution Information (as defined below) must occur on the graphic user interface employed by the end user to access such Covered Code (which may include display on a splash screen), if any. The size of the graphic image should be consistent with the size of the other elements of the Attribution Information. If the access by the end user to the Executable and Source Code does not create a graphic user interface for access to the Covered Code, this obligation shall not apply. If the Original Code displays such Attribution Information in a particular form (such as in the form of a splash screen, notice at login, an “about” display, or dedicated attribution area on user interface screens), continued use of such form for that Attribution Information is one way of meeting this requirement for notice.
|
||||||
License(s).
|
|
||||||
|
(b) Attribution information may only include a copyright notice, a brief phrase, graphic image and a URL (“Attribution Information”) and is subject to the Attribution Limits as defined below. For these purposes, prominent shall mean display for sufficient duration to give reasonable notice to the user of the identity of the Original Developer and that if You include Attribution Information or similar information for other parties, You must ensure that the Attribution Information for the Original Developer shall be no less prominent than such Attribution Information or similar information for the other party. For greater certainty, the Original Developer may choose to specify in Exhibit B below that the above attribution requirement only applies to an Executable and Source Code resulting from the Original Code or any Modification, but not a Larger Work. The intent is to provide for reasonably modest attribution, therefore the Original Developer cannot require that You display, at any time, more than the following information as Attribution Information: (a) a copyright notice including the name of the Original Developer; (b) a word or one phrase (not exceeding 10 words); (c) one graphic image provided by the Original Developer; and (d) a URL (collectively, the “Attribution Limits”).
|
||||||
3.4. Notices
|
|
||||||
|
(c) If Exhibit B does not include any Attribution Information, then there are no requirements for You to display any Attribution Information of the Original Developer.
|
||||||
You may not remove or alter the substance of any license notices
|
|
||||||
(including copyright notices, patent notices, disclaimers of warranty,
|
(d) You acknowledge that all trademarks, service marks and/or trade names contained within the Attribution Information distributed with the Covered Code are the exclusive property of their owners and may only be used with the permission of their owners, or under circumstances otherwise permitted by law or as expressly set out in this License.
|
||||||
or limitations of liability) contained within the Source Code Form of
|
|
||||||
the Covered Software, except that You may alter any license notices to
|
15. ADDITIONAL TERM: NETWORK USE.
|
||||||
the extent required to remedy known factual inaccuracies.
|
The term “External Deployment” means the use, distribution, or communication of the Original Code or Modifications in any way such that the Original Code or Modifications may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Code or Modifications as a distribution under section 3.1 and make Source Code available under Section 3.2.
|
||||||
|
|
||||||
3.5. Application of Additional Terms
|
EXHIBIT A. Common Public Attribution License Version 1.0.
|
||||||
|
|
||||||
You may choose to offer, and to charge a fee for, warranty, support,
|
"The contents of this file are subject to the Common Public Attribution License Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://opensource.org/license/cpal_1-0. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
|
||||||
indemnity or liability obligations to one or more recipients of Covered
|
Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
|
||||||
Software. However, You may do so only on Your own behalf, and not on
|
The Original Code is CustosPublic.
|
||||||
behalf of any Contributor. You must make it absolutely clear that any
|
The Original Developer is the Initial Developer.
|
||||||
such warranty, support, indemnity, or liability obligation is offered by
|
The Initial Developer of the Original Code is Marek Novák. All portions of the code written by Marek Novák are Copyright (c) 2026. All Rights Reserved.
|
||||||
You alone, and You hereby agree to indemnify every Contributor for any
|
Contributor: none."
|
||||||
liability incurred by such Contributor as a result of warranty, support,
|
|
||||||
indemnity or liability terms You offer. You may include additional
|
EXHIBIT B. Attribution Information
|
||||||
disclaimers of warranty and limitations of liability specific to any
|
|
||||||
jurisdiction.
|
Attribution Copyright Notice: Copyright (c) 2026 Marek Novák
|
||||||
|
Attribution Phrase (not exceeding 10 words): Built on Domi
|
||||||
4. Inability to Comply Due to Statute or Regulation
|
Attribution URL: https://aula.marek-novak.cz
|
||||||
---------------------------------------------------
|
Graphic Image as provided in the Covered Code, if any: none.
|
||||||
|
Display of Attribution Information is required in Larger Works which are defined in the CPAL as a work which combines Covered Code or portions thereof with code not governed by the terms of the CPAL.
|
||||||
If it is impossible for You to comply with any of the terms of this
|
|
||||||
License with respect to some or all of the Covered Software due to
|
|
||||||
statute, judicial order, or regulation then You must: (a) comply with
|
|
||||||
the terms of this License to the maximum extent possible; and (b)
|
|
||||||
describe the limitations and the code they affect. Such description must
|
|
||||||
be placed in a text file included with all distributions of the Covered
|
|
||||||
Software under this License. Except to the extent prohibited by statute
|
|
||||||
or regulation, such description must be sufficiently detailed for a
|
|
||||||
recipient of ordinary skill to be able to understand it.
|
|
||||||
|
|
||||||
5. Termination
|
|
||||||
--------------
|
|
||||||
|
|
||||||
5.1. The rights granted under this License will terminate automatically
|
|
||||||
if You fail to comply with any of its terms. However, if You become
|
|
||||||
compliant, then the rights granted under this License from a particular
|
|
||||||
Contributor are reinstated (a) provisionally, unless and until such
|
|
||||||
Contributor explicitly and finally terminates Your grants, and (b) on an
|
|
||||||
ongoing basis, if such Contributor fails to notify You of the
|
|
||||||
non-compliance by some reasonable means prior to 60 days after You have
|
|
||||||
come back into compliance. Moreover, Your grants from a particular
|
|
||||||
Contributor are reinstated on an ongoing basis if such Contributor
|
|
||||||
notifies You of the non-compliance by some reasonable means, this is the
|
|
||||||
first time You have received notice of non-compliance with this License
|
|
||||||
from such Contributor, and You become compliant prior to 30 days after
|
|
||||||
Your receipt of the notice.
|
|
||||||
|
|
||||||
5.2. If You initiate litigation against any entity by asserting a patent
|
|
||||||
infringement claim (excluding declaratory judgment actions,
|
|
||||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
|
||||||
directly or indirectly infringes any patent, then the rights granted to
|
|
||||||
You by any and all Contributors for the Covered Software under Section
|
|
||||||
2.1 of this License shall terminate.
|
|
||||||
|
|
||||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
|
||||||
end user license agreements (excluding distributors and resellers) which
|
|
||||||
have been validly granted by You or Your distributors under this License
|
|
||||||
prior to termination shall survive termination.
|
|
||||||
|
|
||||||
************************************************************************
|
|
||||||
* *
|
|
||||||
* 6. Disclaimer of Warranty *
|
|
||||||
* ------------------------- *
|
|
||||||
* *
|
|
||||||
* Covered Software is provided under this License on an "as is" *
|
|
||||||
* basis, without warranty of any kind, either expressed, implied, or *
|
|
||||||
* statutory, including, without limitation, warranties that the *
|
|
||||||
* Covered Software is free of defects, merchantable, fit for a *
|
|
||||||
* particular purpose or non-infringing. The entire risk as to the *
|
|
||||||
* quality and performance of the Covered Software is with You. *
|
|
||||||
* Should any Covered Software prove defective in any respect, You *
|
|
||||||
* (not any Contributor) assume the cost of any necessary servicing, *
|
|
||||||
* repair, or correction. This disclaimer of warranty constitutes an *
|
|
||||||
* essential part of this License. No use of any Covered Software is *
|
|
||||||
* authorized under this License except under this disclaimer. *
|
|
||||||
* *
|
|
||||||
************************************************************************
|
|
||||||
|
|
||||||
************************************************************************
|
|
||||||
* *
|
|
||||||
* 7. Limitation of Liability *
|
|
||||||
* -------------------------- *
|
|
||||||
* *
|
|
||||||
* Under no circumstances and under no legal theory, whether tort *
|
|
||||||
* (including negligence), contract, or otherwise, shall any *
|
|
||||||
* Contributor, or anyone who distributes Covered Software as *
|
|
||||||
* permitted above, be liable to You for any direct, indirect, *
|
|
||||||
* special, incidental, or consequential damages of any character *
|
|
||||||
* including, without limitation, damages for lost profits, loss of *
|
|
||||||
* goodwill, work stoppage, computer failure or malfunction, or any *
|
|
||||||
* and all other commercial damages or losses, even if such party *
|
|
||||||
* shall have been informed of the possibility of such damages. This *
|
|
||||||
* limitation of liability shall not apply to liability for death or *
|
|
||||||
* personal injury resulting from such party's negligence to the *
|
|
||||||
* extent applicable law prohibits such limitation. Some *
|
|
||||||
* jurisdictions do not allow the exclusion or limitation of *
|
|
||||||
* incidental or consequential damages, so this exclusion and *
|
|
||||||
* limitation may not apply to You. *
|
|
||||||
* *
|
|
||||||
************************************************************************
|
|
||||||
|
|
||||||
8. Litigation
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Any litigation relating to this License may be brought only in the
|
|
||||||
courts of a jurisdiction where the defendant maintains its principal
|
|
||||||
place of business and such litigation shall be governed by laws of that
|
|
||||||
jurisdiction, without reference to its conflict-of-law provisions.
|
|
||||||
Nothing in this Section shall prevent a party's ability to bring
|
|
||||||
cross-claims or counter-claims.
|
|
||||||
|
|
||||||
9. Miscellaneous
|
|
||||||
----------------
|
|
||||||
|
|
||||||
This License represents the complete agreement concerning the subject
|
|
||||||
matter hereof. If any provision of this License is held to be
|
|
||||||
unenforceable, such provision shall be reformed only to the extent
|
|
||||||
necessary to make it enforceable. Any law or regulation which provides
|
|
||||||
that the language of a contract shall be construed against the drafter
|
|
||||||
shall not be used to construe this License against a Contributor.
|
|
||||||
|
|
||||||
10. Versions of the License
|
|
||||||
---------------------------
|
|
||||||
|
|
||||||
10.1. New Versions
|
|
||||||
|
|
||||||
Mozilla Foundation is the license steward. Except as provided in Section
|
|
||||||
10.3, no one other than the license steward has the right to modify or
|
|
||||||
publish new versions of this License. Each version will be given a
|
|
||||||
distinguishing version number.
|
|
||||||
|
|
||||||
10.2. Effect of New Versions
|
|
||||||
|
|
||||||
You may distribute the Covered Software under the terms of the version
|
|
||||||
of the License under which You originally received the Covered Software,
|
|
||||||
or under the terms of any subsequent version published by the license
|
|
||||||
steward.
|
|
||||||
|
|
||||||
10.3. Modified Versions
|
|
||||||
|
|
||||||
If you create software not governed by this License, and you want to
|
|
||||||
create a new license for such software, you may create and use a
|
|
||||||
modified version of this License if you rename the license and remove
|
|
||||||
any references to the name of the license steward (except to note that
|
|
||||||
such modified license differs from this License).
|
|
||||||
|
|
||||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
|
||||||
Licenses
|
|
||||||
|
|
||||||
If You choose to distribute Source Code Form that is Incompatible With
|
|
||||||
Secondary Licenses under the terms of this version of the License, the
|
|
||||||
notice described in Exhibit B of this License must be attached.
|
|
||||||
|
|
||||||
Exhibit A - Source Code Form License Notice
|
|
||||||
-------------------------------------------
|
|
||||||
|
|
||||||
This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
If it is not possible or desirable to put the notice in a particular
|
|
||||||
file, then You may include the notice in a location (such as a LICENSE
|
|
||||||
file in a relevant directory) where a recipient would be likely to look
|
|
||||||
for such a notice.
|
|
||||||
|
|
||||||
You may add additional accurate notices of copyright ownership.
|
|
||||||
|
|
||||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
|
||||||
---------------------------------------------------------
|
|
||||||
|
|
||||||
This Source Code Form is "Incompatible With Secondary Licenses", as
|
|
||||||
defined by the Mozilla Public License, v. 2.0.
|
|
||||||
@@ -21,4 +21,20 @@ for what it does and does not protect. Report vulnerabilities as described in [`
|
|||||||
cargo test --workspace
|
cargo test --workspace
|
||||||
```
|
```
|
||||||
|
|
||||||
Licence: MPL-2.0. The memorable-password words come from the EFF wordlist (CC BY 3.0 US), filtered with the ESDB/SCOWL English dictionary (see `crates/custos-gen/wordlists/SOURCES.md`).
|
## Licence
|
||||||
|
|
||||||
|
CustosPublic is licensed under the **Common Public Attribution License 1.0** (SPDX `CPAL-1.0`), from v0.20.0 on: see
|
||||||
|
[LICENSE](LICENSE). Versions before this change (up to and including v0.19.1) stay available under MPL-2.0 to those
|
||||||
|
who received them under it.
|
||||||
|
|
||||||
|
**Attribution (Exhibit B).** Anyone who redistributes CustosPublic, or software built on it, must show this credit
|
||||||
|
where CPAL-1.0 §14 asks for it:
|
||||||
|
|
||||||
|
| | |
|
||||||
|
| :-- | :-- |
|
||||||
|
| Attribution Copyright Notice | Copyright (c) 2026 Marek Novák |
|
||||||
|
| Attribution Phrase | Built on Domi |
|
||||||
|
| Attribution URL | https://aula.marek-novak.cz |
|
||||||
|
| Graphic Image | none |
|
||||||
|
|
||||||
|
Third-party parts keep their own licences. The memorable-password words come from the EFF wordlist (CC BY 3.0 US), filtered with the ESDB/SCOWL English dictionary (see `crates/custos-gen/wordlists/SOURCES.md`).
|
||||||
|
|||||||
@@ -195,6 +195,12 @@ pub fn minisign_public(public: &[u8; 32], key_id: &[u8; 8]) -> String {
|
|||||||
format!("untrusted comment: minisign public key {}\n{}\n", key_id_hex(key_id), BASE64.encode(&raw))
|
format!("untrusted comment: minisign public key {}\n{}\n", key_id_hex(key_id), BASE64.encode(&raw))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A plain Ed25519 signature over `message` itself: no prehash, no digest, no wrapping (core 0.21.0, the Domi
|
||||||
|
/// licence, docs/SIGNING.md "Domi licences"). ed25519-dalek's deterministic RFC 8032 signature.
|
||||||
|
pub fn ed25519_plain(secret: &Ed25519Secret, message: &[u8]) -> [u8; 64] {
|
||||||
|
SigningKey::from_bytes(&secret.0).sign(message).to_bytes()
|
||||||
|
}
|
||||||
|
|
||||||
/// A prehashed minisign signature file over a file whose BLAKE2b-512 is `digest`.
|
/// A prehashed minisign signature file over a file whose BLAKE2b-512 is `digest`.
|
||||||
/// The trusted comment is `timestamp:<unix seconds>\tfile:<file>\thashed`, as minisign writes it.
|
/// The trusted comment is `timestamp:<unix seconds>\tfile:<file>\thashed`, as minisign writes it.
|
||||||
pub fn minisign(
|
pub fn minisign(
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ mod crypto;
|
|||||||
mod device;
|
mod device;
|
||||||
mod format;
|
mod format;
|
||||||
pub mod identity;
|
pub mod identity;
|
||||||
|
pub mod licence;
|
||||||
mod item;
|
mod item;
|
||||||
pub mod provision;
|
pub mod provision;
|
||||||
mod recovery;
|
mod recovery;
|
||||||
|
|||||||
@@ -0,0 +1,843 @@
|
|||||||
|
//! Domi licences (core 0.21.0, docs/SIGNING.md "Domi licences"; the byte format is Fundamentum's docs/LICENCE.md,
|
||||||
|
//! licence v1): the key `domi-licence`, the strict parser of what it signs, and Mark's licence grant.
|
||||||
|
//!
|
||||||
|
//! The key is an Ed25519 key in the signing store under the reserved id [`LICENCE_KEY`], with no scope: every
|
||||||
|
//! other signing path refuses it, so it signs only the two payload kinds here (a licence, a revocation list), and
|
||||||
|
//! no other key signs them. Its secret never leaves this module and `signing.rs`; only its public key does.
|
||||||
|
//!
|
||||||
|
//! What it signs is parsed here **before** anything else, byte for byte as the spec's strict parser does (§2.4
|
||||||
|
//! steps 1–4 and 7 for a licence, §4.1 for a revocation list): malformed input is refused with the spec's code and
|
||||||
|
//! never reaches a card. Then the grant decides: a licence from `licence-issue` (its Canalis app id, and a
|
||||||
|
//! Domi-signed program) whose apps are all on Mark's allowlist, within the cap, is signed at once; anything else
|
||||||
|
//! that is well formed asks Mark on a card. A revocation list always asks. Refused outright, never a card: a licence
|
||||||
|
//! whose `issued` is more than a day from this clock, a licence id this key signed before (`replay`), a revocation
|
||||||
|
//! list whose `seq` is not higher than the highest this key signed (`rollback`), and any caller but `licence-issue`.
|
||||||
|
//!
|
||||||
|
//! The grant and the log live in the signing store's `licence` member, which cores before 0.21.0 ignore (and drop if
|
||||||
|
//! they save the vault: then the grant is gone, which fails closed, and the service's own anti-rollback check still
|
||||||
|
//! holds, Fundamentum docs/LICENCE.md §4.2). The key itself is an ordinary Ed25519 entry every core reads.
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::{Error, Vault};
|
||||||
|
|
||||||
|
/// The reserved id of the licence key.
|
||||||
|
pub const LICENCE_KEY: &str = "domi-licence";
|
||||||
|
/// The one Canalis app that may ask for a licence signature.
|
||||||
|
pub const LICENCE_ISSUER: &str = "licence-issue";
|
||||||
|
|
||||||
|
/// The first line of a licence payload, inside the signed bytes.
|
||||||
|
pub const LICENCE_PREFIX: &str = "domi-licence-v1\n";
|
||||||
|
/// The first line of a revocation list payload, inside the signed bytes.
|
||||||
|
pub const REVOCATIONS_PREFIX: &str = "domi-revocations-v1\n";
|
||||||
|
|
||||||
|
/// What the `sig:` line adds to a payload to make the file: `sig: ` (5), 86 characters, LF.
|
||||||
|
const SIG_LINE_LEN: usize = 5 + 86 + 1;
|
||||||
|
/// The largest licence payload signed: the spec caps the **file** at 4096 bytes, so a payload is at most what still
|
||||||
|
/// fits with its signature line. Stricter than the spec's payload parser, never looser.
|
||||||
|
pub const LICENCE_PAYLOAD_MAX: usize = 4096 - SIG_LINE_LEN;
|
||||||
|
/// The largest revocation list payload signed, for the spec's 61 440-byte file.
|
||||||
|
pub const REVOCATIONS_PAYLOAD_MAX: usize = 61_440 - SIG_LINE_LEN;
|
||||||
|
|
||||||
|
/// How far a licence's `issued` may be from this clock, either way (seconds).
|
||||||
|
pub const CLOCK_TOLERANCE_S: i64 = 86_400;
|
||||||
|
/// At most this many licence signatures in a rolling day; past it, each one asks on a card.
|
||||||
|
pub const DAY_CAP: usize = 50;
|
||||||
|
const DAY_MS: i64 = 86_400_000;
|
||||||
|
/// At most this many app ids on the allowlist.
|
||||||
|
pub const ALLOW_MAX: usize = 256;
|
||||||
|
/// At most this many signatures in the log. Every licence id and revocation `seq` signed must stay known (replay,
|
||||||
|
/// rollback), so a full log refuses to sign more rather than forget (`log_full`).
|
||||||
|
pub const LOG_MAX: usize = 20_000;
|
||||||
|
|
||||||
|
const MAX_APPS: usize = 64;
|
||||||
|
const MAX_SEQ: u64 = (1 << 53) - 1;
|
||||||
|
const LICENCE_FIELDS: [&str; 7] = ["id", "issued", "nickname", "bundle", "scope", "seats", "apps"];
|
||||||
|
const REVOCATION_FIELDS: [&str; 3] = ["seq", "issued", "revoked"];
|
||||||
|
|
||||||
|
/// A licence payload, as parsed.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub struct Licence {
|
||||||
|
pub id: String,
|
||||||
|
/// Unix seconds.
|
||||||
|
pub issued: i64,
|
||||||
|
pub nickname: String,
|
||||||
|
pub bundle: String,
|
||||||
|
/// `None` for `scope: household`, the seat count for `scope: seat`.
|
||||||
|
pub seats: Option<u8>,
|
||||||
|
/// Sorted ascending and unique.
|
||||||
|
pub apps: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A revocation list payload, as parsed.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub struct Revocations {
|
||||||
|
pub seq: u64,
|
||||||
|
/// Unix seconds.
|
||||||
|
pub issued: i64,
|
||||||
|
/// Sorted strictly ascending.
|
||||||
|
pub revoked: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// What a payload is.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub enum Payload {
|
||||||
|
Licence(Licence),
|
||||||
|
Revocations(Revocations),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Why a payload is not signed. [`LicenceRefusal::code`] is the spec's error code (Fundamentum docs/LICENCE.md §8)
|
||||||
|
/// where the spec has one, else Custos's own. None carries payload or key bytes.
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
|
||||||
|
pub enum LicenceRefusal {
|
||||||
|
/// The spec's strict parser refused the payload (§2.4 steps 1–4 and 7, §4.1).
|
||||||
|
#[error("the payload is malformed: {0}")]
|
||||||
|
Malformed(&'static str),
|
||||||
|
/// There is no `domi-licence` key yet.
|
||||||
|
#[error("there is no licence key in this vault")]
|
||||||
|
NoKey,
|
||||||
|
/// Only `licence-issue` may ask.
|
||||||
|
#[error("only licence-issue may ask for a licence signature")]
|
||||||
|
NotAllowed,
|
||||||
|
/// The licence's `issued` is more than a day from this clock.
|
||||||
|
#[error("the licence is dated more than a day from this PC's clock")]
|
||||||
|
Clock,
|
||||||
|
/// This key signed a licence with this id before.
|
||||||
|
#[error("a licence with this id was signed before")]
|
||||||
|
Replay,
|
||||||
|
/// This key signed a revocation list with this `seq` or a higher one before.
|
||||||
|
#[error("a revocation list with this seq or a higher one was signed before")]
|
||||||
|
Rollback,
|
||||||
|
/// The log is full.
|
||||||
|
#[error("the licence log is full")]
|
||||||
|
LogFull,
|
||||||
|
/// Asked to sign without a card where the grant does not cover the request.
|
||||||
|
#[error("this needs Mark's answer on a card")]
|
||||||
|
NeedsCard,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LicenceRefusal {
|
||||||
|
pub fn code(self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
LicenceRefusal::Malformed(c) => c,
|
||||||
|
LicenceRefusal::NoKey => "no_key",
|
||||||
|
LicenceRefusal::NotAllowed => "not_allowed",
|
||||||
|
LicenceRefusal::Clock => "clock",
|
||||||
|
LicenceRefusal::Replay => "replay",
|
||||||
|
LicenceRefusal::Rollback => "rollback",
|
||||||
|
LicenceRefusal::LogFull => "log_full",
|
||||||
|
LicenceRefusal::NeedsCard => "needs_card",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- the strict parser (Fundamentum docs/LICENCE.md §2.4 steps 1–4 and 7, §4.1) ----
|
||||||
|
|
||||||
|
fn malformed(code: &'static str) -> LicenceRefusal {
|
||||||
|
LicenceRefusal::Malformed(code)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A licence id: 8–64 bytes of `[A-Za-z0-9_-]`.
|
||||||
|
pub fn licence_id_ok(s: &str) -> bool {
|
||||||
|
(8..=64).contains(&s.len()) && s.bytes().all(|b| b.is_ascii_alphanumeric() || b == b'_' || b == b'-')
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A Tessera id (a bundle, an app): 1–32 bytes of `[a-z0-9-]`, not starting or ending with `-`.
|
||||||
|
pub fn tessera_id_ok(s: &str) -> bool {
|
||||||
|
(1..=32).contains(&s.len())
|
||||||
|
&& s.bytes().all(|b| b.is_ascii_lowercase() || b.is_ascii_digit() || b == b'-')
|
||||||
|
&& !s.starts_with('-')
|
||||||
|
&& !s.ends_with('-')
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A nickname: 1–32 bytes of `[A-Za-z0-9 ._-]`, no space at either end, never two spaces in a row.
|
||||||
|
fn nickname_ok(s: &str) -> bool {
|
||||||
|
(1..=32).contains(&s.len())
|
||||||
|
&& s.bytes().all(|b| b.is_ascii_alphanumeric() || matches!(b, b' ' | b'.' | b'_' | b'-'))
|
||||||
|
&& !s.starts_with(' ')
|
||||||
|
&& !s.ends_with(' ')
|
||||||
|
&& !s.contains(" ")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `[1-9]`, `[1-4][0-9]` or `50`.
|
||||||
|
fn seats(s: &str) -> Option<u8> {
|
||||||
|
let ok = matches!(s.as_bytes(), [b'1'..=b'9'] | [b'1'..=b'4', b'0'..=b'9'] | [b'5', b'0']);
|
||||||
|
ok.then(|| s.parse().ok()).flatten()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Decimal 1 to 2^53 − 1, no leading zero, no sign.
|
||||||
|
fn seq(s: &str) -> Option<u64> {
|
||||||
|
let digits = !s.is_empty() && s.len() <= 16 && s.bytes().all(|b| b.is_ascii_digit()) && !s.starts_with('0');
|
||||||
|
digits.then(|| s.parse::<u64>().ok()).flatten().filter(|n| (1..=MAX_SEQ).contains(n))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `YYYY-MM-DDTHH:MM:SSZ`, year 2000–2999, a real Gregorian date, no leap second: Unix seconds.
|
||||||
|
pub fn parse_utc(s: &str) -> Option<i64> {
|
||||||
|
let b = s.as_bytes();
|
||||||
|
if b.len() != 20 || b[4] != b'-' || b[7] != b'-' || b[10] != b'T' || b[13] != b':' || b[16] != b':' || b[19] != b'Z' {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let num = |from: usize, to: usize| -> Option<i64> {
|
||||||
|
let part = &b[from..to];
|
||||||
|
part.iter().all(u8::is_ascii_digit).then(|| part.iter().fold(0i64, |n, d| n * 10 + i64::from(d - b'0')))
|
||||||
|
};
|
||||||
|
let (y, mo, d) = (num(0, 4)?, num(5, 7)?, num(8, 10)?);
|
||||||
|
let (h, mi, sec) = (num(11, 13)?, num(14, 16)?, num(17, 19)?);
|
||||||
|
let leap = (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
|
||||||
|
let days_in = match mo {
|
||||||
|
1 | 3 | 5 | 7 | 8 | 10 | 12 => 31,
|
||||||
|
4 | 6 | 9 | 11 => 30,
|
||||||
|
2 if leap => 29,
|
||||||
|
2 => 28,
|
||||||
|
_ => return None,
|
||||||
|
};
|
||||||
|
if !(2000..=2999).contains(&y) || !(1..=days_in).contains(&d) || h > 23 || mi > 59 || sec > 59 {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
// Days from the civil date (Howard Hinnant's algorithm).
|
||||||
|
let (yy, mm) = if mo <= 2 { (y - 1, mo + 9) } else { (y, mo - 3) };
|
||||||
|
let era = yy.div_euclid(400);
|
||||||
|
let yoe = yy - era * 400;
|
||||||
|
let doy = (153 * mm + 2) / 5 + d - 1;
|
||||||
|
let doe = yoe * 365 + yoe / 4 - yoe / 100 + doy;
|
||||||
|
let days = era * 146_097 + doe - 719_468;
|
||||||
|
Some(days * 86_400 + h * 3600 + mi * 60 + sec)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The apps value: every element a Tessera id, at most 64, then sorted ascending and unique (in that order of checks).
|
||||||
|
fn apps(s: &str) -> Result<Vec<String>, LicenceRefusal> {
|
||||||
|
let list: Vec<&str> = s.split(',').collect();
|
||||||
|
if !list.iter().all(|a| tessera_id_ok(a)) {
|
||||||
|
return Err(malformed("bad_apps"));
|
||||||
|
}
|
||||||
|
if list.len() > MAX_APPS {
|
||||||
|
return Err(malformed("too_many_apps"));
|
||||||
|
}
|
||||||
|
for pair in list.windows(2) {
|
||||||
|
match pair[0].cmp(pair[1]) {
|
||||||
|
std::cmp::Ordering::Equal => return Err(malformed("apps_duplicate")),
|
||||||
|
std::cmp::Ordering::Greater => return Err(malformed("apps_unsorted")),
|
||||||
|
std::cmp::Ordering::Less => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(list.into_iter().map(String::from).collect())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `<name>: <value>`: a 1–16 byte `[a-z]` name, one space, a non-empty value.
|
||||||
|
fn field(line: &str) -> Result<(&str, &str), LicenceRefusal> {
|
||||||
|
let (name, value) = line.split_once(": ").ok_or(malformed("bad_line"))?;
|
||||||
|
if !(1..=16).contains(&name.len()) || !name.bytes().all(|b| b.is_ascii_lowercase()) || value.is_empty() {
|
||||||
|
return Err(malformed("bad_line"));
|
||||||
|
}
|
||||||
|
Ok((name, value))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Steps 1–4 on a payload, and the lines after the prefix (step 7's input). The prefix says the kind.
|
||||||
|
fn structure(input: &[u8]) -> Result<(bool, Vec<&str>), LicenceRefusal> {
|
||||||
|
if input.len() > REVOCATIONS_PAYLOAD_MAX {
|
||||||
|
return Err(malformed("too_large"));
|
||||||
|
}
|
||||||
|
if input.is_empty() {
|
||||||
|
return Err(malformed("truncated"));
|
||||||
|
}
|
||||||
|
if input.contains(&b'\r') {
|
||||||
|
return Err(malformed("crlf"));
|
||||||
|
}
|
||||||
|
if input.iter().any(|&b| b != b'\n' && !(0x20..=0x7e).contains(&b)) {
|
||||||
|
return Err(malformed("bad_byte"));
|
||||||
|
}
|
||||||
|
let licence = input.starts_with(LICENCE_PREFIX.as_bytes());
|
||||||
|
let prefix = if licence {
|
||||||
|
LICENCE_PREFIX
|
||||||
|
} else if input.starts_with(REVOCATIONS_PREFIX.as_bytes()) {
|
||||||
|
REVOCATIONS_PREFIX
|
||||||
|
} else if LICENCE_PREFIX.as_bytes().starts_with(input) || REVOCATIONS_PREFIX.as_bytes().starts_with(input) {
|
||||||
|
return Err(malformed("truncated"));
|
||||||
|
} else {
|
||||||
|
return Err(malformed("bad_prefix"));
|
||||||
|
};
|
||||||
|
if licence && input.len() > LICENCE_PAYLOAD_MAX {
|
||||||
|
return Err(malformed("too_large"));
|
||||||
|
}
|
||||||
|
if input.last() != Some(&b'\n') {
|
||||||
|
return Err(malformed("truncated"));
|
||||||
|
}
|
||||||
|
// Printable ASCII and LF only: valid UTF-8.
|
||||||
|
let text = std::str::from_utf8(input).map_err(|_| malformed("bad_byte"))?;
|
||||||
|
let body = &text[prefix.len()..];
|
||||||
|
let lines = if body.is_empty() { Vec::new() } else { body[..body.len() - 1].split('\n').collect() };
|
||||||
|
Ok((licence, lines))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn licence_fields(lines: &[&str]) -> Result<Licence, LicenceRefusal> {
|
||||||
|
let mut v: [Option<&str>; 7] = [None; 7];
|
||||||
|
let mut last: Option<usize> = None;
|
||||||
|
let (mut issued, mut household, mut seat_count, mut app_list) = (None, None, None, None);
|
||||||
|
for line in lines {
|
||||||
|
let (name, value) = field(line)?;
|
||||||
|
let i = LICENCE_FIELDS.iter().position(|f| *f == name).ok_or(malformed("unknown_field"))?;
|
||||||
|
if v[i].is_some() {
|
||||||
|
return Err(malformed("duplicate_field"));
|
||||||
|
}
|
||||||
|
if last.is_some_and(|l| i < l) {
|
||||||
|
return Err(malformed("field_order"));
|
||||||
|
}
|
||||||
|
last = Some(i);
|
||||||
|
v[i] = Some(value);
|
||||||
|
match i {
|
||||||
|
0 if !licence_id_ok(value) => return Err(malformed("bad_id")),
|
||||||
|
1 => issued = Some(parse_utc(value).ok_or(malformed("bad_issued"))?),
|
||||||
|
2 if !nickname_ok(value) => return Err(malformed("bad_nickname")),
|
||||||
|
3 if !tessera_id_ok(value) => return Err(malformed("bad_bundle")),
|
||||||
|
4 => {
|
||||||
|
household = Some(match value {
|
||||||
|
"household" => true,
|
||||||
|
"seat" => false,
|
||||||
|
_ => return Err(malformed("bad_scope")),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
5 => seat_count = Some(seats(value).ok_or(malformed("bad_seats"))?),
|
||||||
|
6 => app_list = Some(apps(value)?),
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let (Some(id), Some(issued), Some(nickname), Some(bundle), Some(household), Some(apps)) =
|
||||||
|
(v[0], issued, v[2], v[3], household, app_list)
|
||||||
|
else {
|
||||||
|
return Err(malformed("missing_field"));
|
||||||
|
};
|
||||||
|
let seats = match (household, seat_count) {
|
||||||
|
(true, None) => None,
|
||||||
|
(true, Some(_)) => return Err(malformed("seats_with_household")),
|
||||||
|
(false, Some(n)) => Some(n),
|
||||||
|
(false, None) => return Err(malformed("seats_missing")),
|
||||||
|
};
|
||||||
|
Ok(Licence { id: id.into(), issued, nickname: nickname.into(), bundle: bundle.into(), seats, apps })
|
||||||
|
}
|
||||||
|
|
||||||
|
fn revocation_fields(lines: &[&str]) -> Result<Revocations, LicenceRefusal> {
|
||||||
|
let (mut seq_v, mut issued) = (None, None);
|
||||||
|
let mut revoked: Vec<String> = Vec::new();
|
||||||
|
let mut last: Option<usize> = None;
|
||||||
|
for line in lines {
|
||||||
|
let (name, value) = field(line)?;
|
||||||
|
let i = REVOCATION_FIELDS.iter().position(|f| *f == name).ok_or(malformed("unknown_field"))?;
|
||||||
|
let seen = match i {
|
||||||
|
0 => seq_v.is_some(),
|
||||||
|
1 => issued.is_some(),
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
|
if seen {
|
||||||
|
return Err(malformed("duplicate_field"));
|
||||||
|
}
|
||||||
|
if last.is_some_and(|l| i < l) {
|
||||||
|
return Err(malformed("field_order"));
|
||||||
|
}
|
||||||
|
last = Some(i);
|
||||||
|
match i {
|
||||||
|
0 => seq_v = Some(seq(value).ok_or(malformed("bad_seq"))?),
|
||||||
|
1 => issued = Some(parse_utc(value).ok_or(malformed("bad_issued"))?),
|
||||||
|
_ => {
|
||||||
|
if !licence_id_ok(value) {
|
||||||
|
return Err(malformed("bad_id"));
|
||||||
|
}
|
||||||
|
if let Some(prev) = revoked.last() {
|
||||||
|
match prev.as_str().cmp(value) {
|
||||||
|
std::cmp::Ordering::Equal => return Err(malformed("revoked_duplicate")),
|
||||||
|
std::cmp::Ordering::Greater => return Err(malformed("revoked_unsorted")),
|
||||||
|
std::cmp::Ordering::Less => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
revoked.push(value.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let (Some(seq), Some(issued)) = (seq_v, issued) else { return Err(malformed("missing_field")) };
|
||||||
|
Ok(Revocations { seq, issued, revoked })
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The strict parser on a payload: a licence (§2.4 steps 1–4 and 7) or a revocation list (§4.1), by its prefix.
|
||||||
|
/// Custos never sees a `sig:` line, so steps 5 and 6 do not apply: one in a payload is an `unknown_field`.
|
||||||
|
pub fn parse_payload(payload: &[u8]) -> Result<Payload, LicenceRefusal> {
|
||||||
|
let (licence, lines) = structure(payload)?;
|
||||||
|
if licence {
|
||||||
|
licence_fields(&lines).map(Payload::Licence)
|
||||||
|
} else {
|
||||||
|
revocation_fields(&lines).map(Payload::Revocations)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- the grant, the log, and what Custos does with a request ----
|
||||||
|
|
||||||
|
/// Mark's licence grant: what `licence-issue` may have signed without a card. Nothing in it is secret.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct LicenceGrant {
|
||||||
|
/// The app ids a licence may name and still be signed without a card (Tessera ids, sorted, unique).
|
||||||
|
pub allow: Vec<String>,
|
||||||
|
/// Unix milliseconds: when Mark gave it, or last changed it.
|
||||||
|
pub granted: i64,
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub last_used: Option<i64>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub uses: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// How a signature was allowed.
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "lowercase")]
|
||||||
|
pub enum LicenceBy {
|
||||||
|
/// Mark's licence grant covered it: no card.
|
||||||
|
Grant,
|
||||||
|
/// Mark said yes on a card.
|
||||||
|
Card,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// One signature in the log: when, what (a licence's id and apps, or a revocation list's seq and count), and how it
|
||||||
|
/// was allowed. Never the signature, the payload or the nickname.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct LicenceEntry {
|
||||||
|
pub at: i64,
|
||||||
|
pub by: LicenceBy,
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub licence: Option<String>,
|
||||||
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
|
pub apps: Vec<String>,
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub seq: Option<u64>,
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub revoked: Option<u64>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The grant and the log, in the signing store.
|
||||||
|
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct LicenceStore {
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub grant: Option<LicenceGrant>,
|
||||||
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
|
pub log: Vec<LicenceEntry>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LicenceStore {
|
||||||
|
pub(crate) fn is_empty(&self) -> bool {
|
||||||
|
self.grant.is_none() && self.log.is_empty()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// What this core could have written; anything else makes the vault refuse to open.
|
||||||
|
pub(crate) fn ok(&self) -> bool {
|
||||||
|
let grant_ok = self.grant.as_ref().is_none_or(|g| allow_ok(&g.allow));
|
||||||
|
let entry_ok = |e: &LicenceEntry| match (&e.licence, e.seq) {
|
||||||
|
(Some(id), None) => {
|
||||||
|
licence_id_ok(id)
|
||||||
|
&& e.revoked.is_none()
|
||||||
|
&& (1..=MAX_APPS).contains(&e.apps.len())
|
||||||
|
&& e.apps.iter().all(|a| tessera_id_ok(a))
|
||||||
|
}
|
||||||
|
(None, Some(n)) => (1..=MAX_SEQ).contains(&n) && e.apps.is_empty(),
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
|
grant_ok && self.log.len() <= LOG_MAX && self.log.iter().all(entry_ok)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn allow_ok(allow: &[String]) -> bool {
|
||||||
|
allow.len() <= ALLOW_MAX && allow.iter().all(|a| tessera_id_ok(a)) && allow.windows(2).all(|p| p[0] < p[1])
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Why a well-formed request asks Mark on a card instead of being signed at once. Shown on the card.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase", tag = "why")]
|
||||||
|
pub enum CardReason {
|
||||||
|
/// A revocation list always asks.
|
||||||
|
Revocations,
|
||||||
|
/// There is no licence grant.
|
||||||
|
NoGrant,
|
||||||
|
/// The caller is not a program signed with Domi's certificate.
|
||||||
|
NotDomiSigned,
|
||||||
|
/// *Sign only with a card* is ticked.
|
||||||
|
CardSigning,
|
||||||
|
/// These apps are not on the allowlist.
|
||||||
|
OffAllowlist { apps: Vec<String> },
|
||||||
|
/// The day's cap of licence signatures is reached.
|
||||||
|
OverCap { signed: usize },
|
||||||
|
}
|
||||||
|
|
||||||
|
/// What Custos would do with a well-formed request.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub struct LicenceAsk {
|
||||||
|
pub payload: Payload,
|
||||||
|
/// Empty: the grant signs it now. Else the card's reasons.
|
||||||
|
pub card: Vec<CardReason>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Who asks: the caller's authenticated Canalis app id, and whether its program is signed with one of Domi's
|
||||||
|
/// code-signing certificates (the desktop's check; docs/25 in Custos).
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
pub struct Caller<'a> {
|
||||||
|
pub app: &'a str,
|
||||||
|
pub domi_signed: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Vault {
|
||||||
|
/// Makes the licence key (Ed25519) and returns its 32-byte public key, the one the Atrium Domi service ships.
|
||||||
|
/// Refused when there is one already. Call it only from Mark's own click. The caller saves.
|
||||||
|
pub fn licence_key_create(&mut self, now: i64) -> Result<[u8; 32], Error> {
|
||||||
|
if self.signing.get(LICENCE_KEY).is_some() {
|
||||||
|
return Err(Error::Signing(format!("there is a key `{LICENCE_KEY}` already")));
|
||||||
|
}
|
||||||
|
let public = self.signing.add_licence_key(now);
|
||||||
|
let words = format!("licence key {LICENCE_KEY} made");
|
||||||
|
self.security.standing_note(crate::security::Action::StandingGranted, &words, now);
|
||||||
|
Ok(public)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The licence key's public key, if there is one.
|
||||||
|
pub fn licence_public(&self) -> Option<[u8; 32]> {
|
||||||
|
self.signing.get(LICENCE_KEY).and_then(|k| k.public)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The licence grant, if Mark gave it.
|
||||||
|
pub fn licence_grant(&self) -> Option<LicenceGrant> {
|
||||||
|
self.signing.licence.grant.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Gives the licence grant, or replaces its allowlist (its counts stay), and writes `standing-granted`. Refused
|
||||||
|
/// while *Sign only with a card* is ticked, and before there is a licence key. Call it only from Mark's own click.
|
||||||
|
/// The caller saves.
|
||||||
|
pub fn licence_grant_set(&mut self, allow: &[String], now: i64) -> Result<LicenceGrant, Error> {
|
||||||
|
if self.security.is_ticked(crate::security::Item::CardSigning) {
|
||||||
|
return Err(Error::Signing("Sign only with a card is ticked".into()));
|
||||||
|
}
|
||||||
|
if self.signing.get(LICENCE_KEY).is_none() {
|
||||||
|
return Err(Error::Signing("make the licence key first".into()));
|
||||||
|
}
|
||||||
|
let mut list: Vec<String> = Vec::new();
|
||||||
|
for a in allow.iter().map(|a| a.trim()).filter(|a| !a.is_empty()) {
|
||||||
|
if !tessera_id_ok(a) {
|
||||||
|
return Err(Error::Signing(format!("`{a}` is not an app id (a-z, 0-9 and -, up to 32)")));
|
||||||
|
}
|
||||||
|
list.push(a.to_string());
|
||||||
|
}
|
||||||
|
list.sort();
|
||||||
|
list.dedup();
|
||||||
|
if list.len() > ALLOW_MAX {
|
||||||
|
return Err(Error::Signing(format!("the allowlist holds at most {ALLOW_MAX} apps")));
|
||||||
|
}
|
||||||
|
let old = self.signing.licence.grant.clone();
|
||||||
|
let grant = LicenceGrant {
|
||||||
|
allow: list,
|
||||||
|
granted: now,
|
||||||
|
last_used: old.as_ref().and_then(|g| g.last_used),
|
||||||
|
uses: old.map_or(0, |g| g.uses),
|
||||||
|
};
|
||||||
|
let words = format!("Domi licences by {LICENCE_ISSUER}: {}", grant.allow.join(", "));
|
||||||
|
self.security.standing_note(crate::security::Action::StandingGranted, &words, now);
|
||||||
|
self.signing.licence.grant = Some(grant.clone());
|
||||||
|
Ok(grant)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Removes the licence grant (`standing-revoked`): from then on every licence asks on a card. The key and the log
|
||||||
|
/// stay. False when there is none. The caller saves.
|
||||||
|
pub fn licence_grant_revoke(&mut self, now: i64) -> bool {
|
||||||
|
let Some(g) = self.signing.licence.grant.take() else { return false };
|
||||||
|
let words = format!("Domi licences by {LICENCE_ISSUER}: {}", g.allow.join(", "));
|
||||||
|
self.security.standing_note(crate::security::Action::StandingRevoked, &words, now);
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Every licence signature, oldest first.
|
||||||
|
pub fn licence_log(&self) -> &[LicenceEntry] {
|
||||||
|
&self.signing.licence.log
|
||||||
|
}
|
||||||
|
|
||||||
|
/// What Custos does with `payload` from `caller` at `now` (Unix milliseconds): refused (the code says why, no
|
||||||
|
/// card), signed by the grant (no reasons), or asked on a card (its reasons). Changes nothing.
|
||||||
|
pub fn licence_ask(&self, payload: &[u8], caller: Caller<'_>, now: i64) -> Result<LicenceAsk, LicenceRefusal> {
|
||||||
|
let parsed = parse_payload(payload)?;
|
||||||
|
if self.signing.get(LICENCE_KEY).is_none() {
|
||||||
|
return Err(LicenceRefusal::NoKey);
|
||||||
|
}
|
||||||
|
if caller.app != LICENCE_ISSUER {
|
||||||
|
return Err(LicenceRefusal::NotAllowed);
|
||||||
|
}
|
||||||
|
if self.signing.licence.log.len() >= LOG_MAX {
|
||||||
|
return Err(LicenceRefusal::LogFull);
|
||||||
|
}
|
||||||
|
let log = &self.signing.licence.log;
|
||||||
|
let mut card = Vec::new();
|
||||||
|
match &parsed {
|
||||||
|
Payload::Licence(l) => {
|
||||||
|
if (l.issued - now.div_euclid(1000)).abs() > CLOCK_TOLERANCE_S {
|
||||||
|
return Err(LicenceRefusal::Clock);
|
||||||
|
}
|
||||||
|
if log.iter().any(|e| e.licence.as_deref() == Some(l.id.as_str())) {
|
||||||
|
return Err(LicenceRefusal::Replay);
|
||||||
|
}
|
||||||
|
if !caller.domi_signed {
|
||||||
|
card.push(CardReason::NotDomiSigned);
|
||||||
|
}
|
||||||
|
if self.security.is_ticked(crate::security::Item::CardSigning) {
|
||||||
|
card.push(CardReason::CardSigning);
|
||||||
|
}
|
||||||
|
match &self.signing.licence.grant {
|
||||||
|
None => card.push(CardReason::NoGrant),
|
||||||
|
Some(g) => {
|
||||||
|
let off: Vec<String> = l.apps.iter().filter(|a| !g.allow.contains(a)).cloned().collect();
|
||||||
|
if !off.is_empty() {
|
||||||
|
card.push(CardReason::OffAllowlist { apps: off });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let today = log.iter().filter(|e| e.licence.is_some() && e.at > now - DAY_MS).count();
|
||||||
|
if today >= DAY_CAP {
|
||||||
|
card.push(CardReason::OverCap { signed: today });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Payload::Revocations(r) => {
|
||||||
|
if log.iter().filter_map(|e| e.seq).any(|s| s >= r.seq) {
|
||||||
|
return Err(LicenceRefusal::Rollback);
|
||||||
|
}
|
||||||
|
card.push(CardReason::Revocations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(LicenceAsk { payload: parsed, card })
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Checks `payload` again ([`Vault::licence_ask`]) and signs it: by the grant when `by` is [`LicenceBy::Grant`]
|
||||||
|
/// (refused with `needs_card` when the grant does not cover it), or after Mark's yes on a card. Returns the
|
||||||
|
/// signature in base64url without padding (86 characters), and logs it. The caller saves.
|
||||||
|
pub fn licence_sign(
|
||||||
|
&mut self,
|
||||||
|
payload: &[u8],
|
||||||
|
caller: Caller<'_>,
|
||||||
|
by: LicenceBy,
|
||||||
|
now: i64,
|
||||||
|
) -> Result<String, LicenceRefusal> {
|
||||||
|
let ask = self.licence_ask(payload, caller, now)?;
|
||||||
|
if by == LicenceBy::Grant && !ask.card.is_empty() {
|
||||||
|
return Err(LicenceRefusal::NeedsCard);
|
||||||
|
}
|
||||||
|
let signature = self.signing.licence_signature(payload).ok_or(LicenceRefusal::NoKey)?;
|
||||||
|
let entry = match &ask.payload {
|
||||||
|
Payload::Licence(l) => LicenceEntry {
|
||||||
|
at: now,
|
||||||
|
by,
|
||||||
|
licence: Some(l.id.clone()),
|
||||||
|
apps: l.apps.clone(),
|
||||||
|
seq: None,
|
||||||
|
revoked: None,
|
||||||
|
},
|
||||||
|
Payload::Revocations(r) => LicenceEntry {
|
||||||
|
at: now,
|
||||||
|
by,
|
||||||
|
licence: None,
|
||||||
|
apps: Vec::new(),
|
||||||
|
seq: Some(r.seq),
|
||||||
|
revoked: Some(r.revoked.len() as u64),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
self.signing.licence.log.push(entry);
|
||||||
|
if by == LicenceBy::Grant
|
||||||
|
&& let Some(g) = self.signing.licence.grant.as_mut()
|
||||||
|
{
|
||||||
|
g.uses = g.uses.saturating_add(1);
|
||||||
|
g.last_used = Some(now);
|
||||||
|
}
|
||||||
|
Ok(data_encoding::BASE64URL_NOPAD.encode(&signature))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
const NOW_S: i64 = 1_795_896_907; // 2026-11-28T20:15:07Z
|
||||||
|
const NOW: i64 = NOW_S * 1000;
|
||||||
|
|
||||||
|
fn licence(id: &str, apps: &str) -> Vec<u8> {
|
||||||
|
format!(
|
||||||
|
"domi-licence-v1\nid: {id}\nissued: 2026-11-28T20:15:07Z\nnickname: Novak family\nbundle: household-all\n\
|
||||||
|
scope: household\napps: {apps}\n"
|
||||||
|
)
|
||||||
|
.into_bytes()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn revocations(seq: u64, ids: &[&str]) -> Vec<u8> {
|
||||||
|
let mut s = format!("domi-revocations-v1\nseq: {seq}\nissued: 2026-11-28T20:15:07Z\n");
|
||||||
|
for id in ids {
|
||||||
|
s.push_str(&format!("revoked: {id}\n"));
|
||||||
|
}
|
||||||
|
s.into_bytes()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn code(p: &[u8]) -> &'static str {
|
||||||
|
parse_payload(p).unwrap_err().code()
|
||||||
|
}
|
||||||
|
|
||||||
|
const ISSUER: Caller<'static> = Caller { app: LICENCE_ISSUER, domi_signed: true };
|
||||||
|
|
||||||
|
fn vault() -> Vault {
|
||||||
|
let pw = crate::SecretString::from("pw");
|
||||||
|
let mut v = Vault::create(&pw, crate::KdfParams { m_cost_kib: 64, t_cost: 1, p_cost: 1 }).unwrap();
|
||||||
|
v.licence_key_create(NOW).unwrap();
|
||||||
|
v
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_spec_example_parses_and_its_time_is_utc() {
|
||||||
|
assert_eq!(parse_utc("2026-11-28T20:15:07Z"), Some(NOW_S));
|
||||||
|
assert_eq!(parse_utc("2000-01-01T00:00:00Z"), Some(946_684_800));
|
||||||
|
assert_eq!(parse_utc("2024-02-29T00:00:00Z").is_some(), true);
|
||||||
|
for bad in ["2023-02-29T00:00:00Z", "2100-02-29T00:00:00Z", "1999-12-31T23:59:59Z", "2026-11-28T24:00:00Z",
|
||||||
|
"2026-11-28T20:15:60Z", "2026-11-28 20:15:07Z", "2026-11-28T20:15:07z", "2026-13-01T00:00:00Z"] {
|
||||||
|
assert_eq!(parse_utc(bad), None, "{bad}");
|
||||||
|
}
|
||||||
|
let Payload::Licence(l) = parse_payload(&licence("k3Jx0Qm1T9yZpW2bA7cD4e", "calenda,fiscus,medicus,tabula")).unwrap()
|
||||||
|
else {
|
||||||
|
panic!("a licence")
|
||||||
|
};
|
||||||
|
assert_eq!((l.issued, l.seats, l.apps.len()), (NOW_S, None, 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_malformed_payload_is_refused_with_the_specs_code() {
|
||||||
|
let ok = licence("k3Jx0Qm1T9yZpW2bA7cD4e", "calenda,tabula");
|
||||||
|
let with = |from: &str, to: &str| String::from_utf8(ok.clone()).unwrap().replace(from, to).into_bytes();
|
||||||
|
assert_eq!(code(b""), "truncated");
|
||||||
|
assert_eq!(code(b"domi-lic"), "truncated");
|
||||||
|
assert_eq!(code(b"hello\n"), "bad_prefix");
|
||||||
|
assert_eq!(code(&with("\n", "\r\n")), "crlf");
|
||||||
|
assert_eq!(code(&with("Novak", "Nov\tak")), "bad_byte");
|
||||||
|
assert_eq!(code(&ok[..ok.len() - 1]), "truncated");
|
||||||
|
assert_eq!(code(&with("id: ", "id:")), "bad_line");
|
||||||
|
assert_eq!(code(&with("bundle: ", "colour: blue\nbundle: ")), "unknown_field");
|
||||||
|
assert_eq!(code(&with("bundle: ", "id: k3Jx0Qm1T9yZpW2bA7cD4f\nbundle: ")), "duplicate_field");
|
||||||
|
assert_eq!(code(&with("nickname: Novak family\nbundle: household-all", "bundle: household-all\nnickname: Novak family")), "field_order");
|
||||||
|
assert_eq!(code(&with("scope: household\n", "")), "missing_field");
|
||||||
|
assert_eq!(code(&with("k3Jx0Qm1T9yZpW2bA7cD4e", "short")), "bad_id");
|
||||||
|
assert_eq!(code(&with("2026-11-28T20:15:07Z", "2026-02-30T20:15:07Z")), "bad_issued");
|
||||||
|
assert_eq!(code(&with("Novak family", "Novak family")), "bad_nickname");
|
||||||
|
assert_eq!(code(&with("household-all", "-all")), "bad_bundle");
|
||||||
|
assert_eq!(code(&with("scope: household", "scope: family")), "bad_scope");
|
||||||
|
assert_eq!(code(&with("scope: household", "scope: seat\nseats: 51")), "bad_seats");
|
||||||
|
assert_eq!(code(&with("scope: household", "scope: household\nseats: 2")), "seats_with_household");
|
||||||
|
assert_eq!(code(&with("scope: household", "scope: seat")), "seats_missing");
|
||||||
|
assert_eq!(code(&with("calenda,tabula", "calenda,,tabula")), "bad_apps");
|
||||||
|
assert_eq!(code(&with("calenda,tabula", "tabula,calenda")), "apps_unsorted");
|
||||||
|
assert_eq!(code(&with("calenda,tabula", "calenda,calenda")), "apps_duplicate");
|
||||||
|
let many: Vec<String> = (0..65).map(|i| format!("app{i:03}")).collect();
|
||||||
|
assert_eq!(code(&with("calenda,tabula", &many.join(","))), "too_many_apps");
|
||||||
|
assert_eq!(code(&with("apps: calenda,tabula\n", "apps: calenda,tabula\nsig: x\n")), "unknown_field");
|
||||||
|
let mut big = ok.clone();
|
||||||
|
big.truncate(big.len() - 1);
|
||||||
|
big.extend(std::iter::repeat_n(b'a', LICENCE_PAYLOAD_MAX));
|
||||||
|
big.push(b'\n');
|
||||||
|
assert_eq!(code(&big), "too_large");
|
||||||
|
// A seat licence is fine.
|
||||||
|
assert!(parse_payload(&with("scope: household", "scope: seat\nseats: 50")).is_ok());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_revocation_list_parses_strictly() {
|
||||||
|
let a = "AAAAAAAAAAAAAAAAAAAAAA";
|
||||||
|
let b = "BBBBBBBBBBBBBBBBBBBBBB";
|
||||||
|
assert!(matches!(parse_payload(&revocations(1, &[])).unwrap(), Payload::Revocations(r) if r.revoked.is_empty()));
|
||||||
|
assert!(matches!(parse_payload(&revocations(7, &[a, b])).unwrap(), Payload::Revocations(r) if r.seq == 7));
|
||||||
|
assert_eq!(code(&revocations(7, &[b, a])), "revoked_unsorted");
|
||||||
|
assert_eq!(code(&revocations(7, &[a, a])), "revoked_duplicate");
|
||||||
|
assert_eq!(code(&revocations(0, &[])), "bad_seq");
|
||||||
|
assert_eq!(code(&revocations(MAX_SEQ + 1, &[])), "bad_seq");
|
||||||
|
assert_eq!(code(b"domi-revocations-v1\nissued: 2026-11-28T20:15:07Z\n"), "missing_field");
|
||||||
|
let reordered = b"domi-revocations-v1\nseq: 3\nrevoked: AAAAAAAAAAAAAAAAAAAAAA\nissued: 2026-11-28T20:15:07Z\n";
|
||||||
|
assert_eq!(code(reordered), "field_order");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_grant_signs_an_allowed_licence_and_a_signature_verifies() {
|
||||||
|
let mut v = vault();
|
||||||
|
let p = licence("k3Jx0Qm1T9yZpW2bA7cD4e", "calenda,tabula");
|
||||||
|
// No grant yet: a card.
|
||||||
|
assert_eq!(v.licence_ask(&p, ISSUER, NOW).unwrap().card, vec![CardReason::NoGrant]);
|
||||||
|
assert_eq!(v.licence_sign(&p, ISSUER, LicenceBy::Grant, NOW), Err(LicenceRefusal::NeedsCard));
|
||||||
|
v.licence_grant_set(&["tabula".into(), "calenda".into()], NOW).unwrap();
|
||||||
|
let sig = v.licence_sign(&p, ISSUER, LicenceBy::Grant, NOW).unwrap();
|
||||||
|
assert_eq!(sig.len(), 86);
|
||||||
|
let raw = data_encoding::BASE64URL_NOPAD.decode(sig.as_bytes()).unwrap();
|
||||||
|
let key = ed25519_dalek::VerifyingKey::from_bytes(&v.licence_public().unwrap()).unwrap();
|
||||||
|
let sig = ed25519_dalek::Signature::from_slice(&raw).unwrap();
|
||||||
|
assert!(key.verify_strict(&p, &sig).is_ok(), "plain Ed25519 over the exact payload");
|
||||||
|
assert_eq!(v.licence_grant().unwrap().uses, 1);
|
||||||
|
assert_eq!(v.licence_log()[0].licence.as_deref(), Some("k3Jx0Qm1T9yZpW2bA7cD4e"));
|
||||||
|
// The same id again is a replay, refused with no card.
|
||||||
|
assert_eq!(v.licence_ask(&p, ISSUER, NOW).unwrap_err(), LicenceRefusal::Replay);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn off_the_allowlist_unsigned_programs_and_the_cap_ask_on_a_card() {
|
||||||
|
let mut v = vault();
|
||||||
|
v.licence_grant_set(&["tabula".into()], NOW).unwrap();
|
||||||
|
let p = licence("k3Jx0Qm1T9yZpW2bA7cD4e", "calenda,tabula");
|
||||||
|
assert_eq!(v.licence_ask(&p, ISSUER, NOW).unwrap().card, vec![CardReason::OffAllowlist { apps: vec!["calenda".into()] }]);
|
||||||
|
let unsigned = Caller { app: LICENCE_ISSUER, domi_signed: false };
|
||||||
|
let q = licence("k3Jx0Qm1T9yZpW2bA7cD4f", "tabula");
|
||||||
|
assert_eq!(v.licence_ask(&q, unsigned, NOW).unwrap().card, vec![CardReason::NotDomiSigned]);
|
||||||
|
for i in 0..DAY_CAP {
|
||||||
|
v.licence_sign(&licence(&format!("id-number-{i:03}"), "tabula"), ISSUER, LicenceBy::Grant, NOW).unwrap();
|
||||||
|
}
|
||||||
|
assert_eq!(v.licence_ask(&q, ISSUER, NOW).unwrap().card, vec![CardReason::OverCap { signed: DAY_CAP }]);
|
||||||
|
// Mark's card signs past the cap; a day later the grant signs again.
|
||||||
|
assert!(v.licence_sign(&q, ISSUER, LicenceBy::Card, NOW).is_ok());
|
||||||
|
let r = licence("k3Jx0Qm1T9yZpW2bA7cD4g", "tabula");
|
||||||
|
assert_eq!(v.licence_ask(&r, ISSUER, NOW + DAY_MS).unwrap().card, vec![]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn refused_without_a_card_another_caller_a_bad_clock_and_a_rollback() {
|
||||||
|
let mut v = vault();
|
||||||
|
v.licence_grant_set(&["tabula".into()], NOW).unwrap();
|
||||||
|
let p = licence("k3Jx0Qm1T9yZpW2bA7cD4e", "tabula");
|
||||||
|
let other = Caller { app: "atrium", domi_signed: true };
|
||||||
|
assert_eq!(v.licence_ask(&p, other, NOW).unwrap_err(), LicenceRefusal::NotAllowed);
|
||||||
|
assert_eq!(v.licence_ask(&p, ISSUER, NOW + 2 * DAY_MS).unwrap_err(), LicenceRefusal::Clock);
|
||||||
|
assert_eq!(v.licence_ask(&p, ISSUER, NOW - 2 * DAY_MS).unwrap_err(), LicenceRefusal::Clock);
|
||||||
|
// A revocation list always asks, and never goes back.
|
||||||
|
let r5 = revocations(5, &["k3Jx0Qm1T9yZpW2bA7cD4e"]);
|
||||||
|
assert_eq!(v.licence_ask(&r5, ISSUER, NOW).unwrap().card, vec![CardReason::Revocations]);
|
||||||
|
assert_eq!(v.licence_sign(&r5, ISSUER, LicenceBy::Grant, NOW), Err(LicenceRefusal::NeedsCard));
|
||||||
|
v.licence_sign(&r5, ISSUER, LicenceBy::Card, NOW).unwrap();
|
||||||
|
assert_eq!(v.licence_ask(&r5, ISSUER, NOW).unwrap_err(), LicenceRefusal::Rollback);
|
||||||
|
assert_eq!(v.licence_ask(&revocations(4, &[]), ISSUER, NOW).unwrap_err(), LicenceRefusal::Rollback);
|
||||||
|
assert!(v.licence_ask(&revocations(6, &[]), ISSUER, NOW).is_ok());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_licence_key_signs_nothing_else_and_its_state_survives_a_save() {
|
||||||
|
let mut v = vault();
|
||||||
|
assert!(v.licence_key_create(NOW).is_err(), "one licence key");
|
||||||
|
let req = crate::signing::Request {
|
||||||
|
key: LICENCE_KEY.into(),
|
||||||
|
kind: crate::signing::SignKind::Minisign,
|
||||||
|
digest: vec![1; 64],
|
||||||
|
manifest: None,
|
||||||
|
approval: None,
|
||||||
|
run: Some("r-1".into()),
|
||||||
|
context: crate::signing::Context {
|
||||||
|
repo: "mnovak/Custos".into(),
|
||||||
|
pipeline: "release".into(),
|
||||||
|
file: "x.exe".into(),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
via: crate::signing::Via::Local,
|
||||||
|
};
|
||||||
|
assert!(matches!(v.signing_check(&req), Err(crate::signing::Refusal::Invalid(_))));
|
||||||
|
assert!(v.signing_set_scope(LICENCE_KEY, &["*".into()], &["*".into()]).is_err());
|
||||||
|
v.licence_grant_set(&["tabula".into()], NOW).unwrap();
|
||||||
|
v.licence_sign(&licence("k3Jx0Qm1T9yZpW2bA7cD4e", "tabula"), ISSUER, LicenceBy::Grant, NOW).unwrap();
|
||||||
|
let again = Vault::open(&v.to_bytes().unwrap(), &crate::SecretString::from("pw")).unwrap();
|
||||||
|
assert_eq!(again.licence_public(), v.licence_public());
|
||||||
|
assert_eq!(again.licence_grant(), v.licence_grant());
|
||||||
|
assert_eq!(again.licence_log(), v.licence_log());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -829,6 +829,29 @@ mod tests {
|
|||||||
assert_eq!(full.standing_rules()[0].uses, u64::MAX);
|
assert_eq!(full.standing_rules()[0].uses, u64::MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_broken_android_grant_makes_the_vault_refuse_to_open() {
|
||||||
|
let mut v = vault();
|
||||||
|
v.android_grant_set(&["mnovak/*".to_string()], "Marek Novak", "CZ", NOW).unwrap();
|
||||||
|
let json = body_json(&v);
|
||||||
|
assert!(Vault::open(&with_body(&v, &json), &SecretString::from("pw")).is_ok());
|
||||||
|
let from = r#""repos":["mnovak/*"],"o":"Marek Novak","c":"CZ""#;
|
||||||
|
assert!(json.contains(from), "{json}");
|
||||||
|
for to in [
|
||||||
|
r#""repos":["*/*"],"o":"Marek Novak","c":"CZ""#,
|
||||||
|
r#""repos":["*"],"o":"Marek Novak","c":"CZ""#,
|
||||||
|
r#""repos":[],"o":"Marek Novak","c":"CZ""#,
|
||||||
|
r#""repos":["mnovak/*","mnovak/*"],"o":"Marek Novak","c":"CZ""#,
|
||||||
|
r#""repos":["mnovak/*"],"o":"","c":"CZ""#,
|
||||||
|
r#""repos":["mnovak/*"],"o":"Marek Novak","c":"Czech""#,
|
||||||
|
r#""repos":["mnovak/*"],"o":"Marek Novak","c":"CZ","made":["Not An Id"]"#,
|
||||||
|
] {
|
||||||
|
let bad = json.replacen(from, to, 1);
|
||||||
|
let r = Vault::open(&with_body(&v, &bad), &SecretString::from("pw"));
|
||||||
|
assert!(matches!(r, Err(Error::Corrupted)), "{to}: {r:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn a_broken_standing_approval_makes_the_vault_refuse_to_open() {
|
fn a_broken_standing_approval_makes_the_vault_refuse_to_open() {
|
||||||
let v = vault_with_a_standing_approval();
|
let v = vault_with_a_standing_approval();
|
||||||
|
|||||||
@@ -203,6 +203,35 @@ pub struct StandingRule {
|
|||||||
/// At most this many standing approvals in a vault.
|
/// At most this many standing approvals in a vault.
|
||||||
pub const STANDING_MAX: usize = 256;
|
pub const STANDING_MAX: usize = 256;
|
||||||
|
|
||||||
|
/// The Android grant (core 0.19.0, docs/SIGNING.md "The Android grant"): Mark's one answer for every Domi app's
|
||||||
|
/// release APK. It signs an app key's APKs from this PC's pipe, its first signature included, and makes the key when
|
||||||
|
/// the app's first release asks. Nothing in it is secret.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct AndroidGrant {
|
||||||
|
/// `owner/name` or `owner/*`, 1 to [`ANDROID_PATTERNS_MAX`].
|
||||||
|
pub repos: Vec<String>,
|
||||||
|
/// The organisation and country in the certificates of the keys it makes.
|
||||||
|
pub o: String,
|
||||||
|
pub c: String,
|
||||||
|
/// Unix milliseconds: when Mark granted it, or last changed it.
|
||||||
|
pub granted: i64,
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub last_used: Option<i64>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub uses: u64,
|
||||||
|
/// The ids of the keys it made, oldest first.
|
||||||
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
|
pub made: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The one pipeline the Android grant covers.
|
||||||
|
pub const ANDROID_PIPELINE: &str = "release";
|
||||||
|
/// At most this many repository patterns in the Android grant.
|
||||||
|
pub const ANDROID_PATTERNS_MAX: usize = 64;
|
||||||
|
/// At most this many keys the Android grant remembers making.
|
||||||
|
const ANDROID_MADE_MAX: usize = 256;
|
||||||
|
|
||||||
/// A signature handed back to the build.
|
/// A signature handed back to the build.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct Signed {
|
pub struct Signed {
|
||||||
@@ -269,6 +298,9 @@ pub(crate) struct Store {
|
|||||||
pub(crate) keys: Vec<Key>,
|
pub(crate) keys: Vec<Key>,
|
||||||
pub(crate) audit: Vec<AuditEntry>,
|
pub(crate) audit: Vec<AuditEntry>,
|
||||||
standing: Vec<StandingRule>,
|
standing: Vec<StandingRule>,
|
||||||
|
android: Option<AndroidGrant>,
|
||||||
|
/// The licence grant and log (core 0.21.0, `licence.rs`).
|
||||||
|
pub(crate) licence: crate::licence::LicenceStore,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
@@ -303,6 +335,13 @@ pub(crate) struct StoreJson {
|
|||||||
/// Standing approvals (core 0.16.0); absent while there are none.
|
/// Standing approvals (core 0.16.0); absent while there are none.
|
||||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
standing: Vec<StandingRule>,
|
standing: Vec<StandingRule>,
|
||||||
|
/// The Android grant (core 0.19.0); absent while there is none. Older cores ignore and drop it.
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
android: Option<AndroidGrant>,
|
||||||
|
/// The licence grant and log (core 0.21.0); absent while empty. Older cores ignore and drop it: the grant is then
|
||||||
|
/// gone (every licence asks on a card), and the key, an ordinary Ed25519 entry, stays.
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
licence: Option<crate::licence::LicenceStore>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn b64(bytes: &[u8]) -> String {
|
fn b64(bytes: &[u8]) -> String {
|
||||||
@@ -330,7 +369,11 @@ fn unhex8(s: &str) -> Option<[u8; 8]> {
|
|||||||
|
|
||||||
impl Store {
|
impl Store {
|
||||||
pub(crate) fn is_empty(&self) -> bool {
|
pub(crate) fn is_empty(&self) -> bool {
|
||||||
self.keys.is_empty() && self.audit.is_empty() && self.standing.is_empty()
|
self.keys.is_empty()
|
||||||
|
&& self.audit.is_empty()
|
||||||
|
&& self.standing.is_empty()
|
||||||
|
&& self.android.is_none()
|
||||||
|
&& self.licence.is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn from_json(j: StoreJson) -> Option<Store> {
|
pub(crate) fn from_json(j: StoreJson) -> Option<Store> {
|
||||||
@@ -389,7 +432,23 @@ impl Store {
|
|||||||
if j.standing.len() > STANDING_MAX || !j.standing.iter().all(rule_ok) {
|
if j.standing.len() > STANDING_MAX || !j.standing.iter().all(rule_ok) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Some(Store { keys, audit: j.audit, standing: j.standing })
|
if j.android.as_ref().is_some_and(|g| !grant_ok(g)) {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let licence = j.licence.unwrap_or_default();
|
||||||
|
// The licence key is what `add_licence_key` makes: Ed25519 with its public key, release, no scope.
|
||||||
|
let licence_key_ok = |k: &Key| {
|
||||||
|
k.id != crate::licence::LICENCE_KEY
|
||||||
|
|| (k.kind == KeyKind::Ed25519
|
||||||
|
&& k.role == Role::Release
|
||||||
|
&& k.public.is_some()
|
||||||
|
&& k.pipelines.is_empty()
|
||||||
|
&& k.repos.is_empty())
|
||||||
|
};
|
||||||
|
if !licence.ok() || !keys.iter().all(licence_key_ok) {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
Some(Store { keys, audit: j.audit, standing: j.standing, android: j.android, licence })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn json(&self) -> Option<StoreJson> {
|
pub(crate) fn json(&self) -> Option<StoreJson> {
|
||||||
@@ -418,12 +477,47 @@ impl Store {
|
|||||||
repos: k.repos.clone(),
|
repos: k.repos.clone(),
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
Some(StoreJson { keys, audit: self.audit.clone(), standing: self.standing.clone() })
|
Some(StoreJson {
|
||||||
|
keys,
|
||||||
|
audit: self.audit.clone(),
|
||||||
|
standing: self.standing.clone(),
|
||||||
|
android: self.android.clone(),
|
||||||
|
licence: (!self.licence.is_empty()).then(|| self.licence.clone()),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get(&self, id: &str) -> Option<&Key> {
|
pub(crate) fn get(&self, id: &str) -> Option<&Key> {
|
||||||
self.keys.iter().find(|k| k.id == id)
|
self.keys.iter().find(|k| k.id == id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Adds the licence key (`licence.rs`): Ed25519, a release key with no scope and no minisign key id, so no
|
||||||
|
/// pipeline or repository can ever be in its scope. The caller checked there is none. Returns its public key.
|
||||||
|
pub(crate) fn add_licence_key(&mut self, now: i64) -> [u8; 32] {
|
||||||
|
let ed = custos_sign::new_ed25519();
|
||||||
|
self.keys.push(Key {
|
||||||
|
id: crate::licence::LICENCE_KEY.into(),
|
||||||
|
kind: KeyKind::Ed25519,
|
||||||
|
role: Role::Release,
|
||||||
|
name: "Domi licence".into(),
|
||||||
|
secret: Secret::Ed25519(ed.secret),
|
||||||
|
public: Some(ed.public),
|
||||||
|
key_id: None,
|
||||||
|
cert: None,
|
||||||
|
issuer: None,
|
||||||
|
created: now,
|
||||||
|
pipelines: Vec::new(),
|
||||||
|
repos: Vec::new(),
|
||||||
|
});
|
||||||
|
ed.public
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The licence key's plain Ed25519 signature over `payload` (`licence.rs` parsed and allowed it).
|
||||||
|
pub(crate) fn licence_signature(&self, payload: &[u8]) -> Option<[u8; 64]> {
|
||||||
|
match &self.get(crate::licence::LICENCE_KEY)?.secret {
|
||||||
|
Secret::Ed25519(s) => Some(custos_sign::ed25519_plain(s, payload)),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Unix seconds from the vault's milliseconds, as minisign and approvals count them.
|
/// Unix seconds from the vault's milliseconds, as minisign and approvals count them.
|
||||||
@@ -514,6 +608,64 @@ fn rule_words(r: &StandingRule) -> String {
|
|||||||
format!("{} {} {} pipeline {} {}{targets}", r.repo, r.key, kind_word(r.kind), r.pipeline, via_word(r.via))
|
format!("{} {} {} pipeline {} {}{targets}", r.repo, r.key, kind_word(r.kind), r.pipeline, via_word(r.via))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `owner/name`, each 1 to 64 of `A-Z a-z 0-9 . _ -`: the owner and the name, or `None`.
|
||||||
|
fn repo_parts(repo: &str) -> Option<(&str, &str)> {
|
||||||
|
let part =
|
||||||
|
|x: &str| (1..=64).contains(&x.len()) && x.bytes().all(|b| b.is_ascii_alphanumeric() || b"._-".contains(&b));
|
||||||
|
let (owner, name) = repo.split_once('/')?;
|
||||||
|
(part(owner) && part(name)).then_some((owner, name))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The app key of a repository (core 0.19.0): `mnovak/Culina` is `culina-android` (the name in lower case, `.` and
|
||||||
|
/// `_` as `-`); `None` for anything that is not `owner/name` or an id longer than 64.
|
||||||
|
pub fn android_key_id(repo: &str) -> Option<String> {
|
||||||
|
let (_, name) = repo_parts(repo)?;
|
||||||
|
let id: String = name.chars().map(|c| if c == '.' || c == '_' { '-' } else { c.to_ascii_lowercase() }).collect();
|
||||||
|
let id = format!("{id}-android");
|
||||||
|
(id.len() <= 64).then_some(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A pattern of the Android grant: `owner/name`, or `owner/*` for every repository of that owner.
|
||||||
|
fn grant_pattern_ok(p: &str) -> bool {
|
||||||
|
match p.strip_suffix("/*") {
|
||||||
|
Some(owner) => repo_parts(&format!("{owner}/x")).is_some(),
|
||||||
|
None => repo_parts(p).is_some(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn grant_covers(g: &AndroidGrant, repo: &str) -> bool {
|
||||||
|
let Some((owner, _)) = repo_parts(repo) else { return false };
|
||||||
|
g.repos.iter().any(|p| p == repo || p.strip_suffix("/*") == Some(owner))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The certificate's O (1 to 64, no control characters) and C (two ASCII capitals) for the keys the grant makes.
|
||||||
|
fn grant_subject_ok(o: &str, c: &str) -> bool {
|
||||||
|
(1..=64).contains(&o.chars().count())
|
||||||
|
&& !o.chars().any(char::is_control)
|
||||||
|
&& o.trim() == o
|
||||||
|
&& c.len() == 2
|
||||||
|
&& c.bytes().all(|b| b.is_ascii_uppercase())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A stored grant is what [`Vault::android_grant_set`] could have written; anything else makes the vault refuse to
|
||||||
|
/// open.
|
||||||
|
fn grant_ok(g: &AndroidGrant) -> bool {
|
||||||
|
let id_ok = |id: &String| {
|
||||||
|
(1..=64).contains(&id.len()) && id.bytes().all(|b| b.is_ascii_lowercase() || b.is_ascii_digit() || b == b'-')
|
||||||
|
};
|
||||||
|
(1..=ANDROID_PATTERNS_MAX).contains(&g.repos.len())
|
||||||
|
&& g.repos.iter().all(|p| grant_pattern_ok(p))
|
||||||
|
&& g.repos.iter().enumerate().all(|(i, p)| !g.repos[..i].contains(p))
|
||||||
|
&& grant_subject_ok(&g.o, &g.c)
|
||||||
|
&& g.made.len() <= ANDROID_MADE_MAX
|
||||||
|
&& g.made.iter().all(id_ok)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// What the grant says, for the security audit: names only.
|
||||||
|
fn grant_words(g: &AndroidGrant) -> String {
|
||||||
|
format!("Android releases: {} pipeline {ANDROID_PIPELINE}, keys made on first use", g.repos.join(", "))
|
||||||
|
}
|
||||||
|
|
||||||
fn in_scope(list: &[String], what: &str) -> bool {
|
fn in_scope(list: &[String], what: &str) -> bool {
|
||||||
list.iter().any(|x| x == "*" || x == what)
|
list.iter().any(|x| x == "*" || x == what)
|
||||||
}
|
}
|
||||||
@@ -641,7 +793,7 @@ impl Vault {
|
|||||||
{
|
{
|
||||||
return Err(Error::Signing("a key id is 1 to 64 of a-z, 0-9 and -".into()));
|
return Err(Error::Signing("a key id is 1 to 64 of a-z, 0-9 and -".into()));
|
||||||
}
|
}
|
||||||
if self.signing.get(id).is_some() {
|
if self.signing.get(id).is_some() || id == crate::licence::LICENCE_KEY {
|
||||||
return Err(Error::Signing(format!("there is a key `{id}` already")));
|
return Err(Error::Signing(format!("there is a key `{id}` already")));
|
||||||
}
|
}
|
||||||
let name = spec.name.trim();
|
let name = spec.name.trim();
|
||||||
@@ -715,6 +867,9 @@ impl Vault {
|
|||||||
if k.kind == KeyKind::RootCa {
|
if k.kind == KeyKind::RootCa {
|
||||||
return Err(Error::Signing("a root CA signs no requests, so it has no scope".into()));
|
return Err(Error::Signing("a root CA signs no requests, so it has no scope".into()));
|
||||||
}
|
}
|
||||||
|
if k.id == crate::licence::LICENCE_KEY {
|
||||||
|
return Err(Error::Signing("the licence key signs Domi licences only, so it has no scope".into()));
|
||||||
|
}
|
||||||
k.pipelines = pipelines;
|
k.pipelines = pipelines;
|
||||||
k.repos = repos;
|
k.repos = repos;
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -742,6 +897,9 @@ impl Vault {
|
|||||||
/// The check, and the approval it read (for an approval request).
|
/// The check, and the approval it read (for an approval request).
|
||||||
fn check(&self, req: &Request, now: i64) -> Result<(KeyView, Option<custos_sign::Approval>), Refusal> {
|
fn check(&self, req: &Request, now: i64) -> Result<(KeyView, Option<custos_sign::Approval>), Refusal> {
|
||||||
let k = self.signing.get(&req.key).ok_or_else(|| Refusal::NoKey(req.key.clone()))?;
|
let k = self.signing.get(&req.key).ok_or_else(|| Refusal::NoKey(req.key.clone()))?;
|
||||||
|
if k.id == crate::licence::LICENCE_KEY {
|
||||||
|
return Err(Refusal::Invalid(format!("`{}` signs Domi licences only (licence.rs)", k.id)));
|
||||||
|
}
|
||||||
let approver = k.id == APPROVE_KEY && k.kind == KeyKind::Ed25519 && k.role == Role::Release;
|
let approver = k.id == APPROVE_KEY && k.kind == KeyKind::Ed25519 && k.role == Role::Release;
|
||||||
let fits = match (k.kind, req.kind) {
|
let fits = match (k.kind, req.kind) {
|
||||||
(KeyKind::Ed25519, SignKind::Minisign | SignKind::Manifest) => k.id != APPROVE_KEY,
|
(KeyKind::Ed25519, SignKind::Minisign | SignKind::Manifest) => k.id != APPROVE_KEY,
|
||||||
@@ -846,7 +1004,9 @@ impl Vault {
|
|||||||
return Err(r);
|
return Err(r);
|
||||||
}
|
}
|
||||||
let rule = self.standing_rule_for(req, now).map(|r| r.id);
|
let rule = self.standing_rule_for(req, now).map(|r| r.id);
|
||||||
if approval == Approval::Standing && rule.is_none() {
|
// A standing approval first; the Android grant only where none fits (core 0.19.0).
|
||||||
|
let by_grant = approval == Approval::Standing && rule.is_none() && self.android_grant_fits(req, now);
|
||||||
|
if approval == Approval::Standing && rule.is_none() && !by_grant {
|
||||||
let r = Refusal::NeedsApproval(req.key.clone());
|
let r = Refusal::NeedsApproval(req.key.clone());
|
||||||
self.signing_record(req, Outcome::Refused, Some(r.to_string()), None, now);
|
self.signing_record(req, Outcome::Refused, Some(r.to_string()), None, now);
|
||||||
return Err(r);
|
return Err(r);
|
||||||
@@ -902,6 +1062,10 @@ impl Vault {
|
|||||||
r.uses = r.uses.saturating_add(1);
|
r.uses = r.uses.saturating_add(1);
|
||||||
r.last_used = Some(now);
|
r.last_used = Some(now);
|
||||||
}
|
}
|
||||||
|
if by_grant && let Some(g) = self.signing.android.as_mut() {
|
||||||
|
g.uses = g.uses.saturating_add(1);
|
||||||
|
g.last_used = Some(now);
|
||||||
|
}
|
||||||
Ok(Signed { bytes, sha256 })
|
Ok(Signed { bytes, sha256 })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1091,6 +1255,131 @@ impl Vault {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The Android grant, if Mark gave it (core 0.19.0, docs/SIGNING.md "The Android grant").
|
||||||
|
pub fn android_grant(&self) -> Option<AndroidGrant> {
|
||||||
|
self.signing.android.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Stores the Android grant, or replaces its patterns and subject (its counts and the keys it made stay), and
|
||||||
|
/// writes `standing-granted`. Refused while *Sign only with a card* is ticked. Call it only from Mark's own
|
||||||
|
/// click. The caller saves.
|
||||||
|
pub fn android_grant_set(&mut self, repos: &[String], o: &str, c: &str, now: i64) -> Result<AndroidGrant, Error> {
|
||||||
|
if self.security.is_ticked(crate::security::Item::CardSigning) {
|
||||||
|
return Err(Error::Signing("Sign only with a card is ticked".into()));
|
||||||
|
}
|
||||||
|
let mut patterns: Vec<String> = Vec::new();
|
||||||
|
for p in repos.iter().map(|p| p.trim()).filter(|p| !p.is_empty()) {
|
||||||
|
if !grant_pattern_ok(p) {
|
||||||
|
return Err(Error::Signing(format!(
|
||||||
|
"`{p}` is not a repository (owner/name) or every repository of an owner (owner/*)"
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
if !patterns.iter().any(|x| x == p) {
|
||||||
|
patterns.push(p.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if patterns.is_empty() || patterns.len() > ANDROID_PATTERNS_MAX {
|
||||||
|
return Err(Error::Signing(format!("the grant names 1 to {ANDROID_PATTERNS_MAX} repositories")));
|
||||||
|
}
|
||||||
|
if !grant_subject_ok(o, c) {
|
||||||
|
return Err(Error::Signing(
|
||||||
|
"the certificates need an organisation (1-64 characters) and a two-letter country code".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
let old = self.signing.android.clone();
|
||||||
|
let grant = AndroidGrant {
|
||||||
|
repos: patterns,
|
||||||
|
o: o.into(),
|
||||||
|
c: c.into(),
|
||||||
|
granted: now,
|
||||||
|
last_used: old.as_ref().and_then(|g| g.last_used),
|
||||||
|
uses: old.as_ref().map_or(0, |g| g.uses),
|
||||||
|
made: old.map(|g| g.made).unwrap_or_default(),
|
||||||
|
};
|
||||||
|
self.security.standing_note(crate::security::Action::StandingGranted, &grant_words(&grant), now);
|
||||||
|
self.signing.android = Some(grant.clone());
|
||||||
|
Ok(grant)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Removes the Android grant (`standing-revoked`); the keys it made stay. False when there is none. The caller
|
||||||
|
/// saves.
|
||||||
|
pub fn android_grant_revoke(&mut self, now: i64) -> bool {
|
||||||
|
let Some(g) = self.signing.android.take() else { return false };
|
||||||
|
self.security.standing_note(crate::security::Action::StandingRevoked, &grant_words(&g), now);
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Whether `req` is signed by the Android grant: an `apk` from this PC's pipe with a run, in the key's scope, for
|
||||||
|
/// a repository the grant covers and pipeline `release`, by that repository's own app key (scoped to exactly it
|
||||||
|
/// and `release`, role release), while *Sign only with a card* is not ticked. A key's first signature fits.
|
||||||
|
pub fn android_grant_fits(&self, req: &Request, now: i64) -> bool {
|
||||||
|
let Some(g) = &self.signing.android else { return false };
|
||||||
|
let Ok((view, _)) = self.check(req, now) else { return false };
|
||||||
|
req.kind == SignKind::Apk
|
||||||
|
&& req.via == Via::Local
|
||||||
|
&& req.run.is_some()
|
||||||
|
&& !self.security.is_ticked(crate::security::Item::CardSigning)
|
||||||
|
&& view.kind == KeyKind::Android
|
||||||
|
&& view.role == Role::Release
|
||||||
|
&& req.context.pipeline == ANDROID_PIPELINE
|
||||||
|
&& grant_covers(g, &req.context.repo)
|
||||||
|
&& android_key_id(&req.context.repo).as_deref() == Some(req.key.as_str())
|
||||||
|
&& view.repos == [req.context.repo.clone()]
|
||||||
|
&& view.pipelines == [ANDROID_PIPELINE.to_string()]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Makes `repo`'s app key under the Android grant, when its first release asks (`custos-sign apk`): the grant
|
||||||
|
/// covers `repo`, `pipeline` is `release`, `via` is local, *Sign only with a card* is not ticked, and there is
|
||||||
|
/// no key under that id. RSA-4096, `CN=<Name>`, the grant's O and C, scoped to exactly `repo` and `release`.
|
||||||
|
/// Writes `standing-granted` with `Android grant made <id> for <repo> pipeline release`: a value every core since
|
||||||
|
/// 0.16.0 reads, so the phone and the web vault still open the vault (core 0.19.1). The caller saves. Slow: one
|
||||||
|
/// RSA-4096 key.
|
||||||
|
pub fn android_grant_make_key(&mut self, repo: &str, pipeline: &str, via: Via, now: i64) -> Result<String, Error> {
|
||||||
|
let no = |why: String| Err(Error::Signing(why));
|
||||||
|
let Some(g) = self.signing.android.clone() else { return no("there is no Android grant".into()) };
|
||||||
|
let (Some((_, name)), Some(id)) = (repo_parts(repo), android_key_id(repo)) else {
|
||||||
|
return no(format!("`{repo}` is not a repository (owner/name)"));
|
||||||
|
};
|
||||||
|
if via != Via::Local {
|
||||||
|
return no("the server runner never makes a key".into());
|
||||||
|
}
|
||||||
|
if pipeline != ANDROID_PIPELINE {
|
||||||
|
return no(format!("the Android grant makes keys for the pipeline `{ANDROID_PIPELINE}` only"));
|
||||||
|
}
|
||||||
|
if self.security.is_ticked(crate::security::Item::CardSigning) {
|
||||||
|
return no("Sign only with a card is ticked".into());
|
||||||
|
}
|
||||||
|
if !grant_covers(&g, repo) {
|
||||||
|
return no(format!("the Android grant does not cover `{repo}`"));
|
||||||
|
}
|
||||||
|
if self.signing.get(&id).is_some() {
|
||||||
|
return no(format!("there is a key `{id}` already"));
|
||||||
|
}
|
||||||
|
let mut cn = name.to_string();
|
||||||
|
if let Some(first) = cn.get_mut(0..1) {
|
||||||
|
first.make_ascii_uppercase();
|
||||||
|
}
|
||||||
|
let spec = AndroidKey {
|
||||||
|
id: id.clone(),
|
||||||
|
name: format!("{cn} Android"),
|
||||||
|
cn,
|
||||||
|
o: g.o.clone(),
|
||||||
|
c: g.c.clone(),
|
||||||
|
role: Role::Release,
|
||||||
|
pipelines: vec![ANDROID_PIPELINE.into()],
|
||||||
|
repos: vec![repo.into()],
|
||||||
|
};
|
||||||
|
self.signing_create_android(&spec, now)?;
|
||||||
|
if let Some(g) = self.signing.android.as_mut()
|
||||||
|
&& g.made.len() < ANDROID_MADE_MAX
|
||||||
|
{
|
||||||
|
g.made.push(id.clone());
|
||||||
|
}
|
||||||
|
let words = format!("Android grant made {id} for {repo} pipeline {ANDROID_PIPELINE}");
|
||||||
|
self.security.standing_note(crate::security::Action::StandingGranted, &words, now);
|
||||||
|
Ok(id)
|
||||||
|
}
|
||||||
|
|
||||||
/// Every request any key was named in, oldest first.
|
/// Every request any key was named in, oldest first.
|
||||||
pub fn signing_audit(&self) -> &[AuditEntry] {
|
pub fn signing_audit(&self) -> &[AuditEntry] {
|
||||||
&self.signing.audit
|
&self.signing.audit
|
||||||
|
|||||||
@@ -0,0 +1,266 @@
|
|||||||
|
//! The Android grant (core 0.19.0, docs/SIGNING.md "The Android grant"): one answer for every Domi app's release
|
||||||
|
//! APK. It signs a request for a repository's own app key (`<name>-android`, scoped to exactly that repository and
|
||||||
|
//! `release`) from this PC's pipe, its first signature included, and makes that key when the app's first release
|
||||||
|
//! asks. Everything else still needs a card.
|
||||||
|
|
||||||
|
use custos_vault::security::{Action, Auth, Item};
|
||||||
|
use custos_vault::signing::{
|
||||||
|
AndroidKey, Approval, Context, KeyKind, Outcome, Refusal, Request, Role, SignKind, Via, android_key_id,
|
||||||
|
};
|
||||||
|
use custos_vault::{KdfParams, SecretString, Vault};
|
||||||
|
|
||||||
|
const FAST: KdfParams = KdfParams { m_cost_kib: 64, t_cost: 1, p_cost: 1 };
|
||||||
|
const NOW: i64 = 1_793_750_000_000;
|
||||||
|
const COMMIT: &str = "6925d0cb08b9e0c5c3a4a7a2c37b7f2a9f7ed3b1";
|
||||||
|
|
||||||
|
fn s(v: &[&str]) -> Vec<String> {
|
||||||
|
v.iter().map(|x| x.to_string()).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn vault() -> Vault {
|
||||||
|
let mut v = Vault::create(&SecretString::from("pw"), FAST).unwrap();
|
||||||
|
v.signing_create(Role::Release, &s(&["release"]), &s(&["mnovak/Culina"]), NOW).unwrap();
|
||||||
|
v
|
||||||
|
}
|
||||||
|
|
||||||
|
fn granted(repos: &[&str]) -> Vault {
|
||||||
|
let mut v = vault();
|
||||||
|
v.android_grant_set(&s(repos), "Marek Novak", "CZ", NOW).unwrap();
|
||||||
|
v
|
||||||
|
}
|
||||||
|
|
||||||
|
fn apk(key: &str, repo: &str, pipeline: &str, run: Option<&str>) -> Request {
|
||||||
|
Request {
|
||||||
|
key: key.into(),
|
||||||
|
kind: SignKind::Apk,
|
||||||
|
digest: vec![5; 64],
|
||||||
|
manifest: None,
|
||||||
|
approval: None,
|
||||||
|
run: run.map(Into::into),
|
||||||
|
context: Context {
|
||||||
|
repo: repo.into(),
|
||||||
|
commit: COMMIT.into(),
|
||||||
|
pipeline: pipeline.into(),
|
||||||
|
step: "sign-apk".into(),
|
||||||
|
trigger: "tag".into(),
|
||||||
|
file: "Culina-1.2.0.apk".into(),
|
||||||
|
size: 9_400_000,
|
||||||
|
sha256: "c4995c6e2e0c20fec7e8dcb05d70144da58f42d379c6705df66edb42abafb8a3".into(),
|
||||||
|
version: "1.2.0".into(),
|
||||||
|
},
|
||||||
|
via: Via::Local,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn culina(run: &str) -> Request {
|
||||||
|
apk("culina-android", "mnovak/Culina", "release", Some(run))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn notes(v: &Vault, action: Action) -> Vec<String> {
|
||||||
|
v.security_view(NOW + 1_000)
|
||||||
|
.audit
|
||||||
|
.into_iter()
|
||||||
|
.filter(|e| e.action == action)
|
||||||
|
.map(|e| e.detail.unwrap_or_default())
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn an_app_key_is_named_by_its_repository() {
|
||||||
|
assert_eq!(android_key_id("mnovak/Culina").as_deref(), Some("culina-android"));
|
||||||
|
assert_eq!(android_key_id("mnovak/domi-office").as_deref(), Some("domi-office-android"));
|
||||||
|
assert_eq!(android_key_id("mnovak/Domi.Office_2").as_deref(), Some("domi-office-2-android"));
|
||||||
|
for bad in ["Culina", "mnovak/", "/Culina", "mnovak/*", "a/b/c", "mnovak/Cu lina", "mnovak/Čulina", ""] {
|
||||||
|
assert_eq!(android_key_id(bad), None, "{bad}");
|
||||||
|
}
|
||||||
|
assert_eq!(android_key_id(&format!("mnovak/{}", "x".repeat(57))), None, "the id would be longer than 64");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_grant_makes_an_apps_key_and_signs_its_first_apk_without_a_card() {
|
||||||
|
let mut v = granted(&["mnovak/*"]);
|
||||||
|
assert!(!v.android_grant_fits(&culina("r-1"), NOW + 1), "no key yet");
|
||||||
|
|
||||||
|
let id = v.android_grant_make_key("mnovak/Culina", "release", Via::Local, NOW + 1).unwrap();
|
||||||
|
assert_eq!(id, "culina-android");
|
||||||
|
let k = v.signing_keys().into_iter().find(|k| k.id == id).unwrap();
|
||||||
|
assert_eq!((k.kind, k.role, k.name.as_str()), (KeyKind::Android, Role::Release, "Culina Android"));
|
||||||
|
assert_eq!((k.pipelines.clone(), k.repos.clone()), (s(&["release"]), s(&["mnovak/Culina"])));
|
||||||
|
let cert = String::from_utf8_lossy(k.cert.as_ref().unwrap()).into_owned();
|
||||||
|
assert!(cert.contains("Culina") && cert.contains("Marek Novak"), "the certificate names the app and Mark");
|
||||||
|
|
||||||
|
// Its first signature: no card, recorded as `standing`, counted on the grant.
|
||||||
|
assert!(v.android_grant_fits(&culina("r-1"), NOW + 2));
|
||||||
|
assert!(v.standing_rule_for(&culina("r-1"), NOW + 2).is_none(), "the grant is not a per-key rule");
|
||||||
|
let signed = v.signing_sign(&culina("r-1"), Approval::Standing, NOW + 2);
|
||||||
|
assert!(signed.is_ok(), "{signed:?}");
|
||||||
|
assert_eq!(v.signing_audit().last().unwrap().outcome, Outcome::Standing);
|
||||||
|
assert_eq!(v.signing_audit().last().unwrap().context.file, "Culina-1.2.0.apk");
|
||||||
|
v.signing_sign(&culina("r-2"), Approval::Standing, NOW + 3).unwrap();
|
||||||
|
let g = v.android_grant().unwrap();
|
||||||
|
assert_eq!((g.uses, g.last_used, g.made.clone()), (2, Some(NOW + 3), s(&["culina-android"])));
|
||||||
|
|
||||||
|
// Granting, then the key it made: both `standing-granted`, a value cores since 0.16.0 read (core 0.19.1).
|
||||||
|
let granted_note = notes(&v, Action::StandingGranted);
|
||||||
|
assert_eq!(granted_note.len(), 2, "{granted_note:?}");
|
||||||
|
assert!(granted_note[0].contains("Android releases") && granted_note[0].contains("mnovak/*"), "{granted_note:?}");
|
||||||
|
assert_eq!(granted_note[1], "Android grant made culina-android for mnovak/Culina pipeline release");
|
||||||
|
// The public note call cannot write it.
|
||||||
|
assert!(v.security_note(Action::StandingGranted, "x", NOW).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_grant_never_makes_a_key_it_does_not_cover() {
|
||||||
|
let mut v = granted(&["mnovak/Culina", "mnovak/Liber"]);
|
||||||
|
for (repo, pipeline, via, why) in [
|
||||||
|
("mnovak/Postea", "release", Via::Local, "a repository no pattern matches"),
|
||||||
|
("someone/Culina", "release", Via::Local, "another owner"),
|
||||||
|
("mnovak/Culina", "ci", Via::Local, "another pipeline"),
|
||||||
|
("mnovak/Culina", "release", Via::Remote, "the server runner"),
|
||||||
|
("Culina", "release", Via::Local, "not owner/name"),
|
||||||
|
] {
|
||||||
|
assert!(v.android_grant_make_key(repo, pipeline, via, NOW + 1).is_err(), "{why}");
|
||||||
|
}
|
||||||
|
assert!(v.signing_keys().iter().all(|k| k.kind != KeyKind::Android), "nothing was made");
|
||||||
|
v.android_grant_make_key("mnovak/Liber", "release", Via::Local, NOW + 2).unwrap();
|
||||||
|
assert!(v.android_grant_make_key("mnovak/Liber", "release", Via::Local, NOW + 3).is_err(), "made once");
|
||||||
|
|
||||||
|
v.security_tick(Item::CardSigning, NOW + 4);
|
||||||
|
assert!(v.android_grant_make_key("mnovak/Culina", "release", Via::Local, NOW + 5).is_err(), "paused");
|
||||||
|
v.security_untick(Item::CardSigning, Auth::Hello, NOW + 6);
|
||||||
|
assert!(v.android_grant_revoke(NOW + 7));
|
||||||
|
assert!(v.android_grant_make_key("mnovak/Culina", "release", Via::Local, NOW + 8).is_err(), "no grant");
|
||||||
|
assert_eq!(v.android_grant().map(|g| g.made), None);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn only_the_repositorys_own_app_key_in_its_own_scope_from_this_pc_with_a_run_fits() {
|
||||||
|
let mut v = granted(&["mnovak/*"]);
|
||||||
|
v.android_grant_make_key("mnovak/Culina", "release", Via::Local, NOW).unwrap();
|
||||||
|
// A key of the right name with a wider scope, and one for the wrong repository, made by hand.
|
||||||
|
let wide = AndroidKey {
|
||||||
|
id: "liber-android".into(),
|
||||||
|
name: "Liber Android".into(),
|
||||||
|
cn: "Liber".into(),
|
||||||
|
o: "Marek Novak".into(),
|
||||||
|
c: "CZ".into(),
|
||||||
|
role: Role::Release,
|
||||||
|
pipelines: s(&["release"]),
|
||||||
|
repos: s(&["*"]),
|
||||||
|
};
|
||||||
|
v.signing_create_android(&wide, NOW).unwrap();
|
||||||
|
v.signing_create_android(
|
||||||
|
&AndroidKey { id: "other-android".into(), repos: s(&["mnovak/Rosea"]), ..wide.clone() },
|
||||||
|
NOW,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
v.signing_create_android(&AndroidKey { id: "domi-test-android".into(), role: Role::Test, ..wide.clone() }, NOW)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let mut remote = culina("r-1");
|
||||||
|
remote.via = Via::Remote;
|
||||||
|
let mut minisign = culina("r-1");
|
||||||
|
minisign.kind = SignKind::Minisign;
|
||||||
|
minisign.key = "domi-release".into();
|
||||||
|
minisign.digest = vec![7; 64];
|
||||||
|
for (req, why) in [
|
||||||
|
(remote, "the server runner"),
|
||||||
|
(apk("culina-android", "mnovak/Culina", "release", None), "no run"),
|
||||||
|
(apk("liber-android", "mnovak/Liber", "release", Some("r-1")), "a key with a wider scope"),
|
||||||
|
(apk("other-android", "mnovak/Rosea", "release", Some("r-1")), "not the repository's app key"),
|
||||||
|
(apk("domi-test-android", "mnovak/Liber", "release", Some("r-1")), "a test key"),
|
||||||
|
(minisign, "another kind"),
|
||||||
|
] {
|
||||||
|
assert!(!v.android_grant_fits(&req, NOW + 1), "{why}");
|
||||||
|
assert!(v.signing_sign(&req, Approval::Standing, NOW + 1).is_err(), "{why}: never signed without a card");
|
||||||
|
assert_ne!(v.signing_audit().last().unwrap().outcome, Outcome::Standing, "{why}");
|
||||||
|
}
|
||||||
|
assert_eq!(v.android_grant().unwrap().uses, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn an_explicit_list_covers_only_its_repositories_and_bad_patterns_are_refused() {
|
||||||
|
let mut v = granted(&["mnovak/Culina"]);
|
||||||
|
v.signing_create_android(
|
||||||
|
&AndroidKey {
|
||||||
|
id: "liber-android".into(),
|
||||||
|
name: "Liber Android".into(),
|
||||||
|
cn: "Liber".into(),
|
||||||
|
o: "Marek Novak".into(),
|
||||||
|
c: "CZ".into(),
|
||||||
|
role: Role::Release,
|
||||||
|
pipelines: s(&["release"]),
|
||||||
|
repos: s(&["mnovak/Liber"]),
|
||||||
|
},
|
||||||
|
NOW,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
let liber = apk("liber-android", "mnovak/Liber", "release", Some("r-1"));
|
||||||
|
assert!(!v.android_grant_fits(&liber, NOW + 1), "not in the list");
|
||||||
|
// Editing the list keeps the counts and covers the new repository; a key made by hand in that shape is covered.
|
||||||
|
v.android_grant_set(&s(&["mnovak/Culina", "mnovak/Liber", "mnovak/Liber"]), "Marek Novak", "CZ", NOW + 2).unwrap();
|
||||||
|
assert_eq!(v.android_grant().unwrap().repos, s(&["mnovak/Culina", "mnovak/Liber"]));
|
||||||
|
assert!(v.android_grant_fits(&liber, NOW + 3));
|
||||||
|
|
||||||
|
for bad in [&[][..], &["mnovak"], &["*/*"], &["*"], &["mnovak/*/x"], &["mn ovak/*"], &["mnovak/Cu*"]] {
|
||||||
|
assert!(v.android_grant_set(&s(bad), "Marek Novak", "CZ", NOW + 4).is_err(), "{bad:?}");
|
||||||
|
}
|
||||||
|
let many: Vec<String> = (0..65).map(|i| format!("mnovak/app{i}")).collect();
|
||||||
|
assert!(v.android_grant_set(&many, "Marek Novak", "CZ", NOW + 4).is_err(), "at most 64");
|
||||||
|
assert!(v.android_grant_set(&s(&["mnovak/*"]), "Marek Novak", "Czech", NOW + 4).is_err(), "a two-letter country");
|
||||||
|
assert!(v.android_grant_set(&s(&["mnovak/*"]), "", "CZ", NOW + 4).is_err(), "an organisation");
|
||||||
|
assert_eq!(
|
||||||
|
v.android_grant().unwrap().repos,
|
||||||
|
s(&["mnovak/Culina", "mnovak/Liber"]),
|
||||||
|
"a refused edit changes nothing"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn sign_only_with_a_card_pauses_the_grant_and_revoking_ends_it() {
|
||||||
|
let mut v = granted(&["mnovak/*"]);
|
||||||
|
v.android_grant_make_key("mnovak/Culina", "release", Via::Local, NOW).unwrap();
|
||||||
|
v.security_tick(Item::CardSigning, NOW + 1);
|
||||||
|
assert!(!v.android_grant_fits(&culina("r-1"), NOW + 2));
|
||||||
|
assert!(matches!(v.signing_sign(&culina("r-1"), Approval::Standing, NOW + 2), Err(Refusal::NeedsApproval(_))));
|
||||||
|
assert!(v.android_grant_set(&s(&["mnovak/*"]), "Marek Novak", "CZ", NOW + 2).is_err(), "no grant while ticked");
|
||||||
|
assert!(v.android_grant().is_some(), "kept, paused");
|
||||||
|
v.security_untick(Item::CardSigning, Auth::Hello, NOW + 3);
|
||||||
|
assert!(v.android_grant_fits(&culina("r-1"), NOW + 4));
|
||||||
|
|
||||||
|
assert!(v.android_grant_revoke(NOW + 5));
|
||||||
|
assert!(!v.android_grant_revoke(NOW + 6), "once");
|
||||||
|
assert!(!v.android_grant_fits(&culina("r-2"), NOW + 7));
|
||||||
|
assert!(matches!(v.signing_sign(&culina("r-2"), Approval::Standing, NOW + 7), Err(Refusal::NeedsApproval(_))));
|
||||||
|
// Mark still signs it on a card, and the key stays.
|
||||||
|
assert!(v.signing_sign(&culina("r-2"), Approval::Mark, NOW + 8).is_ok());
|
||||||
|
let revoked = notes(&v, Action::StandingRevoked);
|
||||||
|
assert_eq!(revoked.len(), 1);
|
||||||
|
assert!(revoked[0].contains("Android releases"), "{revoked:?}");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_standing_rule_for_the_same_request_is_used_first() {
|
||||||
|
let mut v = granted(&["mnovak/*"]);
|
||||||
|
v.android_grant_make_key("mnovak/Culina", "release", Via::Local, NOW).unwrap();
|
||||||
|
v.signing_sign(&culina("r-1"), Approval::Mark, NOW + 1).unwrap();
|
||||||
|
v.standing_grant(&culina("r-2"), NOW + 2).unwrap();
|
||||||
|
v.signing_sign(&culina("r-2"), Approval::Standing, NOW + 2).unwrap();
|
||||||
|
assert_eq!(v.standing_rules()[0].uses, 1);
|
||||||
|
assert_eq!(v.android_grant().unwrap().uses, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_grant_and_its_counts_survive_a_reopen() {
|
||||||
|
let mut v = granted(&["mnovak/*", "domi/*"]);
|
||||||
|
v.android_grant_make_key("mnovak/Culina", "release", Via::Local, NOW).unwrap();
|
||||||
|
v.signing_sign(&culina("r-1"), Approval::Standing, NOW + 1).unwrap();
|
||||||
|
|
||||||
|
let mut back = Vault::open(&v.to_bytes().unwrap(), &SecretString::from("pw")).unwrap();
|
||||||
|
assert_eq!(back.android_grant(), v.android_grant());
|
||||||
|
assert!(back.signing_sign(&culina("r-2"), Approval::Standing, NOW + 2).is_ok());
|
||||||
|
assert_eq!(back.android_grant().unwrap().uses, 2);
|
||||||
|
assert!(back.android_grant_revoke(NOW + 3));
|
||||||
|
let again = Vault::open(&back.to_bytes().unwrap(), &SecretString::from("pw")).unwrap();
|
||||||
|
assert_eq!(again.android_grant(), None);
|
||||||
|
}
|
||||||
+5
-2
@@ -149,7 +149,10 @@ of kind `android` and an audit entry of kind `apk` (docs/SIGNING.md); a vault th
|
|||||||
core before 0.14.0. Core 0.16.0 adds the `signing` audit outcome `standing` and the `security` actions
|
core before 0.14.0. Core 0.16.0 adds the `signing` audit outcome `standing` and the `security` actions
|
||||||
`standing-granted` and `standing-revoked` (docs/SIGNING.md, "Standing approvals"): a vault in which a standing
|
`standing-granted` and `standing-revoked` (docs/SIGNING.md, "Standing approvals"): a vault in which a standing
|
||||||
approval was ever granted does not open in a core before 0.16.0. The rules themselves (`signing.standing`) are a
|
approval was ever granted does not open in a core before 0.16.0. The rules themselves (`signing.standing`) are a
|
||||||
member older cores ignore and drop.
|
member older cores ignore and drop. Core 0.19.0 adds the member `signing.android` (the Android grant, docs/SIGNING.md "The Android
|
||||||
|
grant"), which older cores ignore and drop (the grant is lost, never widened). It adds no closed-list value:
|
||||||
|
a key the grant makes is `standing-granted` in the security audit (core 0.19.1), so a vault with the grant still
|
||||||
|
opens in every core since 0.16.0, as the phone app and the web vault may be.
|
||||||
|
|
||||||
### The provision audit (core 0.11.0)
|
### The provision audit (core 0.11.0)
|
||||||
|
|
||||||
@@ -213,7 +216,7 @@ an outcome; a code the server then refuses (its exit 10) is not seen by Custos,
|
|||||||
| `finished` | optional: when that window ended, by *Finish setup*, or `until` once its expiry was noticed |
|
| `finished` | optional: when that window ended, by *Finish setup*, or `until` once its expiry was noticed |
|
||||||
| `ticked` | the checklist items that are ticked: `totp-on-phone`, `hello-approvals`, `narrow-scope`, `rotate-setup`, `no-ssh`, `phone-approves`, and (core 0.13.0) `no-auto-connect`, `no-unattended`, `card-signing` |
|
| `ticked` | the checklist items that are ticked: `totp-on-phone`, `hello-approvals`, `narrow-scope`, `rotate-setup`, `no-ssh`, `phone-approves`, and (core 0.13.0) `no-auto-connect`, `no-unattended`, `card-signing` |
|
||||||
| `keptScope` | optional: the server scope prefixes *Narrow the server scope* replaced (`ask`, `offer`: at most 64 each, 1–200 characters, no control characters), kept for its undo |
|
| `keptScope` | optional: the server scope prefixes *Narrow the server scope* replaced (`ask`, `offer`: at most 64 each, 1–200 characters, no control characters), kept for its undo |
|
||||||
| `audit` | `{at, action, item?, auth?, detail?}`; `action` is `setup-started`, `setup-finished`, `setup-expired`, `ticked`, `unticked`, `ssh-connected`, `totp-moved`, or (core 0.13.0) `auto-connected`, `unattended-stored`, `setup-item-removed`, `unattended-signed`, `taken-over`, or (core 0.16.0) `standing-granted`, `standing-revoked`, or (core 0.17.0) `recovery-created`, `recovery-removed`, `recovered` (docs/FACTORS.md, "The recovery key"; their `detail` is the key's id); `item` a checklist item (with `ticked`, `unticked`); `auth` is `hello` or `password` (with `unticked`); `detail` (core 0.13.0, the four notes; core 0.16.0, the two standing actions) names what happened, never a value: 1–500 characters, no control characters |
|
| `audit` | `{at, action, item?, auth?, detail?}`; `action` is `setup-started`, `setup-finished`, `setup-expired`, `ticked`, `unticked`, `ssh-connected`, `totp-moved`, or (core 0.13.0) `auto-connected`, `unattended-stored`, `setup-item-removed`, `unattended-signed`, `taken-over`, or (core 0.16.0) `standing-granted`, `standing-revoked` (also for the Android grant and the keys it makes), or (core 0.17.0) `recovery-created`, `recovery-removed`, `recovered` (docs/FACTORS.md, "The recovery key"; their `detail` is the key's id); `item` a checklist item (with `ticked`, `unticked`); `auth` is `hello` or `password` (with `unticked`); `detail` (core 0.13.0, the four notes; core 0.16.0, the two standing actions) names what happened, never a value: 1–500 characters, no control characters |
|
||||||
|
|
||||||
The **level** is computed, never stored:
|
The **level** is computed, never stored:
|
||||||
|
|
||||||
|
|||||||
+138
-1
@@ -1,4 +1,4 @@
|
|||||||
# Signing keys (core 0.9.0; deploy approvals 0.12.0; Android APKs 0.14.0; standing approvals 0.16.0; teams 0.18.0)
|
# Signing keys (core 0.9.0; deploy approvals 0.12.0; Android APKs 0.14.0; standing approvals 0.16.0; teams 0.18.0; the Android grant 0.19.0)
|
||||||
|
|
||||||
Custos signs releases for Fabrica Domi · Artifex without a private key ever leaving the vault. A build asks for a
|
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
|
signature over a **digest**; Custos checks who may ask, Mark approves with a match code, and the vault signs and
|
||||||
@@ -249,6 +249,130 @@ Never covered by a rule, by construction: another repository, key, kind, pipelin
|
|||||||
key's scope; a request without a run; a key's first signature; a deploy to a target the rule was not granted for;
|
key's scope; a request without a run; a key's first signature; a deploy to a target the rule was not granted for;
|
||||||
a release signature the server runner asks for; creating a key.
|
a release signature the server runner asks for; creating a key.
|
||||||
|
|
||||||
|
## The Android grant (core 0.19.0)
|
||||||
|
|
||||||
|
A standing approval is one repository's one key, and never a key's first signature. Mark has a dozen Domi apps, each
|
||||||
|
with its own Android key (`<app>-android`), each new: that is a card to make the key's first signature and another to
|
||||||
|
store the rule, per app. **The Android grant** is one answer for all of them: "sign my apps' release APKs, and make
|
||||||
|
each app's key when its first release asks". One grant per vault, in `signing.android`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"android": { "repos": ["mnovak/*"], "o": "Marek Novak", "c": "CZ", "granted": 1794000000000,
|
||||||
|
"lastUsed": 1794100000000, "uses": 3, "made": ["culina-android"] }
|
||||||
|
```
|
||||||
|
|
||||||
|
- `repos`: 1 to 64 patterns, each `owner/name` or `owner/*` (every repository of that owner, never another
|
||||||
|
owner's); owner and name are 1 to 64 of `A-Z a-z 0-9 . _ -`.
|
||||||
|
- `o`, `c`: the certificate subject's organisation and country for the keys it makes.
|
||||||
|
- `uses`, `lastUsed`: as on a standing approval. `made`: the ids of the keys it made, oldest first (at most 256).
|
||||||
|
|
||||||
|
**An app's key** is named by its repository: `android_key_id("mnovak/Culina")` is `culina-android` (the name in
|
||||||
|
lower case, `.` and `_` as `-`). The grant only ever deals in that key, and only when its scope is exactly that
|
||||||
|
repository and the pipeline `release`, with the role `release`: a key with a wider scope (or `*`) is never the
|
||||||
|
grant's, and a key the grant did not make but that has this shape (`postea-android`) is covered too.
|
||||||
|
|
||||||
|
**A request fits the grant** (`android_grant_fits`) when all of these hold:
|
||||||
|
|
||||||
|
- `signing_check` passes (scope as always: the grant never widens a key's scope);
|
||||||
|
- the kind is `apk` and `via` is `local`: an APK the server runner asks for never fits;
|
||||||
|
- the request names a run;
|
||||||
|
- the pipeline is `release` and the repository matches one of the patterns;
|
||||||
|
- the key is that repository's app key, as above;
|
||||||
|
- `card-signing` (*Sign only with a card*) is not ticked.
|
||||||
|
|
||||||
|
A key's first signature fits too: that is the point of the grant. `signing_sign(req, Approval::Standing, now)` signs
|
||||||
|
a request that fits a standing approval or the grant (a standing approval first), records the outcome `standing`,
|
||||||
|
and counts the use on whichever fitted.
|
||||||
|
|
||||||
|
**Making a key** (`android_grant_make_key(repo, pipeline, via, now)`): the grant covers the repository, the
|
||||||
|
pipeline is `release`, `via` is `local`, `card-signing` is not ticked, and the vault has no key under that id. It
|
||||||
|
makes the RSA-4096 key with the certificate `CN=<Name>` (the repository's name, first letter upper case), `O` and `C`
|
||||||
|
from the grant, named `<Name> Android`, scoped to exactly that repository and `release`, adds the id to `made`, and
|
||||||
|
writes `standing-granted` to the security audit (`Android grant made <id> for <repo> pipeline release`). Core 0.19.0
|
||||||
|
wrote a new action, `android-key-made`, which older cores refuse; 0.19.1 keeps to the values every core since 0.16.0
|
||||||
|
reads, because the phone app and the web vault open the same vault. It is a key like any other: not exportable,
|
||||||
|
removed only as any key is.
|
||||||
|
|
||||||
|
**Granting** (`android_grant_set(repos, o, c, now)`) stores or replaces the grant (the counts and `made` stay) and
|
||||||
|
writes `standing-granted` with `Android releases: <patterns> pipeline release, keys made on first use`. It is
|
||||||
|
refused while `card-signing` is ticked. `android_grant_revoke` removes it (`standing-revoked`). Neither asks
|
||||||
|
anyone: the app calls them only from Mark's own click.
|
||||||
|
|
||||||
|
Never covered by the grant: another kind, the server runner, a pipeline other than `release`, a repository no pattern
|
||||||
|
matches, a key that is not the repository's app key, a request without a run, anything while *Sign only with a card*
|
||||||
|
is ticked.
|
||||||
|
|
||||||
|
## Domi licences (core 0.21.0)
|
||||||
|
|
||||||
|
A Domi licence is a small text file the Atrium Domi service checks before it unlocks a paid app. Its byte format,
|
||||||
|
the paste code, the revocation list and the service's own checks are Fundamentum's `docs/LICENCE.md` (licence v1);
|
||||||
|
this core is the one that **signs**, and it parses what it signs exactly as that spec's strict parser does. The code
|
||||||
|
is `crates/custos-vault/src/licence.rs`.
|
||||||
|
|
||||||
|
### The key
|
||||||
|
|
||||||
|
- One key per vault, **`domi-licence`**: Ed25519, made in the vault by Mark's click (`licence_key_create`), never
|
||||||
|
exported. Only its 32-byte public key leaves (`licence_public`); the service ships it.
|
||||||
|
- It is stored as an ordinary Ed25519 entry (release, **no scope**, no minisign key id), so every core reads the vault
|
||||||
|
as before. An empty scope is never in scope, so no older core can sign with it either.
|
||||||
|
- It signs **only** the two payload kinds below, as a plain Ed25519 signature over the exact payload bytes (no
|
||||||
|
prehash, no digest; `custos_sign::ed25519_plain`). `signing_check` refuses it for every other kind, its scope
|
||||||
|
cannot be set, no Android key can take its id, and no other key signs these payloads.
|
||||||
|
|
||||||
|
### What it signs
|
||||||
|
|
||||||
|
| Payload | Starts with | Cap (bytes) | Parser |
|
||||||
|
| :-- | :-- | :-- | :-- |
|
||||||
|
| a licence | `domi-licence-v1
|
||||||
|
` | 4004 | LICENCE.md §2.4 steps 1–4 and 7 |
|
||||||
|
| a revocation list | `domi-revocations-v1
|
||||||
|
` | 61 348 | LICENCE.md §4.1 |
|
||||||
|
|
||||||
|
The caps are the spec's file caps (4096 and 61 440) less the `sig:` line (92 bytes), so every file signed here also
|
||||||
|
passes the service's size check. A malformed payload is refused with the spec's error code (§8: `too_large`,
|
||||||
|
`crlf`, `bad_byte`, `bad_prefix`, `truncated`, `bad_line`, `unknown_field`, `duplicate_field`, `field_order`,
|
||||||
|
`missing_field`, `bad_id`, `bad_issued`, `bad_nickname`, `bad_bundle`, `bad_scope`, `bad_seats`,
|
||||||
|
`seats_with_household`, `seats_missing`, `bad_apps`, `apps_unsorted`, `apps_duplicate`, `too_many_apps`,
|
||||||
|
`bad_seq`, `revoked_unsorted`, `revoked_duplicate`) and **never reaches a card**. A payload never contains a `sig:`
|
||||||
|
line: one is an `unknown_field`.
|
||||||
|
|
||||||
|
### The licence grant
|
||||||
|
|
||||||
|
One grant per vault, in `signing.licence.grant`, given by Mark's click (`licence_grant_set`, `standing-granted`) and
|
||||||
|
removed the same way (`licence_grant_revoke`, `standing-revoked`):
|
||||||
|
|
||||||
|
```json
|
||||||
|
"licence": { "grant": { "allow": ["calenda", "fiscus", "medicus", "tabula"], "granted": 1795896907000,
|
||||||
|
"lastUsed": 1795896990000, "uses": 4 },
|
||||||
|
"log": [ { "at": 1795896990000, "by": "grant", "licence": "k3Jx0Qm1T9yZpW2bA7cD4e",
|
||||||
|
"apps": ["calenda", "tabula"] },
|
||||||
|
{ "at": 1795897000000, "by": "card", "seq": 7, "revoked": 3 } ] }
|
||||||
|
```
|
||||||
|
|
||||||
|
`licence_ask(payload, caller, now)` decides, and changes nothing:
|
||||||
|
|
||||||
|
| | Result |
|
||||||
|
| :-- | :-- |
|
||||||
|
| malformed | refused, the spec's code |
|
||||||
|
| no `domi-licence` key | refused, `no_key` |
|
||||||
|
| a caller whose Canalis app id is not `licence-issue` | refused, `not_allowed` |
|
||||||
|
| the log holds 20 000 signatures | refused, `log_full` (it never forgets what replay and rollback need) |
|
||||||
|
| a licence whose `issued` is more than 24 h from this clock, either way | refused, `clock` |
|
||||||
|
| a licence id this key signed before | refused, `replay` |
|
||||||
|
| a revocation list whose `seq` is not higher than every `seq` this key signed | refused, `rollback` |
|
||||||
|
| a revocation list | **a card, always** |
|
||||||
|
| a licence, and any of: no grant; a caller program not signed with Domi's certificate; *Sign only with a card* ticked; an app not on `allow`; 50 licences signed in the last 24 h | a card, with each reason |
|
||||||
|
| a licence and none of those | signed by the grant, no card |
|
||||||
|
|
||||||
|
`licence_sign(payload, caller, by, now)` checks again, refuses `needs_card` when `by` is `grant` and the grant does
|
||||||
|
not cover it, signs, returns the signature in base64url without padding (86 characters), logs it (when, how, the
|
||||||
|
licence id and its apps, or the list's `seq` and how many ids it revokes: never the signature, the payload or the
|
||||||
|
nickname) and counts the grant's use.
|
||||||
|
|
||||||
|
Cores before 0.21.0 ignore `signing.licence` and drop it if they save the vault: the grant is then gone, so every
|
||||||
|
licence asks again, and the key stays. Replay and rollback are then only as good as what is left; the service keeps
|
||||||
|
its own anti-rollback check (LICENCE.md §4.2), which a restored or rewritten vault cannot get past.
|
||||||
|
|
||||||
## The audit log
|
## 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
|
`audit` is append-only: there is no function that edits or removes an entry. Every request a key is named in gets
|
||||||
@@ -302,6 +426,19 @@ Vault::standing_grant(&request, now) -> StandingRule //
|
|||||||
Vault::standing_rule_for(&request, now) -> Option<StandingRule>
|
Vault::standing_rule_for(&request, now) -> Option<StandingRule>
|
||||||
Vault::standing_rules() -> [StandingRule]
|
Vault::standing_rules() -> [StandingRule]
|
||||||
Vault::standing_revoke(id, now) -> bool
|
Vault::standing_revoke(id, now) -> bool
|
||||||
|
android_key_id(repo) -> Option<String> (core 0.19.0)
|
||||||
|
Vault::android_grant() -> Option<AndroidGrant>
|
||||||
|
Vault::android_grant_set(repos, o, c, now) -> Result<AndroidGrant, Error>
|
||||||
|
Vault::android_grant_revoke(now) -> bool
|
||||||
|
Vault::android_grant_fits(req, now) -> bool
|
||||||
|
Vault::android_grant_make_key(repo, pipeline, via, now) -> Result<String, Error>
|
||||||
|
licence::parse_payload(bytes) -> Payload | LicenceRefusal (core 0.21.0)
|
||||||
|
Vault::licence_key_create(now) -> [u8; 32] // the public key, never the secret
|
||||||
|
Vault::licence_public() -> Option<[u8; 32]>
|
||||||
|
Vault::licence_grant() / licence_grant_set(allow, now) / licence_grant_revoke(now)
|
||||||
|
Vault::licence_ask(payload, Caller { app, domi_signed }, now) -> LicenceAsk { payload, card: [CardReason] }
|
||||||
|
Vault::licence_sign(payload, caller, LicenceBy::{Grant, Card}, now) -> base64url signature
|
||||||
|
Vault::licence_log() -> [LicenceEntry]
|
||||||
```
|
```
|
||||||
|
|
||||||
No function returns a `secret`. The views and the audit entries print and serialise without one; there is a test.
|
No function returns a `secret`. The views and the audit entries print and serialise without one; there is a test.
|
||||||
|
|||||||
Reference in New Issue
Block a user