p-hatan/ mirror

pub repository

mirror.p-hatan.ir

pointycastle

1.0.0

A Dart library implementing cryptographic algorithms

Download archive

Readme

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

Asymmetric block cipher encodings:

  • PKCS1
  • OAEP

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|160|256|320
  • SHA-1
  • SHA-224|256|384|512
  • SHA-512/t (t=8 to 376 and 392 to 504 in multiples of 8)
  • Keccak-224|256|384|512*
  • Tiger
  • Whirlpool

*Keccak is currently implemented as SHA3Digest.

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

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

Changelog

Version 1.0.0 (2018-12-17) (Dart SDK version 2.0)

  • Support Dart 2 and Strong Mode
  • Migrate from package:bignum.BigInteger to dart:core.BigInt
  • Remove Quiver and fixnum dependency
  • OAEP encoding for block ciphers

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.

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add pointycastle
pubspec.yaml
name: pointycastle
version: 1.0.0
author: The Pointy Castle team
description: A Dart library implementing cryptographic algorithms
homepage: https://github.com/PointyCastle/pointycastle
environment:
  sdk: ">=0.8.10+6 <3.0.0"
#documentation: http://pointycastle.github.io/docs/

dev_dependencies:
  benchmark_harness: ">=1.0.5 <2.0.0"
  build_runner: ^0.10.0
  build_test: ^0.10.2
  build_web_compilers: ^0.4.0
  matcher: ">=0.12.0 <0.13.0"
  test: ">=0.12.30 <1.4.0"
  analyzer: "0.32.4"

Version history

VersionPublishedArchiveSHA-256
0.10.0-dev2016-01-26T15:47:08.882ZDownload1b2b97198aeed2251b671d495798b7fb64bf4205fe4e34ce2b9445b553ad04dc
0.10.02016-02-03T23:34:47.717ZDownload4cb6b300ba8e3531d1578977feebe343b249f0de7e078ea4c37c46cd6d8e095a
0.10.0+12016-02-12T14:22:16.128ZDownloadb43cba511aabb7c4061c3fc32e76e453ef93b823cf1245a16a36fa6a92d0e1bf
0.10.0+22016-12-07T23:15:11.612ZDownload9735b0d79142d653f6a23063d450a7b00ee78688853e0f8336b8608068458e30
0.10.0+32016-12-08T03:11:52.527ZDownloada73600c8146bee453cbb97a403fd07271c150d4734b5d5a2f46812d840be7df1
0.10.0+42016-12-08T03:38:10.100ZDownload694d84dcabee80272e194fca256ff9c0f369f00a472c228711471dffe18e8316
0.10.0+52016-12-08T14:37:25.638ZDownload517b1d0964789842b1cd0fba4036d53fe394517b5f8207fd53293cba653e0288
0.11.02018-01-28T16:53:46.490291ZDownloadb0cf5404db85ca5dfe6c07d30d64bebf2868fc6722e999af755a2e95e9a016ba
0.11.12018-01-28T17:36:36.534841ZDownloadfb90ac5dba503b1c211f361fc299d8066747fcd740b8410c9425a1dc2fd72945
1.0.0-rc12018-05-28T16:28:03.989127ZDownload6171dd1511be99d91e00951a79c512ed5ce4da19d9255f2e6c08dba3011daad7
1.0.0-rc22018-06-21T09:43:47.185855ZDownloade7d2ce935341921c504f5d868e476617cda97b076c5c713aee38f110ea84f7ec
1.0.0-rc32018-09-14T20:09:41.086681ZDownloadc7f2351a141fd0045977ebc4ea234ac527a2edbcda7f9fe2d6bca2bf7060fc8e
1.0.0-rc42018-10-04T15:36:41.436233ZDownload96f41a629286d3a9e6cd715f0a9afa48659f7a47666a62b76a16292d25b584e7
1.0.02018-12-17T15:42:10.534222ZDownloadf30c2cfd43a2c5f49031caeeb6fd3724626ba01fc53e14845c24d0493263488e
1.0.12019-02-20T16:14:41.639259ZDownload3c8bca6b347c1276b515d3df0b89cefb097f6d98bb74858f57aab5ee9305c538
1.0.22019-11-15T16:38:46.136833ZDownload4ed9ae487542d265a99f96bb160f76b5cee725376caa6b365aa0df060d64b2db
2.0.0-rc12020-09-12T05:16:21.495202ZDownload7871a8791a004e46fb72ca2dff54d462afc9097fe4e656ba299dec3cc98f758d
2.0.0-rc22020-09-25T07:44:36.309749ZDownload052009b51281946bc59971bf3e887be791e2a128e181908de569892767ed9488
2.0.02020-10-02T04:18:17.009196ZDownloadab5b4252c713b546d462b638ccdb2c94181229c7474a74edde8292ba10b850ba
2.0.12021-01-16T05:15:08.063360ZDownload8c8d9941ab022153b2abdc40ae882dd3e6e8b482688b9581612d56c5d59fa787
3.0.0-nullsafety.22021-02-05T00:27:05.663280ZDownload666796a2673d20ad06c6b6641994bd54f94d12857c0b93a64e1a42252c2f7e4a
3.0.12021-03-24T03:51:36.476467ZDownloada74ed4039c152dd319514f142768d93ad3973860b240d90160cec727c8155f65
3.1.12021-06-04T00:35:49.869661ZDownload48883722393e27548a4ebbd9cef569622485799da1ab144ab2fe5d7e4242843d
3.1.22021-06-17T22:50:45.737361ZDownloadfa7c2f46543a04be3181ab8133de00c676a8c8f75e78d2668816b65405dd053b
3.1.32021-06-29T00:51:41.878311ZDownload416d025f33ef8d69313e0a14d725de4c9bff016551d3d14d244784ac33659304
3.2.0-rc02021-07-05T08:27:57.999331ZDownloaded0cc2e91e0996a6582e87e73fb13cf8e858346d725049740afe8ca9125ebbf4
3.2.02021-07-29T03:42:19.386424ZDownloadadd6af10b663c4460e03dac2ac3a966c062723847967702f4403098608eedbfb
3.3.02021-08-12T09:43:35.064804ZDownload521144963c6488c74ef7b3ce3c28cbcf29db67d5da791a10e89caeca69a380e7
3.3.12021-08-18T06:22:46.887605ZDownloadbe45a0ba99757eb82a18ab2a92fe756e37e06e5318360d0c57b2941ac83ed8cb
3.3.22021-08-27T03:55:13.977419ZDownloadada035ad3c8fdbdb125127ab87c47d5034a9ae700dccdbf1b60b32af52322e4f
3.3.32021-09-03T07:34:51.828926ZDownload99374bc84c43b3d065d88a845591a8e3a4ead5613b56fdb53f01e602b7ecc1df
3.3.42021-09-07T03:53:26.088801ZDownload60da06ea36aa0c411a71b80a80eaef3435394f50b10258673c0e3affaac6e5b4
3.3.52021-10-27T08:23:33.420974ZDownloadda190ccbf664766046c51cbae3abca61aeef369e4d80d2706989ae434b2e90f7
3.4.0-rc12021-11-03T10:13:16.121400ZDownloadbf7616a3ae4e7efc92c9cfeac170defdfceffa7e2ca342b010a92abb713dc05a
3.4.0-rc22021-11-04T07:33:44.535502ZDownloadcb3307bc6532f11a433569b8658acec2ea9bc826b7f8ccbc171ec4373b41f553
3.4.02021-11-09T23:30:15.505651ZDownloadd0d95ef66e5327394d2dab33cbcb2cde3a9fb275abe75ebfedd0f54392878df7
3.5.02021-12-30T09:51:41.732206ZDownload21cc8c830d228dd84c84a9139394702d766622bacd3ea7a2bdcb1f00b280e9a4
3.5.12022-02-08T10:19:48.695746ZDownloade95353c00588645b7e9dd048e705a94186ef90ed2e2f6d96e1f8319abca02df2
3.5.22022-03-07T06:26:59.810689ZDownloadd3031d8b58b62352176b13a734905ebc53d25498c7a5e161e7f3da581f2eb03f
3.6.02022-04-27T06:39:00.710249ZDownload0edfe20fdabaf4cd97e234f66a509f8dc7dc9c55ee2c226027be7be86de612c3
3.6.12022-07-19T06:37:40.752036ZDownload041b249f5c70e8983ebbaff4fdea252c2af8d4912ba64b649edb17615349afef
3.6.22022-09-09T03:35:11.361114ZDownloaddb7306cf0249f838d1a24af52b5a5887c5bf7f31d8bb4e827d071dc0939ad346
3.7.02023-03-16T20:35:02.229325ZDownload57b6b78df14175658f09c5dfcfc51a46ad9561a3504fe679913dab404d0cc0f2
3.7.12023-03-21T19:43:23.159471ZDownloadae73e842cdd27a3467a71d70cefd9b198538aab4fc7dde1d0e8c78c96225abf0
3.7.22023-03-23T18:38:12.847491ZDownloadc3120a968135aead39699267f4c74bc9a08e4e909e86bc1b0af5bfd78691123c
3.7.32023-04-14T16:02:59.714861ZDownload7c1e5f0d23c9016c5bbd8b1473d0d3fb3fc851b876046039509e18e0c7485f2c
3.7.42024-01-15T20:53:27.969113ZDownload43ac87de6e10afabc85c445745a7b799e04de84cebaa4fd7bf55a5e1e9604d29
3.8.02024-04-05T11:22:16.105522ZDownload70fe966348fe08c34bf929582f1d8247d9d9408130723206472b4687227e4333
3.9.02024-04-19T10:19:15.148969ZDownload79fbafed02cfdbe85ef3fd06c7f4bc2cbcba0177e61b765264853d4253b21744
3.9.12024-05-07T18:22:31.393199ZDownload4be0097fcf3fd3e8449e53730c631200ebc7b88016acecab2b0da2f0149222fe
4.0.02025-02-19T10:56:42.595398ZDownload92aa3841d083cc4b0f4709b5c74fd6409a3e6ba833ffc7dc6a8fee096366acf5

Dependencies

No direct dependencies declared.