1 | #! /usr/bin/env perl
|
---|
2 | # Copyright 2021-2024 The OpenSSL Project Authors. All Rights Reserved.
|
---|
3 | #
|
---|
4 | # Licensed under the Apache License 2.0 (the "License"). You may not use
|
---|
5 | # this file except in compliance with the License. You can obtain a copy
|
---|
6 | # in the file LICENSE in the source distribution or at
|
---|
7 | # https://www.openssl.org/source/license.html
|
---|
8 |
|
---|
9 | use Getopt::Long;
|
---|
10 |
|
---|
11 | # Module options for pedantic FIPS mode
|
---|
12 | # self_test_onload happens if install_mac isn't included, don't add it below
|
---|
13 | my $conditional_errors = 1;
|
---|
14 | my $security_checks = 1;
|
---|
15 | my $ems_check = 1;
|
---|
16 | my $no_short_mac = 1;
|
---|
17 | my $drgb_no_trunc_dgst = 1;
|
---|
18 | my $digest_check = 1;
|
---|
19 | my $dsa_sign_disabled = 1;
|
---|
20 | my $tdes_encrypt_disabled = 1;
|
---|
21 | my $pkcs15_pad_disable = 1;
|
---|
22 | my $rsa_pss_saltlen_check = 1;
|
---|
23 | my $rsa_sign_x931_pad_disabled = 1;
|
---|
24 | my $kdf_key_check = 1;
|
---|
25 | my $pbkdf2_lower_bound_check = 1;
|
---|
26 | my $ec_cofactor_check = 1;
|
---|
27 | my $mac_key_check = 1;
|
---|
28 |
|
---|
29 | my $activate = 1;
|
---|
30 | my $version = 1;
|
---|
31 | my $mac_key;
|
---|
32 | my $module_name;
|
---|
33 | my $section_name = "fips_sect";
|
---|
34 |
|
---|
35 | GetOptions("key=s" => \$mac_key,
|
---|
36 | "module=s" => \$module_name,
|
---|
37 | "section_name=s" => \$section_name)
|
---|
38 | or die "Error when getting command line arguments";
|
---|
39 |
|
---|
40 | my $mac_keylen = length($mac_key);
|
---|
41 |
|
---|
42 | use Digest::SHA qw(hmac_sha256_hex);
|
---|
43 | my $module_size = [ stat($module_name) ]->[7];
|
---|
44 |
|
---|
45 | open my $fh, "<:raw", $module_name or die "Trying to open $module_name: $!";
|
---|
46 | read $fh, my $data, $module_size or die "Trying to read $module_name: $!";
|
---|
47 | close $fh;
|
---|
48 |
|
---|
49 | # Calculate HMAC-SHA256 in hex, and split it into a list of two character
|
---|
50 | # chunks, and join the chunks with colons.
|
---|
51 | my @module_mac
|
---|
52 | = ( uc(hmac_sha256_hex($data, pack("H$mac_keylen", $mac_key))) =~ m/../g );
|
---|
53 | my $module_mac = join(':', @module_mac);
|
---|
54 |
|
---|
55 | print <<_____;
|
---|
56 | [$section_name]
|
---|
57 | activate = $activate
|
---|
58 | install-version = $version
|
---|
59 | conditional-errors = $conditional_errors
|
---|
60 | security-checks = $security_checks
|
---|
61 | module-mac = $module_mac
|
---|
62 | tls1-prf-ems-check = $ems_check
|
---|
63 | no-short-mac = $no_short_mac
|
---|
64 | drbg-no-trunc-md = $drgb_no_trunc_dgst
|
---|
65 | signature-digest-check = $digest_check
|
---|
66 | dsa-sign-disabled = $dsa_sign_disabled
|
---|
67 | hkdf-digest-check = $digest_check
|
---|
68 | tls13-kdf-digest-check = $digest_check
|
---|
69 | tls1-prf-digest-check = $digest_check
|
---|
70 | sshkdf-digest-check = $digest_check
|
---|
71 | sskdf-digest-check = $digest_check
|
---|
72 | x963kdf-digest-check = $digest_check
|
---|
73 | tdes-encrypt-disabled = $tdes_encrypt_disabled
|
---|
74 | rsa-pkcs15-pad-disabled = $pkcs15_pad_disable
|
---|
75 | rsa-pss-saltlen-check = $rsa_pss_saltlen_check
|
---|
76 | rsa-sign-x931-pad-disabled = $rsa_sign_x931_pad_disabled
|
---|
77 | hkdf-key-check = $kdf_key_check
|
---|
78 | kbkdf-key-check = $kdf_key_check
|
---|
79 | tls13-kdf-key-check = $kdf_key_check
|
---|
80 | tls1-prf-key-check = $kdf_key_check
|
---|
81 | sshkdf-key-check = $kdf_key_check
|
---|
82 | sskdf-key-check = $kdf_key_check
|
---|
83 | x963kdf-key-check = $kdf_key_check
|
---|
84 | x942kdf-key-check = $kdf_key_check
|
---|
85 | pbkdf2-lower-bound-check = $pbkdf2_lower_bound_check
|
---|
86 | ecdh-cofactor-check = $ec_cofactor_check
|
---|
87 | hmac-key-check = $mac_key_check
|
---|
88 | kmac-key-check = $mac_key_check
|
---|
89 | _____
|
---|