Skip to content

Commit 3140af0

Browse files
author
Daniel Zagaynov
committed
lib/crypt.h: provide list of supported hash algorithms
1 parent 1c8d312 commit 3140af0

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

build-aux/scripts/gen-crypt-h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,22 @@ sub process_hashes_conf {
8787
return;
8888
}
8989

90+
sub dump_provided_hashes {
91+
my ($hashes_conf, $hashes_enabled) = @_;
92+
my %enabled = enabled_set($hashes_enabled);
93+
my $hconf = parse_hashes_conf($hashes_conf);
94+
95+
my @provided_hashes;
96+
while (my ($e, $v) = each %{$hconf->hashes}){
97+
if ($enabled{$e}) {
98+
push(@provided_hashes, "{\"$e\", \"@{[$v->prefix]}\"}");
99+
}
100+
}
101+
$substs{PROVIDED_HASHES} = join(",\n ", @provided_hashes);
102+
103+
return;
104+
}
105+
90106
sub substitute {
91107
my ($infile) = @_;
92108
open my $fh, '<', $infile
@@ -122,6 +138,7 @@ exit 0 if eval {
122138
my $infile = shift @ARGV;
123139
process_config_h(shift @ARGV);
124140
process_hashes_conf(@ARGV) if @ARGV;
141+
dump_provided_hashes(@ARGV) if @ARGV;
125142
substitute($infile);
126143
close STDOUT or die "write error: $!\n";
127144
1;

lib/crypt.h.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,17 @@ extern const char *crypt_preferred_method (void);
244244
/* Version number as a string constant. */
245245
#define XCRYPT_VERSION_STR "@XCRYPT_VERSION_STR@"
246246

247+
/* List of provided by the current build hash algorithms*/
248+
struct hash_alg{
249+
const char *name;
250+
const char *h_prefix;
251+
};
252+
253+
static struct hash_alg const provided_hash_algorithms[] = {
254+
@PROVIDED_HASHES@,
255+
{NULL, NULL}
256+
};
257+
247258
@END_DECLS@
248259

249260
#endif /* crypt.h */

0 commit comments

Comments
 (0)