diff --git a/Cargo.lock b/Cargo.lock index 73ecfbfd..4508742f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4006,13 +4006,19 @@ name = "ledger-cli" version = "0.1.0" dependencies = [ "base64 0.22.1", + "bytes", "chrono", + "futures", + "http-body-util", + "hyper", + "hyper-util", "jsonschema", "ledger-config", "ledger-core", "ledger-gui", "ledger-host", "ledger-import", + "ledger-link", "ledger-mcp", "ledger-package", "ledger-store", @@ -4020,14 +4026,20 @@ dependencies = [ "libc", "minisign", "proptest", + "rcgen", + "relay", "reqwest", "rmcp", "rusqlite", "rust_decimal", + "rustls", "serde_json", "sha2 0.10.9", "tempfile", + "time", "tokio", + "tokio-rustls", + "zeroize", "zip", ] @@ -4085,6 +4097,7 @@ dependencies = [ "ledger-config", "ledger-core", "ledger-import", + "ledger-link", "ledger-package", "ledger-store", "ledger-vault", @@ -4105,6 +4118,7 @@ version = "0.1.0" dependencies = [ "base64 0.22.1", "ledger-core", + "ledger-link", "ledger-mcp", "ledger-store", "libc", diff --git a/THIRD-PARTY-NOTICES.txt b/THIRD-PARTY-NOTICES.txt index 05616714..20f44d12 100644 --- a/THIRD-PARTY-NOTICES.txt +++ b/THIRD-PARTY-NOTICES.txt @@ -23,6 +23,287 @@ Permission to use, copy, modify, and/or distribute this software for any purpose THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +================================================================================ +Apache License 2.0 +================================================================================ + +Used by: + ring 0.17.14 + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +Licenses for support code +------------------------- + +Parts of the TLS test suite are under the Go license. This code is not included +in BoringSSL (i.e. libcrypto and libssl) when compiled, however, so +distributing code linked against BoringSSL does not trigger this license: + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +BoringSSL uses the Chromium test infrastructure to run a continuous build, +trybots etc. The scripts which manage this, and the script for generating build +metadata, are under the Chromium license. Distributing code linked against +BoringSSL does not trigger this license. + +Copyright 2015 The Chromium Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + ================================================================================ Apache License 2.0 ================================================================================ @@ -874,6 +1155,7 @@ Used by: ciborium-ll 0.2.2 ciborium 0.2.2 codespan-reporting 0.13.1 + instant-acme 0.8.5 self_cell 1.3.0 Apache License @@ -1505,6 +1787,7 @@ Apache License 2.0 Used by: gethostname 1.1.0 + ring 0.17.14 Apache License Version 2.0, January 2004 @@ -3068,6 +3351,160 @@ For these and/or other purposes and motivations, and without any expectation of d. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work. +================================================================================ +Community Data License Agreement Permissive 2.0 +================================================================================ + +Used by: + webpki-root-certs 1.0.11 + +# Community Data License Agreement - Permissive - Version 2.0 + +This is the Community Data License Agreement - Permissive, Version +2.0 (the "agreement"). Data Provider(s) and Data Recipient(s) agree +as follows: + +## 1. Provision of the Data + +1.1. A Data Recipient may use, modify, and share the Data made +available by Data Provider(s) under this agreement if that Data +Recipient follows the terms of this agreement. + +1.2. This agreement does not impose any restriction on a Data +Recipient's use, modification, or sharing of any portions of the +Data that are in the public domain or that may be used, modified, +or shared under any other legal exception or limitation. + +## 2. Conditions for Sharing Data + +2.1. A Data Recipient may share Data, with or without modifications, so +long as the Data Recipient makes available the text of this agreement +with the shared Data. + +## 3. No Restrictions on Results + +3.1. This agreement does not impose any restriction or obligations +with respect to the use, modification, or sharing of Results. + +## 4. No Warranty; Limitation of Liability + +4.1. All Data Recipients receive the Data subject to the following +terms: + +THE DATA IS PROVIDED ON AN "AS IS" BASIS, WITHOUT REPRESENTATIONS, +WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED +INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, +NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +NO DATA PROVIDER SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING +WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE DATA OR RESULTS, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +## 5. Definitions + +5.1. "Data" means the material received by a Data Recipient under +this agreement. + +5.2. "Data Provider" means any person who is the source of Data +provided under this agreement and in reliance on a Data Recipient's +agreement to its terms. + +5.3. "Data Recipient" means any person who receives Data directly +or indirectly from a Data Provider and agrees to the terms of this +agreement. + +5.4. "Results" means any outcome obtained by computational analysis +of Data, including for example machine learning models and models' +insights. + + +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +/* Copyright (c) 2014, Intel Corporation. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#ifndef OPENSSL_HEADER_EC_ECP_NISTZ384_H +#define OPENSSL_HEADER_EC_ECP_NISTZ384_H + +#include "../../limbs/limbs.h" + +#define P384_LIMBS (384u / LIMB_BITS) + +typedef struct { + Limb X[P384_LIMBS]; + Limb Y[P384_LIMBS]; + Limb Z[P384_LIMBS]; +} P384_POINT; + +typedef struct { + Limb X[P384_LIMBS]; + Limb Y[P384_LIMBS]; +} P384_POINT_AFFINE; + + +#endif // OPENSSL_HEADER_EC_ECP_NISTZ384_H + + +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! EdDSA Signatures. + +use super::ops::ELEM_LEN; +use crate::digest; + +pub mod signing; +pub mod verification; + +/// The length of an Ed25519 public key. +pub const ED25519_PUBLIC_KEY_LEN: usize = ELEM_LEN; + +pub fn eddsa_digest(signature_r: &[u8], public_key: &[u8], msg: &[u8]) -> digest::Digest { + let mut ctx = digest::Context::new(&digest::SHA512); + ctx.update(signature_r); + ctx.update(public_key); + ctx.update(msg); + ctx.finish() +} + + ================================================================================ ISC License ================================================================================ @@ -3090,6 +3527,622 @@ Used by: // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +// Copyright 2015-2022 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::limb::Limb; + +#[derive(Clone, Copy)] +#[repr(transparent)] +pub struct N0([Limb; 2]); + +impl N0 { + #[cfg(feature = "alloc")] + pub(super) const LIMBS_USED: usize = 64 / crate::limb::LIMB_BITS; + + #[inline] + pub const fn precalculated(n0: u64) -> Self { + #[cfg(target_pointer_width = "64")] + { + Self([n0, 0]) + } + + #[cfg(target_pointer_width = "32")] + { + Self([n0 as Limb, (n0 >> crate::limb::LIMB_BITS) as Limb]) + } + } +} + + +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +// Copyright 2015-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#[cfg(target_pointer_width = "64")] +type CompilerWord = u64; + +#[cfg(target_pointer_width = "32")] +type CompilerWord = u32; + +/// A native word that isn't secret. +/// +/// `LeakyWord` supports `as` conversions to/from native types. +/// +/// XXX: This isn't the native word size on targets where a pointer isn't the +/// same size as a native word. TODO: Fix this. +pub(crate) type LeakyWord = CompilerWord; + + +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +// Copyright 2015-2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::{bb, error}; + +#[deprecated( + note = "To be removed. Internal function not intended for external use with no promises regarding side channels." +)] +pub fn verify_slices_are_equal(a: &[u8], b: &[u8]) -> Result<(), error::Unspecified> { + bb::verify_slices_are_equal(a, b) +} + + +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +// Copyright 2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Elliptic curve operations and schemes using Curve25519. + +pub mod ed25519; + +pub mod x25519; + +mod ops; +mod scalar; + + +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +// Copyright 2016-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::error::{KeyRejected, Unspecified}; + +impl From for Unspecified { + fn from(source: untrusted::EndOfInput) -> Self { + super::erase(source) + } +} + +impl From for Unspecified { + fn from(source: core::array::TryFromSliceError) -> Self { + super::erase(source) + } +} + +impl From for Unspecified { + fn from(source: KeyRejected) -> Self { + super::erase(source) + } +} + + +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +// Copyright 2018 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#[cfg(target_arch = "x86")] +pub fn shift_full_blocks( + in_out: super::overlapping::Overlapping<'_, u8>, + mut transform: impl FnMut(&[u8; BLOCK_LEN]) -> [u8; BLOCK_LEN], +) { + let (in_out, src) = in_out.into_slice_src_mut(); + let in_out_len = in_out[src.clone()].len(); + + for i in (0..in_out_len).step_by(BLOCK_LEN) { + let block = { + let input = + <&[u8; BLOCK_LEN]>::try_from(&in_out[(src.start + i)..][..BLOCK_LEN]).unwrap(); + transform(input) + }; + let output = <&mut [u8; BLOCK_LEN]>::try_from(&mut in_out[i..][..BLOCK_LEN]).unwrap(); + *output = block; + } +} + + +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +// Copyright 2018 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Serialization and deserialization. + +#[doc(hidden)] +pub mod der; + +#[cfg(feature = "alloc")] +mod writer; + +#[cfg(feature = "alloc")] +pub(crate) mod der_writer; + +pub(crate) mod positive; + +pub use self::positive::Positive; + +#[cfg(feature = "alloc")] +pub(crate) use self::writer::TooLongError; + + +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +// Copyright 2019-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::BlockLen; + +pub(super) use self::{ + sha2_32::{block_data_order_32, State32, SHA256_BLOCK_LEN}, + sha2_64::{block_data_order_64, State64, SHA512_BLOCK_LEN}, +}; + +pub(super) const CHAINING_WORDS: usize = 8; + +#[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86_64" +))] +#[macro_use] +mod ffi; + +pub(super) mod fallback; +mod sha2_32; +mod sha2_64; + + +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +// Copyright 2022 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +/// Polyfill for `Option::unwrap()` as a const fn; feature `const_option`. +/// https://github.com/rust-lang/rust/issues/67441. +/// TODO(MSRV): Replace this with `x.unwrap()`. +/// +/// `T: Copy` avoids "constant functions cannot evaluate destructors." +pub const fn unwrap_const(x: Option) -> T +where + T: Copy, +{ + if let Some(x) = x { + x + } else { + panic!("unwrap_const on `None`"); + } +} + + +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// TODO(MSRV 1.76): Replace with `core::ptr::from_mut`. +#[allow(dead_code)] +#[inline(always)] +pub fn from_mut(r: &mut T) -> *mut T { + r +} + +// TODO(MSRV 1.76): Replace with `core::ptr::from_ref`. +#[allow(dead_code)] +#[inline(always)] +pub const fn from_ref(r: &T) -> *const T { + r +} + + +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Integration tests for non-public APIs. + +mod bits_tests; + + +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Utilities to make dealing with slices less tediuous. + +/// Replaces the first N elements of `a` with the first N elements of `b`, where +/// N is `core::cmp::min(a.len(), b.len())`, leaving the rest unchanged. +pub fn overwrite_at_start(a: &mut [T], b: &[T]) { + a.iter_mut().zip(b).for_each(|(a, b)| { + *a = *b; + }); +} + + +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +pub use self::{ + array::Array, + base::{IndexError, Overlapping}, + partial_block::PartialBlock, +}; + +mod array; +mod base; +mod partial_block; + + +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::testutil; +use core::{marker::PhantomData, mem::size_of}; + +/// A ZST that can be added to any type to make the type `!Send`. +#[derive(Clone, Copy)] +pub struct NotSend(PhantomData<*mut ()>); + +impl NotSend { + pub const VALUE: Self = Self(PhantomData); +} + +#[allow(deprecated)] +const _: () = testutil::compile_time_assert_clone::(); +#[allow(deprecated)] +const _: () = testutil::compile_time_assert_copy::(); +const _: () = assert!(size_of::() == 0); + + +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +// Copyright 2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![cfg(all(target_arch = "aarch64", target_endian = "little"))] + +pub(in super::super) mod mont; + + +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +// Copyright 2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![cfg(target_arch = "x86_64")] + +pub(in super::super::super) mod mont; + + +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +// Copyright 2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +mod storage; + +pub(super) use self::storage::{AlignedStorage, LIMBS_PER_CHUNK}; + + +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +// Copyright 2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +pub(super) mod aarch64; +pub(super) mod x86_64; + + ================================================================================ ISC License ================================================================================ @@ -3133,6 +4186,28 @@ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +================================================================================ +ISC License +================================================================================ + +Used by: + ring 0.17.14 + +Copyright 2015-2025 Brian Smith. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + ================================================================================ ISC License ================================================================================ @@ -3888,6 +4963,35 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +================================================================================ +MIT License +================================================================================ + +Used by: + nom 7.1.3 + +Copyright (c) 2014-2019 Geoffroy Couprie + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + ================================================================================ MIT License ================================================================================ @@ -4174,6 +5278,35 @@ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +================================================================================ +MIT License +================================================================================ + +Used by: + hickory-proto 0.26.3 + +Copyright (c) 2015 The Hickory DNS Developers +Copyright (c) 2017 Google LLC. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + ================================================================================ MIT License ================================================================================ @@ -4654,6 +5787,22 @@ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +================================================================================ +MIT License +================================================================================ + +Used by: + yasna 0.6.0 + +Copyright (c) 2016 Masaki Hara + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + ================================================================================ MIT License ================================================================================ @@ -5115,6 +6264,45 @@ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +================================================================================ +MIT License +================================================================================ + +Used by: + asn1-rs-derive 0.6.0 + asn1-rs 0.7.2 + der-parser 10.0.0 + oid-registry 0.8.1 + rusticata-macros 4.1.0 + x509-parser 0.18.1 + +Copyright (c) 2017 Pierre Chifflier + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + + ================================================================================ MIT License ================================================================================ @@ -7116,6 +8304,40 @@ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +================================================================================ +MIT License +================================================================================ + +Used by: + critical-section 1.2.0 + +Copyright (c) 2022 The critical-section authors + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + + ================================================================================ MIT License ================================================================================ @@ -7890,6 +9112,7 @@ MIT License ================================================================================ Used by: + synstructure 0.13.2 synstructure 0.14.0 Copyright 2016 Nika Layzell @@ -9200,6 +10423,7 @@ MIT License Used by: accesskit 0.24.1 + asn1-rs-impl 0.2.0 block2 0.5.1 block2 0.6.2 brotli-decompressor 5.0.3 @@ -9234,6 +10458,7 @@ Used by: objc2 0.6.5 palette_math 0.7.7 profiling 1.0.18 + rcgen 0.14.10 rust_xlsxwriter 0.102.0 type-map 0.5.1 wasmi 1.1.0 @@ -9263,6 +10488,7 @@ Used by: windows_x86_64_gnu 0.53.1 windows_x86_64_msvc 0.52.6 windows_x86_64_msvc 0.53.1 + yamux 0.14.1 MIT License @@ -9771,12 +10997,16 @@ Used by: home 0.5.12 itoa 1.0.18 khronos-egl 6.0.0 + lazy_static 1.5.1 linux-raw-sys 0.12.1 linux-raw-sys 0.4.15 + minimal-lexical 0.2.1 once_cell 1.21.4 paste 1.0.15 pastey 0.2.3 + pin-project-internal 1.1.13 pin-project-lite 0.2.17 + pin-project 1.1.13 piper 0.2.5 polling 3.11.0 portable-atomic 1.15.0 @@ -10502,6 +11732,37 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +================================================================================ +MIT License +================================================================================ + +Used by: + data-encoding 2.11.1 + +The MIT License (MIT) + +Copyright (c) 2015-2020 Julien Cretin +Copyright (c) 2017-2020 Google Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + ================================================================================ MIT License ================================================================================ @@ -10565,6 +11826,36 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +================================================================================ +MIT License +================================================================================ + +Used by: + pem 4.0.0 + +The MIT License (MIT) + +Copyright (c) 2016 Jonathan Creekmore + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + ================================================================================ MIT License ================================================================================ @@ -13416,6 +14707,226 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-------------------------------------------------------------------------------- +Packaged with: + rcgen 0.14.10 (LICENSE) +-------------------------------------------------------------------------------- + +Copyright (c) 2019-2026 est31 and contributors + +Licensed under MIT or Apache License 2.0, +at your option. + +The full list of contributors can be obtained by looking +at the VCS log (originally, this crate was git versioned, +there you can do "git shortlog -sn" for this task). + +MIT License +----------- + +The MIT License (MIT) + +Copyright (c) 2019-2026 est31 and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + + +Apache License, version 2.0 +--------------------------- + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + -------------------------------------------------------------------------------- Packaged with: rust_xlsxwriter 0.102.0 (LICENSE_Apache2.0) @@ -14457,6 +15968,7 @@ Their copyright notices are in their source repositories: accesskit 0.24.1 https://github.com/AccessKit/accesskit alloc-stdlib 0.2.4 https://github.com/dropbox/rust-alloc-no-stdlib + asn1-rs-impl 0.2.0 https://github.com/rusticata/asn1-rs.git block2 0.5.1 https://github.com/madsmtm/objc2 block2 0.6.2 https://github.com/madsmtm/objc2 comemo-macros 0.5.1 https://github.com/typst/comemo @@ -14490,6 +16002,7 @@ Their copyright notices are in their source repositories: wasmi_core 1.1.0 https://github.com/wasmi-labs/wasmi wasmi_ir 1.1.0 https://github.com/wasmi-labs/wasmi wasmparser 0.239.0 https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wasmparser + yamux 0.14.1 https://github.com/paritytech/yamux ================================================================================ FONTS diff --git a/crates/ledger-cli/Cargo.toml b/crates/ledger-cli/Cargo.toml index a51a1126..a99d2b3c 100644 --- a/crates/ledger-cli/Cargo.toml +++ b/crates/ledger-cli/Cargo.toml @@ -15,10 +15,11 @@ path = "src/main.rs" default = ["gui"] # The viewer. Off in the server-only build for another machine (plan # D-22, P9), so a headless machine carries no window libraries. -gui = ["dep:ledger-gui"] +gui = ["dep:ledger-gui", "dep:ledger-link"] [dependencies] ledger-host = { path = "../ledger-host" } +ledger-link = { path = "../ledger-link", optional = true } ledger-mcp = { path = "../ledger-mcp" } ledger-store = { path = "../ledger-store" } ledger-gui = { path = "../ledger-gui", optional = true } @@ -36,7 +37,21 @@ reqwest = "0.13" rusqlite = { version = "0.41", features = ["bundled", "fallible_uint"] } rust_decimal = "1" rmcp = { version = "3", features = ["client", "transport-streamable-http-client-reqwest"] } -tokio = { version = "1", features = ["macros", "rt-multi-thread", "time"] } +tokio = { version = "1", features = ["macros", "rt-multi-thread", "time", "net", "io-util"] } +# The web link end to end (tests/web_link.rs): an in-process relay and +# certificate authority, and a web caller that speaks HTTP/1.1 and HTTP/2. +relay = { path = "../relay" } +ledger-link = { path = "../ledger-link" } +rcgen = { version = "0.14", default-features = false, features = ["ring", "pem"] } +rustls = { version = "0.23", default-features = false, features = ["ring", "std", "tls12"] } +tokio-rustls = { version = "0.26", default-features = false, features = ["ring", "tls12"] } +hyper = { version = "1", features = ["client", "http2"] } +hyper-util = { version = "0.1", features = ["tokio"] } +http-body-util = "0.1" +bytes = "1" +futures = "0.3" +zeroize = "1" +time = "0.3" ledger-config = { path = "../ledger-config" } ledger-core = { path = "../ledger-core" } ledger-package = { path = "../ledger-package" } diff --git a/crates/ledger-cli/src/main.rs b/crates/ledger-cli/src/main.rs index a2e24137..69e68251 100644 --- a/crates/ledger-cli/src/main.rs +++ b/crates/ledger-cli/src/main.rs @@ -76,13 +76,22 @@ struct ViewerOwner { /// 3.1): started with the window, closed with it. All of what is done /// with it is `AppHost`'s, which the tests drive. server: ledger_host::app_server::AppHost, + /// Web assistants: the switch per company, the address and the line to + /// the relay (ledger-host web.rs), in this window's process: the line + /// ends with the window. + web: ledger_host::web::WebAssistants, } #[cfg(feature = "gui")] impl ViewerOwner { fn new(common: ledger_host::commands::Common) -> Self { let server = ledger_host::app_server::AppHost::new(common.root.clone()); - Self { common, server } + let web = ledger_host::web::WebAssistants::new(common.root.clone()); + Self { + common, + server, + web, + } } } @@ -93,7 +102,11 @@ impl ledger_gui::owner::Owner for ViewerOwner { } fn serve_start(&self, open: &[String]) -> Result<(), String> { - self.server.start(open) + self.server.start(open)?; + // What was on when the window closed is on again, for the + // companies that are open. + self.web.restore(&self.server, open); + Ok(()) } fn serve_host_holds(&self) -> bool { @@ -105,7 +118,9 @@ impl ledger_gui::owner::Owner for ViewerOwner { } fn serve_open(&self, book: &str) -> Result, String> { - self.server.open_book(book) + let opened = self.server.open_book(book)?; + self.web.restore(&self.server, &[book.to_string()]); + Ok(opened) } fn serve_close(&self, book: &str) -> Result, String> { @@ -117,6 +132,8 @@ impl ledger_gui::owner::Owner for ViewerOwner { } fn serve_stop(&self) -> Result, String> { + // The line closes first: nothing arrives for books that are closing. + self.web.shutdown(); self.server.stop(ledger_host::app_server::STOP_WAIT) } @@ -207,6 +224,39 @@ impl ledger_gui::owner::Owner for ViewerOwner { self.server.web_set_post(approval, post) } + fn web_state(&self, book: &str) -> Option { + use ledger_gui::owner::WebStep; + let s = self.web.state(book); + Some(ledger_gui::owner::WebConnect { + on: s.on, + step: match s.step { + ledger_link::Step::Off => WebStep::Off, + ledger_link::Step::GettingAddress => WebStep::GettingAddress, + ledger_link::Step::Connecting => WebStep::Connecting, + ledger_link::Step::GettingCertificate => WebStep::GettingCertificate, + ledger_link::Step::Connected => WebStep::Connected, + }, + address: s.address, + connector: s.connector, + words: s.words, + problem: s.problem, + needs_person: s.needs_person, + kept: s.kept, + }) + } + + fn web_turn_on(&self, book: &str) -> Result { + self.web.turn_on(&self.server, book) + } + + fn web_turn_off(&self, book: &str) -> Result { + self.web.turn_off(&self.server, book) + } + + fn web_new_address(&self, _book: &str) -> Result { + self.web.new_address(&self.server) + } + fn serve_revoke(&self, book: &str, name: &str, id: &str) -> Result { self.server.revoke_token(book, name, id) } diff --git a/crates/ledger-host/Cargo.toml b/crates/ledger-host/Cargo.toml index 5ca81669..b3eedc39 100644 --- a/crates/ledger-host/Cargo.toml +++ b/crates/ledger-host/Cargo.toml @@ -11,6 +11,7 @@ description = "wanderbooks: the books open while something holds them (the host, ledger-core = { path = "../ledger-core" } ledger-mcp = { path = "../ledger-mcp" } ledger-store = { path = "../ledger-store" } +ledger-link = { path = "../ledger-link" } serde = { version = "1", features = ["derive"] } serde_json = "1" tokio = { version = "1", features = ["rt-multi-thread", "macros", "io-util", "io-std", "sync", "net", "signal", "time", "process"] } diff --git a/crates/ledger-host/src/lib.rs b/crates/ledger-host/src/lib.rs index bd6bfb2a..43d4cad2 100644 --- a/crates/ledger-host/src/lib.rs +++ b/crates/ledger-host/src/lib.rs @@ -28,6 +28,7 @@ mod start; pub mod tokens; #[cfg(unix)] pub mod update; +pub mod web; /// How a mode stops when it can't go on: the reason is already printed, /// and the number is the process's exit code. diff --git a/crates/ledger-host/src/web.rs b/crates/ledger-host/src/web.rs new file mode 100644 index 00000000..96578c07 --- /dev/null +++ b/crates/ledger-host/src/web.rs @@ -0,0 +1,434 @@ +//! Web assistants, from the app's side: the switch per company, the one +//! address, and the line to the relay, joined to the books server's remote +//! door (plan P15 unit B3; WB-link-6). +//! +//! ```text +//! GOAL: a person turns "Allow web assistants" on for a company and the +//! app offers that company at one durable public address, through +//! the relay, with the sign-in the books server's remote door gives; +//! turned off, the company is no longer offered, and when no company +//! is offered the line and the door are closed; and what was on when +//! the app closed is on again when it opens, once the books are. +//! SOURCE: plan/p15-app-and-relay.md 3.3 (a switch per company, off by +//! default; the address with Copy; "Turning it off closes the line +//! and the door; the name is kept"), 5 (one name per installation, +//! each company a path under it), D-80, D-84, WB-link-6. +//! INVARIANTS: +//! 1. Off by default, and per company: nothing is dialled, listened on +//! or offered until a person turns a company on, and only that +//! company is offered. +//! 2. The order is the door first, then the line when turning on (the +//! door listens on 127.0.0.1 only and wants the secret), and the line +//! first, then the door, when turning off: nothing arrives for a door +//! that is gone, and no door is open to a line that is gone. +//! 3. One address for every company: the address's path names the +//! company (`/b//mcp`), and a new address replaces the +//! secret label, restarts the door at the new issuer (so every token +//! and sign-in made at the old address is refused) and keeps the name. +//! 4. The switches are kept in a private file in the link folder, so +//! they are still on at the next start; a company that is not open +//! yet waits for its tab. +//! 5. The state is read from memory and never waits on the network or +//! the server: the window asks it every frame. +//! 6. A failure at any step leaves nothing half-on: the company is not +//! offered, and if it was the only one the line and the door are +//! closed again; the error is in words. +//! SCENARIOS: +//! 1. See `crates/ledger-cli/tests/web_link.rs`: on, a web assistant +//! signs in through the relay and reads the books, off, on again at +//! the same address, a new address, a restart. +//! ``` + +use crate::app_server::AppHost; +use ledger_link::{DoorTarget, Link, LinkConfig, LinkStatus, Step, Trouble}; +use ledger_mcp::admin::{Request, Response}; +use std::collections::BTreeSet; +use std::path::PathBuf; +use std::sync::{Arc, Mutex, OnceLock}; +use std::time::Duration; + +/// The relay's domain and its own host name. +pub const DOMAIN: &str = "wanderbooks.link"; +/// The relay's host, which its certificate is for. +pub const RELAY_HOST: &str = "relay.wanderbooks.link"; + +const SWITCHES: &str = "web.json"; +const ADMIN_WAIT: Duration = Duration::from_secs(30); + +/// What the Connect page shows of the web assistants of one company. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct WebState { + /// The switch for this company. + pub on: bool, + /// Where it has got to. + pub step: Step, + /// The address, while on. + pub address: Option, + /// The address an assistant is given for this company. + pub connector: Option, + /// A line of progress in words. + pub words: String, + /// What is wrong, in words. + pub problem: Option, + /// Whether the problem needs the person (and is not just waiting). + pub needs_person: bool, + /// An address is kept for when it is turned on again. + pub kept: bool, +} + +impl WebState { + fn off(kept: bool) -> Self { + WebState { + on: false, + step: Step::Off, + address: None, + connector: None, + words: "Web assistants are off.".into(), + problem: None, + needs_person: false, + kept, + } + } +} + +/// How the app reaches the books server's admin requests. +pub trait Admin: Send + Sync { + /// One admin request. + fn admin(&self, request: Request) -> Result; +} + +impl Admin for AppHost { + fn admin(&self, request: Request) -> Result { + self.running()?.call(request, Some(ADMIN_WAIT)) + } +} + +/// How the link is made (tests give it a relay of their own). +pub type Maker = Box Result + Send + Sync>; + +/// Web assistants for this window. +pub struct WebAssistants { + root: Option, + make: Maker, + link: OnceLock, String>>, + on: Mutex>, + /// An error from putting the switches back at the start. + restore_error: Mutex>, + // One change at a time. + busy: Mutex<()>, +} + +fn lock(m: &Mutex) -> std::sync::MutexGuard<'_, T> { + m.lock().unwrap_or_else(|e| e.into_inner()) +} + +/// The program's own relay. +pub fn production(dir: PathBuf) -> Result { + Ok(LinkConfig { + issuer: Arc::new(ledger_link::AcmeIssuer::new(&dir)), + dir, + domain: DOMAIN.into(), + relay_host: RELAY_HOST.into(), + dial: ledger_link::Dial::Host(RELAY_HOST.into(), 443), + relay_tls: ledger_link::public_relay_tls().map_err(|e| e.to_string())?, + timing: ledger_link::Timing::default(), + }) +} + +impl WebAssistants { + /// Web assistants for the data root `root` (else this account's). + pub fn new(root: Option) -> Self { + Self::with_maker(root, Box::new(production)) + } + + /// With a link made another way (tests). + pub fn with_maker(root: Option, make: Maker) -> Self { + WebAssistants { + root, + make, + link: OnceLock::new(), + on: Mutex::new(BTreeSet::new()), + restore_error: Mutex::new(None), + busy: Mutex::new(()), + } + } + + fn dir(&self) -> Result { + let root = + ledger_store::root::Root::find(self.root.as_deref()).map_err(|e| e.to_string())?; + Ok(root.path().join("link")) + } + + fn link(&self) -> Result<&Arc, String> { + self.link + .get_or_init(|| { + let cfg = (self.make)(self.dir()?)?; + Link::start(cfg).map(Arc::new) + }) + .as_ref() + .map_err(Clone::clone) + } + + fn save(&self, set: &BTreeSet) -> Result<(), String> { + let dir = self.dir()?; + let text = serde_json::to_vec(&serde_json::json!({ "books": set })) + .map_err(|_| "can't keep the switches".to_string())?; + ledger_link::private::make_dir(&dir) + .map_err(|e| format!("can't keep the switches ({})", e.kind()))?; + ledger_link::private::write(&dir.join(SWITCHES), &text) + .map_err(|e| format!("can't keep the switches ({})", e.kind())) + } + + fn load(&self) -> BTreeSet { + let Ok(dir) = self.dir() else { + return BTreeSet::new(); + }; + std::fs::read(dir.join(SWITCHES)) + .ok() + .and_then(|b| serde_json::from_slice::(&b).ok()) + .and_then(|v| { + v["books"].as_array().map(|a| { + a.iter() + .filter_map(|s| s.as_str().map(str::to_owned)) + .collect() + }) + }) + .unwrap_or_default() + } + + /// The state of one company's web assistants (INVARIANT 5). + pub fn state(&self, book: &str) -> WebState { + let on = lock(&self.on).contains(book); + let Some(Ok(link)) = self.link.get() else { + // The link was never made: nothing is on, and whether an address + // is kept is read lazily from the folder. + let kept = self + .dir() + .map(|d| d.join("identity.json").exists()) + .unwrap_or(false); + let mut s = WebState::off(kept); + if on { + s.on = true; + s.step = Step::GettingAddress; + s.words = "Getting an address…".into(); + } + return s; + }; + let st = link.status(); + let kept = link.kept_address().is_some(); + if !on { + return WebState::off(kept); + } + Self::describe(book, &st, kept, lock(&self.restore_error).clone()) + } + + fn describe(book: &str, st: &LinkStatus, kept: bool, restore: Option) -> WebState { + let address = st.address.clone(); + let needs_person = st + .trouble + .as_ref() + .is_some_and(|t: &Trouble| !t.mends_itself()); + WebState { + on: true, + step: st.step(), + connector: address.as_ref().map(|a| format!("{a}/b/{book}/mcp")), + address, + words: st.words(), + problem: st.problem().or(restore), + needs_person, + kept, + } + } + + /// Turn web assistants on for `book` (INVARIANTS 1, 2, 6): its words + /// say what happens next. + pub fn turn_on(&self, admin: &dyn Admin, book: &str) -> Result { + let _one = lock(&self.busy); + let link = self.link()?.clone(); + let was = lock(&self.on).clone(); + let door = self.start_door(admin, &link)?; + let offered = admin.admin(Request::RemoteAllow { + book: book.into(), + allowed: true, + }); + match offered { + Ok(Response::Remote(_)) => {} + Ok(Response::Refused(why)) | Err(why) => { + self.unwind(admin, &link, &was); + return Err(why); + } + Ok(other) => { + self.unwind(admin, &link, &was); + return Err(format!("the books server answered oddly: {other:?}")); + } + } + let mut now = was.clone(); + now.insert(book.to_owned()); + if let Err(why) = self.save(&now) { + let _ = admin.admin(Request::RemoteAllow { + book: book.into(), + allowed: false, + }); + self.unwind(admin, &link, &was); + return Err(why); + } + *lock(&self.on) = now; + *lock(&self.restore_error) = None; + link.set_door(Some(door)); + Ok("Web assistants are on. Getting an address and a certificate takes a moment.".into()) + } + + /// The door first (it listens on this computer only), then the line: + /// the line is turned on, so the address is known, and the door is + /// started as that address. + fn start_door(&self, admin: &dyn Admin, link: &Arc) -> Result { + link.turn_on().map_err(|e| e.to_string())?; + let address = link + .status() + .address + .ok_or("Wanderbooks has no address for this yet")?; + let info = match admin.admin(Request::RemoteStart { + public_url: address, + port: None, + }) { + Ok(Response::Remote(info)) => info, + Ok(Response::Refused(why)) | Err(why) => { + if lock(&self.on).is_empty() { + link.turn_off(); + } + return Err(why); + } + Ok(other) => { + if lock(&self.on).is_empty() { + link.turn_off(); + } + return Err(format!("the books server answered oddly: {other:?}")); + } + }; + let listening = info + .listening + .ok_or("the books server's door isn't listening")? + .parse() + .map_err(|_| "the books server's door has an odd address".to_string())?; + let secret = info + .proxy_secret + .ok_or("the books server gave no secret for its door")?; + DoorTarget::new(listening, &secret.0) + } + + /// Put things back as they were `before` a failed change (INVARIANT 6). + fn unwind(&self, admin: &dyn Admin, link: &Arc, before: &BTreeSet) { + if before.is_empty() { + link.turn_off(); + link.set_door(None); + let _ = admin.admin(Request::RemoteStop); + } + } + + /// Turn web assistants off for `book` (INVARIANT 2): with no company + /// left offered, the line closes first, then the door. + pub fn turn_off(&self, admin: &dyn Admin, book: &str) -> Result { + let _one = lock(&self.busy); + let mut now = lock(&self.on).clone(); + now.remove(book); + // Withdraw the company first: nothing new reaches its books. + let withdrawn = admin.admin(Request::RemoteAllow { + book: book.into(), + allowed: false, + }); + let mut note = None; + if let Err(why) = withdrawn { + // The server may be gone already (the books closed); what must + // still happen is the line closing. + note = Some(why); + } + if now.is_empty() + && let Some(Ok(link)) = self.link.get() + { + link.turn_off(); + link.set_door(None); + let _ = admin.admin(Request::RemoteStop); + } + self.save(&now)?; + *lock(&self.on) = now; + Ok(match note { + Some(_) => "Web assistants are off.".into(), + None => "Web assistants are off for this company. Its address is kept for when you turn them on again.".into(), + }) + } + + /// A new address (INVARIANT 3): the one the web assistants use for + /// every company changes; the old one stops working. + pub fn new_address(&self, admin: &dyn Admin) -> Result { + let _one = lock(&self.busy); + let link = self.link()?.clone(); + let on = !lock(&self.on).is_empty(); + if on { + // The old door goes first: nothing signs in at the old address + // while the new one is made. + let _ = admin.admin(Request::RemoteStop); + link.set_door(None); + } + let new = link.new_address().map_err(|e| e.to_string())?; + if on { + let door = self.start_door(admin, &link)?; + let allowed: Vec = lock(&self.on).iter().cloned().collect(); + for book in allowed { + let _ = admin.admin(Request::RemoteAllow { + book, + allowed: true, + }); + } + link.set_door(Some(door)); + } + Ok(format!( + "Your new address is ready ({new}). The old one has stopped working: connect your assistants again with the new one." + )) + } + + /// Put the switches back as they were when the app closed, for the + /// companies that are open (INVARIANT 4). + pub fn restore(&self, admin: &dyn Admin, open: &[String]) { + let kept = self.load(); + for book in open { + if kept.contains(book) + && !lock(&self.on).contains(book) + && let Err(why) = self.turn_on(admin, book) + { + *lock(&self.restore_error) = Some(format!( + "Web assistants could not be turned back on for {book}: {why}" + )); + } + } + } + + /// The window is closing: nothing is dialled or listened on after + /// this. The switches stay as they are on disk. + pub fn shutdown(&self) { + if let Some(Ok(link)) = self.link.get() { + link.turn_off(); + link.set_door(None); + } + } + + /// The network may have changed (a laptop woke): dial again now. + pub fn nudge(&self) { + if let Some(Ok(link)) = self.link.get() { + link.nudge(); + } + } + + /// The link's own status (tests). + pub fn link_status(&self) -> Option { + self.link + .get() + .and_then(|l| l.as_ref().ok()) + .map(|l| l.status()) + } +} + +impl Drop for WebAssistants { + fn drop(&mut self) { + self.shutdown(); + } +} diff --git a/crates/ledger-link/tests/acme.rs b/crates/ledger-link/tests/acme.rs index 2bd070a5..10693695 100644 --- a/crates/ledger-link/tests/acme.rs +++ b/crates/ledger-link/tests/acme.rs @@ -34,6 +34,7 @@ struct Server { orders: Vec, ari_gets: u32, refuse_orders: bool, + certs: HashMap, } struct Order { @@ -150,7 +151,11 @@ impl FakeAcme { if let Some(r) = replaces { order["replaces"] = r.into(); } - with_nonce(json(201, vec![("location", format!("{BASE}/order/{id}"))], order)) + with_nonce(json( + 201, + vec![("location", format!("{BASE}/order/{id}"))], + order, + )) } ("POST", p) if p.starts_with("/authz/") => { let id: usize = p[7..].parse().unwrap(); @@ -180,8 +185,7 @@ impl FakeAcme { B64.encode(Sha256::digest(ka.as_bytes())), ) }; - let seen = - support::dns_txt(self.dns, &format!("_acme-challenge.{ident}.")).await; + let seen = support::dns_txt(self.dns, &format!("_acme-challenge.{ident}.")).await; let ok = seen.contains(&expected); self.state.lock().unwrap().orders[id - 1].authz_valid = ok; with_nonce(json( @@ -222,7 +226,8 @@ impl FakeAcme { let cert = params.signed_by(&self.ca).unwrap(); let mut s = self.state.lock().unwrap(); s.orders[id - 1].done = true; - CERTS.lock().unwrap().insert(id, format!("{}{}", cert.pem(), self.ca.pem())); + s.certs + .insert(id, format!("{}{}", cert.pem(), self.ca.pem())); let o = &s.orders[id - 1]; with_nonce(json( 200, @@ -239,7 +244,7 @@ impl FakeAcme { } ("POST", p) if p.starts_with("/cert/") => { let id: usize = p[6..].parse().unwrap(); - let pem = CERTS.lock().unwrap()[&id].clone(); + let pem = self.state.lock().unwrap().certs[&id].clone(); with_nonce(( 200, vec![("content-type", "application/pem-certificate-chain".into())], @@ -260,14 +265,15 @@ impl FakeAcme { serde_json::json!({"suggestedWindow":{"start":at(self.window.0),"end":at(self.window.1)}}), ) } - _ => json(404, vec![], serde_json::json!({"type":"urn:ietf:params:acme:error:malformed","detail":"no such path"})), + _ => json( + 404, + vec![], + serde_json::json!({"type":"urn:ietf:params:acme:error:malformed","detail":"no such path"}), + ), } } } -static CERTS: std::sync::LazyLock>> = - std::sync::LazyLock::new(|| Mutex::new(HashMap::new())); - struct Http(Arc); impl HttpClient for Http { @@ -278,7 +284,11 @@ impl HttpClient for Http { let fake = self.0.clone(); Box::pin(async move { let (parts, body) = req.into_parts(); - let bytes = body.collect().await.map_err(|e| Error::Other(e.into()))?.to_bytes(); + let bytes = body + .collect() + .await + .map_err(|e| Error::Other(e.into()))? + .to_bytes(); let path = parts.uri.path().to_owned(); assert_eq!(parts.uri.host(), Some("acme.test")); let (status, headers, out) = fake.handle(parts.method.as_str(), &path, &bytes).await; @@ -301,7 +311,11 @@ impl DnsProof for Proof { fn publish<'a>(&'a self, value: &'a str) -> BoxFuture<'a, Result<(), String>> { Box::pin(async move { let r = self.0.publish_txt(value).await.map_err(|e| e.to_string())?; - if r.ok { Ok(()) } else { Err(r.error.unwrap_or_default()) } + if r.ok { + Ok(()) + } else { + Err(r.error.unwrap_or_default()) + } }) } fn clear(&self) -> BoxFuture<'_, ()> { @@ -384,11 +398,13 @@ async fn an_order_goes_through_account_proof_finalize_and_download() { .unwrap(); let der = leaf_der(&issued.chain_pem).unwrap(); let (nb, na, names) = inspect(&der).unwrap(); - assert_eq!(names, [ident.clone()]); + assert_eq!(names, std::slice::from_ref(&ident)); assert!(nb < certs::now() && na > certs::now()); assert!(issued.key_pem.contains("PRIVATE KEY")); // The certificate and key go together (the store checks it). - assert!(certs::StoredCert::new("ledger-accrual-tally-mint", "fake", &issued, &ident, None).is_ok()); + assert!( + certs::StoredCert::new("ledger-accrual-tally-mint", "fake", &issued, &ident, None).is_ok() + ); // The account is kept in a private file, with no contact in it. let file = r.dir.path().join("acme/fake.json"); @@ -396,13 +412,22 @@ async fn an_order_goes_through_account_proof_finalize_and_download() { #[cfg(unix)] { use std::os::unix::fs::PermissionsExt; - assert_eq!(std::fs::metadata(&file).unwrap().permissions().mode() & 0o777, 0o600); + assert_eq!( + std::fs::metadata(&file).unwrap().permissions().mode() & 0o777, + 0o600 + ); + } + { + let st = r.acme.state.lock().unwrap(); + + assert_eq!(st.new_accounts.len(), 1); + assert!( + st.new_accounts[0]["contact"] + .as_array() + .is_none_or(|c| c.is_empty()) + ); + assert_eq!(st.new_accounts[0]["termsOfServiceAgreed"], true); } - let st = r.acme.state.lock().unwrap(); - assert_eq!(st.new_accounts.len(), 1); - assert!(st.new_accounts[0]["contact"].as_array().is_none_or(|c| c.is_empty())); - assert_eq!(st.new_accounts[0]["termsOfServiceAgreed"], true); - drop(st); // The relay holds no proof once the order is done. let left = support::dns_txt( r.env.relay.dns_udp_addr(), @@ -441,7 +466,10 @@ async fn a_renewal_reuses_the_account_names_what_it_replaces_and_reads_the_windo .await .unwrap(); assert_ne!(first.chain_pem, second.chain_pem); - assert_ne!(*first.key_pem, *second.key_pem, "a fresh key for each certificate"); + assert_ne!( + *first.key_pem, *second.key_pem, + "a fresh key for each certificate" + ); { let st = r.acme.state.lock().unwrap(); assert_eq!(st.new_accounts.len(), 1, "the account was reused"); @@ -455,7 +483,10 @@ async fn a_renewal_reuses_the_account_names_what_it_replaces_and_reads_the_windo .await .expect("the authority offers a window"); let now = certs::now(); - assert!((now + 590..=now + 610).contains(&s) && (now + 890..=now + 910).contains(&e), "{s} {e} {now}"); + assert!( + (now + 590..=now + 610).contains(&s) && (now + 890..=now + 910).contains(&e), + "{s} {e} {now}" + ); assert_eq!(r.acme.state.lock().unwrap().ari_gets, 1); }