Crypt-EAMessage
view release on metacpan or search on metacpan
=head2 encrypt_auth_portable
my $ciphertext = $ea->encrypt_auth_portable( $plaintext );
Added in version 1.190900
Encrypts the plain text (or byte string) passed as a parameter, generating
an ASCII (modified base64) cipher text output. This output is safe to pass
as part of a query string or URL. Namely, it doesn't use the standard Base 64
characters C<+> or C</>, replacing them with C<-> and C<_> respectively.
In addition, the cyphertext output will start with a "4".
This is intended for cross-language compatibility, so it does not utilize
store/thaw.
SECURITY NOTE: The contents of a zero length string can be determined from
the length of the encrypted portable message.
=head2 decrypt_auth
my $plaintext = $ea->decrypt_auth( $ciphertext );
Decrypts the cipher text into the object that was frozen during encryption.
If the authentication or decryption fails, an exception is thrown. Otherwise
it returns the plaintext/object.
=head2 generate_key
say "Hex key: " . Crypt::EAMessage->generate_key()
Added in version 1.220390
This is a class method (I.E. you do not need to instantiate the
C<Crypt::EAMessage> class to use this).
Returns a randomly generated key suitable to use with AES256 as a hex number.
=head1 GENERATING AES256 KEYS
To generate a key, a simple Perl program can accomplish this - note that you
should NOT use standard C<rand()> to do this.
use feature 'say';
use Crypt::EAMessage;
my $hexkey = Crypt::EAMessage->generate_key()
say "Key is: $hexkey";
Alternative, you can do this with a one-liner to return a hex key, and the
L<Crypt::EAMessage::Keygen> module:
perl -MCrypt::EAMessage::Keygen -e 1
This will output a random key in hex format suitable for use as an AES256 key.
=head1 SECURITY
Note that this module use L<Storable>. Thus this module should only be used
when the endpoint is trusted. This module will ensure that the stored
object is received without tampering by an intermediary (and is secure even
when an untrusted third party can modify the encrypted message in transit),
because C<thaw> is not called unless the message passes authentication
checks. But if an endpoint can create a malicious message using a valid
key, it is possible that this message could exploit some vulnerability in
the L<Storable> module.
This module does not protect against replay attacks.
This module is not protected against timing attacks.
=head1 ALTERNATIVES
This module implements a tiny subset of the functionality in L<Crypt::Util>
which may be a better choice for more complex use cases.
=head1 BUGS
None known, however it is certainly possible that I am less than perfect!
If you find any bug you believe has security implications, I would
greatly appreciate being notified via email sent to jmaslak@antelope.net
prior to public disclosure. In the event of such notification, I will
attempt to work with you to develop a plan for fixing the bug.
All other bugs can be reported via email to jmaslak@antelope.net or by
using the Git Hub issue tracker
at L<https://github.com/jmaslak/Crypt-EAMessage/issues>
=head1 AUTHOR
Joelle Maslak <jmaslak@antelope.net>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2019-2022 by Joelle Maslak.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
( run in 0.508 second using v1.01-cache-2.11-cpan-39bf76dae61 )