fix(deps): support android 16kb page size + dep updates#68
Merged
Conversation
Reviewer's GuideThis PR replaces the previous EncryptedFile-based key storage with a custom AndroidKeyStore-backed AES-GCM encryption approach (storing IV alongside ciphertext) and updates several core dependencies to newer versions. Class diagram for updated Encryption key storage logicclassDiagram
class Encryption {
<<object>>
+doesKeyExist(keyId: String): Boolean
+storeKey(key: Key, keyId: String)
+loadKey(keyId: String): Key?
-keyName(keyId: String?): String
-getOrCreateSecretKey(): SecretKey
-keyStore: KeyStore
-ANDROID_KEYSTORE: String
-KEY_ALIAS: String
-ENCRYPTION_ALGORITHM: String
-ENCRYPTION_BLOCK_MODE: String
-ENCRYPTION_PADDING: String
-TRANSFORMATION_STRING: String
-GCM_IV_LENGTH: Int
-AES_KEY_SIZE: Int
}
Encryption --> KeyStore
Encryption --> SecretKey
Encryption --> Key
Encryption --> Cipher
Encryption --> File
Encryption --> CipherInputStream
Encryption --> CipherOutputStream
Flow diagram for new key storage and retrieval processflowchart TD
A["storeKey(key, keyId)"] --> B["Get or create SecretKey from AndroidKeyStore"]
B --> C["Initialize AES-GCM Cipher (ENCRYPT_MODE)"]
C --> D["Write IV to start of file"]
D --> E["Encrypt key bytes and write to file using CipherOutputStream"]
F["loadKey(keyId)"] --> G["Read IV from start of file"]
G --> H["Get or create SecretKey from AndroidKeyStore"]
H --> I["Initialize AES-GCM Cipher (DECRYPT_MODE) with IV"]
I --> J["Decrypt key bytes using CipherInputStream"]
J --> K["Return Key object"]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `android/src/main/java/io/rownd/android/util/Encryption.kt:103` </location>
<code_context>
+ FileInputStream(file).use { fileIn ->
+ // Read the IV from the start of the file
+ val iv = ByteArray(GCM_IV_LENGTH)
+ fileIn.read(iv)
+
+ val secretKey = getOrCreateSecretKey()
</code_context>
<issue_to_address>
**issue (bug_risk):** No check for incomplete IV read from file.
If fileIn.read(iv) returns fewer bytes than GCM_IV_LENGTH, cryptographic operations may fail. Please verify the number of bytes read and handle incomplete reads appropriately.
</issue_to_address>
### Comment 2
<location> `android/src/main/java/io/rownd/android/util/Encryption.kt:119-120` </location>
<code_context>
return null
} catch (error: Exception) {
- Log.e("Rownd", "Failed to load encryption key: ${error.message}")
+ Log.e("Rownd", "Failed to load encryption key: ${error.message}", error)
+ // It's possible the key is corrupt or something changed, delete it
+ file.delete()
return null
</code_context>
<issue_to_address>
**issue (bug_risk):** Automatically deleting key file on any exception may be risky.
Restrict key file deletion to cases where corruption or decryption failure is confirmed, rather than on all exceptions.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
BobbyRadford
approved these changes
Nov 18, 2025
0b96c8e to
5380849
Compare
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.
Fixes #67
Summary by Sourcery
Replace EncryptedFile-based key persistence with custom AES-GCM encryption using AndroidKeyStore to support 16KB page-size devices and update various project dependencies
Bug Fixes:
Enhancements:
Build: