1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/*
* Copyright (C) 2007 Bruno Krieg, Daniel Wydler
* Hochschule fuer Technik Rapperswil, Switzerland
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* $Id: fips_signer.c 3964 2008-05-15 14:01:26Z martin $
*/
#include <stdio.h>
#include <crypto/hashers/hasher.h>
#include "fips.h"
int main(int argc, char* argv[])
{
FILE *f;
char *hmac_key = "strongSwan Version " VERSION;
char hmac_signature[BUF_LEN];
/* initialize library */
library_init(STRONGSWAN_CONF);
lib->plugins->load(lib->plugins, IPSEC_PLUGINDIR, "sha1 hmac");
if (!fips_compute_hmac_signature(hmac_key, hmac_signature))
{
exit(1);
}
/**
* write computed HMAC signature to fips_signature.h
*/
f = fopen("fips_signature.h", "wt");
if (f == NULL)
{
exit(1);
}
fprintf(f, "/* SHA-1 HMAC signature computed over TEXT and RODATA of libstrongswan\n");
fprintf(f, " *\n");
fprintf(f, " * This file has been automatically generated by fips_signer\n");
fprintf(f, " * Do not edit manually!\n");
fprintf(f, " */\n");
fprintf(f, "\n");
fprintf(f, "#ifndef FIPS_SIGNATURE_H_\n");
fprintf(f, "#define FIPS_SIGNATURE_H_\n");
fprintf(f, "\n");
fprintf(f, "const char *hmac_key = \"%s\";\n", hmac_key);
fprintf(f, "const char *hmac_signature = \"%s\";\n", hmac_signature);
fprintf(f, "\n");
fprintf(f, "#endif /* FIPS_SIGNATURE_H_ @} */\n");
fclose(f);
library_deinit();
exit(0);
}
|