tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit d061baf359c3a55c0ff0a4a8cc99259e738fcf28
parent 6a1d8be0036468cba365d6b0e3963e3edf342abb
Author: Cristina Horotan <chorotan@mozilla.com>
Date:   Fri,  3 Oct 2025 20:57:19 +0300

Revert "Bug 1990108 (part 2) - Update ohttp and bhttp crates to git rev bf6a983845cc0b540effb3a615e92d914dfcfd0b. r=necko-reviewers,supply-chain-reviewers,toolkit-telemetry-reviewers,valentin,janerik" for causing xpcshell failures on test_ohttp_client.js

This reverts commit 655a08675015317dcb33c51e917c970e89eec2f5.

Revert "Bug 1990108 (part 1) - Stabilize raw_ref_op in our patched Rust compiler. r=glandium"

This reverts commit 17c4a9d25bf2593b7b5107ec9142971ade9b4ce2.

Diffstat:
M.cargo/config.toml.in | 5-----
MCargo.lock | 12+++++++-----
MCargo.toml | 6------
Dbuild/build-rust/rename_AddressOf_to_RawBorrow_inside_the_compiler.patch | 919-------------------------------------------------------------------------------
Dbuild/build-rust/soft_deprecate_the_addr_of_macros.patch | 29-----------------------------
Dbuild/build-rust/stabilize_raw_ref_op.patch | 118-------------------------------------------------------------------------------
Mnetwerk/protocol/http/binary_http/Cargo.toml | 2+-
Mnetwerk/protocol/http/binary_http/src/lib.rs | 7+++----
Msupply-chain/audits.toml | 12------------
Msupply-chain/config.toml | 8--------
Msupply-chain/imports.lock | 8++++----
Mtaskcluster/kinds/toolchain/rust.yml | 3---
Mthird_party/rust/bhttp/.cargo-checksum.json | 4++--
Mthird_party/rust/bhttp/Cargo.toml | 53+++++++++++++----------------------------------------
Mthird_party/rust/bhttp/src/err.rs | 6------
Mthird_party/rust/bhttp/src/lib.rs | 122+++++++++++++++++++++++++------------------------------------------------------
Mthird_party/rust/bhttp/src/parse.rs | 2+-
Mthird_party/rust/bhttp/src/rw.rs | 108++++++++++++++++---------------------------------------------------------------
Mthird_party/rust/bhttp/tests/test.rs | 17++++++++---------
Mthird_party/rust/ohttp/.cargo-checksum.json | 4++--
Athird_party/rust/ohttp/Cargo.lock | 1013+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mthird_party/rust/ohttp/Cargo.toml | 48++++++++++++++++++++++++++++++++++--------------
Mthird_party/rust/ohttp/src/err.rs | 5++++-
Mthird_party/rust/ohttp/src/hpke.rs | 9+++++++++
Mthird_party/rust/ohttp/src/nss/aead.rs | 18++++++++----------
Mthird_party/rust/ohttp/src/nss/hpke.rs | 39++++++++++++++-------------------------
Mthird_party/rust/ohttp/src/nss/p11.rs | 6+++---
Mthird_party/rust/ohttp/src/rh/hpke.rs | 134+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
Mtoolkit/components/glean/Cargo.toml | 2+-
Mtoolkit/components/glean/src/init/viaduct_uploader.rs | 2+-
30 files changed, 1320 insertions(+), 1401 deletions(-)

diff --git a/.cargo/config.toml.in b/.cargo/config.toml.in @@ -75,11 +75,6 @@ git = "https://github.com/jfkthame/mapped_hyph.git" rev = "eff105f6ad7ec9b79816cfc1985a28e5340ad14b" replace-with = "vendored-sources" -[source."git+https://github.com/martinthomson/ohttp.git?rev=bf6a983845cc0b540effb3a615e92d914dfcfd0b"] -git = "https://github.com/martinthomson/ohttp.git" -rev = "bf6a983845cc0b540effb3a615e92d914dfcfd0b" -replace-with = "vendored-sources" - [source."git+https://github.com/mozilla/application-services?rev=f6f667f590ac15367fc37eb1ad3a6bdea4ffc526"] git = "https://github.com/mozilla/application-services" rev = "f6f667f590ac15367fc37eb1ad3a6bdea4ffc526" diff --git a/Cargo.lock b/Cargo.lock @@ -425,8 +425,9 @@ dependencies = [ [[package]] name = "bhttp" -version = "0.6.1" -source = "git+https://github.com/martinthomson/ohttp.git?rev=bf6a983845cc0b540effb3a615e92d914dfcfd0b#bf6a983845cc0b540effb3a615e92d914dfcfd0b" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1300dca7a20730cce82c33fbf8795862556645ef5e9ee835390278c3fe1eb1d0" dependencies = [ "thiserror 1.999.999", ] @@ -5064,10 +5065,11 @@ dependencies = [ [[package]] name = "ohttp" -version = "0.6.1" -source = "git+https://github.com/martinthomson/ohttp.git?rev=bf6a983845cc0b540effb3a615e92d914dfcfd0b#bf6a983845cc0b540effb3a615e92d914dfcfd0b" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a87f4e4cd78d1619b98b6119cde887d20489f70339b9425af080b00db714b6" dependencies = [ - "bindgen 0.72.0", + "bindgen 0.69.999", "byteorder", "hex", "log", diff --git a/Cargo.toml b/Cargo.toml @@ -257,12 +257,6 @@ objc = { git = "https://github.com/glandium/rust-objc", rev = "4de89f5aa9851ceca # allocator-api2 + f95e3419ce41883904fcb2279b52aa35b5f04d76 + fdd92751afa7ce34408b677004b429d597e72c90 allocator-api2 = { git = "https://github.com/glandium/allocator-api2", rev = "ad5f3d56a5a4519eff52af4ff85293431466ef5c" } -# patch ohttp - app-services relies on a version yet to be released. However, even if a new version was released it -# will have bumped the `toml` crate to a version which would cause dupes here. We should remove this and revert back -# to a published version when we can upgrade both a-s and m-c to the same version. -ohttp = { git = "https://github.com/martinthomson/ohttp.git", rev = "bf6a983845cc0b540effb3a615e92d914dfcfd0b" } -bhttp = { git = "https://github.com/martinthomson/ohttp.git", rev = "bf6a983845cc0b540effb3a615e92d914dfcfd0b" } - # application-services overrides to make updating them all simpler. context_id = { git = "https://github.com/mozilla/application-services", rev = "f6f667f590ac15367fc37eb1ad3a6bdea4ffc526" } error-support = { git = "https://github.com/mozilla/application-services", rev = "f6f667f590ac15367fc37eb1ad3a6bdea4ffc526" } diff --git a/build/build-rust/rename_AddressOf_to_RawBorrow_inside_the_compiler.patch b/build/build-rust/rename_AddressOf_to_RawBorrow_inside_the_compiler.patch @@ -1,919 +0,0 @@ -From 35709be02d43b40e7f720408f8a88bf6e9d5501d Mon Sep 17 00:00:00 2001 -From: Ralf Jung <post@ralfj.de> -Date: Mon, 12 Aug 2024 10:57:57 +0200 -Subject: [PATCH] rename AddressOf -> RawBorrow inside the compiler - -diff --git a/compiler/rustc_borrowck/src/def_use.rs b/compiler/rustc_borrowck/src/def_use.rs -index 1f0b0981c8f29..e07d7dd309ae2 100644 ---- a/compiler/rustc_borrowck/src/def_use.rs -+++ b/compiler/rustc_borrowck/src/def_use.rs -@@ -55,8 +55,8 @@ pub fn categorize(context: PlaceContext) -> Option<DefUse> { - PlaceContext::NonMutatingUse(NonMutatingUseContext::PlaceMention) | - PlaceContext::NonUse(NonUseContext::AscribeUserTy(_)) | - -- PlaceContext::MutatingUse(MutatingUseContext::AddressOf) | -- PlaceContext::NonMutatingUse(NonMutatingUseContext::AddressOf) | -+ PlaceContext::MutatingUse(MutatingUseContext::RawBorrow) | -+ PlaceContext::NonMutatingUse(NonMutatingUseContext::RawBorrow) | - PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect) | - PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) | - PlaceContext::NonMutatingUse(NonMutatingUseContext::Move) | -diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs -index 30dd45d847c9b..a529df76bcbc7 100644 ---- a/compiler/rustc_borrowck/src/lib.rs -+++ b/compiler/rustc_borrowck/src/lib.rs -@@ -1242,7 +1242,7 @@ impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> { - ); - } - -- &Rvalue::AddressOf(mutability, place) => { -+ &Rvalue::RawPtr(mutability, place) => { - let access_kind = match mutability { - Mutability::Mut => ( - Deep, -diff --git a/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs b/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs -index f090da031a04b..a57041cd04c52 100644 ---- a/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs -+++ b/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs -@@ -269,7 +269,7 @@ impl<'cx, 'tcx> LoanInvalidationsGenerator<'cx, 'tcx> { - self.access_place(location, place, access_kind, LocalMutationIsAllowed::No); - } - -- &Rvalue::AddressOf(mutability, place) => { -+ &Rvalue::RawPtr(mutability, place) => { - let access_kind = match mutability { - Mutability::Mut => ( - Deep, -diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs -index a2669da1b04e8..6983cda6ddf3b 100644 ---- a/compiler/rustc_borrowck/src/type_check/mod.rs -+++ b/compiler/rustc_borrowck/src/type_check/mod.rs -@@ -756,7 +756,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { - PlaceContext::MutatingUse(_) => ty::Invariant, - PlaceContext::NonUse(StorageDead | StorageLive | VarDebugInfo) => ty::Invariant, - PlaceContext::NonMutatingUse( -- Inspect | Copy | Move | PlaceMention | SharedBorrow | FakeBorrow | AddressOf -+ Inspect | Copy | Move | PlaceMention | SharedBorrow | FakeBorrow | RawBorrow - | Projection, - ) => ty::Covariant, - PlaceContext::NonUse(AscribeUserTy(variance)) => variance, -@@ -2468,7 +2468,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { - self.check_operand(right, location); - } - -- Rvalue::AddressOf(..) -+ Rvalue::RawPtr(..) - | Rvalue::ThreadLocalRef(..) - | Rvalue::Len(..) - | Rvalue::Discriminant(..) -@@ -2485,7 +2485,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { - | Rvalue::ThreadLocalRef(_) - | Rvalue::Repeat(..) - | Rvalue::Ref(..) -- | Rvalue::AddressOf(..) -+ | Rvalue::RawPtr(..) - | Rvalue::Len(..) - | Rvalue::Cast(..) - | Rvalue::ShallowInitBox(..) -diff --git a/compiler/rustc_codegen_cranelift/src/analyze.rs b/compiler/rustc_codegen_cranelift/src/analyze.rs -index c5762638a6b13..72380f50385a1 100644 ---- a/compiler/rustc_codegen_cranelift/src/analyze.rs -+++ b/compiler/rustc_codegen_cranelift/src/analyze.rs -@@ -25,7 +25,7 @@ pub(crate) fn analyze(fx: &FunctionCx<'_, '_, '_>) -> IndexVec<Local, SsaKind> { - for stmt in bb.statements.iter() { - match &stmt.kind { - Assign(place_and_rval) => match &place_and_rval.1 { -- Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => { -+ Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) => { - flag_map[place.local] = SsaKind::NotSsa; - } - _ => {} -diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs -index 9bc7b57c53745..f1d885bf1bce8 100644 ---- a/compiler/rustc_codegen_cranelift/src/base.rs -+++ b/compiler/rustc_codegen_cranelift/src/base.rs -@@ -595,7 +595,7 @@ fn codegen_stmt<'tcx>( - let val = cplace.to_cvalue(fx); - lval.write_cvalue(fx, val) - } -- Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => { -+ Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) => { - let place = codegen_place(fx, place); - let ref_ = place.place_ref(fx, lval.layout()); - lval.write_cvalue(fx, ref_); -diff --git a/compiler/rustc_codegen_ssa/src/mir/analyze.rs b/compiler/rustc_codegen_ssa/src/mir/analyze.rs -index 6794365c9beef..c8cf341628c32 100644 ---- a/compiler/rustc_codegen_ssa/src/mir/analyze.rs -+++ b/compiler/rustc_codegen_ssa/src/mir/analyze.rs -@@ -220,14 +220,14 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx> - | MutatingUseContext::SetDiscriminant - | MutatingUseContext::AsmOutput - | MutatingUseContext::Borrow -- | MutatingUseContext::AddressOf -+ | MutatingUseContext::RawBorrow - | MutatingUseContext::Projection, - ) - | PlaceContext::NonMutatingUse( - NonMutatingUseContext::Inspect - | NonMutatingUseContext::SharedBorrow - | NonMutatingUseContext::FakeBorrow -- | NonMutatingUseContext::AddressOf -+ | NonMutatingUseContext::RawBorrow - | NonMutatingUseContext::Projection, - ) => { - self.locals[local] = LocalKind::Memory; -diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs -index 3c2c29ac7f7d2..d94c6f8ddcec3 100644 ---- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs -+++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs -@@ -584,7 +584,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { - mir::Rvalue::CopyForDeref(place) => { - self.codegen_operand(bx, &mir::Operand::Copy(place)) - } -- mir::Rvalue::AddressOf(mutability, place) => { -+ mir::Rvalue::RawPtr(mutability, place) => { - let mk_ptr = - move |tcx: TyCtxt<'tcx>, ty: Ty<'tcx>| Ty::new_ptr(tcx, ty, mutability); - self.codegen_place_to_pointer(bx, place, mk_ptr) -@@ -813,7 +813,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { - cg_value.len(bx.cx()) - } - -- /// Codegen an `Rvalue::AddressOf` or `Rvalue::Ref` -+ /// Codegen an `Rvalue::RawPtr` or `Rvalue::Ref` - fn codegen_place_to_pointer( - &mut self, - bx: &mut Bx, -@@ -1085,7 +1085,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { - } - mir::Rvalue::Ref(..) | - mir::Rvalue::CopyForDeref(..) | -- mir::Rvalue::AddressOf(..) | -+ mir::Rvalue::RawPtr(..) | - mir::Rvalue::Len(..) | - mir::Rvalue::Cast(..) | // (*) - mir::Rvalue::ShallowInitBox(..) | // (*) -diff --git a/compiler/rustc_const_eval/src/check_consts/check.rs b/compiler/rustc_const_eval/src/check_consts/check.rs -index 32a9247bcc70a..86a5afa65ba87 100644 ---- a/compiler/rustc_const_eval/src/check_consts/check.rs -+++ b/compiler/rustc_const_eval/src/check_consts/check.rs -@@ -431,13 +431,13 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { - return; - } - } -- Rvalue::AddressOf(mutbl, place) => { -+ Rvalue::RawPtr(mutbl, place) => { - if let Some(reborrowed_place_ref) = place_as_reborrow(self.tcx, self.body, place) { - let ctx = match mutbl { - Mutability::Not => { -- PlaceContext::NonMutatingUse(NonMutatingUseContext::AddressOf) -+ PlaceContext::NonMutatingUse(NonMutatingUseContext::RawBorrow) - } -- Mutability::Mut => PlaceContext::MutatingUse(MutatingUseContext::AddressOf), -+ Mutability::Mut => PlaceContext::MutatingUse(MutatingUseContext::RawBorrow), - }; - self.visit_local(reborrowed_place_ref.local, ctx, location); - self.visit_projection(reborrowed_place_ref, ctx, location); -@@ -472,7 +472,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { - } - - Rvalue::Ref(_, BorrowKind::Mut { .. }, place) -- | Rvalue::AddressOf(Mutability::Mut, place) => { -+ | Rvalue::RawPtr(Mutability::Mut, place) => { - // Inside mutable statics, we allow arbitrary mutable references. - // We've allowed `static mut FOO = &mut [elements];` for a long time (the exact - // reasons why are lost to history), and there is no reason to restrict that to -@@ -493,7 +493,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { - } - - Rvalue::Ref(_, BorrowKind::Shared | BorrowKind::Fake(_), place) -- | Rvalue::AddressOf(Mutability::Not, place) => { -+ | Rvalue::RawPtr(Mutability::Not, place) => { - let borrowed_place_has_mut_interior = qualifs::in_place::<HasMutInterior, _>( - self.ccx, - &mut |local| self.qualifs.has_mut_interior(self.ccx, local, location), -diff --git a/compiler/rustc_const_eval/src/check_consts/qualifs.rs b/compiler/rustc_const_eval/src/check_consts/qualifs.rs -index c0f2d113c7e31..c566dc7fa844d 100644 ---- a/compiler/rustc_const_eval/src/check_consts/qualifs.rs -+++ b/compiler/rustc_const_eval/src/check_consts/qualifs.rs -@@ -291,7 +291,7 @@ where - in_operand::<Q, _>(cx, in_local, lhs) || in_operand::<Q, _>(cx, in_local, rhs) - } - -- Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => { -+ Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) => { - // Special-case reborrows to be more like a copy of the reference. - if let Some((place_base, ProjectionElem::Deref)) = place.as_ref().last_projection() { - let base_ty = place_base.ty(cx.body, cx.tcx).ty; -diff --git a/compiler/rustc_const_eval/src/check_consts/resolver.rs b/compiler/rustc_const_eval/src/check_consts/resolver.rs -index ea3a5264357c9..681184f7fbcde 100644 ---- a/compiler/rustc_const_eval/src/check_consts/resolver.rs -+++ b/compiler/rustc_const_eval/src/check_consts/resolver.rs -@@ -96,7 +96,7 @@ where - } - - fn address_of_allows_mutation(&self) -> bool { -- // Exact set of permissions granted by AddressOf is undecided. Conservatively assume that -+ // Exact set of permissions granted by RawPtr is undecided. Conservatively assume that - // it might allow mutation until resolution of #56604. - true - } -@@ -170,7 +170,7 @@ where - self.super_rvalue(rvalue, location); - - match rvalue { -- mir::Rvalue::AddressOf(_mt, borrowed_place) => { -+ mir::Rvalue::RawPtr(_mt, borrowed_place) => { - if !borrowed_place.is_indirect() && self.address_of_allows_mutation() { - let place_ty = borrowed_place.ty(self.ccx.body, self.ccx.tcx).ty; - if Q::in_any_value_of_ty(self.ccx, place_ty) { -diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs -index aaee6f6d247f8..70cfba1922c6e 100644 ---- a/compiler/rustc_const_eval/src/interpret/step.rs -+++ b/compiler/rustc_const_eval/src/interpret/step.rs -@@ -234,7 +234,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { - self.write_immediate(*val, &dest)?; - } - -- AddressOf(_, place) => { -+ RawPtr(_, place) => { - // Figure out whether this is an addr_of of an already raw place. - let place_base_raw = if place.is_indirect_first_projection() { - let ty = self.frame().body.local_decls[place.local].ty; -diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs -index 7cd97166ed1e9..03a76d44cc987 100644 ---- a/compiler/rustc_hir_typeck/src/cast.rs -+++ b/compiler/rustc_hir_typeck/src/cast.rs -@@ -967,7 +967,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { - // need to special-case obtaining a raw pointer - // from a region pointer to a vector. - -- // Coerce to a raw pointer so that we generate AddressOf in MIR. -+ // Coerce to a raw pointer so that we generate RawPtr in MIR. - let array_ptr_type = Ty::new_ptr(fcx.tcx, m_expr.ty, m_expr.mutbl); - fcx.coerce(self.expr, self.expr_ty, array_ptr_type, AllowTwoPhase::No, None) - .unwrap_or_else(|_| { -diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs -index 5dd0e69cf1fe6..212eda666ca05 100644 ---- a/compiler/rustc_middle/src/mir/pretty.rs -+++ b/compiler/rustc_middle/src/mir/pretty.rs -@@ -1038,7 +1038,7 @@ impl<'tcx> Debug for Rvalue<'tcx> { - - CopyForDeref(ref place) => write!(fmt, "deref_copy {place:#?}"), - -- AddressOf(mutability, ref place) => { -+ RawPtr(mutability, ref place) => { - write!(fmt, "&raw {mut_str} {place:?}", mut_str = mutability.ptr_str()) - } - -diff --git a/compiler/rustc_middle/src/mir/statement.rs b/compiler/rustc_middle/src/mir/statement.rs -index 3009ca8d8097a..bc7dfa6205e71 100644 ---- a/compiler/rustc_middle/src/mir/statement.rs -+++ b/compiler/rustc_middle/src/mir/statement.rs -@@ -423,7 +423,7 @@ impl<'tcx> Rvalue<'tcx> { - | Rvalue::Repeat(_, _) - | Rvalue::Ref(_, _, _) - | Rvalue::ThreadLocalRef(_) -- | Rvalue::AddressOf(_, _) -+ | Rvalue::RawPtr(_, _) - | Rvalue::Len(_) - | Rvalue::Cast( - CastKind::IntToInt -diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs -index 1119ff6ff3d60..51b4154ddab78 100644 ---- a/compiler/rustc_middle/src/mir/syntax.rs -+++ b/compiler/rustc_middle/src/mir/syntax.rs -@@ -1293,14 +1293,14 @@ pub enum Rvalue<'tcx> { - /// nature of this operation? - ThreadLocalRef(DefId), - -- /// Creates a pointer with the indicated mutability to the place. -+ /// Creates a raw pointer with the indicated mutability to the place. - /// -- /// This is generated by pointer casts like `&v as *const _` or raw address of expressions like -- /// `&raw v` or `addr_of!(v)`. -+ /// This is generated by pointer casts like `&v as *const _` or raw borrow expressions like -+ /// `&raw const v`. - /// - /// Like with references, the semantics of this operation are heavily dependent on the aliasing - /// model. -- AddressOf(Mutability, Place<'tcx>), -+ RawPtr(Mutability, Place<'tcx>), - - /// Yields the length of the place, as a `usize`. - /// -diff --git a/compiler/rustc_middle/src/mir/tcx.rs b/compiler/rustc_middle/src/mir/tcx.rs -index 1075344dc00f3..8d57d0d865469 100644 ---- a/compiler/rustc_middle/src/mir/tcx.rs -+++ b/compiler/rustc_middle/src/mir/tcx.rs -@@ -170,7 +170,7 @@ impl<'tcx> Rvalue<'tcx> { - let place_ty = place.ty(local_decls, tcx).ty; - Ty::new_ref(tcx, reg, place_ty, bk.to_mutbl_lossy()) - } -- Rvalue::AddressOf(mutability, ref place) => { -+ Rvalue::RawPtr(mutability, ref place) => { - let place_ty = place.ty(local_decls, tcx).ty; - Ty::new_ptr(tcx, place_ty, mutability) - } -diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs -index 3921176873c81..bfb129495ce83 100644 ---- a/compiler/rustc_middle/src/mir/visit.rs -+++ b/compiler/rustc_middle/src/mir/visit.rs -@@ -682,13 +682,13 @@ macro_rules! make_mir_visitor { - ); - } - -- Rvalue::AddressOf(m, path) => { -+ Rvalue::RawPtr(m, path) => { - let ctx = match m { - Mutability::Mut => PlaceContext::MutatingUse( -- MutatingUseContext::AddressOf -+ MutatingUseContext::RawBorrow - ), - Mutability::Not => PlaceContext::NonMutatingUse( -- NonMutatingUseContext::AddressOf -+ NonMutatingUseContext::RawBorrow - ), - }; - self.visit_place(path, ctx, location); -@@ -1299,8 +1299,8 @@ pub enum NonMutatingUseContext { - /// FIXME: do we need to distinguish shallow and deep fake borrows? In fact, do we need to - /// distinguish fake and normal deep borrows? - FakeBorrow, -- /// AddressOf for *const pointer. -- AddressOf, -+ /// `&raw const`. -+ RawBorrow, - /// PlaceMention statement. - /// - /// This statement is executed as a check that the `Place` is live without reading from it, -@@ -1333,8 +1333,8 @@ pub enum MutatingUseContext { - Drop, - /// Mutable borrow. - Borrow, -- /// AddressOf for *mut pointer. -- AddressOf, -+ /// `&raw mut`. -+ RawBorrow, - /// Used as base for another place, e.g., `x` in `x.y`. Could potentially mutate the place. - /// For example, the projection `x.y` is marked as a mutation in these cases: - /// ```ignore (illustrative) -@@ -1386,8 +1386,8 @@ impl PlaceContext { - pub fn is_address_of(&self) -> bool { - matches!( - self, -- PlaceContext::NonMutatingUse(NonMutatingUseContext::AddressOf) -- | PlaceContext::MutatingUse(MutatingUseContext::AddressOf) -+ PlaceContext::NonMutatingUse(NonMutatingUseContext::RawBorrow) -+ | PlaceContext::MutatingUse(MutatingUseContext::RawBorrow) - ) - } - -diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs -index f2ea32275f9b1..aca1390935ef1 100644 ---- a/compiler/rustc_middle/src/thir.rs -+++ b/compiler/rustc_middle/src/thir.rs -@@ -407,7 +407,7 @@ pub enum ExprKind<'tcx> { - arg: ExprId, - }, - /// A `&raw [const|mut] $place_expr` raw borrow resulting in type `*[const|mut] T`. -- AddressOf { -+ RawBorrow { - mutability: hir::Mutability, - arg: ExprId, - }, -diff --git a/compiler/rustc_middle/src/thir/visit.rs b/compiler/rustc_middle/src/thir/visit.rs -index f198881043739..e246ecebbec0b 100644 ---- a/compiler/rustc_middle/src/thir/visit.rs -+++ b/compiler/rustc_middle/src/thir/visit.rs -@@ -92,7 +92,7 @@ pub fn walk_expr<'thir, 'tcx: 'thir, V: Visitor<'thir, 'tcx>>( - } - VarRef { id: _ } | UpvarRef { closure_def_id: _, var_hir_id: _ } => {} - Borrow { arg, borrow_kind: _ } => visitor.visit_expr(&visitor.thir()[arg]), -- AddressOf { arg, mutability: _ } => visitor.visit_expr(&visitor.thir()[arg]), -+ RawBorrow { arg, mutability: _ } => visitor.visit_expr(&visitor.thir()[arg]), - Break { value, label: _ } => { - if let Some(value) = value { - visitor.visit_expr(&visitor.thir()[value]) -diff --git a/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs b/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs -index 56896d945e5f3..0b13ceb574d04 100644 ---- a/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs -+++ b/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs -@@ -244,8 +244,8 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> { - ExprKind::Borrow { borrow_kind, arg } => Ok( - Rvalue::Ref(self.tcx.lifetimes.re_erased, *borrow_kind, self.parse_place(*arg)?) - ), -- ExprKind::AddressOf { mutability, arg } => Ok( -- Rvalue::AddressOf(*mutability, self.parse_place(*arg)?) -+ ExprKind::RawBorrow { mutability, arg } => Ok( -+ Rvalue::RawPtr(*mutability, self.parse_place(*arg)?) - ), - ExprKind::Binary { op, lhs, rhs } => Ok( - Rvalue::BinaryOp(*op, Box::new((self.parse_operand(*lhs)?, self.parse_operand(*rhs)?))) -diff --git a/compiler/rustc_mir_build/src/build/expr/as_place.rs b/compiler/rustc_mir_build/src/build/expr/as_place.rs -index b80d9de70c8da..07784982631f8 100644 ---- a/compiler/rustc_mir_build/src/build/expr/as_place.rs -+++ b/compiler/rustc_mir_build/src/build/expr/as_place.rs -@@ -542,7 +542,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { - | ExprKind::PointerCoercion { .. } - | ExprKind::Repeat { .. } - | ExprKind::Borrow { .. } -- | ExprKind::AddressOf { .. } -+ | ExprKind::RawBorrow { .. } - | ExprKind::Match { .. } - | ExprKind::If { .. } - | ExprKind::Loop { .. } -diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs -index 379d2140c09c5..0c9571da3cf7f 100644 ---- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs -+++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs -@@ -512,7 +512,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { - | ExprKind::NeverToAny { .. } - | ExprKind::Use { .. } - | ExprKind::Borrow { .. } -- | ExprKind::AddressOf { .. } -+ | ExprKind::RawBorrow { .. } - | ExprKind::Adt { .. } - | ExprKind::Loop { .. } - | ExprKind::LogicalOp { .. } -diff --git a/compiler/rustc_mir_build/src/build/expr/category.rs b/compiler/rustc_mir_build/src/build/expr/category.rs -index e07ba6b6e9383..e0349e3e3f668 100644 ---- a/compiler/rustc_mir_build/src/build/expr/category.rs -+++ b/compiler/rustc_mir_build/src/build/expr/category.rs -@@ -51,7 +51,7 @@ impl Category { - | ExprKind::Use { .. } - | ExprKind::Adt { .. } - | ExprKind::Borrow { .. } -- | ExprKind::AddressOf { .. } -+ | ExprKind::RawBorrow { .. } - | ExprKind::Yield { .. } - | ExprKind::Call { .. } - | ExprKind::InlineAsm { .. } => Some(Category::Rvalue(RvalueFunc::Into)), -diff --git a/compiler/rustc_mir_build/src/build/expr/into.rs b/compiler/rustc_mir_build/src/build/expr/into.rs -index 01b32b8e05e49..1c805ed20cc36 100644 ---- a/compiler/rustc_mir_build/src/build/expr/into.rs -+++ b/compiler/rustc_mir_build/src/build/expr/into.rs -@@ -303,12 +303,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { - this.cfg.push_assign(block, source_info, destination, borrow); - block.unit() - } -- ExprKind::AddressOf { mutability, arg } => { -+ ExprKind::RawBorrow { mutability, arg } => { - let place = match mutability { - hir::Mutability::Not => this.as_read_only_place(block, arg), - hir::Mutability::Mut => this.as_place(block, arg), - }; -- let address_of = Rvalue::AddressOf(mutability, unpack!(block = place)); -+ let address_of = Rvalue::RawPtr(mutability, unpack!(block = place)); - this.cfg.push_assign(block, source_info, destination, address_of); - block.unit() - } -diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs -index 9b85ad0ad0891..e4e5844d2ef8e 100644 ---- a/compiler/rustc_mir_build/src/check_unsafety.rs -+++ b/compiler/rustc_mir_build/src/check_unsafety.rs -@@ -397,7 +397,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> { - | ExprKind::Scope { .. } - | ExprKind::Cast { .. } => {} - -- ExprKind::AddressOf { .. } -+ ExprKind::RawBorrow { .. } - | ExprKind::Adt { .. } - | ExprKind::Array { .. } - | ExprKind::Binary { .. } -@@ -498,7 +498,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> { - } - } - } -- ExprKind::AddressOf { arg, .. } => { -+ ExprKind::RawBorrow { arg, .. } => { - if let ExprKind::Scope { value: arg, .. } = self.thir[arg].kind - // THIR desugars UNSAFE_STATIC into *UNSAFE_STATIC_REF, where - // UNSAFE_STATIC_REF holds the addr of the UNSAFE_STATIC, so: take two steps -diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs -index d4de5fac96eb0..2cbaed2cc6258 100644 ---- a/compiler/rustc_mir_build/src/thir/cx/expr.rs -+++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs -@@ -143,7 +143,7 @@ impl<'tcx> Cx<'tcx> { - arg: self.thir.exprs.push(expr), - }, - Adjust::Borrow(AutoBorrow::RawPtr(mutability)) => { -- ExprKind::AddressOf { mutability, arg: self.thir.exprs.push(expr) } -+ ExprKind::RawBorrow { mutability, arg: self.thir.exprs.push(expr) } - } - Adjust::DynStar => ExprKind::Cast { source: self.thir.exprs.push(expr) }, - }; -@@ -396,7 +396,7 @@ impl<'tcx> Cx<'tcx> { - } - - hir::ExprKind::AddrOf(hir::BorrowKind::Raw, mutability, arg) => { -- ExprKind::AddressOf { mutability, arg: self.mirror_expr(arg) } -+ ExprKind::RawBorrow { mutability, arg: self.mirror_expr(arg) } - } - - hir::ExprKind::Block(blk, _) => ExprKind::Block { block: self.mirror_block(blk) }, -diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs -index 85b9dacb1293c..bc1acd51c6911 100644 ---- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs -+++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs -@@ -325,7 +325,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> { - Assign { .. } | AssignOp { .. } | InlineAsm { .. } | Let { .. } => true, - - // These evaluate to a value. -- AddressOf { .. } -+ RawBorrow { .. } - | Adt { .. } - | Array { .. } - | Binary { .. } -diff --git a/compiler/rustc_mir_build/src/thir/print.rs b/compiler/rustc_mir_build/src/thir/print.rs -index 2d4b39e7b08f3..ce7774f594882 100644 ---- a/compiler/rustc_mir_build/src/thir/print.rs -+++ b/compiler/rustc_mir_build/src/thir/print.rs -@@ -379,8 +379,8 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> { - self.print_expr(*arg, depth_lvl + 2); - print_indented!(self, ")", depth_lvl); - } -- AddressOf { mutability, arg } => { -- print_indented!(self, "AddressOf {", depth_lvl); -+ RawBorrow { mutability, arg } => { -+ print_indented!(self, "RawBorrow {", depth_lvl); - print_indented!(self, format!("mutability: {:?}", mutability), depth_lvl + 1); - print_indented!(self, "arg:", depth_lvl + 1); - self.print_expr(*arg, depth_lvl + 2); -diff --git a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs -index 2ec3b53bc9814..d7e738b8829e0 100644 ---- a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs -+++ b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs -@@ -703,7 +703,7 @@ where - statements: vec![ - self.assign( - ptr, -- Rvalue::AddressOf(Mutability::Mut, tcx.mk_place_index(self.place, cur)), -+ Rvalue::RawPtr(Mutability::Mut, tcx.mk_place_index(self.place, cur)), - ), - self.assign( - cur.into(), -diff --git a/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs b/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs -index 885fdd0d58bea..e8e78fb8a89ee 100644 ---- a/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs -+++ b/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs -@@ -94,7 +94,7 @@ where - match rvalue { - // We ignore fake borrows as these get removed after analysis and shouldn't effect - // the layout of generators. -- Rvalue::AddressOf(_, borrowed_place) -+ Rvalue::RawPtr(_, borrowed_place) - | Rvalue::Ref(_, BorrowKind::Mut { .. } | BorrowKind::Shared, borrowed_place) => { - if !borrowed_place.is_indirect() { - self.trans.gen_(borrowed_place.local); -diff --git a/compiler/rustc_mir_dataflow/src/impls/initialized.rs b/compiler/rustc_mir_dataflow/src/impls/initialized.rs -index 7822fb17f7298..ddfd0739358d1 100644 ---- a/compiler/rustc_mir_dataflow/src/impls/initialized.rs -+++ b/compiler/rustc_mir_dataflow/src/impls/initialized.rs -@@ -351,7 +351,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, '_, 'tcx> { - && let Some((_, rvalue)) = statement.kind.as_assign() - && let mir::Rvalue::Ref(_, mir::BorrowKind::Mut { .. }, place) - // FIXME: Does `&raw const foo` allow mutation? See #90413. -- | mir::Rvalue::AddressOf(_, place) = rvalue -+ | mir::Rvalue::RawPtr(_, place) = rvalue - && let LookupResult::Exact(mpi) = self.move_data().rev_lookup.find(place.as_ref()) - { - on_all_children_bits(self.move_data(), mpi, |child| { -diff --git a/compiler/rustc_mir_dataflow/src/impls/liveness.rs b/compiler/rustc_mir_dataflow/src/impls/liveness.rs -index 48bdb1316012f..24a4b32ceb7c4 100644 ---- a/compiler/rustc_mir_dataflow/src/impls/liveness.rs -+++ b/compiler/rustc_mir_dataflow/src/impls/liveness.rs -@@ -189,13 +189,13 @@ impl DefUse { - - // All other contexts are uses... - PlaceContext::MutatingUse( -- MutatingUseContext::AddressOf -+ MutatingUseContext::RawBorrow - | MutatingUseContext::Borrow - | MutatingUseContext::Drop - | MutatingUseContext::Retag, - ) - | PlaceContext::NonMutatingUse( -- NonMutatingUseContext::AddressOf -+ NonMutatingUseContext::RawBorrow - | NonMutatingUseContext::Copy - | NonMutatingUseContext::Inspect - | NonMutatingUseContext::Move -diff --git a/compiler/rustc_mir_dataflow/src/move_paths/builder.rs b/compiler/rustc_mir_dataflow/src/move_paths/builder.rs -index 86091379f5a92..14390723ba4b6 100644 ---- a/compiler/rustc_mir_dataflow/src/move_paths/builder.rs -+++ b/compiler/rustc_mir_dataflow/src/move_paths/builder.rs -@@ -432,7 +432,7 @@ impl<'b, 'a, 'tcx, F: Fn(Ty<'tcx>) -> bool> Gatherer<'b, 'a, 'tcx, F> { - } - Rvalue::CopyForDeref(..) => unreachable!(), - Rvalue::Ref(..) -- | Rvalue::AddressOf(..) -+ | Rvalue::RawPtr(..) - | Rvalue::Discriminant(..) - | Rvalue::Len(..) - | Rvalue::NullaryOp( -diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs -index 139fd592f69a3..2b20a35b61e29 100644 ---- a/compiler/rustc_mir_dataflow/src/value_analysis.rs -+++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs -@@ -177,7 +177,7 @@ pub trait ValueAnalysis<'tcx> { - match rvalue { - Rvalue::Use(operand) => self.handle_operand(operand, state), - Rvalue::CopyForDeref(place) => self.handle_operand(&Operand::Copy(*place), state), -- Rvalue::Ref(..) | Rvalue::AddressOf(..) => { -+ Rvalue::Ref(..) | Rvalue::RawPtr(..) => { - // We don't track such places. - ValueOrPlace::TOP - } -diff --git a/compiler/rustc_mir_transform/src/add_retag.rs b/compiler/rustc_mir_transform/src/add_retag.rs -index 16977a63c598e..12a68790374e5 100644 ---- a/compiler/rustc_mir_transform/src/add_retag.rs -+++ b/compiler/rustc_mir_transform/src/add_retag.rs -@@ -131,9 +131,9 @@ impl<'tcx> MirPass<'tcx> for AddRetag { - // Ptr-creating operations already do their own internal retagging, no - // need to also add a retag statement. - // *Except* if we are deref'ing a Box, because those get desugared to directly working -- // with the inner raw pointer! That's relevant for `AddressOf` as Miri otherwise makes it -+ // with the inner raw pointer! That's relevant for `RawPtr` as Miri otherwise makes it - // a NOP when the original pointer is already raw. -- Rvalue::AddressOf(_mutbl, place) => { -+ Rvalue::RawPtr(_mutbl, place) => { - // Using `is_box_global` here is a bit sketchy: if this code is - // generic over the allocator, we'll not add a retag! This is a hack - // to make Stacked Borrows compatible with custom allocator code. -diff --git a/compiler/rustc_mir_transform/src/check_alignment.rs b/compiler/rustc_mir_transform/src/check_alignment.rs -index a1dbd7dc50ec7..5dfdcfc8b9446 100644 ---- a/compiler/rustc_mir_transform/src/check_alignment.rs -+++ b/compiler/rustc_mir_transform/src/check_alignment.rs -@@ -71,7 +71,7 @@ struct PointerFinder<'tcx, 'a> { - impl<'tcx, 'a> Visitor<'tcx> for PointerFinder<'tcx, 'a> { - fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, location: Location) { - // We want to only check reads and writes to Places, so we specifically exclude -- // Borrows and AddressOf. -+ // Borrow and RawBorrow. - match context { - PlaceContext::MutatingUse( - MutatingUseContext::Store -diff --git a/compiler/rustc_mir_transform/src/deduce_param_attrs.rs b/compiler/rustc_mir_transform/src/deduce_param_attrs.rs -index 370e930b74098..71af099199ea9 100644 ---- a/compiler/rustc_mir_transform/src/deduce_param_attrs.rs -+++ b/compiler/rustc_mir_transform/src/deduce_param_attrs.rs -@@ -40,7 +40,7 @@ impl<'tcx> Visitor<'tcx> for DeduceReadOnly { - // This is a mutation, so mark it as such. - true - } -- PlaceContext::NonMutatingUse(NonMutatingUseContext::AddressOf) => { -+ PlaceContext::NonMutatingUse(NonMutatingUseContext::RawBorrow) => { - // Whether mutating though a `&raw const` is allowed is still undecided, so we - // disable any sketchy `readonly` optimizations for now. - // But we only need to do this if the pointer would point into the argument. -diff --git a/compiler/rustc_mir_transform/src/dest_prop.rs b/compiler/rustc_mir_transform/src/dest_prop.rs -index 054cdbc6bad9f..ed924761892c7 100644 ---- a/compiler/rustc_mir_transform/src/dest_prop.rs -+++ b/compiler/rustc_mir_transform/src/dest_prop.rs -@@ -576,7 +576,7 @@ impl WriteInfo { - Rvalue::ThreadLocalRef(_) - | Rvalue::NullaryOp(_, _) - | Rvalue::Ref(_, _, _) -- | Rvalue::AddressOf(_, _) -+ | Rvalue::RawPtr(_, _) - | Rvalue::Len(_) - | Rvalue::Discriminant(_) - | Rvalue::CopyForDeref(_) => (), -diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs -index e16911d79c378..90e3ba26a438e 100644 ---- a/compiler/rustc_mir_transform/src/gvn.rs -+++ b/compiler/rustc_mir_transform/src/gvn.rs -@@ -45,7 +45,7 @@ - //! - //! # Handling of references - //! --//! We handle references by assigning a different "provenance" index to each Ref/AddressOf rvalue. -+//! We handle references by assigning a different "provenance" index to each Ref/RawPtr rvalue. - //! This ensure that we do not spuriously merge borrows that should not be merged. Meanwhile, we - //! consider all the derefs of an immutable reference to a freeze type to give the same value: - //! ```ignore (MIR) -@@ -832,7 +832,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { - self.simplify_place_projection(place, location); - return self.new_pointer(*place, AddressKind::Ref(borrow_kind)); - } -- Rvalue::AddressOf(mutbl, ref mut place) => { -+ Rvalue::RawPtr(mutbl, ref mut place) => { - self.simplify_place_projection(place, location); - return self.new_pointer(*place, AddressKind::Address(mutbl)); - } -diff --git a/compiler/rustc_mir_transform/src/instsimplify.rs b/compiler/rustc_mir_transform/src/instsimplify.rs -index 1589653968c2e..3ec553d0ba0c5 100644 ---- a/compiler/rustc_mir_transform/src/instsimplify.rs -+++ b/compiler/rustc_mir_transform/src/instsimplify.rs -@@ -141,7 +141,7 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> { - - /// Transform `&(*a)` ==> `a`. - fn simplify_ref_deref(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) { -- if let Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) = rvalue { -+ if let Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) = rvalue { - if let Some((base, ProjectionElem::Deref)) = place.as_ref().last_projection() { - if rvalue.ty(self.local_decls, self.tcx) != base.ty(self.local_decls, self.tcx).ty { - return; -diff --git a/compiler/rustc_mir_transform/src/known_panics_lint.rs b/compiler/rustc_mir_transform/src/known_panics_lint.rs -index 7202cc2d0427e..7eed47cf2398e 100644 ---- a/compiler/rustc_mir_transform/src/known_panics_lint.rs -+++ b/compiler/rustc_mir_transform/src/known_panics_lint.rs -@@ -419,8 +419,8 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { - } - - // Do not try creating references (#67862) -- Rvalue::AddressOf(_, place) | Rvalue::Ref(_, _, place) => { -- trace!("skipping AddressOf | Ref for {:?}", place); -+ Rvalue::RawPtr(_, place) | Rvalue::Ref(_, _, place) => { -+ trace!("skipping RawPtr | Ref for {:?}", place); - - // This may be creating mutable references or immutable references to cells. - // If that happens, the pointed to value could be mutated via that reference. -@@ -616,7 +616,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { - ImmTy::from_scalar(Scalar::from_target_usize(len, self), layout).into() - } - -- Ref(..) | AddressOf(..) => return None, -+ Ref(..) | RawPtr(..) => return None, - - NullaryOp(ref null_op, ty) => { - let op_layout = self.use_ecx(|this| this.ecx.layout_of(ty))?; -@@ -969,9 +969,9 @@ impl<'tcx> Visitor<'tcx> for CanConstProp { - // mutation. - | NonMutatingUse(NonMutatingUseContext::SharedBorrow) - | NonMutatingUse(NonMutatingUseContext::FakeBorrow) -- | NonMutatingUse(NonMutatingUseContext::AddressOf) -+ | NonMutatingUse(NonMutatingUseContext::RawBorrow) - | MutatingUse(MutatingUseContext::Borrow) -- | MutatingUse(MutatingUseContext::AddressOf) => { -+ | MutatingUse(MutatingUseContext::RawBorrow) => { - trace!("local {:?} can't be propagated because it's used: {:?}", local, context); - self.can_const_prop[local] = ConstPropMode::NoPropagation; - } -diff --git a/compiler/rustc_mir_transform/src/large_enums.rs b/compiler/rustc_mir_transform/src/large_enums.rs -index e407929c9a7fd..cbc3169f2f10a 100644 ---- a/compiler/rustc_mir_transform/src/large_enums.rs -+++ b/compiler/rustc_mir_transform/src/large_enums.rs -@@ -214,7 +214,7 @@ impl EnumSizeOpt { - source_info, - kind: StatementKind::Assign(Box::new(( - dst, -- Rvalue::AddressOf(Mutability::Mut, *lhs), -+ Rvalue::RawPtr(Mutability::Mut, *lhs), - ))), - }; - -@@ -238,7 +238,7 @@ impl EnumSizeOpt { - source_info, - kind: StatementKind::Assign(Box::new(( - src, -- Rvalue::AddressOf(Mutability::Not, *rhs), -+ Rvalue::RawPtr(Mutability::Not, *rhs), - ))), - }; - -diff --git a/compiler/rustc_mir_transform/src/promote_consts.rs b/compiler/rustc_mir_transform/src/promote_consts.rs -index 48a3266ae6f0d..6e84914ef972c 100644 ---- a/compiler/rustc_mir_transform/src/promote_consts.rs -+++ b/compiler/rustc_mir_transform/src/promote_consts.rs -@@ -551,7 +551,7 @@ impl<'tcx> Validator<'_, 'tcx> { - self.validate_operand(rhs)?; - } - -- Rvalue::AddressOf(_, place) => { -+ Rvalue::RawPtr(_, place) => { - // We accept `&raw *`, i.e., raw reborrows -- creating a raw pointer is - // no problem, only using it is. - if let Some((place_base, ProjectionElem::Deref)) = place.as_ref().last_projection() -diff --git a/compiler/rustc_mir_transform/src/ref_prop.rs b/compiler/rustc_mir_transform/src/ref_prop.rs -index 76e65099e9028..973a191d786e1 100644 ---- a/compiler/rustc_mir_transform/src/ref_prop.rs -+++ b/compiler/rustc_mir_transform/src/ref_prop.rs -@@ -227,7 +227,7 @@ fn compute_replacement<'tcx>( - } - } - } -- Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => { -+ Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) => { - let mut place = *place; - // Try to see through `place` in order to collapse reborrow chains. - if place.projection.first() == Some(&PlaceElem::Deref) -diff --git a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs -index ea4f5fca59e67..9c3f903e0eab7 100644 ---- a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs -+++ b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs -@@ -343,7 +343,7 @@ impl<'tcx> AsyncDestructorCtorShimBuilder<'tcx> { - .tcx - .mk_place_elems(&[PlaceElem::Deref, PlaceElem::Field(field, field_ty)]), - }; -- self.put_temp_rvalue(Rvalue::AddressOf(Mutability::Mut, place)) -+ self.put_temp_rvalue(Rvalue::RawPtr(Mutability::Mut, place)) - } - - /// If given Self is an enum puts `to_drop: *mut FieldTy` on top of -@@ -363,7 +363,7 @@ impl<'tcx> AsyncDestructorCtorShimBuilder<'tcx> { - PlaceElem::Field(field, field_ty), - ]), - }; -- self.put_temp_rvalue(Rvalue::AddressOf(Mutability::Mut, place)) -+ self.put_temp_rvalue(Rvalue::RawPtr(Mutability::Mut, place)) - } - - /// If given Self is an enum puts `to_drop: *mut FieldTy` on top of -diff --git a/compiler/rustc_mir_transform/src/ssa.rs b/compiler/rustc_mir_transform/src/ssa.rs -index fb870425f6ef8..76591f526250c 100644 ---- a/compiler/rustc_mir_transform/src/ssa.rs -+++ b/compiler/rustc_mir_transform/src/ssa.rs -@@ -2,9 +2,9 @@ - //! 1/ They are only assigned-to once, either as a function parameter, or in an assign statement; - //! 2/ This single assignment dominates all uses; - //! --//! As we do not track indirect assignments, a local that has its address taken (either by --//! AddressOf or by borrowing) is considered non-SSA. However, it is UB to modify through an --//! immutable borrow of a `Freeze` local. Those can still be considered to be SSA. -+//! As we do not track indirect assignments, a local that has its address taken (via a borrow or raw -+//! borrow operator) is considered non-SSA. However, it is UB to modify through an immutable borrow -+//! of a `Freeze` local. Those can still be considered to be SSA. - - use rustc_data_structures::graph::dominators::Dominators; - use rustc_index::bit_set::BitSet; -@@ -262,7 +262,7 @@ impl<'tcx> Visitor<'tcx> for SsaVisitor<'tcx, '_> { - PlaceContext::MutatingUse(MutatingUseContext::Projection) - | PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection) => bug!(), - // Anything can happen with raw pointers, so remove them. -- PlaceContext::NonMutatingUse(NonMutatingUseContext::AddressOf) -+ PlaceContext::NonMutatingUse(NonMutatingUseContext::RawBorrow) - | PlaceContext::MutatingUse(_) => { - self.assignments[local] = Set1::Many; - } -diff --git a/compiler/rustc_mir_transform/src/validate.rs b/compiler/rustc_mir_transform/src/validate.rs -index 491ae1c0d083f..36908036796c1 100644 ---- a/compiler/rustc_mir_transform/src/validate.rs -+++ b/compiler/rustc_mir_transform/src/validate.rs -@@ -1345,7 +1345,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { - } - Rvalue::Repeat(_, _) - | Rvalue::ThreadLocalRef(_) -- | Rvalue::AddressOf(_, _) -+ | Rvalue::RawPtr(_, _) - | Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf | NullOp::UbChecks, _) - | Rvalue::Discriminant(_) => {} - } -diff --git a/compiler/rustc_smir/src/rustc_smir/convert/mir.rs b/compiler/rustc_smir/src/rustc_smir/convert/mir.rs -index da705e6f9598a..c442ca861d35b 100644 ---- a/compiler/rustc_smir/src/rustc_smir/convert/mir.rs -+++ b/compiler/rustc_smir/src/rustc_smir/convert/mir.rs -@@ -174,7 +174,7 @@ impl<'tcx> Stable<'tcx> for mir::Rvalue<'tcx> { - ThreadLocalRef(def_id) => { - stable_mir::mir::Rvalue::ThreadLocalRef(tables.crate_item(*def_id)) - } -- AddressOf(mutability, place) => { -+ RawPtr(mutability, place) => { - stable_mir::mir::Rvalue::AddressOf(mutability.stable(tables), place.stable(tables)) - } - Len(place) => stable_mir::mir::Rvalue::Len(place.stable(tables)), -diff --git a/compiler/rustc_ty_utils/src/consts.rs b/compiler/rustc_ty_utils/src/consts.rs -index 2492688352342..4ded935b801d3 100644 ---- a/compiler/rustc_ty_utils/src/consts.rs -+++ b/compiler/rustc_ty_utils/src/consts.rs -@@ -192,7 +192,7 @@ fn recurse_build<'tcx>( - ExprKind::Borrow { arg, .. } => { - let arg_node = &body.exprs[*arg]; - -- // Skip reborrows for now until we allow Deref/Borrow/AddressOf -+ // Skip reborrows for now until we allow Deref/Borrow/RawBorrow - // expressions. - // FIXME(generic_const_exprs): Verify/explain why this is sound - if let ExprKind::Deref { arg } = arg_node.kind { -@@ -202,7 +202,7 @@ fn recurse_build<'tcx>( - } - } - // FIXME(generic_const_exprs): We may want to support these. -- ExprKind::AddressOf { .. } | ExprKind::Deref { .. } => maybe_supported_error( -+ ExprKind::RawBorrow { .. } | ExprKind::Deref { .. } => maybe_supported_error( - GenericConstantTooComplexSub::AddressAndDerefNotSupported(node.span), - )?, - ExprKind::Repeat { .. } | ExprKind::Array { .. } => { -@@ -343,7 +343,7 @@ impl<'a, 'tcx> IsThirPolymorphic<'a, 'tcx> { - | thir::ExprKind::VarRef { .. } - | thir::ExprKind::UpvarRef { .. } - | thir::ExprKind::Borrow { .. } -- | thir::ExprKind::AddressOf { .. } -+ | thir::ExprKind::RawBorrow { .. } - | thir::ExprKind::Break { .. } - | thir::ExprKind::Continue { .. } - | thir::ExprKind::Return { .. } -diff --git a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs -index 553af913ef9df..95fbf0b2ea20a 100644 ---- a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs -+++ b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs -@@ -110,7 +110,7 @@ fn check_rvalue<'tcx>( - ) -> McfResult { - match rvalue { - Rvalue::ThreadLocalRef(_) => Err((span, "cannot access thread local storage in const fn".into())), -- Rvalue::Len(place) | Rvalue::Discriminant(place) | Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => { -+ Rvalue::Len(place) | Rvalue::Discriminant(place) | Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) => { - check_place(tcx, *place, span, body, msrv) - }, - Rvalue::CopyForDeref(place) => check_place(tcx, *place, span, body, msrv), diff --git a/build/build-rust/soft_deprecate_the_addr_of_macros.patch b/build/build-rust/soft_deprecate_the_addr_of_macros.patch @@ -1,29 +0,0 @@ -From b8464961a2681585a6231b93cd7e85e50022c2b3 Mon Sep 17 00:00:00 2001 -From: Ralf Jung <post@ralfj.de> -Date: Sat, 13 Jul 2024 13:56:05 +0200 -Subject: [PATCH] soft-deprecate the addr_of macros - -diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs -index 25d8f4a0adbd9..3fe5212cea779 100644 ---- a/library/core/src/ptr/mod.rs -+++ b/library/core/src/ptr/mod.rs -@@ -2209,6 +2209,9 @@ impl<F: FnPtr> fmt::Debug for F { - - /// Creates a `const` raw pointer to a place, without creating an intermediate reference. - /// -+/// `addr_of!(expr)` is equivalent to `&raw const expr`. The macro is *soft-deprecated*; -+/// use `&raw const` instead. -+/// - /// Creating a reference with `&`/`&mut` is only allowed if the pointer is properly aligned - /// and points to initialized data. For cases where those requirements do not hold, - /// raw pointers should be used instead. However, `&expr as *const _` creates a reference -@@ -2283,6 +2286,9 @@ pub macro addr_of($place:expr) { - - /// Creates a `mut` raw pointer to a place, without creating an intermediate reference. - /// -+/// `addr_of_mut!(expr)` is equivalent to `&raw mut expr`. The macro is *soft-deprecated*; -+/// use `&raw mut` instead. -+/// - /// Creating a reference with `&`/`&mut` is only allowed if the pointer is properly aligned - /// and points to initialized data. For cases where those requirements do not hold, - /// raw pointers should be used instead. However, `&mut expr as *mut _` creates a reference diff --git a/build/build-rust/stabilize_raw_ref_op.patch b/build/build-rust/stabilize_raw_ref_op.patch @@ -1,118 +0,0 @@ -From 79503dd742253cdca54f10aec9052ff477ccaf38 Mon Sep 17 00:00:00 2001 -From: Ralf Jung <post@ralfj.de> -Date: Sat, 13 Jul 2024 13:53:56 +0200 -Subject: [PATCH] stabilize raw_ref_op - -diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs -index 214a37bca03e2..5ab99fbac866f 100644 ---- a/compiler/rustc_ast_passes/src/feature_gate.rs -+++ b/compiler/rustc_ast_passes/src/feature_gate.rs -@@ -539,7 +539,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) { - } - } - gate_all!(gen_blocks, "gen blocks are experimental"); -- gate_all!(raw_ref_op, "raw address of syntax is experimental"); - gate_all!(const_trait_impl, "const trait impls are experimental"); - gate_all!( - half_open_range_patterns_in_slices, -diff --git a/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs b/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs -index e603ac566f4ec..ccbd5a78485d7 100644 ---- a/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs -+++ b/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs -@@ -6,8 +6,7 @@ - extern_types, - naked_functions, - thread_local, -- repr_simd, -- raw_ref_op -+ repr_simd - )] - #![no_core] - #![allow(dead_code, non_camel_case_types, internal_features)] -diff --git a/compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs b/compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs -index 9f096e9022012..dcfa34cb729d8 100644 ---- a/compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs -+++ b/compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs -@@ -2,7 +2,7 @@ - - #![feature( - no_core, unboxed_closures, start, lang_items, never_type, linkage, -- extern_types, thread_local, raw_ref_op -+ extern_types, thread_local - )] - #![no_core] - #![allow(dead_code, internal_features, non_camel_case_types)] -diff --git a/compiler/rustc_error_codes/src/error_codes/E0745.md b/compiler/rustc_error_codes/src/error_codes/E0745.md -index 23ee7af30f418..32b28f3de949f 100644 ---- a/compiler/rustc_error_codes/src/error_codes/E0745.md -+++ b/compiler/rustc_error_codes/src/error_codes/E0745.md -@@ -3,7 +3,6 @@ The address of temporary value was taken. - Erroneous code example: - - ```compile_fail,E0745 --# #![feature(raw_ref_op)] - fn temp_address() { - let ptr = &raw const 2; // error! - } -@@ -15,7 +14,6 @@ In this example, `2` is destroyed right after the assignment, which means that - To avoid this error, first bind the temporary to a named local variable: - - ``` --# #![feature(raw_ref_op)] - fn temp_address() { - let val = 2; - let ptr = &raw const val; // ok! -diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs -index 3d5ecbaae32a2..7838abca9b890 100644 ---- a/compiler/rustc_feature/src/accepted.rs -+++ b/compiler/rustc_feature/src/accepted.rs -@@ -321,6 +321,8 @@ declare_features! ( - (accepted, raw_dylib, "1.71.0", Some(58713)), - /// Allows keywords to be escaped for use as identifiers. - (accepted, raw_identifiers, "1.30.0", Some(48589)), -+ /// Allows `&raw const $place_expr` and `&raw mut $place_expr` expressions. -+ (accepted, raw_ref_op, "CURRENT_RUSTC_VERSION", Some(64490)), - /// Allows relaxing the coherence rules such that - /// `impl<T> ForeignTrait<LocalType> for ForeignType<T>` is permitted. - (accepted, re_rebalance_coherence, "1.41.0", Some(55437)), -diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs -index 459df9ea1b859..14e353f13ca49 100644 ---- a/compiler/rustc_feature/src/unstable.rs -+++ b/compiler/rustc_feature/src/unstable.rs -@@ -565,8 +565,6 @@ declare_features! ( - (unstable, precise_capturing, "1.79.0", Some(123432)), - /// Allows macro attributes on expressions, statements and non-inline modules. - (unstable, proc_macro_hygiene, "1.30.0", Some(54727)), -- /// Allows `&raw const $place_expr` and `&raw mut $place_expr` expressions. -- (unstable, raw_ref_op, "1.41.0", Some(64490)), - /// Makes `&` and `&mut` patterns eat only one layer of references in Rust 2024. - (incomplete, ref_pat_eat_one_layer_2024, "1.79.0", Some(123076)), - /// Makes `&` and `&mut` patterns eat only one layer of references in Rust 2024—structural variant -diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs -index e0917ba43e41c..422206ebbce07 100644 ---- a/compiler/rustc_parse/src/parser/expr.rs -+++ b/compiler/rustc_parse/src/parser/expr.rs -@@ -851,7 +851,7 @@ impl<'a> Parser<'a> { - self.expect_and()?; - let has_lifetime = self.token.is_lifetime() && self.look_ahead(1, |t| t != &token::Colon); - let lifetime = has_lifetime.then(|| self.expect_lifetime()); // For recovery, see below. -- let (borrow_kind, mutbl) = self.parse_borrow_modifiers(lo); -+ let (borrow_kind, mutbl) = self.parse_borrow_modifiers(); - let attrs = self.parse_outer_attributes()?; - let expr = if self.token.is_range_separator() { - self.parse_expr_prefix_range(attrs) -@@ -871,13 +871,12 @@ impl<'a> Parser<'a> { - } - - /// Parse `mut?` or `raw [ const | mut ]`. -- fn parse_borrow_modifiers(&mut self, lo: Span) -> (ast::BorrowKind, ast::Mutability) { -+ fn parse_borrow_modifiers(&mut self) -> (ast::BorrowKind, ast::Mutability) { - if self.check_keyword(kw::Raw) && self.look_ahead(1, Token::is_mutability) { - // `raw [ const | mut ]`. - let found_raw = self.eat_keyword(kw::Raw); - assert!(found_raw); - let mutability = self.parse_const_or_mut().unwrap(); -- self.psess.gated_spans.gate(sym::raw_ref_op, lo.to(self.prev_token.span)); - (ast::BorrowKind::Raw, mutability) - } else { - // `mut?` diff --git a/netwerk/protocol/http/binary_http/Cargo.toml b/netwerk/protocol/http/binary_http/Cargo.toml @@ -6,6 +6,6 @@ edition = "2021" [dependencies] nserror = { path = "../../../../xpcom/rust/nserror" } nsstring = { path = "../../../../xpcom/rust/nsstring" } -bhttp = "0.6" +bhttp = "0.3" thin-vec = { version = "0.2.1", features = ["gecko-ffi"] } xpcom = { path = "../../../../xpcom/rust/xpcom" } diff --git a/netwerk/protocol/http/binary_http/src/lib.rs b/netwerk/protocol/http/binary_http/src/lib.rs @@ -9,7 +9,7 @@ extern crate thin_vec; #[macro_use] extern crate xpcom; -use bhttp::{Message, Mode, StatusCode}; +use bhttp::{Message, Mode}; use nserror::{nsresult, NS_ERROR_FAILURE, NS_ERROR_INVALID_ARG, NS_ERROR_UNEXPECTED, NS_OK}; use nsstring::{nsACString, nsCString}; use std::io::Cursor; @@ -180,7 +180,7 @@ impl BinaryHttp { .collect(); let content = decoded.content().to_vec(); let binary_http_response = BinaryHttpResponse::allocate(InitBinaryHttpResponse { - status: status.into(), + status, headers, content, }); @@ -232,8 +232,7 @@ impl BinaryHttp { fn encode_response(&self, response: &nsIBinaryHttpResponse) -> Result<ThinVec<u8>, nsresult> { let mut status = 0; unsafe { response.GetStatus(&mut status) }.to_result()?; - let mut message = - Message::response(StatusCode::try_from(status).map_err(|_| NS_ERROR_FAILURE)?); + let mut message = Message::response(status); let mut header_names = ThinVec::new(); unsafe { response.GetHeaderNames(&mut header_names) }.to_result()?; let mut header_values = ThinVec::with_capacity(header_names.len()); diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml @@ -1024,12 +1024,6 @@ who = "Mike Hommey <mh+mozilla@glandium.org>" criteria = "safe-to-deploy" delta = "0.13.0 -> 0.13.1" -[[audits.bhttp]] -who = "Mark Hammond <mhammond@skippinet.com.au>" -criteria = "safe-to-deploy" -delta = "0.6.1 -> 0.6.1@git:bf6a983845cc0b540effb3a615e92d914dfcfd0b" -importable = false - [[audits.bindgen]] who = "Emilio Cobos Álvarez <emilio@crisal.io>" criteria = "safe-to-deploy" @@ -4496,12 +4490,6 @@ criteria = "safe-to-deploy" delta = "0.33.0 -> 0.36.4" notes = "Hardly any new unsafe code, no new dependencies nor side-effectful std functions. Plenty of new tests." -[[audits.ohttp]] -who = "Mark Hammond <mhammond@skippinet.com.au>" -criteria = "safe-to-deploy" -delta = "0.6.1 -> 0.6.1@git:bf6a983845cc0b540effb3a615e92d914dfcfd0b" -importable = false - [[audits.once_cell]] who = "Mike Hommey <mh+mozilla@glandium.org>" criteria = "safe-to-deploy" diff --git a/supply-chain/config.toml b/supply-chain/config.toml @@ -31,10 +31,6 @@ notes = "This is the upstream code plus the ARM intrinsics workaround from qcms, audit-as-crates-io = true notes = "This is the upstream code plus a few local fixes, see bug 1685697." -[policy.bhttp] -audit-as-crates-io = true -notes = "This is upstream code in between released versions." - [policy."bindgen:0.72.0@git:9366e0af8da529c958b4cd4fcbe492d951c86f5c"] audit-as-crates-io = true notes = "This is the upstream code not yet released" @@ -203,10 +199,6 @@ notes = "This is a pinned version of the upstream code, pending update of the cr audit-as-crates-io = true notes = "This is the upstream code plus a backported fix." -[policy.ohttp] -audit-as-crates-io = true -notes = "This is upstream code in between released versions." - [policy.osclientcerts] audit-as-crates-io = false notes = "This is a first-party crate that happens to have been pushed to crates.io a very long time ago but was yanked." diff --git a/supply-chain/imports.lock b/supply-chain/imports.lock @@ -44,8 +44,8 @@ user-login = "jschanck" user-name = "John Schanck" [[publisher.bhttp]] -version = "0.6.1" -when = "2025-06-19" +version = "0.3.1" +when = "2023-02-23" user-id = 128763 user-login = "martinthomson" user-name = "Martin Thomson" @@ -457,8 +457,8 @@ user-login = "seanmonstar" user-name = "Sean McArthur" [[publisher.ohttp]] -version = "0.6.1" -when = "2025-06-19" +version = "0.6.0" +when = "2025-06-18" user-id = 128763 user-login = "martinthomson" user-name = "Martin Thomson" diff --git a/taskcluster/kinds/toolchain/rust.yml b/taskcluster/kinds/toolchain/rust.yml @@ -117,9 +117,6 @@ linux64-rust-1.81-dev: '--patch', 'stabilize-unsafe-attributes.patch', '--patch', 'stabilize-iter_repeat_n.patch', '--patch', 'stabilize-const_fn_floating_point_arithmetic.patch', - '--patch', 'stabilize_raw_ref_op.patch', - '--patch', 'soft_deprecate_the_addr_of_macros.patch', - '--patch', 'rename_AddressOf_to_RawBorrow_inside_the_compiler.patch', '--channel', 'dev', '--host', 'x86_64-unknown-linux-gnu', '--target', 'x86_64-unknown-linux-gnu', diff --git a/third_party/rust/bhttp/.cargo-checksum.json b/third_party/rust/bhttp/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"f67579f75f89317e8e2137cbfd59a2656692313921744089fda61c698743dc25","README.md":"30c2c4a78875fd78a6b007954ed0aceed4004983e5ff62a38261bbcd1a9c36a3","src/err.rs":"f380bc2c62cc0acc7d2a11f988b8cbd94014ae1665cdf5271165a511e7be0800","src/lib.rs":"619c1508a57222561bc4c193dafbcf88bf7685a743e99a90c44cf26874abaea2","src/parse.rs":"c759c0446c1016b412c4d294686713f296888dfa9713d9c6fa7382d4e4b5540a","src/rw.rs":"df7a0efd46e3ac0561428929bd447aef97ce380c83d2855996a0bf3a71cee0a7","tests/test.rs":"37c93b4f3e74ab474004bdc2d6688e970443ee006c4ea7101fcfcf17e8f7f880"},"package":null} -\ No newline at end of file +{"files":{"Cargo.toml":"50cee393fec5ecf4c7c34fbbaefa37c3c5a6bf6c3acee2d035ac49d691c74f16","README.md":"30c2c4a78875fd78a6b007954ed0aceed4004983e5ff62a38261bbcd1a9c36a3","src/err.rs":"0b605edff622d043c9269675c74e412f3363a04060f2921356d0afcd27987c02","src/lib.rs":"0aff5fd18b0f90f3228a8f4c643ebb679fca8c909f497cbeb2f7e18009d8e932","src/parse.rs":"a2428cf6736cb6d251bb2c95d80d84f3c3fd0197a831f94045408ac592fd7013","src/rw.rs":"a667035f34b41e2492a417d1aad6454422f6769ece578faa75205a6335449511","tests/test.rs":"ec171a6a4d469de8d4fe921872a9c0e15b27ae9ca2c19ff4e756b5941e0a8b57"},"package":"1300dca7a20730cce82c33fbf8795862556645ef5e9ee835390278c3fe1eb1d0"} +\ No newline at end of file diff --git a/third_party/rust/bhttp/Cargo.toml b/third_party/rust/bhttp/Cargo.toml @@ -11,33 +11,24 @@ [package] edition = "2021" -rust-version = "1.82.0" name = "bhttp" -version = "0.6.1" +version = "0.3.1" authors = ["Martin Thomson <mt@lowentropy.net>"] -build = false -autolib = false -autobins = false -autoexamples = false -autotests = false -autobenches = false -description = "Binary HTTP messages (RFC 9292)" -homepage = "https://github.com/martinthomson/ohttp" -readme = "../README.md" -keywords = [ - "ohttp", - "http", - "bhttp", - "ietf", -] -categories = [ - "network-programming", - "web-programming", - "security", -] +description = "Binary HTTP messages (draft-ietf-httpbis-binary-message)" +readme = "README.md" license = "MIT OR Apache-2.0" repository = "https://github.com/martinthomson/ohttp" +[dependencies.thiserror] +version = "1" + +[dependencies.url] +version = "2" +optional = true + +[dev-dependencies.hex] +version = "0.4" + [features] bhttp = [ "read-bhttp", @@ -52,21 +43,3 @@ read-bhttp = [] read-http = ["url"] write-bhttp = [] write-http = [] - -[lib] -name = "bhttp" -path = "src/lib.rs" - -[[test]] -name = "test" -path = "tests/test.rs" - -[dependencies] -thiserror = "1" - -[dependencies.url] -version = "2" -optional = true - -[dev-dependencies] -hex = "0.4" diff --git a/third_party/rust/bhttp/src/err.rs b/third_party/rust/bhttp/src/err.rs @@ -6,16 +6,10 @@ pub enum Error { ConnectUnsupported, #[error("a field contained invalid Unicode: {0}")] CharacterEncoding(#[from] std::string::FromUtf8Error), - #[error("read a response when expecting a request")] - ExpectedRequest, - #[error("read a request when expecting a response")] - ExpectedResponse, #[error("a field contained an integer value that was out of range: {0}")] IntRange(#[from] std::num::TryFromIntError), #[error("the mode of the message was invalid")] InvalidMode, - #[error("the status code of a response needs to be in 100..=599")] - InvalidStatus, #[error("IO error {0}")] Io(#[from] std::io::Error), #[error("a field or line was missing a necessary character 0x{0:x}")] diff --git a/third_party/rust/bhttp/src/lib.rs b/third_party/rust/bhttp/src/lib.rs @@ -10,7 +10,6 @@ use std::convert::TryFrom; feature = "write-bhttp" ))] use std::io; - #[cfg(feature = "read-http")] use url::Url; @@ -19,9 +18,6 @@ mod parse; #[cfg(any(feature = "read-bhttp", feature = "write-bhttp"))] mod rw; -#[cfg(any(feature = "read-http", feature = "read-bhttp",))] -use std::borrow::BorrowMut; - pub use err::Error; #[cfg(any( feature = "read-http", @@ -37,6 +33,8 @@ use parse::{index_of, trim_ows, COMMA}; use rw::{read_varint, read_vec}; #[cfg(feature = "write-bhttp")] use rw::{write_len, write_varint, write_vec}; +#[cfg(any(feature = "read-http", feature = "read-bhttp",))] +use std::borrow::BorrowMut; #[cfg(feature = "read-http")] const CONTENT_LENGTH: &[u8] = b"content-length"; @@ -45,48 +43,7 @@ const COOKIE: &[u8] = b"cookie"; const TRANSFER_ENCODING: &[u8] = b"transfer-encoding"; const CHUNKED: &[u8] = b"chunked"; -#[derive(Clone, Copy, PartialEq, Eq)] -pub struct StatusCode(u16); - -impl StatusCode { - pub const OK: Self = StatusCode(200); - - #[must_use] - pub fn informational(self) -> bool { - matches!(self.0, 100..=199) - } - - #[must_use] - pub fn code(self) -> u16 { - self.0 - } -} - -impl TryFrom<u64> for StatusCode { - type Error = Error; - - fn try_from(value: u64) -> Result<Self, Self::Error> { - Self::try_from(u16::try_from(value).map_err(|_| Error::InvalidStatus)?) - } -} - -impl TryFrom<u16> for StatusCode { - type Error = Error; - - fn try_from(value: u16) -> Result<Self, Self::Error> { - if matches!(value, 100..=599) { - Ok(Self(value)) - } else { - Err(Error::InvalidStatus) - } - } -} - -impl From<StatusCode> for u16 { - fn from(value: StatusCode) -> Self { - value.code() - } -} +pub type StatusCode = u16; pub trait ReadSeek: io::BufRead + io::Seek {} impl<T> ReadSeek for io::Cursor<T> where T: AsRef<[u8]> {} @@ -96,7 +53,7 @@ impl<T> ReadSeek for io::BufReader<T> where T: io::Read + io::Seek {} #[cfg(any(feature = "read-bhttp", feature = "write-bhttp"))] pub enum Mode { KnownLength, - IndeterminateLength, + IndefiniteLength, } pub struct Field { @@ -429,7 +386,7 @@ impl ControlData { if index_of(SLASH, &a).is_some() { // Probably a response, so treat it as such. let status_str = String::from_utf8(b)?; - let code = StatusCode::try_from(status_str.parse::<u64>()?)?; + let code = status_str.parse::<u16>()?; Ok(Self::Response(code)) } else if index_of(COLON, &b).is_some() { // Now try to parse the URL. @@ -485,9 +442,7 @@ impl ControlData { path, } } else { - Self::Response(StatusCode::try_from( - read_varint(r)?.ok_or(Error::Truncated)?, - )?) + Self::Response(u16::try_from(read_varint(r)?.ok_or(Error::Truncated)?)?) }; Ok(v) } @@ -497,7 +452,7 @@ impl ControlData { #[must_use] fn informational(&self) -> Option<StatusCode> { match self { - Self::Response(v) if v.informational() => Some(*v), + Self::Response(v) if *v >= 100 && *v < 200 => Some(*v), _ => None, } } @@ -508,8 +463,8 @@ impl ControlData { match (self, mode) { (Self::Request { .. }, Mode::KnownLength) => 0, (Self::Response(_), Mode::KnownLength) => 1, - (Self::Request { .. }, Mode::IndeterminateLength) => 2, - (Self::Response(_), Mode::IndeterminateLength) => 3, + (Self::Request { .. }, Mode::IndefiniteLength) => 2, + (Self::Response(_), Mode::IndefiniteLength) => 3, } } @@ -527,7 +482,7 @@ impl ControlData { write_vec(authority, w)?; write_vec(path, w)?; } - Self::Response(status) => write_varint(status.code(), w)?, + Self::Response(status) => write_varint(*status, w)?, } Ok(()) } @@ -552,7 +507,7 @@ impl ControlData { w.write_all(b" HTTP/1.1\r\n")?; } Self::Response(status) => { - let buf = format!("HTTP/1.1 {} Reason\r\n", status.code()); + let buf = format!("HTTP/1.1 {} Reason\r\n", *status); w.write_all(buf.as_bytes())?; } } @@ -583,7 +538,7 @@ impl InformationalResponse { #[cfg(feature = "write-bhttp")] fn write_bhttp(&self, mode: Mode, w: &mut impl io::Write) -> Res<()> { - write_varint(self.status.code(), w)?; + write_varint(self.status, w)?; self.fields.write_bhttp(mode, w)?; Ok(()) } @@ -705,31 +660,30 @@ impl Message { let mut header = FieldSection::read_http(r)?; - let (content, trailer) = - if matches!(control.status().map(StatusCode::code), Some(204 | 304)) { - // 204 and 304 have no body, no matter what Content-Length says. - // Unfortunately, we can't do the same for responses to HEAD. - (Vec::new(), FieldSection::default()) - } else if header.is_chunked() { - let content = Self::read_chunked(r)?; - let trailer = FieldSection::read_http(r)?; - (content, trailer) - } else { - let mut content = Vec::new(); - if let Some(cl) = header.get(CONTENT_LENGTH) { - let cl_str = String::from_utf8(Vec::from(cl))?; - let cl_int = cl_str.parse::<usize>()?; - if cl_int > 0 { - content.resize(cl_int, 0); - r.borrow_mut().read_exact(&mut content)?; - } - } else { - // Note that for a request, the spec states that the content is - // empty, but this just reads all input like for a response. - r.borrow_mut().read_to_end(&mut content)?; + let (content, trailer) = if matches!(control.status(), Some(204) | Some(304)) { + // 204 and 304 have no body, no matter what Content-Length says. + // Unfortunately, we can't do the same for responses to HEAD. + (Vec::new(), FieldSection::default()) + } else if header.is_chunked() { + let content = Self::read_chunked(r)?; + let trailer = FieldSection::read_http(r)?; + (content, trailer) + } else { + let mut content = Vec::new(); + if let Some(cl) = header.get(CONTENT_LENGTH) { + let cl_str = String::from_utf8(Vec::from(cl))?; + let cl_int = cl_str.parse::<usize>()?; + if cl_int > 0 { + content.resize(cl_int, 0); + r.borrow_mut().read_exact(&mut content)?; } - (content, FieldSection::default()) - }; + } else { + // Note that for a request, the spec states that the content is + // empty, but this just reads all input like for a response. + r.borrow_mut().read_to_end(&mut content)?; + } + (content, FieldSection::default()) + }; header.strip_connection_headers(); Ok(Self { @@ -780,7 +734,7 @@ impl Message { let request = t == 0 || t == 2; let mode = match t { 0 | 1 => Mode::KnownLength, - 2 | 3 => Mode::IndeterminateLength, + 2 | 3 => Mode::IndefiniteLength, _ => return Err(Error::InvalidMode), }; @@ -794,7 +748,7 @@ impl Message { let header = FieldSection::read_bhttp(mode, r)?; let mut content = read_vec(r)?.unwrap_or_default(); - if mode == Mode::IndeterminateLength && !content.is_empty() { + if mode == Mode::IndefiniteLength && !content.is_empty() { loop { let mut extra = read_vec(r)?.unwrap_or_default(); if extra.is_empty() { @@ -825,7 +779,7 @@ impl Message { self.header.write_bhttp(mode, w)?; write_vec(&self.content, w)?; - if mode == Mode::IndeterminateLength && !self.content.is_empty() { + if mode == Mode::IndefiniteLength && !self.content.is_empty() { write_len(0, w)?; } self.trailer.write_bhttp(mode, w)?; diff --git a/third_party/rust/bhttp/src/parse.rs b/third_party/rust/bhttp/src/parse.rs @@ -56,7 +56,7 @@ pub fn index_of(v: u8, line: &[u8]) -> Option<usize> { pub fn split_at(v: u8, mut line: Vec<u8>) -> Option<(Vec<u8>, Vec<u8>)> { index_of(v, &line).map(|i| { let tail = line.split_off(i + 1); - _ = line.pop(); + let _ = line.pop(); (line, tail) }) } diff --git a/third_party/rust/bhttp/src/rw.rs b/third_party/rust/bhttp/src/rw.rs @@ -1,17 +1,18 @@ -#[cfg(feature = "read-bhttp")] -use std::borrow::BorrowMut; -use std::{convert::TryFrom, io}; - use crate::err::Res; #[cfg(feature = "read-bhttp")] use crate::{err::Error, ReadSeek}; +#[cfg(feature = "read-bhttp")] +use std::borrow::BorrowMut; +use std::{convert::TryFrom, io}; #[cfg(feature = "write-bhttp")] #[allow(clippy::cast_possible_truncation)] -pub(crate) fn write_uint<const N: usize>(v: impl Into<u64>, w: &mut impl io::Write) -> Res<()> { - let v = v.into().to_be_bytes(); - assert!((1..=std::mem::size_of::<u64>()).contains(&N)); - w.write_all(&v[std::mem::size_of::<u64>() - N..])?; +fn write_uint(n: u8, v: impl Into<u64>, w: &mut impl io::Write) -> Res<()> { + let v = v.into(); + assert!(n > 0 && usize::from(n) < std::mem::size_of::<u64>()); + for i in 0..n { + w.write_all(&[((v >> (8 * (n - i - 1))) & 0xff) as u8])?; + } Ok(()) } @@ -19,11 +20,11 @@ pub(crate) fn write_uint<const N: usize>(v: impl Into<u64>, w: &mut impl io::Wri pub fn write_varint(v: impl Into<u64>, w: &mut impl io::Write) -> Res<()> { let v = v.into(); match () { - () if v < (1 << 6) => write_uint::<1>(v, w), - () if v < (1 << 14) => write_uint::<2>(v | (1 << 14), w), - () if v < (1 << 30) => write_uint::<4>(v | (2 << 30), w), - () if v < (1 << 62) => write_uint::<8>(v | (3 << 62), w), - () => panic!("varint value too large"), + _ if v < (1 << 6) => write_uint(1, v, w), + _ if v < (1 << 14) => write_uint(2, v | (1 << 14), w), + _ if v < (1 << 30) => write_uint(4, v | (2 << 30), w), + _ if v < (1 << 62) => write_uint(8, v | (3 << 62), w), + _ => panic!("Varint value too large"), } } @@ -48,16 +49,15 @@ where let mut buf = [0; 7]; let count = r.borrow_mut().read(&mut buf[..n])?; if count == 0 { - Ok(None) + return Ok(None); } else if count < n { - Err(Error::Truncated) - } else { - let mut v = 0; - for i in &buf[..n] { - v = (v << 8) | u64::from(*i); - } - Ok(Some(v)) + return Err(Error::Truncated); + } + let mut v = 0; + for i in &buf[..n] { + v = (v << 8) | u64::from(*i); } + Ok(Some(v)) } #[cfg(feature = "read-bhttp")] @@ -95,7 +95,7 @@ where if end - pos < len { return Err(Error::Truncated); } - _ = r.seek(SeekFrom::Start(pos))?; + let _ = r.seek(SeekFrom::Start(pos))?; let mut v = vec![0; usize::try_from(len)?]; r.read_exact(&mut v)?; @@ -104,67 +104,3 @@ where Ok(None) } } - -#[cfg(test)] -mod test { - use std::io::Cursor; - - use super::{read_varint, write_varint}; - use crate::{rw::read_vec, Error}; - - #[test] - fn basics() { - for i in [ - 0_u64, - 1, - 17, - 63, - 64, - 100, - 0x3fff, - 0x4000, - 0x1_0002, - 0x3fff_ffff, - 0x4000_0000, - 0x3456_dead_beef, - 0x3fff_ffff_ffff_ffff, - ] { - let mut buf = Vec::new(); - write_varint(i, &mut buf).unwrap(); - let sz_bytes = (64 - i.leading_zeros() + 2).div_ceil(8); // +2 size bits, rounded up - assert_eq!( - buf.len(), - usize::try_from(sz_bytes.next_power_of_two()).unwrap() - ); - - let o = read_varint(&mut Cursor::new(buf.clone())).unwrap(); - assert_eq!(Some(i), o); - - for cut in 1..buf.len() { - let e = read_varint(&mut Cursor::new(buf[..cut].to_vec())).unwrap_err(); - assert!(matches!(e, Error::Truncated)); - } - } - } - - #[test] - fn read_nothing() { - let o = read_varint(&mut Cursor::new(Vec::new())).unwrap(); - assert!(o.is_none()); - } - - #[test] - #[should_panic(expected = "varint value too large")] - fn too_big() { - std::mem::drop(write_varint(0x4000_0000_0000_0000_u64, &mut Vec::new())); - } - - #[test] - fn too_big_vec() { - let mut buf = Vec::new(); - write_varint(10_u64, &mut buf).unwrap(); - buf.resize(10, 0); // Not enough extra for the promised length. - let e = read_vec(&mut Cursor::new(buf.clone())).unwrap_err(); - assert!(matches!(e, Error::Truncated)); - } -} diff --git a/third_party/rust/bhttp/tests/test.rs b/third_party/rust/bhttp/tests/test.rs @@ -1,9 +1,8 @@ // Rather than grapple with #[cfg(...)] for every variable and import. #![cfg(all(feature = "http", feature = "bhttp"))] -use std::{io::Cursor, mem::drop}; - use bhttp::{Error, Message, Mode}; +use std::{io::Cursor, mem::drop}; const CHUNKED_HTTP: &[u8] = b"HTTP/1.1 200 OK\r\n\ Transfer-Encoding: camel, chunked\r\n\ @@ -24,7 +23,7 @@ const CHUNKED_KNOWN: &[u8] = &[ 0x74, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73, 0x20, 0x43, 0x52, 0x4c, 0x46, 0x2e, 0x0d, 0x0a, 0x0d, 0x07, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x65, 0x72, 0x04, 0x74, 0x65, 0x78, 0x74, ]; -const CHUNKED_INDETERMINATE: &[u8] = &[ +const CHUNKED_INDEFINITE: &[u8] = &[ 0x03, 0x40, 0xc8, 0x00, 0x1d, 0x54, 0x68, 0x69, 0x73, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73, 0x20, 0x43, 0x52, 0x4c, 0x46, 0x2e, 0x0d, 0x0a, 0x00, 0x07, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x65, 0x72, 0x04, 0x74, 0x65, 0x78, 0x74, @@ -59,8 +58,8 @@ fn chunked_read_known() { } #[test] -fn chunked_read_indeterminate() { - drop(Message::read_bhttp(&mut Cursor::new(CHUNKED_INDETERMINATE)).unwrap()); +fn chunked_read_indefinite() { + drop(Message::read_bhttp(&mut Cursor::new(CHUNKED_INDEFINITE)).unwrap()); } #[test] @@ -75,14 +74,14 @@ fn chunked_to_known() { } #[test] -fn chunked_to_indeterminate() { +fn chunked_to_indefinite() { let m = Message::read_http(&mut Cursor::new(CHUNKED_HTTP)).unwrap(); assert!(m.header().get(TRANSFER_ENCODING).is_none()); let mut buf = Vec::new(); - m.write_bhttp(Mode::IndeterminateLength, &mut buf).unwrap(); + m.write_bhttp(Mode::IndefiniteLength, &mut buf).unwrap(); println!("result: {}", hex::encode(&buf)); - assert_eq!(&buf[..], CHUNKED_INDETERMINATE); + assert_eq!(&buf[..], CHUNKED_INDEFINITE); } #[test] @@ -138,7 +137,7 @@ fn tiny_response() { const RESPONSE: &[u8] = &[0x01, 0x40, 0xc8]; let m = Message::read_bhttp(&mut Cursor::new(RESPONSE)).unwrap(); assert!(m.informational().is_empty()); - assert_eq!(m.control().status().unwrap().code(), 200); + assert_eq!(m.control().status().unwrap(), 200); assert!(m.control().method().is_none()); assert!(m.control().scheme().is_none()); assert!(m.control().authority().is_none()); diff --git a/third_party/rust/ohttp/.cargo-checksum.json b/third_party/rust/ohttp/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"74baeadbe2810a83b2e49bab9ea7069bc033873b83a9e8cee16adee94bba73d6","README.md":"ca2de60828b7ec7d80729fd3e064cd8e08e3a72a94a50f29b7f4bd23b044fdbd","bindings/bindings.toml":"a016870127b63151e760c964d687934a4883ee165bdd9718341c8dd50be5a3f2","bindings/nspr_err.h":"2d5205d017b536c2d838bcf9bc4ec79f96dd50e7bb9b73892328781f1ee6629d","bindings/nspr_error.h":"e41c03c77b8c22046f8618832c9569fbcc7b26d8b9bbc35eea7168f35e346889","bindings/nss_init.h":"cd4dffd0c629ece5786736dd6d26db8a96f56fd56ef95b150c623c41080c2f9e","bindings/nss_p11.h":"a16f60d0210d5823f2d92d0c04988a0bb1da85901388490cb3e755a62cc7d5dd","bindings/nss_secerr.h":"713e8368bdae5159af7893cfa517dabfe5103cede051dee9c9557c850a2defc6","build.rs":"4a107baae67552e72f4db35a6dfdcef2101ff38350130f33ff37c882f542b934","src/config.rs":"bea6c3af58f3d03e9c06fa008523c57b6ea71a3c37a575823719418ea50e2072","src/err.rs":"f94da3b7d148e491471d5b6b0d450597b5e3ea05126576352b2879b446ff1430","src/hpke.rs":"d09e673a967f76e59f0b9c9d4c8ad25a9cf1f580dc7ebbdcbefc03f30e0642e7","src/lib.rs":"bfc972343aa3fa6707b0aaea04c25f1b6fa2ff3f9e9761ae6a09f9be52fce214","src/nss/aead.rs":"4bab67456c774f557035c01f5fb10be61f76c95ce4d7773d599268dba4527ec2","src/nss/err.rs":"d367116bf9840ebe06d358066a1755f7d9936438dbc2e4e71a6b345d05e4bcd5","src/nss/hkdf.rs":"fe66619f75affd4b812494c1433411b382a49b4bfbad5c0ac4deea89fea8065b","src/nss/hpke.rs":"e9dc855fa5c91a57d86c32859ab2f5e0c6f51bb2e97ac5710a5ce5152e1f2082","src/nss/mod.rs":"0308592fbc48ecf7cd13a92f2b0cea29fbcd9b8082586cee21d36329bf71042a","src/nss/p11.rs":"f6e68fe5a81271db63fd11e601bc83e5dca3b589064b528bc50403eaccf8c627","src/rand.rs":"be3a82fb6090b5cb833c2b8ba6e72690b9f44f7f91477e2c5b70b75623174b87","src/rh/aead.rs":"88dd43ffec20a8870a424d27dbda0a9db74f4b3d1b03097220854a304ab091cd","src/rh/hkdf.rs":"4c6e59ca24498939e9b8da2da6336ae2f62396101f1b9b25f1ae587ab21c1a9d","src/rh/hpke.rs":"0de3fd7a12ff551308a5ce6ad04cf077296571c265ddd3083d62b2bf7e51f70d","src/rh/mod.rs":"850772462778a74fd7402b4bb765ad57011b02729e6aa1bb3236afd490e5c3a4"},"package":null} -\ No newline at end of file +{"files":{"Cargo.lock":"622e3baf2dfa2877383d36bfa4533f6f25503bfadc8a4a8dc575a349d5431979","Cargo.toml":"5260b29fc57caee665b6454d4d7b7e478e7a01699886c11cab3f0bba89f353c1","README.md":"ca2de60828b7ec7d80729fd3e064cd8e08e3a72a94a50f29b7f4bd23b044fdbd","bindings/bindings.toml":"a016870127b63151e760c964d687934a4883ee165bdd9718341c8dd50be5a3f2","bindings/nspr_err.h":"2d5205d017b536c2d838bcf9bc4ec79f96dd50e7bb9b73892328781f1ee6629d","bindings/nspr_error.h":"e41c03c77b8c22046f8618832c9569fbcc7b26d8b9bbc35eea7168f35e346889","bindings/nss_init.h":"cd4dffd0c629ece5786736dd6d26db8a96f56fd56ef95b150c623c41080c2f9e","bindings/nss_p11.h":"a16f60d0210d5823f2d92d0c04988a0bb1da85901388490cb3e755a62cc7d5dd","bindings/nss_secerr.h":"713e8368bdae5159af7893cfa517dabfe5103cede051dee9c9557c850a2defc6","build.rs":"4a107baae67552e72f4db35a6dfdcef2101ff38350130f33ff37c882f542b934","src/config.rs":"bea6c3af58f3d03e9c06fa008523c57b6ea71a3c37a575823719418ea50e2072","src/err.rs":"533b382c7e74906521395fdff4b514981535fe1b45b307528c547bb545765adf","src/hpke.rs":"b98b3a1d2e87bd89d43d89e2513e2d3211832aef3fd2157337939186aa7c8531","src/lib.rs":"bfc972343aa3fa6707b0aaea04c25f1b6fa2ff3f9e9761ae6a09f9be52fce214","src/nss/aead.rs":"1c7982c7020eaa573fe5b9b713ec8134057269a9c369b9632040ebfad562befa","src/nss/err.rs":"d367116bf9840ebe06d358066a1755f7d9936438dbc2e4e71a6b345d05e4bcd5","src/nss/hkdf.rs":"fe66619f75affd4b812494c1433411b382a49b4bfbad5c0ac4deea89fea8065b","src/nss/hpke.rs":"cbd353d2f0c8db82fcf25dac2f2d2554e8a6258c4b21e0279e618fb2f992c49c","src/nss/mod.rs":"0308592fbc48ecf7cd13a92f2b0cea29fbcd9b8082586cee21d36329bf71042a","src/nss/p11.rs":"e3404eb484906fd7fa97f91cc8740f6660f9a064d229c5d16b6a74efa37ecfee","src/rand.rs":"be3a82fb6090b5cb833c2b8ba6e72690b9f44f7f91477e2c5b70b75623174b87","src/rh/aead.rs":"88dd43ffec20a8870a424d27dbda0a9db74f4b3d1b03097220854a304ab091cd","src/rh/hkdf.rs":"4c6e59ca24498939e9b8da2da6336ae2f62396101f1b9b25f1ae587ab21c1a9d","src/rh/hpke.rs":"1eff4bb08f3d6ac6fb0cc75e1c05785e58d5c0a436227d0b0e48ead6b5ed77ed","src/rh/mod.rs":"850772462778a74fd7402b4bb765ad57011b02729e6aa1bb3236afd490e5c3a4"},"package":"a4a87f4e4cd78d1619b98b6119cde887d20489f70339b9425af080b00db714b6"} +\ No newline at end of file diff --git a/third_party/rust/ohttp/Cargo.lock b/third_party/rust/ohttp/Cargo.lock @@ -0,0 +1,1013 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aead" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" +dependencies = [ + "generic-array", + "rand_core", +] + +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common", + "generic-array", +] + +[[package]] +name = "aes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +dependencies = [ + "cfg-if", + "cipher 0.3.0", + "cpufeatures 0.2.17", + "opaque-debug", +] + +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if", + "cipher 0.4.4", + "cpufeatures 0.2.17", +] + +[[package]] +name = "aes-gcm" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc3be92e19a7ef47457b8e6f90707e12b6ac5d20c6f3866584fa3be0787d839f" +dependencies = [ + "aead 0.4.3", + "aes 0.7.5", + "cipher 0.3.0", + "ctr 0.7.0", + "ghash 0.4.4", + "subtle", +] + +[[package]] +name = "aes-gcm" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" +dependencies = [ + "aead 0.5.2", + "aes 0.8.4", + "cipher 0.4.4", + "ctr 0.9.2", + "ghash 0.5.1", + "subtle", +] + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "bindgen" +version = "0.69.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "itertools", + "lazy_static", + "lazycell", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn", +] + +[[package]] +name = "bitflags" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chacha20" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fee7ad89dc1128635074c268ee661f90c3f7e83d9fd12910608c36b47d6c3412" +dependencies = [ + "cfg-if", + "cipher 0.3.0", + "cpufeatures 0.1.5", + "zeroize", +] + +[[package]] +name = "chacha20" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" +dependencies = [ + "cfg-if", + "cipher 0.4.4", + "cpufeatures 0.2.17", +] + +[[package]] +name = "chacha20poly1305" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1580317203210c517b6d44794abfbe600698276db18127e37ad3e69bf5e848e5" +dependencies = [ + "aead 0.4.3", + "chacha20 0.7.1", + "cipher 0.3.0", + "poly1305 0.7.2", + "zeroize", +] + +[[package]] +name = "chacha20poly1305" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" +dependencies = [ + "aead 0.5.2", + "chacha20 0.9.1", + "cipher 0.4.4", + "poly1305 0.8.0", + "zeroize", +] + +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", + "zeroize", +] + +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "cpufeatures" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" +dependencies = [ + "libc", +] + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "rand_core", + "typenum", +] + +[[package]] +name = "crypto-mac" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25fab6889090c8133f3deb8f73ba3c65a7f456f66436fc012a1b1e272b1e103e" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "ctr" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a232f92a03f37dd7d7dd2adc67166c77e9cd88de5b019b9a9eecfaeaf7bfd481" +dependencies = [ + "cipher 0.3.0", +] + +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher 0.4.4", +] + +[[package]] +name = "curve25519-dalek" +version = "4.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "curve25519-dalek-derive", + "fiat-crypto", + "rustc_version", + "subtle", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common", + "subtle", +] + +[[package]] +name = "either" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7914353092ddf589ad78f25c5c1c21b7f80b0ff8621e7c814c3485b5306da9d" + +[[package]] +name = "env_logger" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" +dependencies = [ + "log", +] + +[[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "ghash" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" +dependencies = [ + "opaque-debug", + "polyval 0.5.3", +] + +[[package]] +name = "ghash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1" +dependencies = [ + "opaque-debug", + "polyval 0.6.2", +] + +[[package]] +name = "glob" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hkdf" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01706d578d5c281058480e673ae4086a9f4710d8df1ad80a5b03e39ece5f886b" +dependencies = [ + "digest 0.9.0", + "hmac 0.11.0", +] + +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac 0.12.1", +] + +[[package]] +name = "hmac" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +dependencies = [ + "crypto-mac", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "hpke" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e04a5933a381bb81f00b083fce6b4528e16d735dbeecbb2bdb45e0dbbf3f7e17" +dependencies = [ + "aead 0.5.2", + "aes-gcm 0.10.3", + "byteorder", + "chacha20poly1305 0.10.1", + "digest 0.10.7", + "generic-array", + "hkdf 0.12.4", + "hmac 0.12.1", + "rand_core", + "sha2 0.10.8", + "subtle", + "x25519-dalek", + "zeroize", +] + +[[package]] +name = "hpke_pq" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8b405447b60d50d27aaaba4fb6d7888d63868dcc4f3409bf6c4250360de07ba" +dependencies = [ + "aead 0.5.2", + "aes-gcm 0.10.3", + "byteorder", + "chacha20poly1305 0.10.1", + "digest 0.10.7", + "generic-array", + "hkdf 0.12.4", + "hmac 0.12.1", + "rand_core", + "safe_pqc_kyber", + "sha2 0.10.8", + "subtle", + "x25519-dalek", + "zeroize", +] + +[[package]] +name = "inout" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" +dependencies = [ + "generic-array", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.2.170" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" + +[[package]] +name = "libloading" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" +dependencies = [ + "cfg-if", + "windows-targets", +] + +[[package]] +name = "log" +version = "0.4.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "mozbuild" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "903970ae2f248d7275214cf8f387f8ba0c4ea7e3d87a320e85493db60ce28616" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "ohttp" +version = "0.6.0" +dependencies = [ + "aead 0.4.3", + "aes-gcm 0.9.2", + "bindgen", + "byteorder", + "chacha20poly1305 0.8.0", + "env_logger", + "hex", + "hkdf 0.11.0", + "hpke", + "hpke_pq", + "log", + "mozbuild", + "rand", + "regex", + "serde", + "serde_derive", + "sha2 0.9.9", + "thiserror", + "toml", +] + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "poly1305" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" +dependencies = [ + "cpufeatures 0.2.17", + "opaque-debug", + "universal-hash 0.4.0", +] + +[[package]] +name = "poly1305" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" +dependencies = [ + "cpufeatures 0.2.17", + "opaque-debug", + "universal-hash 0.5.1", +] + +[[package]] +name = "polyval" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "opaque-debug", + "universal-hash 0.4.0", +] + +[[package]] +name = "polyval" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "opaque-debug", + "universal-hash 0.5.1", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "safe_pqc_kyber" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "108c4ad7fe882cbb078ff40de415658e9d827f636e4fb17e7d5a97503a9aceaf" +dependencies = [ + "rand_core", +] + +[[package]] +name = "semver" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f79dfe2d285b0488816f30e700a7438c5a73d816b5b7d3ac72fbc48b0d185e03" + +[[package]] +name = "serde" +version = "1.0.218" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.218" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures 0.2.17", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "digest 0.10.7", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "typenum" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" + +[[package]] +name = "unicode-ident" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe" + +[[package]] +name = "universal-hash" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common", + "subtle", +] + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "x25519-dalek" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" +dependencies = [ + "curve25519-dalek", + "rand_core", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/third_party/rust/ohttp/Cargo.toml b/third_party/rust/ohttp/Cargo.toml @@ -11,9 +11,9 @@ [package] edition = "2021" -rust-version = "1.82.0" +rust-version = "1.81.0" name = "ohttp" -version = "0.6.1" +version = "0.6.0" authors = ["Martin Thomson <mt@lowentropy.net>"] build = "build.rs" autolib = false @@ -23,7 +23,7 @@ autotests = false autobenches = false description = "Oblivious HTTP" homepage = "https://github.com/martinthomson/ohttp" -readme = "../README.md" +readme = "README.md" keywords = [ "ohttp", "http", @@ -52,6 +52,7 @@ gecko = [ "mozbuild", ] nss = ["bindgen"] +pq = ["hpke-pq"] rust-hpke = [ "rand", "aead", @@ -68,11 +69,6 @@ unsafe-print-secrets = [] name = "ohttp" path = "src/lib.rs" -[dependencies] -byteorder = "1.4" -hex = "0.4" -thiserror = "1" - [dependencies.aead] version = "0.4" features = ["std"] @@ -82,10 +78,16 @@ optional = true version = "0.9" optional = true +[dependencies.byteorder] +version = "1.4" + [dependencies.chacha20poly1305] version = "0.8" optional = true +[dependencies.hex] +version = "0.4" + [dependencies.hkdf] version = "0.11" optional = true @@ -99,6 +101,17 @@ features = [ optional = true default-features = false +[dependencies.hpke-pq] +version = "0.11.0" +features = [ + "std", + "x25519", + "xyber768d00", +] +optional = true +default-features = false +package = "hpke_pq" + [dependencies.log] version = "0.4" default-features = false @@ -115,17 +128,15 @@ optional = true version = "0.9" optional = true +[dependencies.thiserror] +version = "1" + [dev-dependencies.env_logger] version = "0.10" default-features = false -[build-dependencies] -serde = "1.0" -serde_derive = "1.0" -toml = "0.5" - [build-dependencies.bindgen] -version = "0.72" +version = "0.69" features = ["runtime"] optional = true default-features = false @@ -133,3 +144,12 @@ default-features = false [build-dependencies.mozbuild] version = "0.1" optional = true + +[build-dependencies.serde] +version = "1.0" + +[build-dependencies.serde_derive] +version = "1.0" + +[build-dependencies.toml] +version = "0.5" diff --git a/third_party/rust/ohttp/src/err.rs b/third_party/rust/ohttp/src/err.rs @@ -10,9 +10,12 @@ pub enum Error { Crypto(#[from] crate::nss::Error), #[error("an error was found in the format")] Format, - #[cfg(feature = "rust-hpke")] + #[cfg(all(feature = "rust-hpke", not(feature = "pq")))] #[error("a problem occurred with HPKE: {0}")] Hpke(#[from] ::hpke::HpkeError), + #[cfg(all(feature = "rust-hpke", feature = "pq"))] + #[error("a problem occurred with HPKE: {0}")] + Hpke(#[from] ::hpke_pq::HpkeError), #[error("an internal error occurred")] Internal, #[error("the wrong type of key was provided for the selected KEM")] diff --git a/third_party/rust/ohttp/src/hpke.rs b/third_party/rust/ohttp/src/hpke.rs @@ -32,6 +32,9 @@ macro_rules! convert_enum { convert_enum! { pub enum Kem { X25519Sha256 = 32, + + #[cfg(feature = "pq")] + X25519Kyber768Draft00 = 48, } } @@ -40,6 +43,9 @@ impl Kem { pub fn n_enc(self) -> usize { match self { Kem::X25519Sha256 => 32, + + #[cfg(feature = "pq")] + Kem::X25519Kyber768Draft00 => 1120, } } @@ -47,6 +53,9 @@ impl Kem { pub fn n_pk(self) -> usize { match self { Kem::X25519Sha256 => 32, + + #[cfg(feature = "pq")] + Kem::X25519Kyber768Draft00 => 1216, } } } diff --git a/third_party/rust/ohttp/src/nss/aead.rs b/third_party/rust/ohttp/src/nss/aead.rs @@ -1,11 +1,3 @@ -use std::{ - convert::{TryFrom, TryInto}, - mem, - os::raw::c_int, -}; - -use log::trace; - use super::{ err::secstatus_to_res, p11::{ @@ -21,6 +13,12 @@ use crate::{ err::{Error, Res}, hpke::Aead as AeadId, }; +use log::trace; +use std::{ + convert::{TryFrom, TryInto}, + mem, + os::raw::c_int, +}; /// All the nonces are the same length. Exploit that. pub const NONCE_LEN: usize = 12; @@ -145,7 +143,7 @@ impl Aead { aad.as_ptr(), c_int_len(aad.len()), ct.as_mut_ptr(), - &raw mut ct_len, + &mut ct_len, c_int_len(ct.len()), // signed :( tag.as_mut_ptr(), c_int_len(tag.len()), @@ -178,7 +176,7 @@ impl Aead { aad.as_ptr(), c_int_len(aad.len()), pt.as_mut_ptr(), - &raw mut pt_len, + &mut pt_len, c_int_len(pt.len()), // signed :( ct.as_ptr().add(pt_expected).cast_mut(), // const cast :( c_int_len(TAG_LEN), diff --git a/third_party/rust/ohttp/src/nss/hpke.rs b/third_party/rust/ohttp/src/nss/hpke.rs @@ -1,3 +1,10 @@ +use super::{ + super::hpke::{Aead, Kdf, Kem}, + err::{sec::SEC_ERROR_INVALID_ARGS, secstatus_to_res, Error}, + p11::{sys, Item, PrivateKey, PublicKey, Slot, SymKey}, +}; +use crate::err::Res; +use log::{log_enabled, trace}; use std::{ convert::TryFrom, ops::Deref, @@ -5,16 +12,8 @@ use std::{ ptr::{addr_of_mut, null, null_mut}, }; -use log::{log_enabled, trace}; pub use sys::{HpkeAeadId as AeadId, HpkeKdfId as KdfId, HpkeKemId as KemId}; -use super::{ - super::hpke::{Aead, Kdf, Kem}, - err::{sec::SEC_ERROR_INVALID_ARGS, secstatus_to_res, Error}, - p11::{sys, Item, PrivateKey, PublicKey, Slot, SymKey}, -}; -use crate::err::Res; - /// Configuration for `Hpke`. #[derive(Clone, Copy)] pub struct Config { @@ -97,7 +96,7 @@ impl Exporter for HpkeContext { self.ptr, &Item::wrap(info), c_uint::try_from(len).unwrap(), - &raw mut out, + &mut out, ) })?; SymKey::from_ptr(out) @@ -139,12 +138,7 @@ impl HpkeS { pub fn seal(&mut self, aad: &[u8], pt: &[u8]) -> Res<Vec<u8>> { let mut out: *mut sys::SECItem = null_mut(); secstatus_to_res(unsafe { - sys::PK11_HPKE_Seal( - *self.context, - &Item::wrap(aad), - &Item::wrap(pt), - &raw mut out, - ) + sys::PK11_HPKE_Seal(*self.context, &Item::wrap(aad), &Item::wrap(pt), &mut out) })?; let v = Item::from_ptr(out)?; Ok(unsafe { v.into_vec() }) @@ -209,7 +203,7 @@ impl HpkeR { *context, k.as_ptr(), c_uint::try_from(k.len()).unwrap(), - &raw mut ptr, + &mut ptr, ) })?; PublicKey::from_ptr(ptr) @@ -218,12 +212,7 @@ impl HpkeR { pub fn open(&mut self, aad: &[u8], ct: &[u8]) -> Res<Vec<u8>> { let mut out: *mut sys::SECItem = null_mut(); secstatus_to_res(unsafe { - sys::PK11_HPKE_Open( - *self.context, - &Item::wrap(aad), - &Item::wrap(ct), - &raw mut out, - ) + sys::PK11_HPKE_Open(*self.context, &Item::wrap(aad), &Item::wrap(ct), &mut out) })?; let v = Item::from_ptr(out)?; Ok(unsafe { v.into_vec() }) @@ -267,7 +256,7 @@ pub fn generate_key_pair(kem: Kem) -> Res<(PrivateKey, PublicKey)> { *slot, sys::CK_MECHANISM_TYPE::from(sys::CKM_EC_KEY_PAIR_GEN), addr_of_mut!(wrapped).cast(), - &raw mut public_ptr, + &mut public_ptr, sys::PK11_ATTR_SESSION | sys::PK11_ATTR_INSENSITIVE | sys::PK11_ATTR_PUBLIC, sys::CK_FLAGS::from(sys::CKF_DERIVE), sys::CK_FLAGS::from(sys::CKF_DERIVE), @@ -284,7 +273,7 @@ pub fn generate_key_pair(kem: Kem) -> Res<(PrivateKey, PublicKey)> { *slot, sys::CK_MECHANISM_TYPE::from(sys::CKM_EC_KEY_PAIR_GEN), addr_of_mut!(wrapped).cast(), - &raw mut public_ptr, + &mut public_ptr, sys::PK11_ATTR_SESSION | sys::PK11_ATTR_SENSITIVE | sys::PK11_ATTR_PRIVATE, sys::CK_FLAGS::from(sys::CKF_DERIVE), sys::CK_FLAGS::from(sys::CKF_DERIVE), @@ -297,7 +286,7 @@ pub fn generate_key_pair(kem: Kem) -> Res<(PrivateKey, PublicKey)> { assert_eq!(secret_ptr.is_null(), public_ptr.is_null()); let sk = PrivateKey::from_ptr(secret_ptr)?; let pk = PublicKey::from_ptr(public_ptr)?; - trace!("Generated key pair: sk={sk:?} pk={pk:?}"); + trace!("Generated key pair: sk={:?} pk={:?}", sk, pk); Ok((sk, pk)) } diff --git a/third_party/rust/ohttp/src/nss/p11.rs b/third_party/rust/ohttp/src/nss/p11.rs @@ -87,7 +87,7 @@ impl PrivateKey { PK11ObjectType::PK11_TypePrivKey, (**self).cast(), CK_ATTRIBUTE_TYPE::from(CKA_VALUE), - &raw mut key_item, + &mut key_item, ) })?; let slc = unsafe { @@ -98,7 +98,7 @@ impl PrivateKey { // use the scoped `Item` implementation. This is OK as long as nothing // panics between `PK11_ReadRawAttribute` succeeding and here. unsafe { - SECITEM_FreeItem(&raw mut key_item, PRBool::from(false)); + SECITEM_FreeItem(&mut key_item, PRBool::from(false)); } Ok(key) } @@ -135,7 +135,7 @@ impl PublicKey { sys::PK11_HPKE_Serialize( **self, buf.as_mut_ptr(), - &raw mut len, + &mut len, c_uint::try_from(buf.len()).unwrap(), ) })?; diff --git a/third_party/rust/ohttp/src/rh/hpke.rs b/third_party/rust/ohttp/src/rh/hpke.rs @@ -1,8 +1,13 @@ use std::ops::Deref; +#[cfg(not(feature = "pq"))] use ::hpke as rust_hpke; +#[cfg(feature = "pq")] +use ::hpke_pq as rust_hpke; use ::rand::thread_rng; use log::trace; +#[cfg(feature = "pq")] +use rust_hpke::kem::X25519Kyber768Draft00; use rust_hpke::{ aead::{AeadCtxR, AeadCtxS, AeadTag, AesGcm128, ChaCha20Poly1305}, kdf::HkdfSha256, @@ -61,6 +66,9 @@ impl Default for Config { #[derive(Clone)] pub enum PublicKey { X25519(<X25519HkdfSha256 as KemTrait>::PublicKey), + + #[cfg(feature = "pq")] + X25519Kyber768Draft00(<X25519Kyber768Draft00 as KemTrait>::PublicKey), } impl PublicKey { @@ -68,6 +76,9 @@ impl PublicKey { pub fn key_data(&self) -> Res<Vec<u8>> { Ok(match self { Self::X25519(k) => Vec::from(k.to_bytes().as_slice()), + + #[cfg(feature = "pq")] + Self::X25519Kyber768Draft00(k) => Vec::from(k.to_bytes().as_slice()), }) } } @@ -86,6 +97,9 @@ impl std::fmt::Debug for PublicKey { #[derive(Clone)] pub enum PrivateKey { X25519(<X25519HkdfSha256 as KemTrait>::PrivateKey), + + #[cfg(feature = "pq")] + X25519Kyber768Draft00(<X25519Kyber768Draft00 as KemTrait>::PrivateKey), } impl PrivateKey { @@ -93,6 +107,9 @@ impl PrivateKey { pub fn key_data(&self) -> Res<Vec<u8>> { Ok(match self { Self::X25519(k) => Vec::from(k.to_bytes().as_slice()), + + #[cfg(feature = "pq")] + Self::X25519Kyber768Draft00(k) => Vec::from(k.to_bytes().as_slice()), }) } } @@ -115,12 +132,25 @@ enum SenderContextX25519HkdfSha256HkdfSha256 { ChaCha20Poly1305(Box<AeadCtxS<ChaCha20Poly1305, HkdfSha256, X25519HkdfSha256>>), } +#[cfg(feature = "pq")] +enum SenderContextX25519Kyber768Draft00HkdfSha256 { + AesGcm128(Box<AeadCtxS<AesGcm128, HkdfSha256, X25519Kyber768Draft00>>), +} + enum SenderContextX25519HkdfSha256 { HkdfSha256(SenderContextX25519HkdfSha256HkdfSha256), } +#[cfg(feature = "pq")] +enum SenderContextX25519Kyber768Draft00 { + HkdfSha256(SenderContextX25519Kyber768Draft00HkdfSha256), +} + enum SenderContext { X25519HkdfSha256(SenderContextX25519HkdfSha256), + + #[cfg(feature = "pq")] + X25519Kyber768Draft00(SenderContextX25519Kyber768Draft00), } impl SenderContext { @@ -138,6 +168,14 @@ impl SenderContext { let tag = context.seal_in_place_detached(plaintext, aad)?; Vec::from(tag.to_bytes().as_slice()) } + + #[cfg(feature = "pq")] + Self::X25519Kyber768Draft00(SenderContextX25519Kyber768Draft00::HkdfSha256( + SenderContextX25519Kyber768Draft00HkdfSha256::AesGcm128(context), + )) => { + let tag = context.seal_in_place_detached(plaintext, aad)?; + Vec::from(tag.to_bytes().as_slice()) + } }) } @@ -153,6 +191,13 @@ impl SenderContext { )) => { context.export(info, out_buf)?; } + + #[cfg(feature = "pq")] + Self::X25519Kyber768Draft00(SenderContextX25519Kyber768Draft00::HkdfSha256( + SenderContextX25519Kyber768Draft00HkdfSha256::AesGcm128(context), + )) => { + context.export(info, out_buf)?; + } } Ok(()) } @@ -230,6 +275,17 @@ impl HpkeS { SenderContextX25519HkdfSha256::HkdfSha256, SenderContextX25519HkdfSha256HkdfSha256::ChaCha20Poly1305, }, + + #[cfg(feature = "pq")] + { + Kem::X25519Kyber768Draft00 => X25519Kyber768Draft00, + Kdf::HkdfSha256 => HkdfSha256, + Aead::Aes128Gcm => AesGcm128, + PublicKey::X25519Kyber768Draft00, + SenderContext::X25519Kyber768Draft00, + SenderContextX25519Kyber768Draft00::HkdfSha256, + SenderContextX25519Kyber768Draft00HkdfSha256::AesGcm128, + }, ]}; Ok(Self { @@ -277,12 +333,25 @@ enum ReceiverContextX25519HkdfSha256HkdfSha256 { ChaCha20Poly1305(Box<AeadCtxR<ChaCha20Poly1305, HkdfSha256, X25519HkdfSha256>>), } +#[cfg(feature = "pq")] +enum ReceiverContextX25519Kyber768Draft00HkdfSha256 { + AesGcm128(Box<AeadCtxR<AesGcm128, HkdfSha256, X25519Kyber768Draft00>>), +} + enum ReceiverContextX25519HkdfSha256 { HkdfSha256(ReceiverContextX25519HkdfSha256HkdfSha256), } +#[cfg(feature = "pq")] +enum ReceiverContextX25519Kyber768Draft00 { + HkdfSha256(ReceiverContextX25519Kyber768Draft00HkdfSha256), +} + enum ReceiverContext { X25519HkdfSha256(ReceiverContextX25519HkdfSha256), + + #[cfg(feature = "pq")] + X25519Kyber768Draft00(ReceiverContextX25519Kyber768Draft00), } impl ReceiverContext { @@ -312,6 +381,20 @@ impl ReceiverContext { context.open_in_place_detached(ct, aad, &tag)?; ct } + + #[cfg(feature = "pq")] + Self::X25519Kyber768Draft00(ReceiverContextX25519Kyber768Draft00::HkdfSha256( + ReceiverContextX25519Kyber768Draft00HkdfSha256::AesGcm128(context), + )) => { + if ciphertext.len() < AeadTag::<AesGcm128>::size() { + return Err(Error::Truncated); + } + let (ct, tag_slice) = + ciphertext.split_at_mut(ciphertext.len() - AeadTag::<AesGcm128>::size()); + let tag = AeadTag::<AesGcm128>::from_bytes(tag_slice)?; + context.open_in_place_detached(ct, aad, &tag)?; + ct + } }) } @@ -327,6 +410,13 @@ impl ReceiverContext { )) => { context.export(info, out_buf)?; } + + #[cfg(feature = "pq")] + Self::X25519Kyber768Draft00(ReceiverContextX25519Kyber768Draft00::HkdfSha256( + ReceiverContextX25519Kyber768Draft00HkdfSha256::AesGcm128(context), + )) => { + context.export(info, out_buf)?; + } } Ok(()) } @@ -401,6 +491,17 @@ impl HpkeR { ReceiverContextX25519HkdfSha256::HkdfSha256, ReceiverContextX25519HkdfSha256HkdfSha256::ChaCha20Poly1305, }, + + #[cfg(feature = "pq")] + { + Kem::X25519Kyber768Draft00 => X25519Kyber768Draft00, + Kdf::HkdfSha256 => HkdfSha256, + Aead::Aes128Gcm => AesGcm128, + PrivateKey::X25519Kyber768Draft00, + ReceiverContext::X25519Kyber768Draft00, + ReceiverContextX25519Kyber768Draft00::HkdfSha256, + ReceiverContextX25519Kyber768Draft00HkdfSha256::AesGcm128, + }, ]}; Ok(Self { context, config }) @@ -415,6 +516,11 @@ impl HpkeR { Kem::X25519Sha256 => { PublicKey::X25519(<X25519HkdfSha256 as KemTrait>::PublicKey::from_bytes(k)?) } + + #[cfg(feature = "pq")] + Kem::X25519Kyber768Draft00 => PublicKey::X25519Kyber768Draft00( + <X25519Kyber768Draft00 as KemTrait>::PublicKey::from_bytes(k)?, + ), }) } @@ -450,8 +556,17 @@ pub fn generate_key_pair(kem: Kem) -> Res<(PrivateKey, PublicKey)> { let (sk, pk) = X25519HkdfSha256::gen_keypair(&mut csprng); (PrivateKey::X25519(sk), PublicKey::X25519(pk)) } + + #[cfg(feature = "pq")] + Kem::X25519Kyber768Draft00 => { + let (sk, pk) = X25519Kyber768Draft00::gen_keypair(&mut csprng); + ( + PrivateKey::X25519Kyber768Draft00(sk), + PublicKey::X25519Kyber768Draft00(pk), + ) + } }; - trace!("Generated key pair: sk={sk:?} pk={pk:?}"); + trace!("Generated key pair: sk={:?} pk={:?}", sk, pk); Ok((sk, pk)) } @@ -462,8 +577,17 @@ pub fn derive_key_pair(kem: Kem, ikm: &[u8]) -> Res<(PrivateKey, PublicKey)> { let (sk, pk) = X25519HkdfSha256::derive_keypair(ikm); (PrivateKey::X25519(sk), PublicKey::X25519(pk)) } + + #[cfg(feature = "pq")] + Kem::X25519Kyber768Draft00 => { + let (sk, pk) = X25519Kyber768Draft00::derive_keypair(ikm); + ( + PrivateKey::X25519Kyber768Draft00(sk), + PublicKey::X25519Kyber768Draft00(pk), + ) + } }; - trace!("Derived key pair: sk={sk:?} pk={pk:?}"); + trace!("Derived key pair: sk={:?} pk={:?}", sk, pk); Ok((sk, pk)) } @@ -521,4 +645,10 @@ mod test { fn seal_open_chacha() { seal_open(Aead::ChaCha20Poly1305, Kem::X25519Sha256); } + + #[cfg(feature = "pq")] + #[test] + fn seal_open_xyber768d00() { + seal_open(Aead::Aes128Gcm, Kem::X25519Kyber768Draft00); + } } diff --git a/toolkit/components/glean/Cargo.toml b/toolkit/components/glean/Cargo.toml @@ -19,7 +19,7 @@ viaduct = "0.1" url = "2.1" thin-vec = { version = "0.2.1", features = ["gecko-ffi"] } ohttp = { version = "0.6", default-features = false, features = ["gecko", "nss", "client"] } -bhttp = "0.6" +bhttp = "0.3" thiserror = "1.0" mozbuild = "0.1" diff --git a/toolkit/components/glean/src/init/viaduct_uploader.rs b/toolkit/components/glean/src/init/viaduct_uploader.rs @@ -142,7 +142,7 @@ fn ohttp_upload(upload_request: PingUploadRequest) -> Result<UploadResult, Viadu .control() .status() .ok_or(ViaductUploaderError::Fatal)?; - Ok(UploadResult::http_status(res.code() as i32)) + Ok(UploadResult::http_status(res as i32)) } else { Ok(UploadResult::http_status(res.status as i32)) }