CryptoPassphrase  Check-in [9b9a2973bb]

Overview
Comment:[iOS] Show activity indicator during generation
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9b9a2973bb85ab5265bb64c37ec5db9b1e2657129d6984a1b0e1f9faeb68d128
User & Date: js on 2016-10-09 22:32:20
Other Links: manifest | tags
Context
2016-10-10
21:36
Replace confusable letters by special characters check-in: 03ad721972 user: js tags: trunk
2016-10-09
22:32
[iOS] Show activity indicator during generation check-in: 9b9a2973bb user: js tags: trunk
17:47
[iOS] Add about dialog check-in: 0ba1eb505d user: js tags: trunk
Changes

Modified iOS/Base.lproj/Main.storyboard from [54a6c0549b] to [f7f42c49a3].

458
459
460
461
462
463
464



































465
466
                        <outlet property="passphraseField" destination="DJv-Ey-Hka" id="zkA-6v-zc1"/>
                    </connections>
                </tableViewController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="o5r-z3-hVF" userLabel="First Responder" sceneMemberID="firstResponder"/>
            </objects>
            <point key="canvasLocation" x="1993" y="-423"/>
        </scene>



































    </scenes>
</document>







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
                        <outlet property="passphraseField" destination="DJv-Ey-Hka" id="zkA-6v-zc1"/>
                    </connections>
                </tableViewController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="o5r-z3-hVF" userLabel="First Responder" sceneMemberID="firstResponder"/>
            </objects>
            <point key="canvasLocation" x="1993" y="-423"/>
        </scene>
        <!--View Controller-->
        <scene sceneID="8JA-Zd-1zR">
            <objects>
                <viewController storyboardIdentifier="activityIndicator" id="asG-zz-a8o" sceneMemberID="viewController">
                    <layoutGuides>
                        <viewControllerLayoutGuide type="top" id="hu7-uJ-ly6"/>
                        <viewControllerLayoutGuide type="bottom" id="vvJ-kn-Vjf"/>
                    </layoutGuides>
                    <view key="view" alpha="0.90000000000000002" contentMode="scaleToFill" id="c3D-Ze-5hZ">
                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                        <subviews>
                            <activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" animating="YES" style="whiteLarge" translatesAutoresizingMaskIntoConstraints="NO" id="Qe7-Bk-J1n"/>
                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Generating…" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gXF-vs-Gda">
                                <constraints>
                                    <constraint firstAttribute="width" constant="101" id="jwK-5C-D2D"/>
                                </constraints>
                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                <nil key="highlightedColor"/>
                            </label>
                        </subviews>
                        <color key="backgroundColor" cocoaTouchSystemColor="darkTextColor"/>
                        <constraints>
                            <constraint firstItem="Qe7-Bk-J1n" firstAttribute="centerY" secondItem="c3D-Ze-5hZ" secondAttribute="centerY" id="9Lb-iu-cD0"/>
                            <constraint firstItem="Qe7-Bk-J1n" firstAttribute="centerX" secondItem="c3D-Ze-5hZ" secondAttribute="centerX" id="DYg-1r-kfn"/>
                            <constraint firstItem="Qe7-Bk-J1n" firstAttribute="centerX" secondItem="gXF-vs-Gda" secondAttribute="centerX" id="d15-94-nf5"/>
                            <constraint firstItem="gXF-vs-Gda" firstAttribute="top" secondItem="Qe7-Bk-J1n" secondAttribute="bottom" constant="8" symbolic="YES" id="n3a-cK-5jh"/>
                        </constraints>
                    </view>
                </viewController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="VFj-Pa-4qu" userLabel="First Responder" sceneMemberID="firstResponder"/>
            </objects>
            <point key="canvasLocation" x="2896.8000000000002" y="-423.23838080959524"/>
        </scene>
    </scenes>
</document>

Modified iOS/ShowDetailsController.m from [71047772f8] to [ff4cbf141f].

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 ()
- (NSMutableString*)_generate;
- (void)_generateAndCopy;
- (void)_generateAndShow;
@end

static void
clearNSMutableString(NSMutableString *string)
{







|







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)_generateAndCopy;
- (void)_generateAndShow;
@end

static void
clearNSMutableString(NSMutableString *string)
{
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
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
186
187
188
189
190

191

192
193
194
195
196
197
198
			break;
		}
	}
}

- (void)_generateAndCopy
{
	NSMutableString *password = [self _generate];

	UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
	pasteBoard.string = password;

	clearNSMutableString(password);

	UIAlertController *alert = [UIAlertController
	    alertControllerWithTitle: @"Password Generated"
			     message: @"The password has been copied into the "
				      @"clipboard."
		      preferredStyle: UIAlertControllerStyleAlert];
	[alert addAction:
	    [UIAlertAction actionWithTitle: @"OK"
				     style: UIAlertActionStyleDefault
				   handler: ^ (UIAlertAction *action) {
		[self.navigationController popViewControllerAnimated: YES];
	}]];

	[self presentViewController: alert
			   animated: YES
			 completion: nil];

}

- (void)_generateAndShow
{
	NSMutableString *password = [self _generate];

	UIAlertController *alert = [UIAlertController
	    alertControllerWithTitle: @"Generated Passphrase"
			     message: password
		      preferredStyle: UIAlertControllerStyleAlert];
	[alert addAction:
	    [UIAlertAction actionWithTitle: @"OK"
				     style: UIAlertActionStyleDefault
				   handler: ^ (UIAlertAction *action) {
		[self.navigationController popViewControllerAnimated: YES];

	}]];

	[self presentViewController: alert
			   animated: YES
			 completion: ^ {
		clearNSMutableString(password);

	}];
}

- (NSMutableString*)_generate
{









	id <PasswordGenerator> generator;
	char *passphrase;

	if (_legacy)
		generator = [LegacyPasswordGenerator generator];
	else
		generator = [NewPasswordGenerator generator];

	generator.site = _name;
	generator.length = _length;

	passphrase = of_strdup([self.passphraseField.text UTF8String]);
	@try {
		self.passphraseField.text = @"";
		generator.passphrase = passphrase;

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

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


	return password;

}

- (IBAction)remove: (id)sender
{
	UIAlertController *alert = [UIAlertController
	    alertControllerWithTitle: @"Remove Site?"
			     message: @"Do you want to remove this site?"







|
<
|
|

|

|
|
|
|
|
|
|
|
|
|
|

|
|
|
>




|
<
|
|
|
|
|
|
|
|
|
>
|

|
|
|
|
>



|

>
>
>
>
>
>
>
>
>
|
|

|
|
|
|

|
|

|
|
|
|

|
|
|
|
|

|
|
|
|

>
|
>







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
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
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
			break;
		}
	}
}

- (void)_generateAndCopy
{
	[self _generateWithCallback: ^ (NSMutableString *password) {

		UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
		pasteBoard.string = password;

		clearNSMutableString(password);

		UIAlertController *alert = [UIAlertController
		    alertControllerWithTitle: @"Password Generated"
				     message: @"The password has been copied "
					      @"into the clipboard."
			      preferredStyle: UIAlertControllerStyleAlert];
		[alert addAction:
		    [UIAlertAction actionWithTitle: @"OK"
					     style: UIAlertActionStyleDefault
					   handler: ^ (UIAlertAction *action) {
			[self.navigationController popViewControllerAnimated: YES];
		}]];

		[self presentViewController: alert
				   animated: YES
				 completion: nil];
	}];
}

- (void)_generateAndShow
{
	[self _generateWithCallback: ^ (NSMutableString *password) {

		UIAlertController *alert = [UIAlertController
		    alertControllerWithTitle: @"Generated Passphrase"
				     message: password
			      preferredStyle: UIAlertControllerStyleAlert];
		[alert addAction:
		    [UIAlertAction actionWithTitle: @"OK"
					     style: UIAlertActionStyleDefault
					   handler: ^ (UIAlertAction *action) {
			[self.navigationController
			    popViewControllerAnimated: YES];
		}]];

		[self presentViewController: alert
				   animated: YES
				 completion: ^ {
			clearNSMutableString(password);
		}];
	}];
}

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

	dispatch_async(dispatch_get_global_queue(
	    DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^ {
		id <PasswordGenerator> generator;
		char *passphrase;

		if (_legacy)
			generator = [LegacyPasswordGenerator generator];
		else
			generator = [NewPasswordGenerator generator];

		generator.site = _name;
		generator.length = _length;

		passphrase = of_strdup([self.passphraseField.text UTF8String]);
		@try {
			self.passphraseField.text = @"";
			generator.passphrase = passphrase;

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

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

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

- (IBAction)remove: (id)sender
{
	UIAlertController *alert = [UIAlertController
	    alertControllerWithTitle: @"Remove Site?"
			     message: @"Do you want to remove this site?"