VirtualBox

source: vbox/trunk/src/libs/openssl-3.1.7/util/mk-fipsmodule-cnf.pl@ 106683

Last change on this file since 106683 was 104078, checked in by vboxsync, 11 months ago

openssl-3.1.5: Applied and adjusted our OpenSSL changes to 3.1.4. bugref:10638

File size: 1.6 KB
Line 
1#! /usr/bin/env perl
2# Copyright 2021-2023 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
9use 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
13my $conditional_errors = 1;
14my $security_checks = 1;
15my $ems_check = 1;
16my $drgb_no_trunc_dgst = 1;
17
18my $activate = 1;
19my $mac_key;
20my $module_name;
21my $section_name = "fips_sect";
22
23GetOptions("key=s" => \$mac_key,
24 "module=s" => \$module_name,
25 "section_name=s" => \$section_name)
26 or die "Error when getting command line arguments";
27
28my $mac_keylen = length($mac_key);
29
30use Digest::SHA qw(hmac_sha256_hex);
31my $module_size = [ stat($module_name) ]->[7];
32
33open my $fh, "<:raw", $module_name or die "Trying to open $module_name: $!";
34read $fh, my $data, $module_size or die "Trying to read $module_name: $!";
35close $fh;
36
37# Calculate HMAC-SHA256 in hex, and split it into a list of two character
38# chunks, and join the chunks with colons.
39my @module_mac
40 = ( uc(hmac_sha256_hex($data, pack("H$mac_keylen", $mac_key))) =~ m/../g );
41my $module_mac = join(':', @module_mac);
42
43print <<_____;
44[$section_name]
45activate = $activate
46conditional-errors = $conditional_errors
47security-checks = $security_checks
48tls1-prf-ems-check = $ems_check
49drbg-no-trunc-md = $drgb_no_trunc_dgst
50module-mac = $module_mac
51_____
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette