-
Notifications
You must be signed in to change notification settings - Fork 505
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
enable encryption of contacts, accounts, and crypto DB #3878
Conversation
…ontacts, accounts, and crypto DB
private let keychainStore: KeychainStore = KeychainStore(withKeychain: Keychain(service: keychainService, accessGroup: BuildSettings.keychainAccessGroup)) | ||
|
||
private override init() { | ||
} |
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.
You should call super.init()
here but better to remove this init
as there is nothing to do.
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.
I'd prefer let the init private as the EncryptionKeyManager is only meant to be instantiated through the singleton pattern
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.
Ok I missed the private
private static let contactsIv: KeyValueStoreKey = "contactsIv" | ||
private static let contactsAesKey: KeyValueStoreKey = "contactsKey" | ||
private static let accountIv: KeyValueStoreKey = "acountIv" | ||
private static let accountAesKey: KeyValueStoreKey = "acountKey" | ||
private static let realmCryptoKey: KeyValueStoreKey = "realmCryptoKey" |
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.
You can let these variable as is. Just to mention that you can also group some variable sharing the same purpose like this:
private enum StoreKeys {
static let contactsIv: KeyValueStoreKey
static let contactsAes: KeyValueStoreKey
static let realmCrypto: KeyValueStoreKey
...
}
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.
Good idea but I'm not sure we need enum in this case.
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.
It can be a struct
with just constants. Using an enum
in this sample is just to indicate that we cannot instantiate it.
} | ||
|
||
private func generateKeyIfNotExists(forKey key: String, size: Int) { | ||
if !keychainStore.containsObject(forKey: key) { |
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.
Prefer using:
guard keychainStore.containsObject(forKey: key) else {
return
}
in this context
// MARK: - Private methods | ||
|
||
private func generateIvIfNotExists(forKey key: String) { | ||
if !keychainStore.containsObject(forKey: key) { |
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.
Prefer using:
guard keychainStore.containsObject(forKey: key) else {
return
}
in this context
# Conflicts: # CHANGES.rst # Riot.xcodeproj/project.pbxproj
Last changes requires this PR: matrix-org/matrix-ios-sdk#1027 |
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.
@manuroe your changes LGTM
fix #3867