ios - 将加密 key 存储在 defaultConfiguration 中是否安全?

标签 ios swift security realm keychain

我的 Realm 数据库已加密。 encryptionKey 存储在 Keychain 中。管理此 key 的更安全方法是什么?

目前,在实例化任何 Realm 之前,我正在从 application(application:didFinishLaunchingWithOptions:) 调用设置 defaultConfiguration(schemaVersion、migrationBlock、fileURL 等和 encryptionKey)的方法。稍后,Realms 在整个应用程序中使用此 defaultConfiguration 进行实例化。 像那样:

// AppDelegate
   var config = Realm.Configuration.defaultConfiguration
   config.schemaVersion = 5
   config.migrationBlock = { migration, oldSchemaVersion in ... }
   config.encryptionKey = KeychainManager.getRealmEncryptionKey()
   Realm.Configuration.defaultConfiguration = config

// Somewhere else, later
   Realm()

将 encryptionKey 放入 defaultConfiguration 是否安全? defaultConfiguration 在运行时存储在哪里,从中提取 key 有多容易?

或者更好的方法是在每个 Realm 实例化时从 Keychain 请求 encryptionKey 并将其放入自定义配置中,该配置仅在 Realm 实例的生命周期中出现在内存中?像这样:

// AppDelegate
   var config = Realm.Configuration.defaultConfiguration
   config.schemaVersion = 5
   config.migrationBlock = { migration, oldSchemaVersion in ... }
   Realm.Configuration.defaultConfiguration = config

// Somewhere else, later
   var configTemp = Realm.Configuration.defaultConfiguration
   configTemp.encryptionKey = KeychainManager.getRealmEncryptionKey()
   Realm(configuration: configTemp)

最佳答案

Is it safe to put encryptionKey into defaultConfiguration? Where is defaultConfiguration stored at runtime and how easy will it be to extrude key from it?

key 存储在 Realm 配置的内存中。如果您想知道一个单独的进程突破 iOS 沙盒的可能性有多大,请检查您的应用程序的内存并从中提取 key ……我们只是说这将是对最高级别操作系统的利用学位,Apple 将面临公关灾难。

所以真的,你应该做对你最方便的事情。只要您不将加密 key 以明文形式保存在磁盘上,您就会尽可能地安全。

关于ios - 将加密 key 存储在 defaultConfiguration 中是否安全?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40991523/

相关文章:

ios - 您的帐户已经有一个有效的 ios 分发证书(在虚拟机上)

ios - LibGDX 应用因不包含 NSCalendarsUsageDescription 而被 AppStore 拒绝

ios - 单选按钮不会通过选择而改变

ios - 就从图片网址下载图片而言,URLSession 与 GCD 有什么区别?

swift - 打开 MPO 文件并提取嵌入的图像

php - cookies 的解剖

ios - 以编程方式添加重复的 uiview

ios - MFMessageComposeViewController iOS7 添加附件数据 :typeIdentifier:filename: not working

python - 使用 os.path.abspath 来验证不受信任的文件名的位置是否安全?

angularjs - 用于ElasticSearch的Nginx反向代理仅允许_search端点