Repository navigation
Conversation
…elease/0.1.3alpha) Each symmetric cipher instantiation carries its own key type, so a key made for one algorithm cannot be used with another: a new public trait SymmetricCipherKey<KEY_LEN>, a shallow wrapper over KeyMaterial<KEY_LEN> that carries the algorithm's key policy, and a generic parameter K: SymmetricCipherKey<KEY_LEN> threaded through the cipher traits and every mode in bouncycastle-cipher. Each alias gets its key type (AES_CBC_128_Key, AES_GCM_256_Key, Ascon_AEAD128_Key, ...). This is PR bcgit#167 (02b852b) re-applied to release/0.1.3alpha as one commit. bcgit#167 was written against feature/simple-ciphers at 20b9051; release has since taken the rest of that branch (PR bcgit#133), so the change is ported onto it: - Ascon: the key type goes onto release's Ascon_AEAD128<Dir> struct; bcgit#167's changes to the removed AsconAead128 wrappers and inherent API are dropped. Resume no longer re-checks the key, since a typed key has passed the policy when it was made. Suspended-state layout is unchanged. - API added on release after 20b9051 now takes &K as well: the AEADCipherEncryptor *_nonce methods, CCM's one-shot and trait-pair impls, GCM's do_encrypt_init_nonce. - The toy block cipher lives in crypto/cipher/tests/common on release; ToyCipherKey is ported there, and the tests/modes toys and the ctr_key_stream unit tests share one inclusion of it. core-test-framework drops the bouncycastle-rng dependency bcgit#167 added for the toy. - Tests and benches that release reorganised get bcgit#167's change in their new form: padded_alias_tests.rs and alias_tests.rs (for cbc_/ecb_alias_tests.rs), the suspend-test macro, the de-duplicated aes_modes_benches, alg_name_tests, the mem-usage benches. - bcgit#167's ECB-based rewrites of fips197_tests, sp800_38a_ecb_tests and ecb_bc-test-data use release's modes::hazmat::ecb::Ecb path, ModeNames bound and do_*_blocks_inplace. - aes_benches.rs is deleted as in bcgit#167; the aes_modes_benches docs no longer refer to it. Assisted-by: Claude:claude-fable-5-1 Assisted-by: Claude:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
(this is a refactor of #167 onto release/0.1.3alpha after #133 was merged)
The core problem being solved here is that when a symmetric cipher algorithm simply requires a
key: &KeyMaterial<N>, then nothing is preventing you from, for example, using the same key for AES_128_CBC and Ascon_AEAD128.This PR adds per-algorithm key types, such as
AES_128_CBC_KeyandAscon_AEAD128_Keyso that cross-algorithm key re-use can be detected and blocked at compile-time.Claude-generated PR description:
Each symmetric cipher instantiation carries its own key type, so a key made for one algorithm cannot be used with another: a new public trait SymmetricCipherKey<KEY_LEN>, a shallow wrapper over KeyMaterial<KEY_LEN> that carries the algorithm's key policy, and a generic parameter K: SymmetricCipherKey<KEY_LEN> threaded through the cipher traits and every mode in bouncycastle-cipher. Each alias gets its key type (AES_CBC_128_Key, AES_GCM_256_Key, Ascon_AEAD128_Key, ...).
This is PR #167 (02b852b) re-applied to release/0.1.3alpha as one commit. #167 was written against feature/simple-ciphers at 20b9051; release has since taken the rest of that branch (PR #133), so the change is ported onto it:
Assisted-by: Claude:claude-fable-5-1
Assisted-by: Claude:claude-opus-5-5