CryptoPassphrase  Check-in [496f11bd4b]

Overview
Comment:iOS: Update to recent changes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 496f11bd4b7d18ad38653da99426f0504b08ac33f41c89081815415218abf3a7
User & Date: js on 2020-01-03 00:19:45
Other Links: manifest | tags
Context
2020-06-24
17:23
Adjust to ObjFW changes check-in: 6de67efc1d user: js tags: trunk
2020-01-03
00:19
iOS: Update to recent changes check-in: 496f11bd4b user: js tags: trunk
00:03
Use non-swappable memory check-in: d5ba7b8a87 user: js tags: trunk
Changes

Modified iOS/ShowDetailsController.swift from [3b6682d3d0] to [768edd5da6].

147
148
149
150
151
152
153
154
155







156
157
158
159
160
161
162
163
164

165
166
167
168

169
170
171
172
173
174
175

176
177
178
179
180
181
182
183
184
185
147
148
149
150
151
152
153


154
155
156
157
158
159
160
161
162
163
164
165
166
167


168




169
170






171
172
173

174
175
176
177
178
179
180







-
-
+
+
+
+
+
+
+







-
-
+
-
-
-
-
+

-
-
-
-
-
-
+


-








            let keyFilePath =
                documentDirectory.ofObject.appending(keyFile.ofObject)
            generator.keyFile = OFMutableData(contentsOfFile: keyFilePath)
        }

        let passphraseText = (passphraseField?.text ?? "") as NSString
        let passphrase = of_strdup(passphraseText.utf8String!)!
        generator.passphrase = UnsafePointer<CChar>(passphrase)
        let passphraseLen =
            passphraseText.lengthOfBytes(using: String.Encoding.utf8.rawValue)
        let passphrase = OFSecureData(count: passphraseLen,
                                      allowsSwappableMemory: false)
        memcpy(passphrase.mutableItems, passphraseText.utf8String!,
               passphraseLen)
        generator.passphrase = passphrase

        let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
        let activityController = mainStoryboard.instantiateViewController(
            withIdentifier: "activityIndicator")
        navigationController?.view.addSubview(activityController.view)

        DispatchQueue.global(qos: .default).async {
            OFException.try({
                generator.derivePassword()
            generator.derivePassword()
            }, finally: {
                if let keyFile = generator.keyFile as? OFMutableData {
                    of_explicit_memset(keyFile.mutableItems, 0, keyFile.count)
                }
        }

                of_explicit_memset(passphrase, 0, strlen(passphrase))
                free(passphrase)
            })
        }

        let password = NSMutableString(bytes: generator.output,
        let password = NSMutableString(bytes: generator.output.items,
                                       length: generator.length,
                                       encoding: String.Encoding.utf8.rawValue)!
        of_explicit_memset(generator.output, 0, generator.length)

        DispatchQueue.main.sync {
            activityController.view.isHidden = true
            block(password)
        }
    }