Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
Problem: didn't verify secrets against public key in DirectPath
Browse files Browse the repository at this point in the history
Solution:
- verify decreted secret against public key
- also verify leaf keypackage against leaf secret
  • Loading branch information
yihuang committed Jul 29, 2020
1 parent 22fcea3 commit 2d6c0b8
Show file tree
Hide file tree
Showing 7 changed files with 436 additions and 168 deletions.
4 changes: 2 additions & 2 deletions chain-tx-enclave-next/mls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ x509-parser = "0.8.0-beta4"
secrecy = "0.7.0"
sha2 = "0.9"
hkdf = { version = "0.9", features = ["std"] }
hpke = { version = "0.1.8", default-features = false, features = ["p256"] }
hpke = { version = "0.1.8", default-features = false, features = ["p256", "std"] }
aead = "0.3"
rand = "0.7"
chrono="0.4.13"
ra-client = { path = "../enclave-ra/ra-client" }
subtle = "2.2.3"
chain-util = { path = "../../chain-util", default-features = false }
chain-util = { path = "../../chain-util" }

[dev-dependencies]
chrono = "0.4"
Expand Down
9 changes: 3 additions & 6 deletions chain-tx-enclave-next/mls/src/ciphersuite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,7 @@ impl CipherSuite {
CipherSuite::MLS10_128_DHKEMP256_AES128GCM_SHA256_P256 => {
let encapped_key = EncappedKey::<
<hpke::kem::DhP256HkdfSha256 as hpke::kem::Kem>::Kex,
>::unmarshal(&ct.kem_output)
.expect("valid encapped key");
>::unmarshal(&ct.kem_output)?;
let mut context = hpke::setup_receiver::<
AesGcm128,
hpke::kdf::HkdfSha256,
Expand All @@ -402,11 +401,9 @@ impl CipherSuite {
let payload_len = ct.ciphertext.len();
let mut payload = ct.ciphertext[0..payload_len - 16].to_vec();
let tag_bytes = &ct.ciphertext[payload_len - 16..payload_len];
let tag = AeadTag::<AesGcm128>::unmarshal(tag_bytes).expect("valid tag");
let tag = AeadTag::<AesGcm128>::unmarshal(tag_bytes)?;

context
.open(&mut payload, aad, &tag)
.expect("decryption failed");
context.open(&mut payload, aad, &tag)?;
Ok(payload)
}
}
Expand Down
Loading

0 comments on commit 2d6c0b8

Please sign in to comment.