Crypt-NaCl-Sodium

 view release on metacpan or  search on metacpan

lib/Crypt/NaCl/Sodium.pm  view on Meta::CPAN

Returns an unpredictable number between 0 and optional C<$upper_bound>
(excluded).
If C<$upper_bound> is not specified the maximum value is C<0xffffffff>
(included).

=head2 increment

    increment($nonce, ...);

B<NOTE:> This function is deprecated and will be removed in next version. Please
use L<Data::BytesLocker/"increment">.

Increments an arbitrary long unsigned number(s) (in place). Function runs in constant-time
for a given length of arguments and considers them to be encoded in
little-endian format.

=head2 random_bytes

    my $bytes = random_bytes($num_of_bytes);

Generates unpredictable sequence of C<$num_of_bytes> bytes.

The length of the C<$bytes> equals the value of C<$num_of_bytes>.

Returns L<Data::BytesLocker> object.

=head2 add

    # equivalent of sodium_add($S, $l, length($l))
    my $x = Crypt::NaCl::Sodium::add($S, $l);

Accepts two integers.  It computes (a + b) mod 2^(8*len) in constant time
for a given length and returns the result.

Returns Integer

=head2 has_aes128ctr

    my $supported = Crypt::NaCl::Sodium::has_aes128ctr()

Checks whether the underlying libsodium supports ASE128CTR

Returns &PL_sv_yes or &PL_sx_no

=head2 sodium_version_string

    my $version = Crypt::NaCl::Sodium::sodium_version_string()

Gets the libsodium version string

Returns a string like "1.0.18"

=head1 VARIABLES

=head2 $Data::BytesLocker::DEFAULT_LOCKED

    use Crypt::NaCl::Sodium;
    $Data::BytesLocker::DEFAULT_LOCKED = 1;

By default all values returned from the provided methods are
unlocked L<Data::BytesLocker> objects. If this variable is set to true then
the returned objects are locked and require calling
L<Data::BytesLocker/"unlock"> before accessing.

=head1 SEE ALSO

=over 4

=item * L<Crypt::NaCl::Sodium::secretbox> - Secret-key authenticated encryption (XSalsa20/Poly1305 MAC)

=item * L<Crypt::NaCl::Sodium::auth> - Secret-key message authentication (HMAC-SHA256, HMAC-SHA512, HMAC-SHA512/256 )

=item * L<Crypt::NaCl::Sodium::aead> - Authenticated Encryption with Additional Data (ChaCha20/Poly1305 MAC, AES256-GCM)

=item * L<Crypt::NaCl::Sodium::box> - Public-key authenticated encryption (Curve25519/XSalsa20/Poly1305 MAC)

=item * L<Crypt::NaCl::Sodium::sign> - Public-key signatures (Ed25519)

=item * L<Crypt::NaCl::Sodium::generichash> - Generic hashing (Blake2b)

=item * L<Crypt::NaCl::Sodium::shorthash> - Short-input hashing (SipHash-2-4)

=item * L<Crypt::NaCl::Sodium::pwhash> - Password hashing (yescrypt)

=item * L<Crypt::NaCl::Sodium::hash> - SHA-2 (SHA-256, SHA-512)

=item * L<Crypt::NaCl::Sodium::onetimeauth> - One-time authentication (Poly1305)

=item * L<Crypt::NaCl::Sodium::scalarmult> - Diffie-Hellman (Curve25519)

=item * L<Crypt::NaCl::Sodium::stream> - Stream ciphers (XSalsa20, ChaCha20, Salsa20, AES-128-CTR)

=item * L<Data::BytesLocker> - guarded data storage

=item * L<libsodium|http://jedisct1.gitbooks.io/libsodium> - libsodium

=back

=head1 AUTHOR

Alex J. G. Burzyński <F<ajgb@cpan.org>>

=head1 COPYRIGHT & LICENSE

Copyright (c) 2015 Alex J. G. Burzyński. All rights reserved.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=cut



( run in 1.739 second using v1.01-cache-2.11-cpan-39bf76dae61 )