The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Crypt::Perl - Cryptography in pure Perl

DESCRIPTION

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 OpenSSL, 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:

SUPPORTED PUBLIC KEY ALGORITHMS

SECURITY

Bytes::Random::Secure::Tiny supplies random number generation; see that module’s documentation for details of its reliability. (Code paths that don’t need randomness—such as deterministic ECDSA signatures—should be even safer.)

An extensive test suite is included that compares against OpenSSL and LibTomCrypt (i.e., CryptX), when available.

That said: NO GUARANTEES!!! It’s best to restrict use of this library to contexts where more “visible” cryptography libraries like the ones mentioned elsewhere here are unavailable.

Of course, even OpenSSL has not been trouble-free, either!

Caveat emptor.

HISTORICAL VULNERABILITIES

SPEED

RSA key generation is slow—too slow, probably, unless you have Math::BigInt::GMP or 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 in pure Perl.

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

TODO

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

  • Document the exception system so that applications can use it.

  • Add more tests, e.g., against CryptX.

  • Some formal security audit would be nice.

  • Make it faster :)

ACKNOWLEDGEMENTS

Much of the logic here comes from Kenji Urushima’s jsrsasign.

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

The Ed25519 logic is ported from forge.js.

Deterministic ECDSA logic derived in part from python-ecdsa.

Other parts are ported from LibTomCrypt.

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

LICENSE

This library is licensed under the same license as Perl.

AUTHOR

Felipe Gasper (FELIPE)