Skip to content
Open
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
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,6 @@ required-features = ["getrandom"]

[lib]
bench = false

[patch.crates-io]
x-wing = { git = "https://github.com/str4d/RustCrypto-KEMs.git", rev = "faabbc960470b38a51f4aec07ce7f1d1c381d401" }
11 changes: 8 additions & 3 deletions src/kem/xwing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use hybrid_array::typenum::{Prod, Sum, U3, U32, U64, U1024, Unsigned};
use rand_core::CryptoRng;
use shake::Shake256;
use subtle::{Choice, ConstantTimeEq};
use x_wing::{Decapsulator, KeyExport, TryKeyInit, kem::Decapsulate};
use x_wing::{Decapsulator, KeyExport, TryKeyInit, kem::TryDecapsulate};
use zeroize::Zeroize;

// Type-level size constants for X-Wing
Expand Down Expand Up @@ -48,7 +48,9 @@ impl Deserializable for PrivateKey {
let mut arr = [0u8; Self::OutputSize::USIZE];
arr.copy_from_slice(encoded);

let sk = PrivateKey(arr.into());
let sk = PrivateKey(
x_wing::DecapsulationKey::from(arr).reject_x25519_non_contributory_behaviour(),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can make this configurable like I did in RustCrypto/KEMs#369 if you prefer for the next release.

);
arr.zeroize();

Ok(sk)
Expand Down Expand Up @@ -178,7 +180,10 @@ impl KemTrait for XWing {
"X-Wing doesn't support authenticated encapsulation. Use Base or Psk operation mode."
);

let ss = sk_recip.0.decapsulate(&encapped_key.0);
let ss = sk_recip
.0
.try_decapsulate(&encapped_key.0)
.map_err(|_| HpkeError::DecapError)?;
Ok(SharedSecret(ss))
}

Expand Down
Loading