diff options
-rw-r--r-- | build-aux/BuildCommon.pm | 25 | ||||
-rw-r--r-- | build-aux/gen-crypt-hashes-h | 17 | ||||
-rw-r--r-- | lib/crypt.c | 1 |
3 files changed, 27 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. diff --git a/lib/crypt.c b/lib/crypt.c index 8e4fb74..b109b56 100644 --- a/lib/crypt.c +++ b/lib/crypt.c @@ -68,6 +68,7 @@ struct hashfn /* The type of this field is unsigned char to ensure that it cannot be set larger than the size of an internal buffer in crypt_gensalt_rn. */ unsigned char nrbytes; + unsigned char is_strong; }; static const struct hashfn hash_algorithms[] = |