summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2016-04-12 06:07:40 +0000
committerNorbert Preining <preining@logic.at>2016-04-12 06:07:40 +0000
commitdd4bdccfb5d96b72900478b3d07651d6b7382e6a (patch)
tree5cf7dbac2f95bbefad89028f3d37a1aa368da687 /Master
parente4ea0d46df62e587ae70e6ab7711ac1c013bef32 (diff)
replace sha256 with generic checksum
We use tldigest($string) or tlchecksum($file) to generate checksum. The algorithm can be changed at any time provided that tldigest and tlchecksum (in TLUtils) and the setting TLConfig::ChecksumLength are kept in sync. git-svn-id: svn://tug.org/texlive/trunk@40429 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rwxr-xr-xMaster/texmf-dist/scripts/texlive/tlmgr.pl18
-rw-r--r--Master/tlpkg/TeXLive/TLConfig.pm5
-rw-r--r--Master/tlpkg/TeXLive/TLPOBJ.pm41
-rw-r--r--Master/tlpkg/TeXLive/TLUtils.pm16
4 files changed, 43 insertions, 37 deletions
diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl
index 13da7e23c30..bbfaecc872a 100755
--- a/Master/texmf-dist/scripts/texlive/tlmgr.pl
+++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl
@@ -5837,7 +5837,7 @@ sub setup_one_remotetlpdb {
my $local_copy_tlpdb_used = 0;
if ($location =~ m;^(http|ftp)://;) {
# first check that the saved tlpdb is present at all
- my $loc_digest = Digest::SHA::sha256_hex($location);
+ my $loc_digest = TeXLive::TLUtils::tldigest($location);
my $loc_copy_of_remote_tlpdb =
"$Master/$InfraLocation/texlive.tlpdb.$loc_digest";
ddebug("loc_digest = $loc_digest\n");
@@ -5846,11 +5846,11 @@ sub setup_one_remotetlpdb {
ddebug("loc copy found!\n");
# we found the tlpdb matching the current location
# check for the remote hash
- my $path = "$location/$InfraLocation/$DatabaseName.sha256";
+ my $path = "$location/$InfraLocation/$DatabaseName.checksum";
ddebug("remote path of digest = $path\n");
my $fh = TeXLive::TLUtils::download_file($path, "|");
my $rem_digest;
- if (read ($fh, $rem_digest, 64) != 64) {
+ if (read ($fh, $rem_digest, $ChecksumLength) != $ChecksumLength) {
info(<<END_NO_INTERNET);
No connection to the internet.
Unable to download the checksum of the remote TeX Live database,
@@ -5869,10 +5869,10 @@ END_NO_INTERNET
$local_copy_tlpdb_used = 1;
} else {
ddebug("found remote digest: $rem_digest\n");
- my $rem_copy_digest = TeXLive::TLUtils::tlsha256($loc_copy_of_remote_tlpdb);
+ my $rem_copy_digest = TeXLive::TLUtils::tlchecksum($loc_copy_of_remote_tlpdb);
ddebug("rem_copy_digest = $rem_copy_digest\n");
if ($rem_copy_digest eq $rem_digest) {
- debug("sha256 of local copy identical with remote hash\n");
+ debug("checksum of local copy identical with remote hash\n");
$remotetlpdb = TeXLive::TLPDB->new(root => $location,
tlpdbfile => $loc_copy_of_remote_tlpdb);
$local_copy_tlpdb_used = 1;
@@ -5882,9 +5882,9 @@ END_NO_INTERNET
}
if (!$local_copy_tlpdb_used) {
# TODO verification
- # here we should add code to download the remote .sha256.gpg (.asc?)
+ # here we should add code to download the remote .checksum.gpg (.asc?)
# and verify it.
- my $path = "$location/$InfraLocation/$DatabaseName.sha256.asc";
+ my $path = "$location/$InfraLocation/$DatabaseName.checksum.asc";
my $fh = TeXLive::TLUtils::download_file($path, "|");
# TODO verify ...
$remotetlpdb = TeXLive::TLPDB->new(root => $location);
@@ -5963,9 +5963,9 @@ FROZEN
# save remote database if it is a net location
# make sure that the writeout of the tlpdb is done in UNIX mode
- # since otherwise the sha256 will change.
+ # since otherwise the checksum will change.
if (!$local_copy_tlpdb_used && $location =~ m;^(http|ftp)://;) {
- my $loc_digest = Digest::SHA::sha256_hex($location);
+ my $loc_digest = TeXLive::TLUtils::tldigest($location);
my $loc_copy_of_remote_tlpdb =
"$Master/$InfraLocation/texlive.tlpdb.$loc_digest";
my $tlfh;
diff --git a/Master/tlpkg/TeXLive/TLConfig.pm b/Master/tlpkg/TeXLive/TLConfig.pm
index 166451419a7..d2dba83146b 100644
--- a/Master/tlpkg/TeXLive/TLConfig.pm
+++ b/Master/tlpkg/TeXLive/TLConfig.pm
@@ -50,6 +50,7 @@ BEGIN {
$NetworkTimeout
$PartialEngineSupport
$F_OK $F_WARNING $F_ERROR $F_NOPOSTACTION
+ $ChecksumLength
);
@EXPORT = @EXPORT_OK;
}
@@ -213,6 +214,10 @@ our $F_ERROR = 2;
# all fine, but no need to run post actions
our $F_NOPOSTACTION = 4;
+# The length of a checksum generated by tlchecksum and contained in
+# texlive.tlpdb.checksum. Needs to be in agreement with the hash
+# method used in TLUtils::tlchecksum and TLUtils::tldigest
+$ChecksumLength = 128;
1;
diff --git a/Master/tlpkg/TeXLive/TLPOBJ.pm b/Master/tlpkg/TeXLive/TLPOBJ.pm
index 0da988c1aae..134d7cd8453 100644
--- a/Master/tlpkg/TeXLive/TLPOBJ.pm
+++ b/Master/tlpkg/TeXLive/TLPOBJ.pm
@@ -169,9 +169,9 @@ sub from_fh {
|| $cmd eq 'doccontainermd5') {
$arg =~ /^[a-f0-9]{32}$/ or die "Illegal md5 value: $line!";
$self->{$cmd} = $arg;
- } elsif ($cmd eq 'containersha256' || $cmd eq 'srccontainersha256'
- || $cmd eq 'doccontainersha256') {
- $arg =~ /^[a-f0-9]{64}$/ or die "Illegal sha256 value: $line!";
+ } elsif ($cmd eq 'containerchecksum' || $cmd eq 'srccontainerchecksum'
+ || $cmd eq 'doccontainerchecksum') {
+ $arg =~ /^[a-f0-9]{$ChecksumLength}$/ or die "Illegal checksum value: $line!";
$self->{$cmd} = $arg;
} elsif ($cmd eq 'name') {
$arg =~ /^([-.\w]+)$/ or die("Invalid name: $line!");
@@ -312,8 +312,8 @@ sub writeout {
if (defined($self->{'containermd5'})) {
print $fd "containermd5 $self->{'containermd5'}\n";
}
- if (defined($self->{'containersha256'})) {
- print $fd "containersha256 $self->{'containersha256'}\n";
+ if (defined($self->{'containerchecksum'})) {
+ print $fd "containerchecksum $self->{'containerchecksum'}\n";
}
if (defined($self->{'doccontainersize'})) {
print $fd "doccontainersize $self->{'doccontainersize'}\n";
@@ -321,8 +321,8 @@ sub writeout {
if (defined($self->{'doccontainermd5'})) {
print $fd "doccontainermd5 $self->{'doccontainermd5'}\n";
}
- if (defined($self->{'doccontainersha256'})) {
- print $fd "doccontainersha256 $self->{'doccontainersha256'}\n";
+ if (defined($self->{'doccontainerchecksum'})) {
+ print $fd "doccontainerchecksum $self->{'doccontainerchecksum'}\n";
}
if (defined($self->{'docfiles'}) && (@{$self->{'docfiles'}})) {
print $fd "docfiles size=$self->{'docsize'}\n";
@@ -347,8 +347,8 @@ sub writeout {
if (defined($self->{'srccontainermd5'})) {
print $fd "srccontainermd5 $self->{'srccontainermd5'}\n";
}
- if (defined($self->{'srccontainersha256'})) {
- print $fd "srccontainersha256 $self->{'srccontainersha256'}\n";
+ if (defined($self->{'srccontainerchecksum'})) {
+ print $fd "srccontainerchecksum $self->{'srccontainerchecksum'}\n";
}
if (defined($self->{'srcfiles'}) && (@{$self->{'srcfiles'}})) {
print $fd "srcfiles size=$self->{'srcsize'}\n";
@@ -687,7 +687,7 @@ sub make_container {
return (0, 0, "");
}
my $size = (stat "$destdir/$containername") [7];
- my $sha256 = TeXLive::TLUtils::tlsha256("$destdir/$containername");
+ my $checksum = TeXLive::TLUtils::tlchecksum("$destdir/$containername");
# cleaning up
unlink("$tlpobjdir/$self->{'name'}.tlpobj");
@@ -696,8 +696,8 @@ sub make_container {
rmdir($InfraLocation) if $removetlpkgdir;
xchdir($cwd);
- debug(" done $containername, size $size, $sha256\n");
- return ($size, $sha256, "$destdir/$containername");
+ debug(" done $containername, size $size, $checksum\n");
+ return ($size, $checksum, "$destdir/$containername");
}
@@ -1490,16 +1490,13 @@ there are 6 more possible keys:
$tlpobj->containersize
$tlpobj->doccontainersize
$tlpobj->srccontainersize
- $tlpobj->containermd5
- $tlpobj->doccontainermd5
- $tlpobj->srccontainermd5
- $tlpobj->containersha256
- $tlpobj->doccontainersha256
- $tlpobj->srccontainersha256
-
-describing the respective sizes and md5sums/sha256sums in bytes and as hex string, resp.
-The latter two are only present
-if src/doc file container splitting is activated for that install medium.
+ $tlpobj->containerchecksum
+ $tlpobj->doccontainerchecksum
+ $tlpobj->srccontainerchecksum
+
+describing the respective sizes and checksums in bytes and as hex string, resp.
+The latter two are only present if src/doc file container splitting is
+activated for that install medium.
=head1 OTHER FUNCTIONS
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm
index 0a9e527c516..6274e0b20aa 100644
--- a/Master/tlpkg/TeXLive/TLUtils.pm
+++ b/Master/tlpkg/TeXLive/TLUtils.pm
@@ -99,7 +99,7 @@ C<TeXLive::TLUtils> -- utilities used in TeX Live infrastructure
TeXLive::TLUtils::give_ctan_mirror();
TeXLive::TLUtils::give_ctan_mirror_base();
TeXLive::TLUtils::tlmd5($path);
- TeXLive::TLUtils::tlsha256($path);
+ TeXLive::TLUtils::tlchecksum($path);
TeXLive::TLUtils::compare_tlpobjs($tlpA, $tlpB);
TeXLive::TLUtils::compare_tlpdbs($tlpdbA, $tlpdbB);
TeXLive::TLUtils::report_tlpdb_differences(\%ret);
@@ -174,7 +174,7 @@ BEGIN {
&create_mirror_list
&extract_mirror_entry
&tlmd5
- &tlsha256
+ &tlchecksum
&wsystem
&xsystem
&run_cmd
@@ -3582,16 +3582,20 @@ sub tlmd5 {
}
}
-sub tlsha256 {
+sub tldigest {
+ return (Digest::SHA::sha512_hex(shift));
+}
+
+sub tlchecksum {
my ($file) = @_;
if (-r $file) {
open(FILE, $file) || die "open($file) failed: $!";
binmode(FILE);
- my $sha256hash = Digest::SHA->new(256)->addfile(*FILE)->hexdigest;
+ my $cshash = Digest::SHA->new(512)->addfile(*FILE)->hexdigest;
close(FILE);
- return $sha256hash;
+ return $cshash;
} else {
- tlwarn("tlsha256, given file not readable: $file\n");
+ tlwarn("tlchecksum: given file not readable: $file\n");
return "";
}
}