package Crypt::Perl;

use strict;
use warnings;

our $VERSION = '0.33';

=encoding utf-8

=head1 NAME

Crypt::Perl - Cryptography in pure Perl


Just as it sounds: cryptography with no non-core XS dependencies!
This is useful if you don’t have access to
other tools that do this work like L<OpenSSL|>, L<CryptX>,
etc. Of course, if you do have access to one of those tools, they may suit
your purpose better.

See submodules for usage examples of:


=item * Key generation

=item * Key parsing

=item * Signing & verification

=item * Encryption & decryption

=item * Import (L<Crypt::Perl::PK>) from & export to L<JSON Web Key|> format

=item * L<JWK thumbprints|>

=item * Certificate Signing Request (PKCS #10) generation (L<Crypt::Perl::PKCS10>)

=item * SSL/TLS certificate (X.509) generation (L<Crypt::Perl::X509v3>), including
a broad variety of extensions




=item * L<RSA|Crypt::Perl::RSA>

=item * L<ECDSA|Crypt::Perl::ECDSA>

=item * L<Ed25519|Crypt::Perl::Ed25519>



Given the number of original tests in this distribution, I am B<reasonably>
confident that this code is as secure as the random number generation in
L<Bytes::Random::Secure::Tiny> can allow. The tests verify the logic here
against OpenSSL, on which millions of applications rely every day.

That said: B<NO GUARANTEES!!!> The tests here are original, but the
production logic is ported from elsewhere. There has been no formal security
review. L<I found at least one security flaw|>
in one of the source libraries; there may be more.

For this reason it is best to restrict use of this library to internal systems.
Public-facing interfaces should prefer more “visible” cryptographic libraries
like the ones mentioned elsewhere here.

Of course, L<OpenSSL has not been trouble-free, either!|>

Caveat emptor.

=head1 SPEED

RSA key generation is slow—too slow, probably, unless you have
L<Math::BigInt::GMP> or L<Math::BigInt::Pari> (either of which requires XS).
It’s one application where pure-Perl cryptography just doesn’t seem
feasible. :-( Everything else, though, including all ECDSA and Ed25519
operations, should be fine.

Note that this distribution’s test suite is pretty slow without an
XS backend.

=head1 TODO

There are TODO items listed in the submodules; the following are general
to the entire distribution.


=item * Document the exception system so that applications can use it.

=item * Add more tests, e.g., against L<CryptX>.

=item * Some formal security audit would be nice.

=item * Make it faster :)



Much of the logic here comes from Kenji Urushima’s L<jsrsasign|>.

Most of the tests depend on the near-ubiquitous L<OpenSSL|>,
without which the Internet would be a very, very different reality from
what we know!

The Ed25519 logic is ported from L<forge.js|>.

Other parts are ported from L<LibTomCrypt|>.

Special thanks to Antonio de la Piedra for having submitted
multiple high-quality, in-depth bug reports.

=head1 LICENSE

This library is licensed under the same license as Perl.

=head1 AUTHOR

Felipe Gasper (FELIPE)