-
Notifications
You must be signed in to change notification settings - Fork 46
Add KeyStoreBackedSecretKeyProvider, Fixes AB#3274176 #2674
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
Conversation
|
❌ Work item link check failed. Description does not contain AB#{ID}. Click here to Learn more. |
…tants and documentation; refine StorageEncryptionManager logic; clean up PredefinedKeyProvider and MockAES256KeyProvider imports.
…move CipherSpec and KeyGenSpec classes; enhance CryptoParameterSpecFactory with updated parameter specifications.
…lasses; update unwrapping logic, enhance cipher specifications, and improve key retrieval methods.
…edKeyProvider - Added AndroidWrappedKeyProviderFactory to create wrapped key loaders based on feature flags. - Introduced OAEPAndroidWrappedKeyProvider for handling key wrapping and unwrapping using OAEP padding. - Updated CryptoParameterSpecFactory to support new key generation specifications and improved documentation. - Refactored CryptoSpecs to enhance clarity and maintainability. - Removed deprecated methods from AndroidKeyStoreUtil to streamline key management. - Enhanced unit tests for CryptoParameterSpecFactory to cover new functionality and edge cases. - Cleaned up FileUtil by removing unused methods related to string file operations.
…ons; refactor NewAndroidWrappedKeyProvider to utilize new specs and remove legacy key generation methods.
…eyProvider in tests; add KeyStoreBackedSecretKeyProvider and factory for key management.
- Introduced `KeyStoreBackedSecretKeyProvider` to replace the legacy `AndroidWrappedKeyProvider`, improving security with enhanced encryption paddings. - Updated `CryptoParameterSpecFactory` to include detailed initialization logging and improved cipher specification handling. - Refactored `KeyGenSpec` and `LegacyKeyGenSpec` for better clarity and added documentation. - Enhanced `AndroidKeyStoreUtil` to provide clearer methods for retrieving encryption paddings from key pairs. - Updated tests to reflect changes in method names and ensure compatibility with the new key provider. - Added telemetry attributes for secret key wrapping operations to improve observability. - Modified feature flags to control the use of the new key provider implementation.
…add Kotlin test cases
…p and unwrap methods
…rmats - Added WrappedSecretKeyLegacySerializer for backward compatibility with legacy key formats. - Implemented WrappedSecretKeySerializerManager to manage serialization formats and version detection. - Updated WrappedSecretKeyTest to cover serialization and deserialization for both legacy and new formats. - Enhanced version detection logic to handle different serialization formats. - Modified CommonFlight to control the WrappedSecretKey serializer version instead of a simple enable/disable flag.
… logging in serializer manager
There’s no limitation in the code; I chose this approach so that in case of a rollback, it’s easier to move from one state to another. It also provides more granularity in the release, allowing us to ensure that each step of the new changes works as expected. |
… in KeyStoreBackedSecretKeyProvider
...va/com/microsoft/identity/common/crypto/wrappedsecretkey/WrappedSecretKeyLegacySerializer.kt
Show resolved
Hide resolved
...om/microsoft/identity/common/crypto/wrappedsecretkey/WrappedSecretKeyJsonObjectSerializer.kt
Outdated
Show resolved
Hide resolved
…ove metadata handling
…add unit tests for serializer manager
.../microsoft/identity/common/crypto/wrappedsecretkey/WrappedSecretKeyBinaryStreamSerializer.kt
Show resolved
Hide resolved
common/src/main/java/com/microsoft/identity/common/crypto/KeyStoreBackedSecretKeyProvider.kt
Outdated
Show resolved
Hide resolved
...va/com/microsoft/identity/common/crypto/wrappedsecretkey/WrappedSecretKeyLegacySerializer.kt
Show resolved
Hide resolved
.../microsoft/identity/common/crypto/wrappedsecretkey/WrappedSecretKeySerializerWithMetadata.kt
Outdated
Show resolved
Hide resolved
.../microsoft/identity/common/crypto/wrappedsecretkey/WrappedSecretKeySerializerWithMetadata.kt
Outdated
Show resolved
Hide resolved
mohitc1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
…zer and update related classes for improved structure and metadata handling.
…dWrappedKeyProvider
Summary
This PR has two main goals: to seamlessly update the encryption padding used in the Android KeyStore, and to lay the groundwork for integrating future cryptographic requirements with minimal changes.
Phase 1: Replace
AndroidWrappedKeyProviderwithKeyStoreBackedSecretKeyProviderController Flag:
ENABLE_KEYSTORE_BACKED_SECRET_KEY_PROVIDERBehavior When Enabled:
KeyStoreBackedSecretKeyProviderinstead ofAndroidWrappedKeyProvider.KeyPairoaepCipherSpecandpkcs1CipherSpec)KeyPairsupports.KeyPaironly supportsPKCS1, then all keys will be encrypted and decrypted usingPKCS1.Goal:
Tests
AndroidWrappedKeyProviderTesthas been parameterized to confirm both providers behave identically.KeyStoreBackedSecretKeyProviderRolloutTest.javaincludes test to validate migration and rollbackPhase 2: Enable New Wrapped Secret Key Format with Metadata Support
Before introducing new key types, we need to ensure that all new keys include additional metadata that specifies how they were encrypted.
Controller Flag:
ENABLE_NEW_WRAPPED_SECRET_KEY_FORMATBehavior When Enabled:
WrappedSecretKeywill use an enhanced binary format with the following structure:Goal:
WrappedSecretKeycan read both new and old keys.Tests
WrappedSecretKeyTestPhase 3: Add OAEP encryption padding.
Controller Flag:
ENABLE_OAEP_WITH_SHA_AND_MGF1_PADDINGBehavior When Enabled:
CryptoParameterSpecFactorywill now return two paddings:ENCRYPTION_PADDING_RSA_PKCS1andENCRYPTION_PADDING_RSA_OAEPfor the KeyGen specifications.KeyStoreBackedSecretKeyProviderwill generate aKeyPairthat supportsENCRYPTION_PADDING_RSA_OAEP.SecretKeyneeds to be wrapped, the provider will select OAEP, since theKeyPairnow supports this padding and OAEP cipher support was already introduced in Phase 1.Goal:
Tests
KeyStoreBackedSecretKeyProviderRolloutTest.javaincludes test to validate migration and rollbackTelemetry
AB#3274176
https://github.com/AzureAD/ad-accounts-for-android/pull/3166