1
2
3
4
5
6
7
8
9
|
/*
* Copyright (c) 2016, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/scrypt-pwgen.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
|
|
|
1
2
3
4
5
6
7
8
9
|
/*
* Copyright (c) 2016, 2017, Jonathan Schleifer <js@heap.zone>
*
* https://heap.zone/git/scrypt-pwgen.git
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
|
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
if (_legacy)
generator = [LegacyPasswordGenerator generator];
else
generator = [NewPasswordGenerator generator];
generator.site = _name;
generator.length = _length;
passphrase = of_strdup(self.passphraseField.text.UTF8String);
generator.passphrase = passphrase;
mainStoryboard = [UIStoryboard storyboardWithName: @"Main"
bundle: nil];
activityController = [mainStoryboard
instantiateViewControllerWithIdentifier: @"activityIndicator"];
[self.navigationController.view addSubview: activityController.view];
dispatch_async(dispatch_get_global_queue(
DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^ {
@try {
[generator derivePassword];
} @finally {
of_explicit_memset(passphrase, 0, strlen(passphrase));
free(passphrase);
}
NSMutableString *password = [[[NSMutableString alloc]
initWithBytes: (char *)generator.output
length: generator.length
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
if (_legacy)
generator = [LegacyPasswordGenerator generator];
else
generator = [NewPasswordGenerator generator];
generator.site = _name;
generator.length = _length;
if (_keyFile != nil) {
NSString *documentDirectory;
OFString *keyFilePath;
if ((documentDirectory = NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory, NSUserDomainMask, YES).firstObject) ==
nil) {
NSLog(@"Could not get key files: No documents "
@"directory");
return;
}
keyFilePath = [documentDirectory.OFObject
stringByAppendingPathComponent: _keyFile];
generator.keyFile = [OFMutableData
dataWithContentsOfFile: keyFilePath];
}
passphrase = of_strdup(self.passphraseField.text.UTF8String);
generator.passphrase = passphrase;
mainStoryboard = [UIStoryboard storyboardWithName: @"Main"
bundle: nil];
activityController = [mainStoryboard
instantiateViewControllerWithIdentifier: @"activityIndicator"];
[self.navigationController.view addSubview: activityController.view];
dispatch_async(dispatch_get_global_queue(
DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^ {
@try {
[generator derivePassword];
} @finally {
if (generator.keyFile != nil)
of_explicit_memset(
(void *)generator.keyFile.items, 0,
generator.keyFile.count);
of_explicit_memset(passphrase, 0, strlen(passphrase));
free(passphrase);
}
NSMutableString *password = [[[NSMutableString alloc]
initWithBytes: (char *)generator.output
length: generator.length
|