Codebase list libcryptx-perl / 257262c
new digests SHA512_224 + SHA512_256 Karel Miko 9 years ago
5 changed file(s) with 15 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
1010 use File::Glob qw(bsd_glob);
1111
1212 sub equal_files {
13 return 0 unless -f $_[0] && -f $_[1];
1314 my $d1 = sha1_hex(read_file(shift, binmode => ':raw'));
1415 my $d2 = sha1_hex(read_file(shift, binmode => ':raw'));
1516 return $d1 eq $d2;
3435 SHA256 => { ltc=>'sha256', info=>'Hash function SHA-256 [size: 256 bits]', urls=>['http://en.wikipedia.org/wiki/SHA-2'] },
3536 SHA384 => { ltc=>'sha384', info=>'Hash function SHA-384 [size: 384 bits]', urls=>['http://en.wikipedia.org/wiki/SHA-2'] },
3637 SHA512 => { ltc=>'sha512', info=>'Hash function SHA-512 [size: 512 bits]', urls=>['http://en.wikipedia.org/wiki/SHA-2'] },
38 SHA512_224 => { ltc=>'sha512_224',info=>'Hash function SHA-512/224 [size: 224 bits]', urls=>['http://en.wikipedia.org/wiki/SHA-2'] },
39 SHA512_256 => { ltc=>'sha512_256',info=>'Hash function SHA-512/256 [size: 256 bits]', urls=>['http://en.wikipedia.org/wiki/SHA-2'] },
3740 Tiger192 => { ltc=>'tiger', info=>'Hash function Tiger-192 [size: 192 bits]', urls=>['http://en.wikipedia.org/wiki/Tiger_(cryptography)'] },
3841 Whirlpool => { ltc=>'whirlpool', info=>'Hash function Whirlpool [size: 512 bits]', urls=>['http://en.wikipedia.org/wiki/Whirlpool_(cryptography)'] },
3942 );
8083
8184 my $t_out = catfile($outdir_t, "digest_".lc($n).".t");
8285 my $t_tt = Template->new(ABSOLUTE=>1) || die $Template::ERROR, "\n";
83 $t_tt->process("$FindBin::Bin/Digest.t.tt", $data, "$t_out.$$") || die $t_tt->error(), "\n";
86 $t_tt->process("$FindBin::Bin/Digest.t.tt", $data, "$t_out.$$", {binmode=>1}) || die $t_tt->error(), "\n";
8487 copy("$t_out.$$", $t_out) and warn("Writting '$t_out'\n") unless equal_files("$t_out.$$", $t_out);
8588 unlink "$t_out.$$";
8689 }
8891 if ($outdir_l) {
8992 my $pm_out = catfile($outdir_l, "Crypt", "Digest", "$n.pm");
9093 my $pm_tt = Template->new(ABSOLUTE=>1) || die $Template::ERROR, "\n";
91 $pm_tt->process("$FindBin::Bin/Digest.pm.tt", $data, $pm_out) || die $pm_tt->error(), "\n";
94 $pm_tt->process("$FindBin::Bin/Digest.pm.tt", $data, $pm_out, {binmode=>1}) || die $pm_tt->error(), "\n";
9295 }
9396
9497 }
3232 RIPEMD256 => 'rmd256',
3333 RIPEMD320 => 'rmd320',
3434 TIGER192 => 'tiger',
35 SHA512_224=> 'sha512-224',
36 SHA512_256=> 'sha512-256',
3537 );
3638 $name =~ s/^Crypt::Digest:://i;
3739 return $trans{uc($name)} if defined $trans{uc($name)};
171173
172174 'CHAES', 'MD2', 'MD4', 'MD5', 'RIPEMD128', 'RIPEMD160',
173175 'RIPEMD256', 'RIPEMD320', 'SHA1', 'SHA224', 'SHA256',
174 'SHA384', 'SHA512', 'Tiger192', 'Whirlpool'
176 'SHA384', 'SHA512', 'SHA512_224', 'SHA512_256', 'Tiger192', 'Whirlpool'
175177
176178 (simply any <FUNCNAME> for which there is Crypt::Digest::<FUNCNAME> module)
177179
249251
250252 $d = Crypt::Digest->new($name);
251253 # $name could be: 'CHAES', 'MD2', 'MD4', 'MD5', 'RIPEMD128', 'RIPEMD160',
252 # 'RIPEMD256', 'RIPEMD320', 'SHA1', 'SHA224', 'SHA256',
253 # 'SHA384', 'SHA512', 'Tiger192', 'Whirlpool'
254 # 'RIPEMD256', 'RIPEMD320', 'SHA1', 'SHA224', 'SHA256', 'SHA384',
255 # 'SHA512', 'SHA512_224', 'SHA512_256', 'Tiger192', 'Whirlpool'
254256 #
255257 # simply any <FUNCNAME> for which there is Crypt::Digest::<FUNCNAME> module
256258
22 use strict;
33 use warnings ;
44
5 our $VERSION = '0.021';
5 our $VERSION = '0.021_2';
66
77 require XSLoader;
88 XSLoader::load('CryptX', $VERSION);
4141
4242 L<Crypt::Digest::CHAES>, L<Crypt::Digest::MD2>, L<Crypt::Digest::MD4>, L<Crypt::Digest::MD5>, L<Crypt::Digest::RIPEMD128>, L<Crypt::Digest::RIPEMD160>,
4343 L<Crypt::Digest::RIPEMD256>, L<Crypt::Digest::RIPEMD320>, L<Crypt::Digest::SHA1>, L<Crypt::Digest::SHA224>, L<Crypt::Digest::SHA256>, L<Crypt::Digest::SHA384>,
44 L<Crypt::Digest::SHA512>, L<Crypt::Digest::Tiger192>, L<Crypt::Digest::Whirlpool>
44 L<Crypt::Digest::SHA512>, L<Crypt::Digest::SHA512_224>, L<Crypt::Digest::SHA512_256>, L<Crypt::Digest::Tiger192>, L<Crypt::Digest::Whirlpool>
4545
4646 =item * Message Authentication Codes
4747
276276 if(register_hash(&sha256_desc)==-1) { croak("FATAL: cannot register_hash sha256"); }
277277 if(register_hash(&sha384_desc)==-1) { croak("FATAL: cannot register_hash sha384"); }
278278 if(register_hash(&sha512_desc)==-1) { croak("FATAL: cannot register_hash sha512"); }
279 if(register_hash(&sha512_224_desc)==-1) { croak("FATAL: cannot register_hash sha512_224"); }
280 if(register_hash(&sha512_256_desc)==-1) { croak("FATAL: cannot register_hash sha512_256"); }
279281 if(register_hash(&tiger_desc)==-1) { croak("FATAL: cannot register_hash tiger"); }
280282 if(register_hash(&whirlpool_desc)==-1) { croak("FATAL: cannot register_hash whirlpool"); }
281283 /* --- */
6161 if (rv != CRYPT_OK) croak("FATAL: digest process failed: %s", error_to_string(rv));
6262 }
6363 }
64 XPUSHs(sv_2mortal(newSVsv(ST(0)))); /* XXX-HACK returning 'self' */
64 XPUSHs(ST(0)); /* return self */
6565 }
6666
6767 SV *