-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More flexible API for AWS LC cipher suite (#246)
* More flexible builder for AWS LC cipher suite * Fixup * Bump version * Fixup --------- Co-authored-by: Marta Mularczyk <[email protected]>
- Loading branch information
Showing
7 changed files
with
214 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use mls_rs_core::crypto::{CipherSuite, CipherSuiteProvider}; | ||
use mls_rs_crypto_awslc::{AwsLcCipherSuiteBuilder, AwsLcHash}; | ||
use mls_rs_crypto_traits::{AeadId, Curve, KdfId}; | ||
|
||
use aws_lc_rs::hmac; | ||
|
||
#[test] | ||
fn custom_cipher_suite() { | ||
let cs = AwsLcCipherSuiteBuilder::new() | ||
.aead(AeadId::Aes128Gcm) | ||
.hash(AwsLcHash::new(CipherSuite::P256_AES128).unwrap()) | ||
.kdf(KdfId::HkdfSha384) | ||
.mac_algo(hmac::HMAC_SHA384) | ||
.signing(Curve::P521) | ||
.hpke(CipherSuite::P521_AES256) | ||
.build(CipherSuite::new(12345)) | ||
.unwrap(); | ||
|
||
let (sk, pk) = cs.kem_derive(b"12345").unwrap(); | ||
let ctxt = cs.hpke_seal(&pk, b"info", Some(b"aad"), b"pt").unwrap(); | ||
|
||
cs.hpke_open(&ctxt, &sk, &pk, b"info", Some(b"aad")) | ||
.unwrap(); | ||
} | ||
|
||
#[cfg(feature = "post-quantum")] | ||
#[test] | ||
fn custom_pq_cipher_suite() { | ||
use mls_rs_crypto_awslc::{MlKem, Sha3}; | ||
|
||
let hash = AwsLcHash::new_sha3(Sha3::SHA3_384).unwrap(); | ||
|
||
let cs = AwsLcCipherSuiteBuilder::new() | ||
.hash(hash) | ||
.combined_hpke( | ||
CipherSuite::CURVE25519_AES128, | ||
MlKem::MlKem1024, | ||
KdfId::HkdfSha384, | ||
AeadId::Aes256Gcm, | ||
hash, | ||
) | ||
.fallback_cipher_suite(CipherSuite::P521_AES256) | ||
.build(CipherSuite::new(12345)) | ||
.unwrap(); | ||
|
||
let (sk, pk) = cs.kem_derive(b"12345").unwrap(); | ||
let ctxt = cs.hpke_seal(&pk, b"info", Some(b"aad"), b"pt").unwrap(); | ||
|
||
cs.hpke_open(&ctxt, &sk, &pk, b"info", Some(b"aad")) | ||
.unwrap(); | ||
} |