generated from amazon-archives/__template_Custom
-
Notifications
You must be signed in to change notification settings - Fork 37
Key Package Generation / Join API 1.x #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c89fe34
Fix CI (#223)
mulmarta 3add368
feat(mls-rs): Verify the update path even in case of a self removal (…
ManevilleF 543b050
Fix bug where double-hitting a ciphertext deleted the whole ratchet (…
mulmarta d160ba6
Work around rust < 1.78 crash (#231)
glandium 2af95d3
Avoid intermediate Vec in TreeKemPublic::update_hashes (#230)
glandium 158a9d3
Add API for deleting exporters (#227)
mulmarta 18fd04f
Key package generation 1.x
0a9f377
Fix clippy warnings
fe1c93f
Initial implementation of group join 1.x
cf94d25
Add example for 1x API
369a67b
Apply suggestions from code review
5349dd3
Add SigningData struct
953107b
Fixup
1769d3b
Add more tests
eb50742
Fixup
a2d704b
Fixup
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,92 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // Copyright by contributors to this project. | ||
| // SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
|
|
||
| use std::convert::Infallible; | ||
|
|
||
| use mls_rs::{ | ||
| client_builder::MlsConfig, | ||
| error::MlsError, | ||
| identity::{ | ||
| basic::{BasicCredential, BasicIdentityProvider}, | ||
| SigningIdentity, | ||
| }, | ||
| CipherSuite, CipherSuiteProvider, Client, CryptoProvider, ExtensionList, KeyPackageStorage, | ||
| }; | ||
| use mls_rs_core::key_package::KeyPackageData; | ||
|
|
||
| const CIPHERSUITE: CipherSuite = CipherSuite::CURVE25519_AES128; | ||
|
|
||
| fn main() -> Result<(), MlsError> { | ||
| let crypto_provider = mls_rs_crypto_openssl::OpensslCryptoProvider::default(); | ||
|
|
||
| // Create clients for Alice and Bob | ||
| let alice = make_client(crypto_provider.clone(), "alice")?; | ||
| let bob = make_client(crypto_provider.clone(), "bob")?; | ||
|
|
||
| // Bob generates key package. We store secrets in memory, no need for any storage. | ||
| let key_package_generation = bob | ||
| .key_package_builder(CIPHERSUITE, None)? | ||
| .valid_for_sec(123) | ||
| .build()?; | ||
|
|
||
| let stored_secrets = key_package_generation.key_package_data; | ||
|
|
||
| // Alice creates a group with Bob. | ||
| let mut alice_group = alice.create_group(ExtensionList::default(), Default::default())?; | ||
|
|
||
| let welcomes = alice_group | ||
| .commit_builder() | ||
| .add_member(key_package_generation.key_package_message)? | ||
| .build()? | ||
| .welcome_messages; | ||
|
|
||
| alice_group.apply_pending_commit()?; | ||
|
|
||
| // Bob joins | ||
| let mut bob_group = bob.group_joiner(&welcomes[0], stored_secrets)?.join()?.0; | ||
|
|
||
| // Alice and bob can chat | ||
| let msg = alice_group.encrypt_application_message(b"hello world", Default::default())?; | ||
| let msg = bob_group.process_incoming_message(msg)?; | ||
|
|
||
| println!("Received message: {:?}", msg); | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| #[derive(Clone)] | ||
| struct NoOpKeyPackageStorage; | ||
|
|
||
| impl KeyPackageStorage for NoOpKeyPackageStorage { | ||
| type Error = Infallible; | ||
|
|
||
| fn delete(&mut self, _: &[u8]) -> Result<(), Infallible> { | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn get(&self, _: &[u8]) -> Result<Option<KeyPackageData>, Infallible> { | ||
| Ok(None) | ||
| } | ||
|
|
||
| fn insert(&mut self, _: Vec<u8>, _: KeyPackageData) -> Result<(), Infallible> { | ||
| Ok(()) | ||
| } | ||
| } | ||
|
|
||
| fn make_client<P: CryptoProvider + Clone>( | ||
| crypto_provider: P, | ||
| name: &str, | ||
| ) -> Result<Client<impl MlsConfig>, MlsError> { | ||
| let cipher_suite = crypto_provider.cipher_suite_provider(CIPHERSUITE).unwrap(); | ||
| let (secret, public) = cipher_suite.signature_key_generate().unwrap(); | ||
| let basic_identity = BasicCredential::new(name.as_bytes().to_vec()); | ||
| let signing_identity = SigningIdentity::new(basic_identity.into_credential(), public); | ||
|
|
||
| Ok(Client::builder() | ||
| .identity_provider(BasicIdentityProvider) | ||
| .crypto_provider(crypto_provider) | ||
| .signing_identity(signing_identity, secret, CIPHERSUITE) | ||
| .key_package_repo(NoOpKeyPackageStorage) | ||
| .build()) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.