pointycastle 0.11.1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 86

Pointy Castle

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.

Algorithms

As of the last release, the following algorithms are implemented:

Block ciphers:

  • AES

Asymmetric block ciphers:

  • RSA

Stream ciphers:

  • Salsa20

Block cipher modes of operation:

  • CBC (Cipher Block Chaining mode)
  • CFB (Cipher Feedback mode)
  • ECB (Electronic Code Book mode)
  • GCTR (GOST 28147 OFB counter mode)
  • OFB (Output FeedBack mode)
  • CTR (Counter mode)
  • SIC

Paddings:

  • PKCS7

Digests:

  • MD2
  • MD4
  • MD5
  • RIPEMD-128
  • RIPEMD-160
  • RIPEMD-256
  • RIPEMD-320
  • SHA-1
  • SHA-224
  • SHA-256
  • SHA-3
  • SHA-384
  • SHA-512
  • SHA-512/t
  • Tiger
  • Whirlpool

MACs:

  • HMAC

Signatures:

  • (DET-)ECDSA
  • RSA

Password based key derivators:

  • PBKDF2
  • scrypt

Asymmetric key generators:

  • ECDSA
  • RSA

Secure PRNGs:

  • Based on block cipher in CTR mode
  • Based on block cipher in CTR mode with auto reseed (for forward security)
  • Based on Fortuna algorithm

Usage

There are two ways to use the algorithms that PointyCastle provides: with or without using the registry.

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/pointycastly.dart";

void main() {
  Digest sha256 = new Digest("SHA-256");
  // or
  KeyDerivator derivator = new KeyDerivator("SHA-1/HMAC/PBKDF2");
}

Without the registry

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");
}

Without dart:mirrors or package:reflectable (Flutter)

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

Libraries

  • package:pointycastle/pointycastle.dart: exports the high-level API and the registry loaded with all available implementations
  • package:pointycastle/api.dart: exports the high-level API and the registry without any implementations
  • package:pointycastle/export.dart: exports the API and all implementation classes

Changelog

Version 0.10.0 (2016-02-04) (Dart SDK version 0.14.0)

  • First Pointy Castle release.

  • Reorganised file structure.

  • Completely new Registry implementation that dynamically loads imported implementations using reflection. It is explained in this commit.

  • Migrated from unittest to test package.

cipher releases

Version 0.8.0 (2014-??-??) (Dart SDK version ???)

  • [bug 80] PaddedBlockCipher doesn't add padding when data length is a multiple of the block size. This fix introduces a BREAKING CHANGE in PaddedBlockCipher specification. Read its API documentation to know about the changes.

Version 0.7.0 (2014-03-22) (Dart SDK version 1.3.0-dev.5.2)

  • [enh 15] Implement stream cipher benchmarks.

  • [enh 64] Benchmark and optimize digests.

  • [enh 74] Make SHA-3 usable in terms of speed.

  • [bug 67] Removed some unused code.

  • [bug 68] Fix process() method of PaddedBlockCipher.

  • [bug 75] Remove a registry dependency in the Scrypt algorithm.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  pointycastle: "^0.11.1"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


      import 'package:pointycastle/pointycastle.dart';
  
Version Uploaded Documentation Archive
0.11.1 Jan 28, 2018 Go to the documentation of pointycastle 0.11.1 Download pointycastle 0.11.1 archive
0.11.0 Jan 28, 2018 Go to the documentation of pointycastle 0.11.0 Download pointycastle 0.11.0 archive
0.10.0+5 Dec 8, 2016 Go to the documentation of pointycastle 0.10.0+5 Download pointycastle 0.10.0+5 archive
0.10.0+4 Dec 8, 2016 Go to the documentation of pointycastle 0.10.0+4 Download pointycastle 0.10.0+4 archive
0.10.0+3 Dec 8, 2016 Go to the documentation of pointycastle 0.10.0+3 Download pointycastle 0.10.0+3 archive
0.10.0+2 Dec 7, 2016 Go to the documentation of pointycastle 0.10.0+2 Download pointycastle 0.10.0+2 archive
0.10.0+1 Feb 12, 2016 Go to the documentation of pointycastle 0.10.0+1 Download pointycastle 0.10.0+1 archive
0.10.0 Feb 3, 2016 Go to the documentation of pointycastle 0.10.0 Download pointycastle 0.10.0 archive
1.0.0-rc2 Jun 21, 2018 Go to the documentation of pointycastle 1.0.0-rc2 Download pointycastle 1.0.0-rc2 archive
1.0.0-rc1 May 28, 2018 Go to the documentation of pointycastle 1.0.0-rc1 Download pointycastle 1.0.0-rc1 archive

All 11 versions...

Analysis

We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
88 / 100
Health:
Code health derived from static analysis. [more]
88 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80 / 100
Overall score:
Weighted score of the above. [more]
86
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:pointycastle/pointycastle.dart.

Suggestions

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 33 errors 271 hints.

    Strong-mode analysis of lib/asymmetric/rsa.dart failed with the following error:

    line: 58 col: 3
    Invalid override. The type of 'RSAEngine.init' ('(bool, AsymmetricKeyParameter<RSAAsymmetricKey>) → void') isn't a subtype of 'AsymmetricBlockCipher.init' ('(bool, CipherParameters) → void').

    Strong-mode analysis of lib/block/aes_fast.dart failed with the following error:

    line: 61 col: 3
    Invalid override. The type of 'AESFastEngine.init' ('(bool, KeyParameter) → void') isn't a subtype of 'BlockCipher.init' ('(bool, CipherParameters) → void').

    Similar analysis of the following files failed:

    • lib/block/modes/cbc.dart (error)
    • lib/digests/sha3.dart (error)
    • lib/ecc/ecc_base.dart (error)
    • lib/ecc/ecc_fp.dart (error)
    • lib/key_derivators/pbkdf2.dart (error)
    • lib/key_derivators/scrypt.dart (error)
    • lib/macs/hmac.dart (error)
    • lib/padded_block_cipher/padded_block_cipher_impl.dart (error)
    • lib/random/fortuna_random.dart (error)
    • lib/signers/ecdsa_signer.dart (error)
    • lib/signers/rsa_signer.dart (error)
    • lib/src/ufixnum.dart (error)
    • lib/stream/salsa20.dart (error)
    • lib/stream/sic.dart (error)
    • lib/adapters/stream_cipher_as_block_cipher.dart (hint)
    • lib/api.dart (hint)
    • lib/asymmetric/api.dart (hint)
    • lib/asymmetric/pkcs1.dart (hint)
    • lib/block/modes/cfb.dart (hint)
    • lib/block/modes/ctr.dart (hint)
    • lib/block/modes/ecb.dart (hint)
    • lib/block/modes/gctr.dart (hint)
    • lib/block/modes/ofb.dart (hint)
    • lib/block/modes/sic.dart (hint)
    • lib/digests/md2.dart (hint)
    • lib/digests/md4.dart (hint)
    • lib/digests/md5.dart (hint)
    • lib/digests/ripemd128.dart (hint)
    • lib/digests/ripemd160.dart (hint)
    • lib/digests/ripemd256.dart (hint)
    • lib/digests/ripemd320.dart (hint)
    • lib/digests/sha1.dart (hint)
    • lib/digests/sha224.dart (hint)
    • lib/digests/sha256.dart (hint)
    • lib/digests/sha384.dart (hint)
    • lib/digests/sha512.dart (hint)
    • lib/digests/sha512t.dart (hint)
    • lib/digests/tiger.dart (hint)
    • lib/digests/whirlpool.dart (hint)
    • lib/ecc/api.dart (hint)
    • lib/ecc/curves/brainpoolp160r1.dart (hint)
    • lib/ecc/curves/brainpoolp160t1.dart (hint)
    • lib/ecc/curves/brainpoolp192r1.dart (hint)
    • lib/ecc/curves/brainpoolp192t1.dart (hint)
    • lib/ecc/curves/brainpoolp224r1.dart (hint)
    • lib/ecc/curves/brainpoolp224t1.dart (hint)
    • lib/ecc/curves/brainpoolp256r1.dart (hint)
    • lib/ecc/curves/brainpoolp256t1.dart (hint)
    • lib/ecc/curves/brainpoolp320r1.dart (hint)
    • lib/ecc/curves/brainpoolp320t1.dart (hint)
    • lib/ecc/curves/brainpoolp384r1.dart (hint)
    • lib/ecc/curves/brainpoolp384t1.dart (hint)
    • lib/ecc/curves/brainpoolp512r1.dart (hint)
    • lib/ecc/curves/brainpoolp512t1.dart (hint)
    • lib/ecc/curves/gostr3410_2001_cryptopro_a.dart (hint)
    • lib/ecc/curves/gostr3410_2001_cryptopro_b.dart (hint)
    • lib/ecc/curves/gostr3410_2001_cryptopro_c.dart (hint)
    • lib/ecc/curves/gostr3410_2001_cryptopro_xcha.dart (hint)
    • lib/ecc/curves/gostr3410_2001_cryptopro_xchb.dart (hint)
    • lib/ecc/curves/prime192v1.dart (hint)
    • lib/ecc/curves/prime192v2.dart (hint)
    • lib/ecc/curves/prime192v3.dart (hint)
    • lib/ecc/curves/prime239v1.dart (hint)
    • lib/ecc/curves/prime239v2.dart (hint)
    • lib/ecc/curves/prime239v3.dart (hint)
    • lib/ecc/curves/prime256v1.dart (hint)
    • lib/ecc/curves/secp112r1.dart (hint)
    • lib/ecc/curves/secp112r2.dart (hint)
    • lib/ecc/curves/secp128r1.dart (hint)
    • lib/ecc/curves/secp128r2.dart (hint)
    • lib/ecc/curves/secp160k1.dart (hint)
    • lib/ecc/curves/secp160r1.dart (hint)
    • lib/ecc/curves/secp160r2.dart (hint)
    • lib/ecc/curves/secp192k1.dart (hint)
    • lib/ecc/curves/secp192r1.dart (hint)
    • lib/ecc/curves/secp224k1.dart (hint)
    • lib/ecc/curves/secp224r1.dart (hint)
    • lib/ecc/curves/secp256k1.dart (hint)
    • lib/ecc/curves/secp256r1.dart (hint)
    • lib/ecc/curves/secp384r1.dart (hint)
    • lib/ecc/curves/secp521r1.dart (hint)
    • lib/export.dart (hint)
    • lib/impl.dart (hint)
    • lib/key_derivators/api.dart (hint)
    • lib/key_generators/api.dart (hint)
    • lib/key_generators/ec_key_generator.dart (hint)
    • lib/key_generators/rsa_key_generator.dart (hint)
    • lib/paddings/pkcs7.dart (hint)
    • lib/pointycastle.dart (hint)
    • lib/random/auto_seed_block_ctr_random.dart (hint)
    • lib/random/block_ctr_random.dart (hint)
    • lib/src/api/algorithm.dart (hint)
    • lib/src/api/assymetric_block_cipher.dart (hint)
    • lib/src/api/assymetric_key.dart (hint)
    • lib/src/api/assymetric_key_pair.dart (hint)
    • lib/src/api/assymetric_key_parameter.dart (hint)
    • lib/src/api/block_cipher.dart (hint)
    • lib/src/api/cipher_parameters.dart (hint)
    • lib/src/api/digest.dart (hint)
    • lib/src/api/key_derivator.dart (hint)
    • lib/src/api/key_generator.dart (hint)
    • lib/src/api/key_generator_parameters.dart (hint)
    • lib/src/api/key_parameter.dart (hint)
    • lib/src/api/mac.dart (hint)
    • lib/src/api/padded_block_cipher.dart (hint)
    • lib/src/api/padded_block_cipher_parameters.dart (hint)
    • lib/src/api/padding.dart (hint)
    • lib/src/api/parameters_with_iv.dart (hint)
    • lib/src/api/parameters_with_random.dart (hint)
    • lib/src/api/private_key.dart (hint)
    • lib/src/api/private_key_parameter.dart (hint)
    • lib/src/api/public_key.dart (hint)
    • lib/src/api/public_key_parameter.dart (hint)
    • lib/src/api/registry_factory_exception.dart (hint)
    • lib/src/api/secure_random.dart (hint)
    • lib/src/api/signature.dart (hint)
    • lib/src/api/signer.dart (hint)
    • lib/src/api/stream_cipher.dart (hint)
    • lib/src/ec_standard_curve_constructor.dart (hint)
    • lib/src/impl/base_asymmetric_block_cipher.dart (hint)
    • lib/src/impl/base_block_cipher.dart (hint)
    • lib/src/impl/base_digest.dart (hint)
    • lib/src/impl/base_key_derivator.dart (hint)
    • lib/src/impl/base_mac.dart (hint)
    • lib/src/impl/base_padding.dart (hint)
    • lib/src/impl/base_stream_cipher.dart (hint)
    • lib/src/impl/long_sha2_family_digest.dart (hint)
    • lib/src/impl/md4_family_digest.dart (hint)
    • lib/src/impl/secure_random_base.dart (hint)
    • lib/src/registry/registry.dart (hint)
    • lib/src/registry/registry_disabled.dart (hint)
    • lib/src/registry/registry_reflectable.dart (hint)
    • lib/stream/ctr.dart (hint)
  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use pointycastle.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=0.8.10+6 <2.0.0
bignum >=0.1.0 <0.2.0 0.1.0
fixnum >=0.10.2 <0.11.0 0.10.7
quiver_collection >=1.0.0 <2.0.0 1.0.0
quiver_pattern >=1.0.0 <2.0.0 1.0.0
reflectable >=1.0.1 <2.0.0 1.0.4 2.0.1
Transitive dependencies
analyzer 0.30.0+4 0.32.1
args 1.4.3
async 2.0.7
barback 0.15.2+16
charcode 1.1.1
cli_util 0.1.3
code_transformers 0.5.1+5
collection 1.14.10
convert 2.0.1
crypto 2.0.5
csslib 0.14.4
dart_style 1.0.9+1 1.1.0
front_end 0.1.0-alpha.4.1 0.1.1
glob 1.1.5
html 0.13.3+1
isolate 1.1.0 2.0.1
kernel 0.3.0-alpha.1.1 0.3.1
logging 0.11.3+1
meta 1.1.5
package_config 1.0.3
path 1.4.2 1.6.1
plugin 0.2.0+2
pool 1.3.5
quiver_iterables 1.0.1
source_maps 0.10.5
source_span 1.4.0
stack_trace 1.9.2
string_scanner 1.0.2
typed_data 1.1.5
utf 0.9.0+4
watcher 0.9.7+8
yaml 2.1.14
Dev dependencies
benchmark_harness >=1.0.4 <2.0.0
browser >=0.10.0 <0.11.0
matcher >=0.12.0 <0.13.0
test >=0.12.7 <0.13.0