Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.63.0"
msrv = "1.85.0"
15 changes: 9 additions & 6 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,29 @@ env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

# This fork ships one configuration: the rust-hpke backend with the secp256k1 DHKEM
# from bitcoin-hpke, on stable Rust. That is what CI gates.
# This fork ships the rust-hpke backend with the secp256k1 DHKEM from bitcoin-hpke.
#
# Not in the matrix, on purpose:
# - nss: NSS has no secp256k1 DHKEM, and the backend has not compiled since the Kem
# enum was pruned to K256Sha256 (bac8f2c). Drop or delete is a separate decision.
# - an MSRV toolchain: the declared MSRV cannot resolve current transitive
# dependencies. Restore the leg when #6 is settled.

jobs:
check:
name: Continuous Integration (rust-hpke, stable)
name: Continuous Integration (rust-hpke)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust:
- 1.85.0 # MSRV
- stable
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy

- name: Build
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
resolver = "2"
resolver = "3"
members = [
"bhttp",
"bhttp-convert",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ install itself.

## Minnimum Supported Rust Version (MSRV)

`ohttp` and `bhttp` should compile on Rust 1.63.0.
`ohttp` and `bhttp` should compile on Rust 1.85.0.
2 changes: 1 addition & 1 deletion bhttp-convert/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "bhttp-convert"
version = "0.5.3"
authors = ["Martin Thomson <mt@lowentropy.net>"]
edition = "2021"
edition = "2024"

[dependencies]
structopt = "0.3"
Expand Down
6 changes: 4 additions & 2 deletions bhttp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
name = "bhttp"
version = "0.5.3"
authors = ["Martin Thomson <mt@lowentropy.net>"]
edition = "2021"
rust-version = "1.63.0"
edition = "2024"
rust-version = "1.85.0"
license = "MIT OR Apache-2.0"
description = "Binary HTTP messages (RFC 9292)"
repository = "https://github.com/martinthomson/ohttp"
Expand All @@ -21,5 +21,7 @@ write-http = []
thiserror = "1"
url = {version = "2", optional = true}

yoke-derive = "=0.8.2"

[dev-dependencies]
hex = "0.4"
10 changes: 3 additions & 7 deletions bhttp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ pub use err::Error;
))]
use err::Res;
#[cfg(feature = "read-http")]
use parse::{downcase, is_ows, read_line, split_at, COLON, SEMICOLON, SLASH, SP};
use parse::{index_of, trim_ows, COMMA};
use parse::{COLON, SEMICOLON, SLASH, SP, downcase, is_ows, read_line, split_at};
use parse::{COMMA, index_of, trim_ows};
#[cfg(feature = "read-bhttp")]
use rw::{read_varint, read_vec};
#[cfg(feature = "write-bhttp")]
Expand Down Expand Up @@ -401,11 +401,7 @@ impl ControlData {
#[must_use]
pub fn path(&self) -> Option<&[u8]> {
if let Self::Request { path, .. } = self {
if path.is_empty() {
None
} else {
Some(path)
}
if path.is_empty() { None } else { Some(path) }
} else {
None
}
Expand Down
2 changes: 1 addition & 1 deletion bhttp/src/rw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{convert::TryFrom, io};

use crate::err::Res;
#[cfg(feature = "read-bhttp")]
use crate::{err::Error, ReadSeek};
use crate::{ReadSeek, err::Error};

#[cfg(feature = "write-bhttp")]
#[allow(clippy::cast_possible_truncation)]
Expand Down
2 changes: 1 addition & 1 deletion ohttp-client-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "ohttp-client-cli"
version = "0.5.3"
authors = ["Martin Thomson <mt@lowentropy.net>"]
edition = "2021"
edition = "2024"

[features]
default = ["rust-hpke"]
Expand Down
2 changes: 1 addition & 1 deletion ohttp-client-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![deny(warnings, clippy::pedantic)]

use bhttp::{Message, Mode};
use ohttp::{init, ClientRequest};
use ohttp::{ClientRequest, init};
use std::io::{self, BufRead, Write};

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion ohttp-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "ohttp-client"
version = "0.5.3"
authors = ["Martin Thomson <mt@lowentropy.net>"]
edition = "2021"
edition = "2024"

[features]
default = ["rust-hpke"]
Expand Down
2 changes: 1 addition & 1 deletion ohttp-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "ohttp-server"
version = "0.5.3"
authors = ["Martin Thomson <mt@lowentropy.net>"]
edition = "2021"
edition = "2024"

[features]
default = ["rust-hpke"]
Expand Down
2 changes: 1 addition & 1 deletion ohttp-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use std::{

use bhttp::{Message, Mode, StatusCode};
use ohttp::{
hpke::{Aead, Kdf, Kem},
KeyConfig, Server as OhttpServer, SymmetricSuite,
hpke::{Aead, Kdf, Kem},
};
use structopt::StructOpt;
use warp::Filter;
Expand Down
4 changes: 2 additions & 2 deletions ohttp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
name = "bitcoin-ohttp"
version = "0.6.0"
authors = ["Dan Gould <d@ngould.dev>"]
edition = "2021"
rust-version = "1.63.0"
edition = "2024"
rust-version = "1.85.0"
build = "build.rs"
license = "MIT OR Apache-2.0"
description = "Oblivious HTTP over secp256k1 and ChaCha20Poly1305"
Expand Down
4 changes: 3 additions & 1 deletion ohttp/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,9 @@ mod nss {
"NSS_DIR path (obtained via `env`) does not exist: {}",
nss_dir.display()
);
panic!("It looks like NSS is not built. Please run `libs/verify-[platform]-environment.sh` in application-services first!");
panic!(
"It looks like NSS is not built. Please run `libs/verify-[platform]-environment.sh` in application-services first!"
);
}

let lib_dir = nss_dir.join("lib");
Expand Down
9 changes: 5 additions & 4 deletions ohttp/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
KeyId,
err::{Error, Res},
hpke::{Aead as AeadId, Kdf, Kem},
KeyId,
};
use byteorder::{NetworkEndian, ReadBytesExt, WriteBytesExt};
use std::{
Expand All @@ -11,13 +11,13 @@ use std::{

#[cfg(feature = "nss")]
use crate::nss::{
hpke::{generate_key_pair, Config as HpkeConfig, HpkeR},
PrivateKey, PublicKey,
hpke::{Config as HpkeConfig, HpkeR, generate_key_pair},
};

#[cfg(feature = "rust-hpke")]
use crate::rh::hpke::{
derive_key_pair, generate_key_pair, Config as HpkeConfig, HpkeR, PrivateKey, PublicKey,
Config as HpkeConfig, HpkeR, PrivateKey, PublicKey, derive_key_pair, generate_key_pair,
};

/// A tuple of KDF and AEAD identifiers.
Expand Down Expand Up @@ -278,8 +278,9 @@ impl AsRef<Self> for KeyConfig {
#[cfg(test)]
mod test {
use crate::{
Error, KeyConfig, KeyId, SymmetricSuite,
hpke::{Aead, Kdf, Kem},
init, Error, KeyConfig, KeyId, SymmetricSuite,
init,
};
use std::iter::zip;

Expand Down
2 changes: 1 addition & 1 deletion ohttp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,10 @@ impl ClientResponse {
#[cfg(all(test, feature = "client", feature = "server"))]
mod test {
use crate::{
ClientRequest, Error, KeyConfig, KeyId, Server,
config::SymmetricSuite,
err::Res,
hpke::{Aead, Kdf, Kem},
ClientRequest, Error, KeyConfig, KeyId, Server,
};
use log::trace;
use std::{fmt::Debug, io::ErrorKind};
Expand Down
8 changes: 4 additions & 4 deletions ohttp/src/nss/aead.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use super::{
err::secstatus_to_res,
p11::{
Item, SymKey,
sys::{
self, PK11Context, PK11_AEADOp, PK11_CreateContextBySymKey, PRBool, CKA_DECRYPT,
self, CK_ATTRIBUTE_TYPE, CK_GENERATOR_FUNCTION, CK_MECHANISM_TYPE, CKA_DECRYPT,
CKA_ENCRYPT, CKA_NSS_MESSAGE, CKG_GENERATE_COUNTER_XOR, CKG_NO_GENERATE, CKM_AES_GCM,
CKM_CHACHA20_POLY1305, CK_ATTRIBUTE_TYPE, CK_GENERATOR_FUNCTION, CK_MECHANISM_TYPE,
CKM_CHACHA20_POLY1305, PK11_AEADOp, PK11_CreateContextBySymKey, PK11Context, PRBool,
},
Item, SymKey,
},
};
use crate::{
Expand Down Expand Up @@ -195,7 +195,7 @@ impl Aead {
mod test {
use super::{
super::{super::hpke::Aead as AeadId, init},
Aead, Mode, SequenceNumber, NONCE_LEN,
Aead, Mode, NONCE_LEN, SequenceNumber,
};

/// Check that the first invocation of encryption matches expected values.
Expand Down
4 changes: 2 additions & 2 deletions ohttp/src/nss/err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ pub fn secstatus_to_res(rv: SECStatus) -> Res<()> {
#[cfg(test)]
mod tests {
use super::{
super::{init, SECFailure, SECSuccess},
secstatus_to_res, PRErrorCode, PR_SetError,
super::{SECFailure, SECSuccess, init},
PR_SetError, PRErrorCode, secstatus_to_res,
};

fn set_error_code(code: PRErrorCode) {
Expand Down
8 changes: 4 additions & 4 deletions ohttp/src/nss/hkdf.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use super::{
super::hpke::{Aead, Kdf},
p11::{
ParamItem, SymKey,
sys::{
self, CKA_DERIVE, CKF_HKDF_SALT_DATA, CKF_HKDF_SALT_NULL, CKM_AES_GCM,
CKM_CHACHA20_POLY1305, CKM_HKDF_DATA, CKM_HKDF_DERIVE, CKM_SHA256, CK_BBOOL,
CK_HKDF_PARAMS, CK_INVALID_HANDLE, CK_MECHANISM_TYPE, CK_OBJECT_HANDLE, CK_ULONG,
self, CK_BBOOL, CK_HKDF_PARAMS, CK_INVALID_HANDLE, CK_MECHANISM_TYPE, CK_OBJECT_HANDLE,
CK_ULONG, CKA_DERIVE, CKF_HKDF_SALT_DATA, CKF_HKDF_SALT_NULL, CKM_AES_GCM,
CKM_CHACHA20_POLY1305, CKM_HKDF_DATA, CKM_HKDF_DERIVE, CKM_SHA256,
},
ParamItem, SymKey,
},
};
use crate::err::Res;
Expand Down
6 changes: 3 additions & 3 deletions ohttp/src/nss/hpke.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::{
super::hpke::{Aead, Kdf, Kem},
err::{sec::SEC_ERROR_INVALID_ARGS, secstatus_to_res, Error},
p11::{sys, Item, PrivateKey, PublicKey, Slot, SymKey},
err::{Error, sec::SEC_ERROR_INVALID_ARGS, secstatus_to_res},
p11::{Item, PrivateKey, PublicKey, Slot, SymKey, sys},
};
use crate::err::Res;
use log::{log_enabled, trace};
Expand Down Expand Up @@ -292,7 +292,7 @@ pub fn generate_key_pair(kem: Kem) -> Res<(PrivateKey, PublicKey)> {

#[cfg(test)]
mod test {
use super::{generate_key_pair, Config, HpkeContext, HpkeR, HpkeS};
use super::{Config, HpkeContext, HpkeR, HpkeS, generate_key_pair};
use crate::{hpke::Aead, init};

const INFO: &[u8] = b"info";
Expand Down
4 changes: 2 additions & 2 deletions ohttp/src/nss/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ pub mod aead;
pub mod hkdf;
pub mod hpke;

pub use self::p11::{random, PrivateKey, PublicKey};
use err::secstatus_to_res;
pub use self::p11::{PrivateKey, PublicKey, random};
pub use err::Error;
use err::secstatus_to_res;
use lazy_static::lazy_static;
use std::ptr::null;

Expand Down
10 changes: 5 additions & 5 deletions ohttp/src/nss/p11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use super::err::{secstatus_to_res, Error};
use super::err::{Error, secstatus_to_res};
use crate::err::Res;
use std::{
convert::TryFrom,
Expand All @@ -28,11 +28,11 @@ pub mod sys {
}

use sys::{
PK11ObjectType, PK11SlotInfo, PK11SymKey, PK11_ExtractKeyValue, PK11_FreeSlot, PK11_FreeSymKey,
CK_ATTRIBUTE_TYPE, CKA_VALUE, PK11_ExtractKeyValue, PK11_FreeSlot, PK11_FreeSymKey,
PK11_GenerateRandom, PK11_GetInternalSlot, PK11_GetKeyData, PK11_ReadRawAttribute,
PK11_ReferenceSymKey, PRBool, SECITEM_FreeItem, SECItem, SECItemType, SECKEYPrivateKey,
SECKEYPublicKey, SECKEY_DestroyPrivateKey, SECKEY_DestroyPublicKey, CKA_VALUE,
CK_ATTRIBUTE_TYPE,
PK11_ReferenceSymKey, PK11ObjectType, PK11SlotInfo, PK11SymKey, PRBool, SECITEM_FreeItem,
SECItem, SECItemType, SECKEY_DestroyPrivateKey, SECKEY_DestroyPublicKey, SECKEYPrivateKey,
SECKEYPublicKey,
};

macro_rules! scoped_ptr {
Expand Down
2 changes: 1 addition & 1 deletion ohttp/src/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use ::rand::{thread_rng, RngCore};
use ::rand::{RngCore, thread_rng};

#[must_use]
pub fn random(size: usize) -> Vec<u8> {
Expand Down
2 changes: 1 addition & 1 deletion ohttp/src/rh/aead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl Aead {
mod test {
use super::{
super::super::{hpke::Aead as AeadId, init},
Aead, Mode, SequenceNumber, NONCE_LEN,
Aead, Mode, NONCE_LEN, SequenceNumber,
};

/// Check that the first invocation of encryption matches expected values.
Expand Down
7 changes: 4 additions & 3 deletions ohttp/src/rh/hpke.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use super::SymKey;
use crate::{
hpke::{Aead, Kdf, Kem},
Error, Res,
hpke::{Aead, Kdf, Kem},
};

use bitcoin_hpke::{
Deserializable, OpModeR, OpModeS, Serializable,
aead::{AeadCtxR, AeadCtxS, AeadTag, ChaCha20Poly1305},
kdf::HkdfSha256,
kem::{Kem as KemTrait, SecpK256HkdfSha256},
setup_receiver, setup_sender, Deserializable, OpModeR, OpModeS, Serializable,
setup_receiver, setup_sender,
};

use ::rand::thread_rng;
Expand Down Expand Up @@ -419,7 +420,7 @@ pub fn derive_key_pair(kem: Kem, ikm: &[u8]) -> Res<(PrivateKey, PublicKey)> {

#[cfg(test)]
mod test {
use super::{generate_key_pair, Config, HpkeR, HpkeS};
use super::{Config, HpkeR, HpkeS, generate_key_pair};
use crate::{
hpke::{Aead, Kem},
init,
Expand Down
Loading