{"id":13552209,"url":"https://github.com/bcgit/pc-dart","last_synced_at":"2025-04-03T03:30:55.835Z","repository":{"id":37404519,"uuid":"225955561","full_name":"bcgit/pc-dart","owner":"bcgit","description":"Pointy Castle - Dart Derived Bouncy Castle APIs","archived":false,"fork":false,"pushed_at":"2024-07-25T07:21:52.000Z","size":4188,"stargazers_count":239,"open_issues_count":63,"forks_count":124,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-10-29T20:20:02.150Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":"https://www.bouncycastle.org/repositories/pc-dart","source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bcgit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-04T20:56:41.000Z","updated_at":"2024-10-28T04:54:25.000Z","dependencies_parsed_at":"2023-02-18T16:05:24.104Z","dependency_job_id":"5d7643c7-e8be-4fae-9700-ad53bc93b652","html_url":"https://github.com/bcgit/pc-dart","commit_stats":{"total_commits":695,"total_committers":62,"mean_commits":"11.209677419354838","dds":0.6676258992805755,"last_synced_commit":"c7009dbf7785f4ff865ddb4eefdaed8c18ef3baa"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcgit%2Fpc-dart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcgit%2Fpc-dart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcgit%2Fpc-dart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcgit%2Fpc-dart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bcgit","download_url":"https://codeload.github.com/bcgit/pc-dart/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246933306,"owners_count":20857046,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T12:02:00.555Z","updated_at":"2025-04-03T03:30:53.375Z","avatar_url":"https://github.com/bcgit.png","language":"Dart","readme":"\nPointy Castle\n=============\n\n![Dart VM](https://github.com/bcgit/pc-dart/workflows/ci-vm/badge.svg) ![Chrome](https://github.com//bcgit/pc-dart/workflows/ci-chrome/badge.svg) ![Node JS](https://github.com/bcgit/pc-dart/workflows/ci-node/badge.svg)\n\nA Dart library for encryption and decryption. In this release, most of the classes are ports of Bouncy Castle from Java\nto Dart. The porting is almost always direct except for some classes that had been added to ease the use of low level\ndata.\n\nTo make sure nothing fails, tests and benchmarks for every algorithm are\nprovided. The expected results are taken from the Bouncy Castle Java version\nand also from standards, and matched against the results got from Pointy Castle.\n\nThis library was adopted from the original project at https://github.com/PointyCastle/pointycastle at the request of the\n authors to help support ongoing development. A list of major contributors is provided at contributors.md\n\nThis library is now ported to non-nullable-by-default, a breaking language feature released by the Dart team! See\nhttps://dart.dev/null-safety and https://dart.dev/null-safety/migration-guide for more details. Please note that both\nnull-safe and non-null-safe versions are available (v3.x.x-nullsafety for null-safe, v2.x.x for non-null-safe). However,\nonly the null-safe version of this library is actively maintained. \n\n## Algorithms\n\nPointycastle implements a large set of algorithms. They must be instantiated and then initialized with\ntheir parameters. Different algorithms have different parameter classes, which represent the\narguments to that algorithm. The relevant parameter type is provided for all the algorithms. To initialize an algorithm, \ncall the init method:\n```dart\nvar algorithmVar = /* instantiate algorithm using registry here */ ;\nvar parameter = /* instantiate relevant parameter class here */ ;\nalgorithmVar.init(parameter);\n```\nSome algorithms will ask for more than just a parameter object in the initialization step. Once you have identified the\nclasses you intend to use in your project, it is recommended that you view the API docs at \nhttps://pub.dev/documentation/pointycastle/latest/ to find the specifics of the methods from the \nclass you want to use.\n\nIn this release, the following algorithms are implemented:\n\n(Most of the below are keywords for algorithms which can be used directly with the registry. The registry is an easy way\nto instantiate classes in PointyCastle. See \"Using the Registry\" for more).\n\n**AEAD ciphers:** To use with the registry, instantiate like this `AEADCipher('ChaCha20-Poly1305')`. Ciphers use `AEADParameters` to initialize.\n\n* 'ChaCha20-Poly1305'\n* 'AES/EAX'\n\n**Block ciphers:** To use with the registry, instantiate like this `PaddedBlockCipher('AES/SomeBlockModeHere/SomePaddingHere')` \nor like this `StreamCipher('AES/SomeStreamModeHere')`. See sections below for modes and paddings.\n  * 'AES'\n  * *Note that block ciphers can be used in stream cipher modes of operation*\n  \n**Block modes of operation:** Most modes use `ParametersWithIV` to initialize. ECB uses `KeyParameter` and GCM uses `AEADParameters`.\n  * 'CBC' (Cipher Block Chaining mode)\n  * 'ECB' (Electronic Code Book mode)\n  * 'CFB-64' (Cipher Feedback mode, using blocks)\n  * 'GCTR' (GOST 28147 OFB counter mode, using blocks)\n  * 'OFB-64' (Output FeedBack mode, using blocks)\n  * 'CTR'/'SIC' (Counter mode, using blocks)\n  * 'IGE' (Infinite Garble Extension)\n  * **Authenticated block modes of operation**\n     - 'GCM' (Galois-Counter mode)\n     - 'CCM' (counter with CBC-MAC)\n     \n**Stream modes of operation:** All modes use `ParametersWithIV` to initialize.\n  * 'CTR'/'SIC' (Counter mode, as a traditional stream)\n\n**Paddings:**\n  * 'PKCS7'\n  * 'ISO7816-4'\n\n**Asymmetric block ciphers:** Instantiate using the registry like this `AsymmetricBlockCipher('RSA/SomeEncodingHere')`. Initialization requires a `RSAPrivateKey` or `RSAPublicKey`.\n  * 'RSA'\n\n**Asymmetric block cipher encodings:**\n  * 'PKCS1'\n  * 'OAEP'\n\n**Stream ciphers:** Instantiation using registry is like this `StreamCipher('ChaCha20/20')`. Initialization requires a `ParametersWithIV`.\n  * 'Salsa20'\n  * 'ChaCha20/(# of rounds)' (original implementation)\n  * 'ChaCha7539/(# of rounds)' (RFC-7539 implementation)\n  * If you don't know how many ChaCha rounds to use, use 20.\n\n**Digests:** Instantiate using registry like this `Digest('Keccak/384')`. No initialization is necessary.\n  * 'Blake2b'\n  * 'MD2'\n  * 'MD4'\n  * 'MD5'\n  * 'RIPEMD-128|160|256|320'\n  * 'SHA-1'\n  * 'SHA-224|256|384|512'\n  * 'SHA-512/t' (t=8 to 376 and 392 to 504 in multiples of 8)\n  * 'Keccak/224|256|384|512'\n  * 'SHA3-224|256|384|512'\n  * 'Tiger'\n  * 'Whirlpool'\n  * 'SM3'\n\n**MACs:** Instantiate using registry like this `Mac('SomeBlockCipher/CMAC')` or `Mac('SomeDigest/HMAC)` or `Mac(SomeBlockCipher/Poly1305)`. CMAC and HMAC require a `KeyParameter` and Poly1305 requires a `ParametersWithIV`.\n  * 'HMAC'\n  * 'CMAC'\n  * 'Poly1305'\n\n**Signatures:** Instantiate using registry like this `Signer('SomeDigestHere/(DET-)ECDSA')` or `Signer('SomeDigestHere/RSA')`\n  * '(DET-)ECDSA'\n  * 'RSA'\n\n**Password based key derivators:** Instantiation using registry like this `KeyDerivator('SomeDigestHere/HMAC/PBKDF2')` \nor `KeyDerivator('scrypt/argon2')`. To initialize, you'll need a `Pbkdf2Parameters`, `ScryptParameters`, or \n`Argon2Parameters`.\n  * 'PBKDF2'\n  * 'scrypt'\n  * 'argon2'\n\n**HMAC based key derivators:** Instantiate using registry like this `KeyDerivator('SomeDigestHere/HKDF')`. To initialize, use an `HkdfParameters`.\n  * 'HKDF'\n\n**Asymmetric key generators** Instantiate using registry like this `KeyDerivator('RSA')`. To initialize, use `ECKeyGeneratorParameters` or `RSAKeyGeneratorParameters`.\n  * 'ECDSA'\n  * 'RSA'\n\n**Secure PRNGs:**\n  * Based on block cipher in CTR mode\n  * Based on block cipher in CTR mode with auto reseed (for forward security)\n  * Based on Fortuna algorithm\n\n### Instantiating implementation objects\n\nThere are two ways to instantiate objects that implement the\nalgorithms:\n\n- using the registry, or\n- without the registry.\n\n#### Using the registry\n\nUsing the registry, the algorithm name is provided to high-level class\nfactories.\n\nThis is especially convenient when an algorithm involves multiple\nalgorithm implementation classes to implement. All the necessary\nclasses can all be instantiated with a single name\n(e.g. \"SHA-256/HMAC\" or \"SHA-1/HMAC/PBKDF2\" or \"AES/CBC/PKCS7\"), and they are\nautomatically combined together with the correct values.\n\nFor example,\n\n```dart\nfinal sha256 = Digest(\"SHA-256\");\nfinal sha1 = Digest(\"SHA-1\");\nfinal md5 = Digest(\"MD5\");\n\nfinal hmacSha256 = Mac(\"SHA-256/HMAC\");\nfinal hmacSha1 = Mac(\"SHA-1/HMAC\");\nfinal hmacMd5 = Mac(\"MD5/HMAC\");\n\nfinal derivator = KeyDerivator(\"SHA-1/HMAC/PBKDF2\");\n\nfinal signer = Signer(\"SHA-256/RSA\");\n```\n\n#### Without the registry\n\nWithout the registry, each implementation class must be instantiated\nusing its constructor.\n\nIf an algorithm involves multiple algorithm implementation classes,\nthey each have to be individually instantiated and combined together\nwith the correct values.\n\nFor example,\n\n``` dart\nfinal sha256 = SHA256Digest();\nfinal sha1 = SHA1Digest();\nfinal md5 = MD5Digest();\n\nfinal hmacSha256 = HMac(SHA256Digest(), 64);\nfinal hmacSha512 = HMac(SHA512Digest(), 128);\nfinal hmacMd5 = HMac(MD5Digest(), 64);\n\nfinal derivator = PBKDF2KeyDerivator(HMac(SHA256Digest(), 64));\n\nfinal signer = RSASigner(SHA256Digest(), '0609608648016503040201');\n```\n\n#### Registry vs without registry\n\nUsing the registry means that all algorithms will be imported by\ndefault, which can increase the compiled size of your program.\n\nTo avoid this, instantiate all classes directly by using the\nconstructors. But which classes can be instantiated with its\nconstructor will depend on which libraries have been imported.\n\n### Importing libraries\n\nA program can take one of these three approaches for importing Point\nCastle libraries:\n\n- only import pointycastle.dart;\n- only import exports.dart; or\n- import api.dart and individual libraries as needed.\n\n#### Only import pointycastle.dart\n\nThe \"pointycastle.dart\" file exports:\n\n- the high-level API; and\n- implementations of the interfaces.\n\nBut it does not export any of the algorithm implementation classes.\n\n``` dart\nimport \"package:pointycastle/pointycastle.dart\";\n```\n\nWith this import, **none** of the implementation classes can be\ninstantiated directly.  The program can only use the registry.\n\nFor example,\n\n``` dart\nfinal sha256 = Digest(\"SHA-256\");\n// final md5 = MD5Digest(); // not available\nfinal p = Padding(\"PKCS7\");\n// final s = FortunaRandom(); // not available\n```\n\n#### Only import exports.dart\n\nThe \"export.dart\" file exports:\n\n- the high-level API,\n- implementations of the interfaces; and\n- every algorithm implementation class.\n\nThat is, everything!\n\n``` dart\nimport \"package:pointycastle/export.dart\";\n```\n\nWith this import, **all** of the implementation classes can be\ninstantiated directly.  The program can also use the registry.\n\n\nFor example, this works without any additional imports:\n\n``` dart\nfinal sha256 = Digest(\"SHA-256\");\nfinal md5 = MD5Digest();\nfinal p = Padding(\"PKCS7\");\nfinal s = FortunaRandom();\n```\n\n#### Import api.dart and individual libraries\n\nThe \"api.dart\" exports only:\n\n- the high-level API.\n\nIt does not include the implementations of the interfaces, nor any\nalgorithm implementation class.\n\n``` dart\nimport \"package:pointycastle/api.dart\";\n// additional imports will be needed\n```\n\nWith this import, only **some** of the implementation classes can be\ninstantiated directly (i.e. those that are also explicitly imported).\nThe program can also use the registry.\n\nFor example, the following only works because of the additional imports:\n\n``` dart\n// In addition to \"package:pointycastle/api.dart\":\nimport \"package:pointycastle/digests/sha256.dart\";\nimport \"package:pointycastle/digests/md5.dart\"\nimport 'package:pointycastle/paddings/pkcs7.dart';\n\nfinal sha256 = Digest(\"SHA-256\");\nfinal md5 = MD5Digest();\nfinal p = Padding(\"PKCS7\");\n// final s = FortunaRandom(); // not available without 'package:pointycastle/random/fortuna_random.dart'\n```\n\n## Tutorials\n\nSome articles on how to use some of Pointy Castle's features can be\nfound under the _tutorials_ directory in the sources.\n\n- [Calculating a digest](https://github.com/bcgit/pc-dart/blob/master/tutorials/digest.md) - calculating a hash or digest (e.g. SHA-256, SHA-1, MD5)\n- [Calculating a HMAC](https://github.com/bcgit/pc-dart/blob/master/tutorials/hmac.md) - calculating a hash-based message authentication code (e.g. HMAC-SHA256, HMAC-SHA1)\n- [Using AES-CBC](https://github.com/bcgit/pc-dart/blob/master/tutorials/aes-cbc.md) - block encryption and decryption with AES-CBC\n- [Using RSA](https://github.com/bcgit/pc-dart/blob/master/tutorials/rsa.md) - key generation, signing/verifying, and encryption/decryption\n- Some [tips](https://github.com/bcgit/pc-dart/blob/master/tutorials/tips.md) on using Pointy Castle\n\n_Note: the above links are to the most recent versions on the master branch on GitHub. They may be different from the version on pub.dev._\n","funding_links":[],"categories":["Dart"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcgit%2Fpc-dart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbcgit%2Fpc-dart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcgit%2Fpc-dart/lists"}