From efa98962b70b74a03e296cdae606e8869f0f2a1d Mon Sep 17 00:00:00 2001 From: UneBaguette <28904802+UneBaguette@users.noreply.github.com> Date: Wed, 1 Jul 2026 20:48:44 +0200 Subject: [PATCH] chore: update copyright headers to SPDX format and code cleanup (#3) - Added VexaHub copyright alongside original Meta copyright - Replaced verbose license blocks with SPDX-License-Identifier - Minor code improvements Reviewed-on: https://dev.unebaguette.fr/vexahub/opaque-vx/pulls/3 Co-authored-by: UneBaguette <28904802+UneBaguette@users.noreply.github.com> Co-committed-by: UneBaguette <28904802+UneBaguette@users.noreply.github.com> --- .cargo/license.rs | 8 ++---- CHANGELOG.md | 1 + Cargo.toml | 2 +- benches/opaque.rs | 8 ++---- examples/digital_locker.rs | 8 ++---- examples/simple_login.rs | 8 ++---- scripts/digital_locker.exp | 7 ++--- scripts/simple_login.exp | 7 ++--- src/ciphersuite.rs | 10 +++---- src/envelope.rs | 8 ++---- src/errors.rs | 8 ++---- src/hash.rs | 8 ++---- src/key_exchange/group/curve25519.rs | 8 ++---- src/key_exchange/group/ed25519.rs | 8 ++---- src/key_exchange/group/elliptic_curve.rs | 24 ++++------------ src/key_exchange/group/mod.rs | 8 ++---- src/key_exchange/group/ristretto255.rs | 8 ++---- src/key_exchange/mod.rs | 17 ++++------- src/key_exchange/shared.rs | 19 ++++--------- src/key_exchange/sigma_i/ecdsa.rs | 8 ++---- src/key_exchange/sigma_i/hash_eddsa.rs | 8 ++---- src/key_exchange/sigma_i/message.rs | 8 ++---- src/key_exchange/sigma_i/mod.rs | 30 ++++++-------------- src/key_exchange/sigma_i/pure_eddsa.rs | 8 ++---- src/key_exchange/sigma_i/shared.rs | 8 ++---- src/key_exchange/tripledh.rs | 8 ++---- src/key_exchange/tripledh_kem.rs | 8 ++---- src/keypair.rs | 8 ++---- src/ksf.rs | 8 ++---- src/lib.rs | 8 ++---- src/messages.rs | 36 ++++++++---------------- src/opaque.rs | 8 ++---- src/serialization/mod.rs | 8 ++---- src/serialization/tests.rs | 8 ++---- src/tests/full_test.rs | 8 ++---- src/tests/full_test_vectors.rs | 8 ++---- src/tests/mock_rng.rs | 8 ++---- src/tests/mod.rs | 8 ++---- src/tests/parser.rs | 8 ++---- src/tests/rfc9807_vectors.rs | 8 ++---- src/tests/test_opaque_vectors.rs | 8 ++---- tests/remote_key.rs | 8 ++---- 42 files changed, 111 insertions(+), 298 deletions(-) diff --git a/.cargo/license.rs b/.cargo/license.rs index 664968b..813a8fb 100644 --- a/.cargo/license.rs +++ b/.cargo/license.rs @@ -1,7 +1,3 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. diff --git a/CHANGELOG.md b/CHANGELOG.md index a74bc9a..6037606 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Forked from [facebook/opaque-ke](https://github.com/facebook/opaque-ke/) at `4.1 * Added **`cryptography`** to `categories` in `Cargo.toml` * Replaced `Hmac` with `SimpleHmac` throughout for `digest 0.11` compatibility * Replaced `bincode` with `postcard` for `no_std` serialization +* Replaced license appendix in files while keeping original copyright * Re-exported `hybrid_array` from crate root * Updated `Hash` trait to remove `BlockSizeUser` bounds incompatible with `digest 0.11` * Updated `GroupEncoding Repr` bound to `hybrid_array::Array` diff --git a/Cargo.toml b/Cargo.toml index 4c08789..7a7fcaa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,7 +68,7 @@ serde = { version = "1", default-features = false, features = [ "derive", ], optional = true } subtle = { version = "2.6", default-features = false } -voprf = { package = "voprf-vx", version = "1.0.0-pre.0", default-features = false, features = [ +voprf = { package = "voprf-vx", version = "1.0.0-pre.1", default-features = false, features = [ "danger", ] } zeroize = { version = "1.9", features = ["zeroize_derive"] } diff --git a/benches/opaque.rs b/benches/opaque.rs index 1968b68..87635c8 100644 --- a/benches/opaque.rs +++ b/benches/opaque.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. #[macro_use] extern crate criterion; diff --git a/examples/digital_locker.rs b/examples/digital_locker.rs index 9f3d634..3d28fd0 100644 --- a/examples/digital_locker.rs +++ b/examples/digital_locker.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! Demonstrates an implementation of a server-side secured digital locker using //! the client's OPAQUE export key, over a command-line interface diff --git a/examples/simple_login.rs b/examples/simple_login.rs index 896150f..7e56847 100644 --- a/examples/simple_login.rs +++ b/examples/simple_login.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! Demonstrates a simple client-server password-based login protocol using //! OPAQUE, over a command-line interface diff --git a/scripts/digital_locker.exp b/scripts/digital_locker.exp index 8e3cbb3..04c01ac 100644 --- a/scripts/digital_locker.exp +++ b/scripts/digital_locker.exp @@ -1,11 +1,8 @@ #!/bin/expect -f +# SPDX-License-Identifier: MIT OR Apache-2.0 +# Copyright (c) VexaHub and contributors. # Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is dual-licensed under either the MIT license found in the -# LICENSE-MIT file in the root directory of this source tree or the Apache -# License, Version 2.0 found in the LICENSE-APACHE file in the root directory -# of this source tree. You may select, at your option, one of the above-listed licenses. set timeout 1 spawn cargo run --example digital_locker diff --git a/scripts/simple_login.exp b/scripts/simple_login.exp index 0a5a0a2..7d6a780 100644 --- a/scripts/simple_login.exp +++ b/scripts/simple_login.exp @@ -1,11 +1,8 @@ #!/bin/expect -f +# SPDX-License-Identifier: MIT OR Apache-2.0 +# Copyright (c) VexaHub and contributors. # Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is dual-licensed under either the MIT license found in the -# LICENSE-MIT file in the root directory of this source tree or the Apache -# License, Version 2.0 found in the LICENSE-APACHE file in the root directory -# of this source tree. You may select, at your option, one of the above-listed licenses. set timeout 1 spawn cargo run --example simple_login --features argon2 diff --git a/src/ciphersuite.rs b/src/ciphersuite.rs index 3f63674..3d6fb54 100644 --- a/src/ciphersuite.rs +++ b/src/ciphersuite.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! Defines the [`CipherSuite`] trait to specify the underlying primitives for //! OPAQUE @@ -36,6 +32,8 @@ where Le<< as CoreProxy>::Core as SmallBlockSizeUser>::_BlockSize, U256>: NonZero, // Envelope: Nonce + Hash // MaskedResponse: (Nonce + Hash) + KePk + // TODO: migrate fully to after hybrid-array v0.5 releases + // https://github.com/RustCrypto/hybrid-array/issues/66 OutputSize>: Add + ArrayLength, Sum>, NonceLen>: ArrayLength + Add< as Group>::PkLen>, MaskedResponseLen: ArrayLength, diff --git a/src/envelope.rs b/src/envelope.rs index 6bf168f..aee886d 100644 --- a/src/envelope.rs +++ b/src/envelope.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. use core::convert::TryFrom; diff --git a/src/errors.rs b/src/errors.rs index 620cfeb..c939a48 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! A list of error types which are produced during an execution of the protocol use core::convert::Infallible; diff --git a/src/hash.rs b/src/hash.rs index 548df23..3d4a8fc 100644 --- a/src/hash.rs +++ b/src/hash.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! A convenience trait for digest bounds used throughout the library diff --git a/src/key_exchange/group/curve25519.rs b/src/key_exchange/group/curve25519.rs index 7abc968..be99963 100644 --- a/src/key_exchange/group/curve25519.rs +++ b/src/key_exchange/group/curve25519.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! Key Exchange group implementation for Curve25519 diff --git a/src/key_exchange/group/ed25519.rs b/src/key_exchange/group/ed25519.rs index c84be14..cbb8bf9 100644 --- a/src/key_exchange/group/ed25519.rs +++ b/src/key_exchange/group/ed25519.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! Key Exchange group implementation for Ed25519 diff --git a/src/key_exchange/group/elliptic_curve.rs b/src/key_exchange/group/elliptic_curve.rs index 9092700..8d2e6de 100644 --- a/src/key_exchange/group/elliptic_curve.rs +++ b/src/key_exchange/group/elliptic_curve.rs @@ -1,23 +1,18 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! Implementation for EC curves via [`elliptic_curve`] traits. use core::ops::Mul; -use digest::OutputSizeUser; -use digest::block_api::BlockSizeUser; + use elliptic_curve::group::GroupEncoding; use elliptic_curve::point::NonIdentity; use elliptic_curve::sec1::{ModulusSize, ToSec1Point}; use elliptic_curve::{ CurveArithmetic, FieldBytesSize, Generate, NonZeroScalar, ProjectivePoint, Scalar, SecretKey, }; -use generic_array::typenum::{IsGreaterOrEqual, IsLess, IsLessOrEqual, Prod, True, U2, U256}; +use generic_array::typenum::U2; use generic_array::{ArrayLength, GenericArray}; use rand::{CryptoRng, Rng}; use voprf::Mode; @@ -40,12 +35,6 @@ where > + ToSec1Point, // Bounds required by voprf::CipherSuite ::SecurityLevel: Mul, - <::Hash as OutputSizeUser>::OutputSize: ArrayLength - + IsLess - + IsLessOrEqual< - <::Hash as BlockSizeUser>::BlockSize, - Output = True, - > + IsGreaterOrEqual::SecurityLevel, U2>, Output = True>, { // We don't use `elliptic_curve::PublicKey` because it stores its internals in a // format ideal for serialization and not computation. This is inconsistent with @@ -105,11 +94,8 @@ where ProjectivePoint: GroupEncoding< Repr = hybrid_array::Array as ModulusSize>::CompressedPointSize>, > + ToSec1Point, + // Bounds required by voprf::CipherSuite ::SecurityLevel: Mul, - <::Hash as OutputSizeUser>::OutputSize: ArrayLength - + IsLess - + IsLessOrEqual<<::Hash as BlockSizeUser>::BlockSize, Output = True> - + IsGreaterOrEqual::SecurityLevel, U2>, Output = True>, { fn diffie_hellman( &self, diff --git a/src/key_exchange/group/mod.rs b/src/key_exchange/group/mod.rs index e1f89e9..ef27622 100644 --- a/src/key_exchange/group/mod.rs +++ b/src/key_exchange/group/mod.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! Includes the [`Group`] trait and definitions for the key exchange groups diff --git a/src/key_exchange/group/ristretto255.rs b/src/key_exchange/group/ristretto255.rs index 0c74721..fa52b2a 100644 --- a/src/key_exchange/group/ristretto255.rs +++ b/src/key_exchange/group/ristretto255.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! Key Exchange group implementation for ristretto255 diff --git a/src/key_exchange/mod.rs b/src/key_exchange/mod.rs index 0f0ef5d..163cbbb 100644 --- a/src/key_exchange/mod.rs +++ b/src/key_exchange/mod.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! Includes instantiations of key exchange protocols used in the login step for //! OPAQUE @@ -22,7 +18,6 @@ use core::ops::Add; use derive_where::derive_where; use digest::Output; use digest::block_api::{CoreProxy, SmallBlockSizeUser}; -use generic_array::sequence::Concat; use generic_array::typenum::{IsLess, Le, NonZero, Sum, U2, U256}; use generic_array::{ArrayLength, GenericArray}; use hybrid_array::Array; @@ -39,7 +34,7 @@ use crate::key_exchange::group::Group; use crate::key_exchange::shared::{NonceLen, STR_CONTEXT}; use crate::keypair::{PrivateKey, PublicKey}; use crate::opaque::{Identifiers, MaskedResponse, MaskedResponseLen}; -use crate::serialization::{SliceExt, i2osp}; +use crate::serialization::{ConcatExt, SliceExt, i2osp}; /// The key exchange trait. pub trait KeyExchange @@ -237,10 +232,8 @@ where ) .clone(); - Concat::concat( - Concat::concat(elem, self.masking_nonce), - self.masked_response.serialize(), - ) + elem.cat(self.masking_nonce) + .cat(self.masked_response.serialize()) } } diff --git a/src/key_exchange/shared.rs b/src/key_exchange/shared.rs index 66d8616..bbe3ecc 100644 --- a/src/key_exchange/shared.rs +++ b/src/key_exchange/shared.rs @@ -1,17 +1,12 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. use core::ops::Add; use derive_where::derive_where; use digest::block_api::{CoreProxy, SmallBlockSizeUser}; use digest::{Digest, Mac, Output, OutputSizeUser, Update}; -use generic_array::sequence::Concat; use generic_array::typenum::{IsLess, Le, NonZero, Sum, U1, U2, U32, U256, Unsigned}; use generic_array::{ArrayLength, GenericArray}; use hkdf::SimpleHkdf as Hkdf; @@ -28,7 +23,7 @@ use crate::errors::{InternalError, ProtocolError}; use crate::hash::{Hash, OutputSize, ProxyHash}; use crate::key_exchange::group::Group; use crate::keypair::{KeyPair, PrivateKey, PublicKey}; -use crate::serialization::{SliceExt, UpdateExt, i2osp}; +use crate::serialization::{ConcatExt, SliceExt, UpdateExt, i2osp}; /////////////// // Constants // @@ -421,9 +416,7 @@ where type Len = Sum; fn serialize(&self) -> GenericArray { - let a = self.client_e_sk.serialize(); - - GenericArray::concat(a, self.client_nonce) + self.client_e_sk.serialize().cat(self.client_nonce) } } @@ -445,7 +438,7 @@ where type Len = Sum; fn serialize(&self) -> GenericArray { - self.client_nonce.concat(self.client_e_pk.serialize()) + self.client_nonce.cat(self.client_e_pk.serialize()) } } @@ -490,6 +483,6 @@ where Ke1MessageIterLen: ArrayLength, { pub(crate) fn serialize(&self) -> GenericArray> { - self.client_nonce.concat(self.client_e_pk.clone()) + self.client_nonce.cat(self.client_e_pk.clone()) } } diff --git a/src/key_exchange/sigma_i/ecdsa.rs b/src/key_exchange/sigma_i/ecdsa.rs index 0ebd884..2e1ed01 100644 --- a/src/key_exchange/sigma_i/ecdsa.rs +++ b/src/key_exchange/sigma_i/ecdsa.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! ECDSA implementation for [`elliptic_curve`] [`Group`] implementations to //! support [`SigmaI`](crate::SigmaI). diff --git a/src/key_exchange/sigma_i/hash_eddsa.rs b/src/key_exchange/sigma_i/hash_eddsa.rs index a1454a1..58cd403 100644 --- a/src/key_exchange/sigma_i/hash_eddsa.rs +++ b/src/key_exchange/sigma_i/hash_eddsa.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! HashEdDSA implementation for [`SigmaI`](crate::SigmaI). Currently only //! supports [`Ed25519`](crate::Ed25519). diff --git a/src/key_exchange/sigma_i/message.rs b/src/key_exchange/sigma_i/message.rs index 927b165..3472344 100644 --- a/src/key_exchange/sigma_i/message.rs +++ b/src/key_exchange/sigma_i/message.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. use core::ops::Add; diff --git a/src/key_exchange/sigma_i/mod.rs b/src/key_exchange/sigma_i/mod.rs index f11982c..9b45a70 100644 --- a/src/key_exchange/sigma_i/mod.rs +++ b/src/key_exchange/sigma_i/mod.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! An implementation of the SIGMA-I key exchange protocol //! @@ -25,7 +21,6 @@ use core::ops::Add; use derive_where::derive_where; use digest::block_api::{BlockSizeUser, CoreProxy, SmallBlockSizeUser}; use digest::{Mac, Output, OutputSizeUser}; -use generic_array::sequence::Concat; use generic_array::typenum::{IsLess, Le, NonZero, Sum, U256}; use generic_array::{ArrayLength, GenericArray}; use hmac::{KeyInit, SimpleHmac}; @@ -521,16 +516,11 @@ where type Len = Ke2StateLen; fn serialize(&self) -> GenericArray { - Concat::concat( - Concat::concat( - Concat::concat( - self.client_s_pk.serialize(), - GenericArray::from_slice(self.session_key.as_slice()).clone(), - ), - self.verify_state.serialize(), - ), - GenericArray::from_slice(self.expected_mac.as_slice()).clone(), - ) + self.client_s_pk + .serialize() + .cat(GenericArray::from_slice(self.session_key.as_slice()).clone()) + .cat(self.verify_state.serialize()) + .cat(GenericArray::from_slice(self.expected_mac.as_slice()).clone()) } } @@ -601,9 +591,7 @@ where type Len = Sum>; fn serialize(&self) -> GenericArray { - Concat::concat( - SIG::serialize_signature(&self.signature), - GenericArray::from_slice(self.mac.as_slice()).clone(), - ) + SIG::serialize_signature(&self.signature) + .cat(GenericArray::from_slice(self.mac.as_slice()).clone()) } } diff --git a/src/key_exchange/sigma_i/pure_eddsa.rs b/src/key_exchange/sigma_i/pure_eddsa.rs index d5e76cc..867510c 100644 --- a/src/key_exchange/sigma_i/pure_eddsa.rs +++ b/src/key_exchange/sigma_i/pure_eddsa.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! PureEdDSA implementation for [`SigmaI`](crate::SigmaI). Currently only //! supports [`Ed25519`](crate::Ed25519). diff --git a/src/key_exchange/sigma_i/shared.rs b/src/key_exchange/sigma_i/shared.rs index 5aef114..db460c2 100644 --- a/src/key_exchange/sigma_i/shared.rs +++ b/src/key_exchange/sigma_i/shared.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. use derive_where::derive_where; use digest::{Output, OutputSizeUser}; diff --git a/src/key_exchange/tripledh.rs b/src/key_exchange/tripledh.rs index 0c37147..7856ac9 100644 --- a/src/key_exchange/tripledh.rs +++ b/src/key_exchange/tripledh.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! An implementation of the Triple Diffie-Hellman key exchange protocol diff --git a/src/key_exchange/tripledh_kem.rs b/src/key_exchange/tripledh_kem.rs index e843a2b..ad1a8e7 100644 --- a/src/key_exchange/tripledh_kem.rs +++ b/src/key_exchange/tripledh_kem.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! TripleDH-KEM is a variant of the OPAQUE Triple Diffie-Hellman handshake in //! which the client supplies a KEM public key in KE1 and the server performs a diff --git a/src/keypair.rs b/src/keypair.rs index 721abaa..9153f12 100644 --- a/src/keypair.rs +++ b/src/keypair.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! Contains the keypair types that must be supplied for the OPAQUE API diff --git a/src/ksf.rs b/src/ksf.rs index 61a0e3c..7d1af18 100644 --- a/src/ksf.rs +++ b/src/ksf.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! Trait specifying a key stretching function diff --git a/src/lib.rs b/src/lib.rs index 860d6d3..db8b278 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! An implementation of the OPAQUE augmented password authentication key //! exchange protocol diff --git a/src/messages.rs b/src/messages.rs index 1146d16..33d94ce 100644 --- a/src/messages.rs +++ b/src/messages.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! Contains the messages used for OPAQUE @@ -12,7 +8,6 @@ use core::ops::Add; use derive_where::derive_where; use digest::Output; -use generic_array::sequence::Concat; use generic_array::typenum::{Sum, Unsigned}; use generic_array::{ArrayLength, GenericArray}; use hybrid_array::Array; @@ -34,7 +29,7 @@ use crate::keypair::PublicKey; use crate::opaque::{ MaskedResponse, MaskedResponseLen, ServerLogin, ServerLoginStartResult, ServerSetup, }; -use crate::serialization::SliceExt; +use crate::serialization::{ConcatExt, SliceExt}; //////////////////////////// // High-level API Structs // @@ -260,7 +255,7 @@ impl RegistrationResponse { self.evaluation_element.value(), )); - elem.concat(self.server_s_pk.serialize()) + elem.cat(self.server_s_pk.serialize()) } /// Deserialization from bytes @@ -302,13 +297,10 @@ impl RegistrationUpload { ArrayLength + Add>, RegistrationUploadLen: ArrayLength, { - Concat::concat( - Concat::concat( - self.client_s_pk.serialize(), - GenericArray::from_slice(self.masking_key.as_slice()).clone(), - ), - self.envelope.serialize(), - ) + self.client_s_pk + .serialize() + .cat(GenericArray::from_slice(self.masking_key.as_slice()).clone()) + .cat(self.envelope.serialize()) } /// Deserialization from bytes @@ -353,7 +345,7 @@ impl CredentialRequest { self.blinded_element.value(), )); - elem.concat(self.ke1_message.serialize()) + elem.cat(self.ke1_message.serialize()) } /// Deserialization from bytes @@ -413,13 +405,9 @@ impl CredentialResponse { self.evaluation_element.value(), )); - Concat::concat( - Concat::concat( - Concat::concat(elem, self.masking_nonce), - self.masked_response.serialize(), - ), - self.ke2_message.serialize(), - ) + elem.cat(self.masking_nonce) + .cat(self.masked_response.serialize()) + .cat(self.ke2_message.serialize()) } /// Deserialization from bytes diff --git a/src/opaque.rs b/src/opaque.rs index f3f7072..251fe89 100644 --- a/src/opaque.rs +++ b/src/opaque.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! Provides the main OPAQUE API diff --git a/src/serialization/mod.rs b/src/serialization/mod.rs index b534636..45ec45f 100644 --- a/src/serialization/mod.rs +++ b/src/serialization/mod.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. use core::ops::Add; diff --git a/src/serialization/tests.rs b/src/serialization/tests.rs index 8fbf2b0..c0741ec 100644 --- a/src/serialization/tests.rs +++ b/src/serialization/tests.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. use core::ops::Add; use std::vec; diff --git a/src/tests/full_test.rs b/src/tests/full_test.rs index 7768983..de24110 100644 --- a/src/tests/full_test.rs +++ b/src/tests/full_test.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. #![allow(unsafe_code)] diff --git a/src/tests/full_test_vectors.rs b/src/tests/full_test_vectors.rs index 56bb712..0066df9 100644 --- a/src/tests/full_test_vectors.rs +++ b/src/tests/full_test_vectors.rs @@ -1,11 +1,7 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. // -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. -// // To regenerate these test vectors, run: // FULL_TEST_VECTORS_FILE=src/tests/full_test_vectors.rs cargo test --features curve25519,ecdsa,ed25519 -- generate_test_vectors diff --git a/src/tests/mock_rng.rs b/src/tests/mock_rng.rs index fe1ce62..4a20190 100644 --- a/src/tests/mock_rng.rs +++ b/src/tests/mock_rng.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. use core::cmp::min; use std::vec::Vec; diff --git a/src/tests/mod.rs b/src/tests/mod.rs index f3a1632..1b17477 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. use serde_json::Value; use std::vec::Vec; diff --git a/src/tests/parser.rs b/src/tests/parser.rs index 83d77d1..d22b9bc 100644 --- a/src/tests/parser.rs +++ b/src/tests/parser.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. use std::string::{String, ToString}; use std::vec::Vec; diff --git a/src/tests/rfc9807_vectors.rs b/src/tests/rfc9807_vectors.rs index 1074a22..2ca092c 100644 --- a/src/tests/rfc9807_vectors.rs +++ b/src/tests/rfc9807_vectors.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. //! The OPAQUE test vectors taken from Appendix C of //! [RFC 9807](https://www.rfc-editor.org/rfc/rfc9807.txt) diff --git a/src/tests/test_opaque_vectors.rs b/src/tests/test_opaque_vectors.rs index 0c56b02..d04c792 100644 --- a/src/tests/test_opaque_vectors.rs +++ b/src/tests/test_opaque_vectors.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. use core::ops::Add; use std::vec; diff --git a/tests/remote_key.rs b/tests/remote_key.rs index 13a9161..fb63db2 100644 --- a/tests/remote_key.rs +++ b/tests/remote_key.rs @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +// Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. -// -// This source code is dual-licensed under either the MIT license found in the -// LICENSE-MIT file in the root directory of this source tree or the Apache -// License, Version 2.0 found in the LICENSE-APACHE file in the root directory -// of this source tree. You may select, at your option, one of the above-listed -// licenses. #![cfg(test_hsm)] #![allow(type_alias_bounds)]