X-Git-Url: http://git.ieval.ro/?p=authen-passphrase-scrypt.git;a=blobdiff_plain;f=lib%2FAuthen%2FPassphrase%2FScrypt.pm;h=52fc683f3934e83f0573168fd5879a81d14eaae6;hp=fabc7aeadb41418fa90872b1b8cbe83bc4979e5c;hb=HEAD;hpb=c03ebc79527feb458486cb360a9a51e50c84d59e diff --git a/lib/Authen/Passphrase/Scrypt.pm b/lib/Authen/Passphrase/Scrypt.pm index fabc7ae..52fc683 100644 --- a/lib/Authen/Passphrase/Scrypt.pm +++ b/lib/Authen/Passphrase/Scrypt.pm @@ -9,7 +9,7 @@ use parent qw/Exporter Authen::Passphrase/; our @EXPORT = qw/crypto_scrypt/; our @EXPORT_OK = @EXPORT; -our $VERSION = '0.001001'; +our $VERSION = '0.002'; use Data::Entropy::Algorithms qw/rand_bits/; use Digest::SHA qw/sha256 hmac_sha256/; @@ -98,9 +98,9 @@ Authen::Passphrase::Scrypt - passphrases using Tarsnap's scrypt algorithm use Authen::Passphrase::Scrypt; # Hash a password - my $sc = Authen::Passphrase::Scrypt->new({ + my $sc = Authen::Passphrase::Scrypt->new( passphrase => 'correcthorsebatterystaple' - }); + ); my $hash = $sc->as_rfc2307; say "The given password hashes to $hash"; @@ -111,13 +111,13 @@ Authen::Passphrase::Scrypt - passphrases using Tarsnap's scrypt algorithm say 'The password was "xkcd"' if $sc->match('xkcd'); # Advanced hashing - my $sc = Authen::Passphrase::Scrypt->new({ + my $sc = Authen::Passphrase::Scrypt->new( passphrase => 'xkcd', logN => 14, # General work factor r => 16, # Memory work factor p => 1, # CPU (parallellism) work factor salt => 'SodiumChloride && sODIUMcHLORIDE', # Must be 32 bytes - }); + ); say 'The given password now hashes to ', $sc->as_rfc2307; =head1 DESCRIPTION @@ -136,10 +136,11 @@ from within L. The methods are: =over -=item Authen::Passphrase::Scrypt->B(I<\%args>) +=item Authen::Passphrase::Scrypt->B(I<%args>) Creates a new L from a given passphrase -and parameters. Use this to hash a passphrase. The arguments are: +and parameters. Use this to hash a passphrase. This function takes +either a key value list or a hashref. The arguments are: =over @@ -176,6 +177,8 @@ fine-tuning: if scrypt uses too much memory but not enough CPU, decrease logN and increase p; if scrypt uses too much CPU but not enough memory, decrease logN and increase r. +Note that C<< 2^logN >> must fit in 64 bits and C<< r * p < 2^30 >>. + =item $sc->B Returns the hash of the passphrase, in RFC2307 format. This is @@ -192,6 +195,7 @@ Returns true if the given passphrase matches the hash, false otherwise. =item Authen::Passphrase::Scrypt->from_crypt + =item $sc->as_crypt These functions both croak. They are provided for compatibility with @@ -211,7 +215,7 @@ Marius Gavrilescu, Emarius@ieval.roE =head1 COPYRIGHT AND LICENSE -Copyright (C) 2017 by Marius Gavrilescu +Copyright (C) 2017-2018 by Marius Gavrilescu This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.24.1 or,