Skip to content

Commit 68bddea

Browse files
authored
feat: add sign with data (#61)
1 parent e25c064 commit 68bddea

23 files changed

+1259
-861
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 3.7.0
2+
3+
- Add SignData methods for compatibility with other platform implementations
4+
- Updated binaries to v1.9.0
5+
6+
17
## 3.6.1
28

39
- Fixed macOS podspec issue when signing apps

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,12 @@ import 'package:fast_rsa/rsa.dart';
9494
void main() async {
9595
var bytesSample = Uint8List.fromList('data'.codeUnits);
9696
97-
var result = await OpenPGP.sign("text","[publicKey here]","[privateKey here]","[passphrase here]");
98-
var result = await OpenPGP.signBytesToString(bytesSample,"[publicKey here]","[privateKey here]","[passphrase here]");
97+
var result = await OpenPGP.sign("text","[privateKey here]","[passphrase here]");
98+
var result = await OpenPGP.signBytesToString(bytesSample,"[privateKey here]","[passphrase here]");
99+
100+
// sign including data
101+
var result = await OpenPGP.signData("text","[privateKey here]","[passphrase here]");
102+
var result = await OpenPGP.signDataBytesToString(bytesSample,"[privateKey here]","[passphrase here]");
99103
100104
}
101105
@@ -111,6 +115,10 @@ void main() async {
111115
112116
var result = await OpenPGP.verify("text signed","text","[publicKey here]");
113117
var result = await OpenPGP.verifyBytes("text signed", bytesSample,"[publicKey here]");
118+
119+
// verify signed with data
120+
var result = await OpenPGP.verifyData("text signed","[publicKey here]");
121+
var result = await OpenPGP.verifyDataBytes(bytesSample,"[publicKey here]");
114122
115123
}
116124
185 KB
Binary file not shown.
201 KB
Binary file not shown.
209 KB
Binary file not shown.
225 KB
Binary file not shown.

example/integration_test/app_test.dart

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,56 @@ void main() {
268268
}, timeout: Timeout(Duration(seconds: 60)));
269269
});
270270

271+
group('Sign And Verify Data', () {
272+
final parent = find.byKey(ValueKey("sign-verify-data"));
273+
274+
testWidgets('Sign / Verify Data', (WidgetTester tester) async {
275+
final instance = app.MyApp();
276+
await tester.pumpWidget(instance);
277+
await tester.pumpAndSettle();
278+
279+
var container = find.descendant(
280+
of: parent,
281+
matching: find.byKey(ValueKey("sign")),
282+
);
283+
await tester.scrollUntilVisible(container, dyScroll, scrollable: list);
284+
await tester.pumpAndSettle();
285+
286+
await tester.enterText(
287+
find.descendant(
288+
of: container, matching: find.byKey(ValueKey("message"))),
289+
input);
290+
await tester.tap(
291+
find.descendant(
292+
of: container, matching: find.byKey(ValueKey("button"))),
293+
);
294+
await tester.pumpAndSettle(Duration(seconds: 3));
295+
var resultSelector = find.descendant(
296+
of: container, matching: find.byKey(ValueKey("result")));
297+
expect(resultSelector, findsOneWidget);
298+
var result = resultSelector.evaluate().single.widget as Text;
299+
expect(result.data != "", equals(true));
300+
301+
container = find.descendant(
302+
of: parent,
303+
matching: find.byKey(ValueKey("verify")),
304+
);
305+
await tester.scrollUntilVisible(container, dyScroll, scrollable: list);
306+
await tester.pumpAndSettle();
307+
308+
await tester.tap(
309+
find.descendant(
310+
of: container, matching: find.byKey(ValueKey("button"))),
311+
);
312+
await tester.pumpAndSettle(Duration(seconds: 3));
313+
resultSelector = find.descendant(
314+
of: container, matching: find.byKey(ValueKey("result")));
315+
expect(resultSelector, findsOneWidget);
316+
result = resultSelector.evaluate().single.widget as Text;
317+
expect(result.data, "VALID");
318+
}, timeout: Timeout(Duration(seconds: 60)));
319+
});
320+
271321
group('Sign And Verify Bytes', () {
272322
final parent = find.byKey(ValueKey("sign-verify-bytes"));
273323

@@ -318,6 +368,56 @@ void main() {
318368
}, timeout: Timeout(Duration(seconds: 60)));
319369
});
320370

371+
group('Sign And Verify Data Bytes', () {
372+
final parent = find.byKey(ValueKey("sign-verify-data-bytes"));
373+
374+
testWidgets('Sign / Verify Data Bytes', (WidgetTester tester) async {
375+
final instance = app.MyApp();
376+
await tester.pumpWidget(instance);
377+
await tester.pumpAndSettle();
378+
379+
var container = find.descendant(
380+
of: parent,
381+
matching: find.byKey(ValueKey("sign")),
382+
);
383+
await tester.scrollUntilVisible(container, dyScroll, scrollable: list);
384+
await tester.pumpAndSettle();
385+
386+
await tester.enterText(
387+
find.descendant(
388+
of: container, matching: find.byKey(ValueKey("message"))),
389+
input);
390+
await tester.tap(
391+
find.descendant(
392+
of: container, matching: find.byKey(ValueKey("button"))),
393+
);
394+
await tester.pumpAndSettle(Duration(seconds: 3));
395+
var resultSelector = find.descendant(
396+
of: container, matching: find.byKey(ValueKey("result")));
397+
expect(resultSelector, findsOneWidget);
398+
var result = resultSelector.evaluate().single.widget as Text;
399+
expect(result.data != "", equals(true));
400+
401+
container = find.descendant(
402+
of: parent,
403+
matching: find.byKey(ValueKey("verify")),
404+
);
405+
await tester.scrollUntilVisible(container, dyScroll, scrollable: list);
406+
await tester.pumpAndSettle();
407+
408+
await tester.tap(
409+
find.descendant(
410+
of: container, matching: find.byKey(ValueKey("button"))),
411+
);
412+
await tester.pumpAndSettle(Duration(seconds: 3));
413+
resultSelector = find.descendant(
414+
of: container, matching: find.byKey(ValueKey("result")));
415+
expect(resultSelector, findsOneWidget);
416+
result = resultSelector.evaluate().single.widget as Text;
417+
expect(result.data, "VALID");
418+
}, timeout: Timeout(Duration(seconds: 60)));
419+
});
420+
321421
group('Generate', () {
322422
final parent = find.byKey(ValueKey("generate"));
323423

example/lib/main.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ import 'package:openpgp_example/encrypt_decrypt_symmetric.dart';
1313
import 'package:openpgp_example/encrypt_decrypt_symmetric_bytes.dart';
1414
import 'package:openpgp_example/generate.dart';
1515
import 'package:openpgp_example/sign_verify.dart';
16+
import 'package:openpgp_example/sign_verify_data.dart';
1617
import 'package:openpgp_example/metadata.dart';
1718
import 'package:openpgp_example/armor.dart';
1819
import 'package:openpgp_example/convert.dart';
1920
import 'package:openpgp_example/sign_verify_bytes.dart';
21+
import 'package:openpgp_example/sign_verify_data_bytes.dart';
2022

2123
const passphrase = 'test';
2224

@@ -149,11 +151,21 @@ class _MyAppState extends State<MyApp> {
149151
keyPair: _defaultKeyPair,
150152
key: Key("sign-verify"),
151153
),
154+
SignAndVerifyData(
155+
title: "Sign And Verify Data",
156+
keyPair: _defaultKeyPair,
157+
key: Key("sign-verify-data"),
158+
),
152159
SignAndVerifyBytes(
153160
title: "Sign And Verify Bytes",
154161
keyPair: _defaultKeyPair,
155162
key: Key("sign-verify-bytes"),
156163
),
164+
SignAndVerifyDataBytes(
165+
title: "Sign And Verify Data Bytes",
166+
keyPair: _defaultKeyPair,
167+
key: Key("sign-verify-data-bytes"),
168+
),
157169
Generate(
158170
title: "Generate",
159171
key: Key("generate"),

example/lib/sign_verify.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class _SignAndVerifyState extends State<SignAndVerify> {
4343
onPressed: (controller) async {
4444
var result = await OpenPGP.sign(
4545
controller.text,
46-
widget.keyPair!.publicKey,
4746
widget.keyPair!.privateKey,
4847
passphrase,
4948
);

example/lib/sign_verify_bytes.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class _SignAndVerifyBytesState extends State<SignAndVerifyBytes> {
4747
onPressed: (controller) async {
4848
var result = await OpenPGP.signBytesToString(
4949
Uint8List.fromList(controller.text.codeUnits),
50-
widget.keyPair!.publicKey,
5150
widget.keyPair!.privateKey,
5251
passphrase,
5352
);
@@ -79,7 +78,6 @@ class _SignAndVerifyBytesState extends State<SignAndVerifyBytes> {
7978
onPressed: (controller) async {
8079
var result = await OpenPGP.signBytes(
8180
Uint8List.fromList(controller.text.codeUnits),
82-
widget.keyPair!.publicKey,
8381
widget.keyPair!.privateKey,
8482
passphrase,
8583
);

0 commit comments

Comments
 (0)