commit | 30f334efdca3d2b1e677229b14ba0f850930dc09 | [log] [tgz] |
---|---|---|
author | Steven Roose <stevenroose@gmail.com> | Mon May 28 18:23:29 2018 +0200 |
committer | Steven Roose <stevenroose@gmail.com> | Mon May 28 18:26:46 2018 +0200 |
tree | 32521eeee000c2b991d2e171c1d6a62589faa00f | |
parent | a825658e55ae8d95fa0636029029ad5dd335293c [diff] |
Release candidate for Dart 2 support
A Dart library for encryption and decryption. As of today, most of the classes are ports of Bouncy Castle from Java to Dart. The porting is almost always direct except for some classes that had been added to ease the use of low level data.
To make sure nothing fails, tests and benchmarks for every algorithm are provided. The expected results are taken from the Bouncy Castle Java version and also from standards, and matched against the results got from Pointy Castle.
As of the last release, the following algorithms are implemented:
Block ciphers:
Asymmetric block ciphers:
Stream ciphers:
Block cipher modes of operation:
Paddings:
Digests:
MACs:
Signatures:
Password based key derivators:
Asymmetric key generators:
Secure PRNGs:
There are two ways to use the algorithms that PointyCastle provides: with or without using the registry.
The registry allows users to easily instantiate classes for the algorithms using the algorithm shorthands like given in the list above. It also makes it possible to seamlessly chain different algorithms together. For example:
import "package:pointycastle/pointycastle.dart"; void main() { Digest sha256 = new Digest("SHA-256"); // or KeyDerivator derivator = new KeyDerivator("SHA-1/HMAC/PBKDF2"); }
Using the registry means that all algorithms will be imported by default, which can possibly increase the compiled size of your program. To avoid this, it is possible to import algorithms one by one. In that case, you can decide to either use the classes directly, or still use the registry. But remember that the registry only contains the classes that you import. For example:
import "package:pointycastle/api.dart"; import "package:pointycastle/digests/sha256.dart"; import "package:pointycastle/digests/sha1.dart"; import "package:pointycastle/macs/hmac.dart"; import "package:pointycastle/key_derivators/pbkdf2.dart"; void main() { Digest sha256 = new SHA256Digest(); // or KeyDerivator derivator = new PBKDF2KeyDerivator( new HMac(new SHA1Digest(), 64)); // But the registry keeps working for all imported algorithms: Digest sha256 = new Digest("SHA-256"); // or KeyDerivator derivator = new KeyDerivator("SHA-1/HMAC/PBKDF2"); }
Because the registry uses reflectable to register all imported algorithm classes and reflectable imports dart:mirrors
, using the registry depends on the ability to import mirrors. Since the Flutter frame work doesn't allow using dart:mirrors, it's not possible to use the registry with Flutter.
The way to use Pointy Castle in Flutter is the way explained in the previous section. However, there is a utility library that exports all available algorithms at once.
import "package:pointycastle/export.dart"; void main() { Digest sha256 = new SHA256Digest(); // or KeyDerivator derivator = new PBKDF2KeyDerivator( new HMac(new SHA1Digest(), 64)); }
package:pointycastle/pointycastle.dart
: exports the high-level API and the registry loaded with all available implementationspackage:pointycastle/api.dart
: exports the high-level API and the registry without any implementationspackage:pointycastle/export.dart
: exports the API and all implementation classes