CryptoPassphrase  Check-in [a3b521da82]

Overview
Comment:Adjust to recent ObjFW changes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: a3b521da82c919bf4ebbd7cd2c1c3d18cd04fbb86ff95a07b56a54cbde972505
User & Date: js on 2017-05-08 00:39:06
Other Links: manifest | tags
Context
2017-08-11
20:17
Adjust to ObjFW changes check-in: 484db716a1 user: js tags: trunk
2017-05-08
00:39
Adjust to recent ObjFW changes check-in: a3b521da82 user: js tags: trunk
2017-04-15
19:23
Fix URL in copyright header check-in: 4514c363cd user: js tags: trunk
Changes

Modified PasswordGenerator.h from [8e2387dd06] to [a21fea91c9].

20
21
22
23
24
25
26
27

28
29
30
31
32
33
20
21
22
23
24
25
26

27
28
29
30
31
32
33







-
+






 * POSSIBILITY OF SUCH DAMAGE.
 */

#import <ObjFW/ObjFW.h>

@protocol PasswordGenerator
@property size_t length;
@property (copy) OFString *site;
@property (nonatomic, copy) OFString *site;
@property const char *passphrase;
@property (readonly) unsigned char *output;

+ (instancetype)generator;
- (void)derivePassword;
@end

Modified iOS/AboutController.h from [a855cd3b87] to [28639844bc].

19
20
21
22
23
24
25
26

27
19
20
21
22
23
24
25

26
27







-
+

 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

@import UIKit;

@interface AboutController: UIViewController <UIWebViewDelegate>
@property (retain, nonatomic) IBOutlet UIWebView *webView;
@property (nonatomic, retain) IBOutlet UIWebView *webView;
@end

Modified iOS/AboutController.m from [ffeb2faff2] to [253edc0533].

76
77
78
79
80
81
82
83
84


85
86
87
88
89
90
91
76
77
78
79
80
81
82


83
84
85
86
87
88
89
90
91







-
-
+
+







- (void)dealloc
{
	[_webView release];

	[super dealloc];
}

-	       (BOOL)webView: (UIWebView*)webView
  shouldStartLoadWithRequest: (NSURLRequest*)request
-	       (BOOL)webView: (UIWebView *)webView
  shouldStartLoadWithRequest: (NSURLRequest *)request
	      navigationType: (UIWebViewNavigationType)navigationType
{
	if (navigationType == UIWebViewNavigationTypeLinkClicked) {
		[[UIApplication sharedApplication] openURL: request.URL
						   options: @{}
					 completionHandler: ^ (BOOL success) {
		}];

Modified iOS/AddSiteController.h from [831f218447] to [2b7d1da06f].

21
22
23
24
25
26
27
28
29
30



31
32
33
34
35
21
22
23
24
25
26
27



28
29
30
31
32
33
34
35







-
-
-
+
+
+





 */

@import UIKit;

#import "MainViewController.h"

@interface AddSiteController: UITableViewController
@property (retain, nonatomic) IBOutlet UITextField *nameField;
@property (retain, nonatomic) IBOutlet UITextField *lengthField;
@property (retain, nonatomic) IBOutlet UISwitch *legacySwitch;
@property (nonatomic, retain) IBOutlet UITextField *nameField;
@property (nonatomic, retain) IBOutlet UITextField *lengthField;
@property (nonatomic, retain) IBOutlet UISwitch *legacySwitch;
@property (retain) MainViewController *mainViewController;

- (IBAction)done: (id)sender;
- (IBAction)cancel: (id)sender;
@end

Modified iOS/AppDelegate.h from [5d56a2961e] to [0d722456ba].

19
20
21
22
23
24
25
26

27
19
20
21
22
23
24
25

26
27







-
+

 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

@import UIKit;

@interface AppDelegate: UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (nonatomic, strong) UIWindow *window;
@end

Modified iOS/MainViewController.h from [51c284ba33] to [ff0377e51e].

23
24
25
26
27
28
29
30

31
23
24
25
26
27
28
29

30
31







-
+

@import UIKit;

#import "SiteStorage.h"

@interface MainViewController: UIViewController <UITableViewDelegate,
    UITableViewDataSource>
@property (retain) SiteStorage *siteStorage;
@property (retain, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, retain) IBOutlet UITableView *tableView;
@end

Modified iOS/MainViewController.m from [08c2db049a] to [6921fa1360].

37
38
39
40
41
42
43
44

45
46
47
48
49
50
51


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67


68
69
70
71
72
73

74
75
76
77
78
79
80
37
38
39
40
41
42
43

44
45
46
47
48
49


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65


66
67
68
69
70
71
72

73
74
75
76
77
78
79
80







-
+





-
-
+
+














-
-
+
+





-
+







{
	[_siteStorage release];
	[_tableView release];

	[super dealloc];
}

-  (NSInteger)tableView: (UITableView*)tableView
-  (NSInteger)tableView: (UITableView *)tableView
  numberOfRowsInSection: (NSInteger)section
{
	return [self.siteStorage sitesCount];
}

- (UITableViewCell*)tableView: (UITableView*)tableView
	cellForRowAtIndexPath: (NSIndexPath*)indexPath
- (UITableViewCell *)tableView: (UITableView *)tableView
	 cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
	UITableViewCell *cell = [tableView
	    dequeueReusableCellWithIdentifier: @"site"];

	if (cell == nil)
		cell = [[[UITableViewCell alloc]
		      initWithStyle: UITableViewCellStyleDefault
		    reuseIdentifier: @"site"] autorelease];

	cell.textLabel.text = [self.siteStorage.sites[indexPath.row] NSObject];

	return cell;
}

-	  (void)tableView: (UITableView*)tableView
  didSelectRowAtIndexPath: (NSIndexPath*)indexPath
-	  (void)tableView: (UITableView *)tableView
  didSelectRowAtIndexPath: (NSIndexPath *)indexPath
{
	[self performSegueWithIdentifier: @"showDetails"
				  sender: self];
}

- (void)prepareForSegue: (UIStoryboardSegue*)segue
- (void)prepareForSegue: (UIStoryboardSegue *)segue
		 sender: (id)sender
{
	if ([segue.identifier isEqual: @"addSite"] ||
	    [segue.identifier isEqual: @"showDetails"])
		[segue.destinationViewController setMainViewController: self];
}
@end

Modified iOS/ShowDetailsController.m from [75a5ea2c02] to [07cb7c3f7e].

27
28
29
30
31
32
33
34

35
36
37
38
39
40
41
27
28
29
30
31
32
33

34
35
36
37
38
39
40
41







-
+








#import "SiteStorage.h"
#import "PasswordGenerator.h"
#import "NewPasswordGenerator.h"
#import "LegacyPasswordGenerator.h"

@interface ShowDetailsController ()
- (void)_generateWithCallback: (void(^)(NSMutableString*))block;
- (void)_generateWithCallback: (void (^)(NSMutableString *))block;
- (void)_generateAndCopy;
- (void)_generateAndShow;
@end

static void
clearNSMutableString(NSMutableString *string)
{
82
83
84
85
86
87
88
89

90
91
92
93
94
95
96


97
98
99
100
101
102
103
82
83
84
85
86
87
88

89
90
91
92
93
94


95
96
97
98
99
100
101
102
103







-
+





-
-
+
+







}

- (void)viewDidAppear: (BOOL)animated
{
	[self.passphraseField becomeFirstResponder];
}

- (BOOL)textFieldShouldReturn: (UITextField*)textField
- (BOOL)textFieldShouldReturn: (UITextField *)textField
{
	[textField resignFirstResponder];
	return NO;
}

-	  (void)tableView: (UITableView*)tableView
  didSelectRowAtIndexPath: (NSIndexPath*)indexPath
-	  (void)tableView: (UITableView *)tableView
  didSelectRowAtIndexPath: (NSIndexPath *)indexPath
{
	[self.passphraseField resignFirstResponder];
	[tableView deselectRowAtIndexPath: indexPath
				 animated: YES];

	if (indexPath.section == 3) {
		switch (indexPath.row) {
157
158
159
160
161
162
163
164

165
166
167
168
169
170
171
157
158
159
160
161
162
163

164
165
166
167
168
169
170
171







-
+







				   animated: YES
				 completion: ^ {
			clearNSMutableString(password);
		}];
	}];
}

- (void)_generateWithCallback: (void(^)(NSMutableString*))block
- (void)_generateWithCallback: (void (^)(NSMutableString *))block
{
	UIStoryboard *mainStoryboard =
	[UIStoryboard storyboardWithName: @"Main"
				  bundle: nil];
	UIViewController *activityController = [mainStoryboard
	    instantiateViewControllerWithIdentifier: @"activityIndicator"];
	[self.navigationController.view addSubview: activityController.view];
191
192
193
194
195
196
197
198

199
200

201
202
203
204
205
206
207
191
192
193
194
195
196
197

198
199

200
201
202
203
204
205
206
207







-
+

-
+







			[generator derivePassword];
		} @finally {
			of_explicit_memset(passphrase, 0, strlen(passphrase));
			free(passphrase);
		}

		NSMutableString *password = [NSMutableString
		    stringWithUTF8String: (char*)generator.output];
		    stringWithUTF8String: (char *)generator.output];
		of_explicit_memset(generator.output, 0,
		    strlen((char*)generator.output));
		    strlen((char *)generator.output));

		activityController.view.hidden = YES;
		block(password);
	});
}

- (IBAction)remove: (id)sender

Modified iOS/SiteStorage.h from [742d8e3dfb] to [ad39e5016f].

21
22
23
24
25
26
27
28

29
30
31
32

33

34
35
36
37
38




39
40
41

42
21
22
23
24
25
26
27

28
29
30
31
32
33

34
35




36
37
38
39
40
41

42
43







-
+




+
-
+

-
-
-
-
+
+
+
+


-
+

 */

@import ObjFW;

@interface SiteStorage: OFObject
{
	OFString *_path;
	OFMutableDictionary <OFString*, OFDictionary <OFNumber*, OFNumber*>*>
	OFMutableDictionary<OFString *, OFDictionary<OFNumber *, OFNumber *> *>
	    *_storage;
	OFArray *_sites;
}

@property (readonly, nonatomic) OFArray<OFString *> *sites;
- (OFArray*)sites;

- (size_t)sitesCount;
- (bool)hasSite: (OFString*)name;
- (size_t)lengthForSite: (OFString*)name;
- (bool)isSiteLegacy: (OFString*)name;
- (void)setSite: (OFString*)site
- (bool)hasSite: (OFString *)name;
- (size_t)lengthForSite: (OFString *)name;
- (bool)isSiteLegacy: (OFString *)name;
- (void)setSite: (OFString *)site
	 length: (size_t)length
	 legacy: (bool)legacy;
- (void)removeSite: (OFString*)name;
- (void)removeSite: (OFString *)name;
@end

Modified iOS/SiteStorage.m from [06f1c18e56] to [ad9c1f261f].

80
81
82
83
84
85
86
87

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102

103
104
105
106
107

108
109
110
111
112
113
114
115
116
117

118
119
120
121
122
123
124
125
126
127

128
129
130
131
132
133
134
135
136
137
138
139
140
141
142

143
144
145
146
147
148
149
80
81
82
83
84
85
86

87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

102
103
104
105
106

107
108
109
110
111
112
113
114
115
116

117
118
119
120
121
122
123
124
125
126

127
128
129
130
131
132
133
134
135
136
137
138
139
140
141

142
143
144
145
146
147
148
149







-
+














-
+




-
+









-
+









-
+














-
+







	[_path release];
	[_storage release];
	[_sites release];

	[super dealloc];
}

- (OFArray*)sites
- (OFArray<OFString *> *)sites
{
	void *pool = objc_autoreleasePoolPush();
	OFArray *sites = [[_storage allKeys] sortedArray];

	[sites retain];
	objc_autoreleasePoolPop(pool);
	return [sites autorelease];
}

- (size_t)sitesCount
{
	return [_storage count];
}

- (bool)hasSite: (OFString*)name
- (bool)hasSite: (OFString *)name
{
	return (_storage[name] != nil);
}

- (size_t)lengthForSite: (OFString*)name
- (size_t)lengthForSite: (OFString *)name
{
	OFDictionary *site = _storage[name];

	if (site == nil)
		@throw [OFInvalidArgumentException exception];

	return [site[lengthField] sizeValue];
}

- (bool)isSiteLegacy: (OFString*)name
- (bool)isSiteLegacy: (OFString *)name
{
	OFDictionary *site = _storage[name];

	if (site == nil)
		@throw [OFInvalidArgumentException exception];

	return [site[legacyField] boolValue];
}

- (void)setSite: (OFString*)site
- (void)setSite: (OFString *)site
	 length: (size_t)length
	 legacy: (bool)legacy
{
	void *pool = objc_autoreleasePoolPush();

	_storage[site] = @{
		lengthField: @(length),
		legacyField: @(legacy)
	};
	[self _update];

	objc_autoreleasePoolPop(pool);
}

- (void)removeSite: (OFString*)name
- (void)removeSite: (OFString *)name
{
	[_storage removeObjectForKey: name];
	[self _update];
}

- (void)_update
{

Modified iOS/scrypt-pwgen.xcodeproj/project.pbxproj from [37645065ae] to [458f6062a4].

358
359
360
361
362
363
364
365

366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383

384
385
386
387
388
389
390
358
359
360
361
362
363
364

365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382

383
384
385
386
387
388
389
390







-
+

















-
+







				ENABLE_BITCODE = NO;
				FRAMEWORK_SEARCH_PATHS = (
					"$(inherited)",
					"$(PROJECT_DIR)",
				);
				INFOPLIST_FILE = Info.plist;
				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
				PRODUCT_BUNDLE_IDENTIFIER = "zone.heap.scrypt-pwgen";
				PRODUCT_BUNDLE_IDENTIFIER = "zone.heap.scrypt-pwgen.ios";
				PRODUCT_NAME = "$(TARGET_NAME)";
			};
			name = Debug;
		};
		4B2E52F51DA942840040D091 /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
				CLANG_ENABLE_OBJC_ARC = NO;
				DEVELOPMENT_TEAM = MXKNFCKFL6;
				ENABLE_BITCODE = NO;
				FRAMEWORK_SEARCH_PATHS = (
					"$(inherited)",
					"$(PROJECT_DIR)",
				);
				INFOPLIST_FILE = Info.plist;
				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
				PRODUCT_BUNDLE_IDENTIFIER = "zone.heap.scrypt-pwgen";
				PRODUCT_BUNDLE_IDENTIFIER = "zone.heap.scrypt-pwgen.ios";
				PRODUCT_NAME = "$(TARGET_NAME)";
			};
			name = Release;
		};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */