feat: Add Samsung Knox integration and biometric fallback to device passcode #781
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.
Add Samsung Knox storage support
What this PR does
Adds Samsung Knox hardware-backed encryption as a new storage option. On Samsung devices, this gives you FIPS 140-2 compliant encryption with dedicated security hardware. On non-Samsung devices, it gracefully falls back to regular Android Keystore.
Also fixed an annoying bug where biometric auth would fail if you didn't have fingerprint/face hardware - now it properly falls back to device PIN/password.
Why Knox?
Samsung Knox provides better isolation than standard Android TEE. On newer Samsung devices (S21+), Knox Vault runs on a completely separate processor from the main Android OS. It's also got government certifications (FIPS 140-2, Common Criteria EAL4+) which matters for banking/healthcare/enterprise apps.
The implementation uses:
New API
What changed
New files:
CipherStorageKnox.kt- Knox encryption implementationKnoxUtils.kt- Knox helper functionsknox-integration.md- Documentation with security detailsknoxTest.spec.js- E2E tests for Knox storageModified:
ResultHandlerInteractiveBiometric.kt- Added KeyguardManager fallback when BiometricPrompt isn't availableKeychainModule.kt- Integrated Knox and fixed passcode fallback logicPackage refactoring:
Moved Knox code to
com.athex.knoxkeychainfor better organization.Biometric fallback fix
While working on this, I noticed biometric auth was throwing errors on devices/emulators without biometric hardware. Fixed it by adding a KeyguardManager fallback that shows the device PIN/password prompt instead. This works globally for all storage types, not just Knox.
Testing
Created E2E tests but they need a real Samsung device to fully test Knox Vault features. The fallback to Android Keystore works fine on emulators and non-Samsung devices though.
When to use Knox
Good for:
Not needed for:
Docs
Added comprehensive docs based on official Samsung Knox documentation:
Breaking changes
None - this is purely additive. Existing code continues to work exactly as before.