Skip to content

Commit 89615e7

Browse files
committed
cryptography_flutter 2.1.0 and a new test suite: fixes lots of issues.
1 parent 8dcf47a commit 89615e7

294 files changed

Lines changed: 12926 additions & 2229 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cryptography_flutter/.gitignore

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
# See https://www.dartlang.org/guides/libraries/private-files
2-
3-
# Files and directories created by pub
4-
.dart_tool/
5-
.packages
6-
.pub/
7-
build/
8-
# If you're building an application, you may want to check-in your pubspec.lock
9-
pubspec.lock
10-
11-
# Directory created by dartdoc
12-
# If you don't generate documentation locally you can remove this line.
13-
doc/api/
14-
151
# Miscellaneous
162
*.class
173
*.log
@@ -22,6 +8,7 @@ doc/api/
228
.buildlog/
239
.history
2410
.svn/
11+
migrate_working_dir/
2512

2613
# IntelliJ related
2714
*.iml
@@ -35,16 +22,18 @@ doc/api/
3522
.vscode/
3623

3724
# Flutter/Dart/Pub related
25+
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
26+
/pubspec.lock
3827
**/doc/api/
3928
**/ios/Flutter/.last_build_id
29+
.dart_tool/
4030
.flutter-plugins
4131
.flutter-plugins-dependencies
32+
.packages
4233
.pub-cache/
34+
.pub/
4335
/build/
4436

45-
# Web related
46-
lib/generated_plugin_registrant.dart
47-
4837
# Symbolication related
4938
app.*.symbols
5039

cryptography_flutter/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 2.1.0
2+
* Many, major bug fixes.
3+
* Some breaking changes to the API, but we decided not to increment the major version because we
4+
don't expect them to affect many developers (while we do want the bug fixes to reach everyone who
5+
uses the package).
6+
* Many new features.
7+
* We have a completely new test suite that ensures correctness and also reports performance with
8+
different input sizes.
9+
110
## 2.0.2
211

312
* Fixes ["cryptography_flutter: Fix propagating error to Flutter + fix fallback to non-plugin encrypt/decrypt"](https://github.com/dint-dev/cryptography/pull/76)

cryptography_flutter/README.md

Lines changed: 79 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,47 @@
11
[![Pub Package](https://img.shields.io/pub/v/cryptography_flutter.svg)](https://pub.dev/packages/cryptography_flutter)
2-
[![Github Actions CI](https://github.com/dint-dev/cryptography/workflows/Dart%20CI/badge.svg)](https://github.com/dint-dev/cryptography/actions?query=workflow%3A%22Dart+CI%22)
2+
[![Github Actions CI](https://github.com/dint-dev/cryptography/workflows/Dart%20CI/badge.svg)](https://github.com/dint-dev/cryptography/actions)
33

44
# Overview
55

66
This is a version of the package [cryptography](https://pub.dev/packages/cryptography) that
77
optimizes performance of some cryptographic algorithms by using native APIs of Android, iOS, and
88
Mac OS X. You must use asynchronous methods to get the performance boost.
99

10-
Maintained by Gohilla Ltd. Licensed under the [Apache License 2.0](LICENSE).
10+
Maintained by Gohilla. Licensed under the [Apache License 2.0](LICENSE).
1111

12-
## Optimized algorithms
13-
### In Android
14-
* [AesCbc()](https://pub.dev/documentation/cryptography/latest/cryptography/AesCbc-class.html)
15-
* [AesCtr()](https://pub.dev/documentation/cryptography/latest/cryptography/AesCtr-class.html)
16-
* [AesGcm()](https://pub.dev/documentation/cryptography/latest/cryptography/AesGcm-class.html)
17-
* [Chacha20.poly1305()](https://pub.dev/documentation/cryptography/latest/cryptography/Chacha20-class.html)
12+
## General behavior
13+
This package contains two kinds of classes:
14+
* Classes such as [FlutterChacha20](https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/FlutterChacha20-class.html)
15+
use operating system APIs in Android / iOS / Mac OS X. If the operating system does not support
16+
the algorithm, the background implementation (such as `BackgroundChacha20`) or a pure Dart
17+
implementation (such as [DartChacha20](https://pub.dev/documentation/cryptography/latest/cryptography.dart/DartChacha20-class.html))
18+
when available.
19+
* Classes such as [BackgroundChacha20](https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/BackgroundChacha20-class.html)
20+
move the computation away from the UI isolate using [compute](https://api.flutter.dev/flutter/foundation/compute-constant.html)
21+
("package:flutter/foundation.dart").
1822

19-
### In iOS and Mac OS X
20-
* [AesGcm()](https://pub.dev/documentation/cryptography/latest/cryptography/AesGcm-class.html)
21-
* [Chacha20.poly1305()](https://pub.dev/documentation/cryptography/latest/cryptography/Chacha20-class.html)
22-
23-
## Links
24-
* [Github project](https://github.com/dint-dev/cryptography)
25-
* [Issue tracker](https://github.com/dint-dev/cryptography/issues)
26-
* [Pub package](https://pub.dev/packages/cryptography_flutter)
27-
* [API reference](https://pub.dev/documentation/cryptography_flutter/latest/)
23+
Both compute very small inputs in the same isolate if the overhead of message passing does not
24+
make sense. For example, if you encrypt a 16 byte message, the computation is done in the same
25+
isolate. Too large inputs are also computed in the same isolate (because you probably should not
26+
allocate a gigabyte cross-isolate message on a mobile phone). We also have a queue to prevent memory
27+
exhaustion that could happen if you send lots of requests concurrently (something we observed
28+
during testing).
2829

2930
# Getting started
3031
In _pubspec.yaml_:
3132
```yaml
3233
dependencies:
33-
cryptography: ^2.0.5
34-
cryptography_flutter: ^2.0.2
34+
cryptography: ^2.1.0
35+
cryptography_flutter: ^2.1.0
3536
```
3637
3738
Then just use:
3839
```dart
3940
import 'package:cryptography_flutter/cryptography_flutter.dart';
4041

4142
void main() {
42-
// Enable Flutter cryptography
43+
// Enable use of operating system APIs.
44+
// This is an optional performance optimization.
4345
FlutterCryptography.enable();
4446

4547
// ....
@@ -48,6 +50,61 @@ void main() {
4850

4951
For APIs, read documentation for [package:cryptography](https://pub.dev/packages/cryptography).
5052

53+
# Optimizations by platform
54+
## In iOS and Mac OS X
55+
Calling `FlutterCryptography.enable()` enables:
56+
* [FlutterAesGcm](https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/FlutterAesGcm-class.html)
57+
* Our benchmarks have shown up to ~50 times better performance.
58+
* [FlutterChacha20](https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/FlutterChacha20-class.html)
59+
* Our benchmarks have shown up to ~10 times better performance.
60+
* [FlutterEd25519](https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/FlutterEd25519-class.html)
61+
* Our benchmarks have shown up to ~10 times better performance.
62+
* [FlutterX25519](https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/FlutterX25519-class.html)
63+
* Our benchmarks have shown up to ~10 times better performance.
64+
65+
By default, maximum input size is 100 MB.
66+
67+
## In Android
68+
We have observe problems with some Android devices. Therefore we have disabled some optimizations
69+
until we have time to investigate the problems.
70+
71+
Calling `FlutterCryptography.enable()` enables:
72+
* [FlutterAesGcm](https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/FlutterAesGcm-class.html)
73+
* Our benchmarks have shown up to ~50 times better performance.
74+
* [FlutterChacha20](https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/FlutterChacha20-class.html)
75+
* Our benchmarks have shown up to ~10 times better performance.
76+
* [BackgroundEd25519](https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/BackgroundEd25519-class.html)
77+
* [BackgroundX25519](https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/BackgroundX25519-class.html)
78+
79+
By default, maximum input size is 20 MB because of memory allocation crashes we observed during
80+
testing.
81+
82+
## In other platforms
83+
In browsers, nothing is changed.
84+
85+
In Windows, Linux, and other platforms:
86+
* [BackgroundAesGcm](https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/BackgroundAesGcm-class.html)
87+
* [BackgroundChacha20](https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/BackgroundChacha20-class.html)
88+
* [BackgroundEd25519](https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/BackgroundEd25519-class.html)
89+
* [BackgroundX25519](https://pub.dev/documentation/cryptography_flutter/latest/cryptography_flutter/BackgroundX25519-class.html)
90+
91+
## Links
92+
* [Github project](https://github.com/dint-dev/cryptography)
93+
* [Issue tracker](https://github.com/dint-dev/cryptography/issues)
94+
* [Pub package](https://pub.dev/packages/cryptography_flutter)
95+
* [API reference](https://pub.dev/documentation/cryptography_flutter/latest/)
96+
97+
5198
# Contributing?
52-
Test the plugin by running integration tests in
53-
_cryptography_flutter/example/_ (see README in the directory).
99+
This is how you run the tests:
100+
```
101+
./tool/test.sh
102+
```
103+
104+
Alternatively:
105+
```
106+
flutter test --no-pub
107+
cd example
108+
flutter test --no-pub integration_test
109+
```
110+
Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
*.iml
2-
.gradle
1+
gradle-wrapper.jar
2+
/.gradle
3+
/captures/
4+
/gradlew
5+
/gradlew.bat
36
/local.properties
4-
/.idea/workspace.xml
5-
/.idea/libraries
6-
.DS_Store
7-
/build
8-
/captures
7+
GeneratedPluginRegistrant.java
8+
9+
# Remember to never publicly share your keystore.
10+
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
11+
key.properties
12+
**/*.keystore
13+
**/*.jks

cryptography_flutter/android/build.gradle

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,50 @@ group 'dev.dint.cryptography_flutter'
22
version '1.0-SNAPSHOT'
33

44
buildscript {
5-
ext.kotlin_version = '1.4.20'
5+
ext.kotlin_version = '1.7.10'
66
repositories {
77
google()
8-
jcenter()
8+
mavenCentral()
99
}
1010

1111
dependencies {
12-
classpath 'com.android.tools.build:gradle:4.1.1'
12+
classpath 'com.android.tools.build:gradle:7.2.0'
1313
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1414
}
1515
}
1616

17-
rootProject.allprojects {
17+
allprojects {
1818
repositories {
1919
google()
20-
jcenter()
20+
mavenCentral()
2121
}
2222
}
2323

2424
apply plugin: 'com.android.library'
2525
apply plugin: 'kotlin-android'
2626

2727
android {
28-
compileSdkVersion 30
28+
compileSdkVersion 31
29+
30+
compileOptions {
31+
sourceCompatibility JavaVersion.VERSION_1_8
32+
targetCompatibility JavaVersion.VERSION_1_8
33+
}
34+
35+
kotlinOptions {
36+
jvmTarget = '1.8'
37+
}
2938

3039
sourceSets {
3140
main.java.srcDirs += 'src/main/kotlin'
3241
}
42+
3343
defaultConfig {
3444
minSdkVersion 21
3545
}
36-
lintOptions {
37-
disable 'InvalidPackage'
38-
}
3946
}
4047

4148
dependencies {
4249
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
43-
implementation "androidx.security:security-crypto:1.1.0-alpha03"
44-
}
50+
implementation "androidx.security:security-crypto:1.1.0-alpha05"
51+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
<manifest package="dev.dint.cryptography_flutter"></manifest>
1+
<manifest package="dev.dint.cryptography_flutter">
2+
</manifest>

0 commit comments

Comments
 (0)