diff options
author | Björn Esser <besser82@fedoraproject.org> | 2021-05-06 20:58:26 +0200 |
---|---|---|
committer | Björn Esser <besser82@fedoraproject.org> | 2021-05-19 20:52:50 +0200 |
commit | 582259ecd3b4ebf41b0225a9a7d1d35f3fd24373 (patch) | |
tree | 0ac3725e87a96800c4b76db85275611670ab717a /build-aux | |
parent | 73be914f1edf7e2ece90a96c01de58b23fee38e9 (diff) | |
download | libxcrypt-582259ecd3b4ebf41b0225a9a7d1d35f3fd24373.tar.gz libxcrypt-582259ecd3b4ebf41b0225a9a7d1d35f3fd24373.tar.bz2 libxcrypt-582259ecd3b4ebf41b0225a9a7d1d35f3fd24373.zip |
lib/crypt.c: New data member `is_strong` for `struct hashfn`.
Add a new data member `is_strong` to the internally used structure
`struct hashfn`. This new data member indicates whether the hashing
function corresponding to the field is considered to be strong.
Diffstat (limited to 'build-aux')
-rw-r--r-- | build-aux/BuildCommon.pm | 25 | ||||
-rw-r--r-- | build-aux/gen-crypt-hashes-h | 17 |
2 files changed, 26 insertions, 16 deletions
diff --git a/build-aux/BuildCommon.pm b/build-aux/BuildCommon.pm index 2b30d3e..cfcdab8 100644 --- a/build-aux/BuildCommon.pm +++ b/build-aux/BuildCommon.pm @@ -293,14 +293,16 @@ sub which { # use Class::Struct HashSpec => [ - name => '$', - prefix => '$', - nrbytes => '$', + name => '$', + prefix => '$', + nrbytes => '$', + is_strong => '$', ]; use Class::Struct HashesConfData => [ hashes => '*%', groups => '*%', max_namelen => '$', + max_nrbyteslen => '$', max_prefixlen => '$', default_candidates => '*@', ]; @@ -351,8 +353,9 @@ sub parse_hashes_conf { my %line_of; my %hashes; my %groups; - my $max_namelen = 0; - my $max_prefixlen = 0; + my $max_namelen = 0; + my $max_nrbyteslen = 0; + my $max_prefixlen = 0; my @default_candidates; local $_; while (<$fh>) { @@ -397,6 +400,10 @@ sub parse_hashes_conf { $nrbytes = 1; } + if ($max_nrbyteslen < length $nrbytes) { + $max_nrbyteslen = length $nrbytes; + } + $flags = q{} if $flags eq ':'; for (split /,/, $flags) { if (!exists $VALID_FLAGS{$_}) { @@ -417,9 +424,10 @@ sub parse_hashes_conf { next if $error; my $entry = HashSpec->new( - name => $name, - prefix => $h_prefix, - nrbytes => $nrbytes, + name => $name, + prefix => $h_prefix, + nrbytes => $nrbytes, + is_strong => $is_strong, ); $hashes{$name} = $entry; for my $g (@grps) { @@ -458,6 +466,7 @@ sub parse_hashes_conf { hashes => \%hashes, groups => \%groups, max_namelen => $max_namelen, + max_nrbyteslen => $max_nrbyteslen, max_prefixlen => $max_prefixlen, default_candidates => \@default_candidates, ); diff --git a/build-aux/gen-crypt-hashes-h b/build-aux/gen-crypt-hashes-h index 0c125d0..056eceb 100644 --- a/build-aux/gen-crypt-hashes-h +++ b/build-aux/gen-crypt-hashes-h @@ -87,15 +87,16 @@ EOT } @enabled_hashes; for my $e (@table_hashes) { - my $name_rn = $e->name . '_rn,'; - my $q_prefix = '"' . $e->prefix . '",'; - printf " { %-*s %d, crypt_%-*s gensalt_%-*s %s }, \\\n", - $hconf->max_prefixlen + 2, $q_prefix, length($e->prefix), - $hconf->max_namelen + 4, $name_rn, - $hconf->max_namelen + 4, $name_rn, - $e->nrbytes; + my $name_rn = $e->name . '_rn,'; + my $q_prefix = '"' . $e->prefix . '",'; + my $str_nrbytes = $e->nrbytes . ','; + printf " { %-*s %d, crypt_%-*s gensalt_%-*s %-*s %s}, \\\n", + $hconf->max_prefixlen + 3, $q_prefix, length($e->prefix), + $hconf->max_namelen + 4, $name_rn, + $hconf->max_namelen + 4, $name_rn, + $hconf->max_nrbyteslen + 1, $str_nrbytes, $e->is_strong; } - print " { 0, 0, 0, 0, 0 }\n"; + print " { 0, 0, 0, 0, 0, 0 }\n"; # The default_candidates array is in decreasing order of strength; # select the first one that's enabled, if any. |