Project

General

Profile

OpenSSL packages for the Testing Environment » History » Version 2

Tobias Brunner, 13.09.2018 12:49

1 1 Tobias Brunner
h1. OpenSSL packages for the Testing Environment
2 1 Tobias Brunner
3 1 Tobias Brunner
The [[TestingEnvironment|testing environment]] uses FIPS-enabled OpenSSL packages based on the original Debian packages. These packages are automatically installed in the root image when the environment is built.
4 1 Tobias Brunner
5 1 Tobias Brunner
The following steps may be used to rebuild the packages.  This how-to uses *Ubuntu 14.04*, but it's similar on Debian or other Ubuntu releases.
6 1 Tobias Brunner
7 1 Tobias Brunner
*Note:* This how-to does not exactly follow the "instructions":https://www.openssl.org/docs/fips.html provided by the OpenSSL project. For FIPS compliance these have to be followed to the letter, but we ignore that for our test environment.
8 1 Tobias Brunner
9 1 Tobias Brunner
h2. sbuild
10 1 Tobias Brunner
11 1 Tobias Brunner
The packages are built using "sbuild":https://wiki.debian.org/sbuild in chroot environments managed with "schroot":https://wiki.debian.org/Schroot. This build environment can be installed as follows.
12 1 Tobias Brunner
13 1 Tobias Brunner
<pre>
14 1 Tobias Brunner
sudo apt-get install sbuild debian-archive-keyring
15 1 Tobias Brunner
sudo sbuild-createchroot <release> /path/to/chroot http://httpredir.debian.org/debian --keyring=/usr/share/keyrings/debian-archive-keyring.gpg
16 1 Tobias Brunner
</pre>
17 1 Tobias Brunner
18 1 Tobias Brunner
_<release>_ is e.g. _jessie_. On Ubuntu 14.04 the line @profile=sbuild@ has to get removed from the file @/etc/schroot/chroot.d/<release>-amd64-sbuild-XXXX@, otherwise entering the chroot won't work correctly.
19 1 Tobias Brunner
20 1 Tobias Brunner
The following command provides a list of all schroot environments:
21 1 Tobias Brunner
22 1 Tobias Brunner
<pre>
23 1 Tobias Brunner
sudo schroot -l
24 1 Tobias Brunner
</pre>
25 1 Tobias Brunner
26 1 Tobias Brunner
A schroot environment may be entered with:
27 1 Tobias Brunner
28 1 Tobias Brunner
<pre>
29 1 Tobias Brunner
sudo schroot -c <release>-amd64-sbuild
30 1 Tobias Brunner
</pre>
31 1 Tobias Brunner
32 2 Tobias Brunner
h3. Only required with versions of sbuild < 0.67.0
33 2 Tobias Brunner
34 1 Tobias Brunner
To self-sign the binary packages a key pair has to be generated with:
35 1 Tobias Brunner
36 1 Tobias Brunner
<pre>
37 1 Tobias Brunner
sudo sbuild-update --keygen
38 1 Tobias Brunner
</pre>
39 1 Tobias Brunner
40 1 Tobias Brunner
h2. OpenSSL FIPS canister
41 1 Tobias Brunner
42 2 Tobias Brunner
Before the package can be built the sources for the FIPS canister have to be prepared:
43 1 Tobias Brunner
44 1 Tobias Brunner
<pre>
45 1 Tobias Brunner
mkdir -p ~/openssl-fips/canister
46 1 Tobias Brunner
cd ~/openssl-fips/canister
47 2 Tobias Brunner
wget https://www.openssl.org/source/openssl-fips-x.x.x.tar.gz
48 1 Tobias Brunner
tar xf openssl-fips-x.x.x.tar.gz
49 1 Tobias Brunner
cd openssl-fips-x.x.x/
50 1 Tobias Brunner
</pre>
51 1 Tobias Brunner
52 2 Tobias Brunner
and built and installed in the schroot environment created above (note that in newer versions the @source:@ prefix is required to make persistent changes):
53 2 Tobias Brunner
54 2 Tobias Brunner
<pre>
55 2 Tobias Brunner
sudo schroot -c source:<release>-amd64-sbuild
56 2 Tobias Brunner
</pre>
57 2 Tobias Brunner
58 1 Tobias Brunner
Then in the schroot:
59 1 Tobias Brunner
<pre>
60 1 Tobias Brunner
# ./config
61 1 Tobias Brunner
# make install
62 1 Tobias Brunner
# logout
63 1 Tobias Brunner
</pre>
64 1 Tobias Brunner
65 1 Tobias Brunner
66 1 Tobias Brunner
67 1 Tobias Brunner
h2. FIPS-enabled OpenSSL
68 1 Tobias Brunner
69 2 Tobias Brunner
*Note:* The current FIPS module (2.0) is not compatible with OpenSSL 1.1.0 and newer
70 2 Tobias Brunner
71 1 Tobias Brunner
The sources for the current packages can easily be obtained using the corresponding ".dsc file":https://wiki.debian.org/dsc from Debian's "package tracker":https://packages.qa.debian.org/o/openssl.html.
72 1 Tobias Brunner
73 1 Tobias Brunner
<pre>
74 1 Tobias Brunner
mkdir -p ~/openssl-fips/openssl
75 1 Tobias Brunner
cd ~/openssl-fips/openssl
76 1 Tobias Brunner
dget -u http://http.debian.net/debian/pool/main/o/openssl/openssl_xxx.dsc
77 1 Tobias Brunner
cd openssl-xxx/
78 1 Tobias Brunner
</pre>
79 1 Tobias Brunner
80 1 Tobias Brunner
To build the packages with FIPS support the @debian/rules@ file has to be modified:
81 1 Tobias Brunner
82 1 Tobias Brunner
* Add _fips_ and _no-speed_ to @CONFARGS@. _no-speed_ is required because the @speed@ utility somehow does not link to the FIPS-enabled library and then does not find some symbols during the package build.  Unfortunately, the @speed.c@ source file is not actually able to follow the @OPENSSL_NO_SPEED@ option, so a patch is required.  In order to build a proper source package this has to be done with quilt (see below).
83 2 Tobias Brunner
* Remove all @make test@ calls (or @build* test@ in newer releases) as these test stuff that is disabled in FIPS mode. It might also be possible to add @nocheck@ to @DEB_BUILD_OPTIONS@.
84 1 Tobias Brunner
85 1 Tobias Brunner
To patch the speed utility quilt is required:
86 1 Tobias Brunner
87 1 Tobias Brunner
<pre>
88 1 Tobias Brunner
sudo apt-get install quilt
89 1 Tobias Brunner
export QUILT_PATCHES=debian/patches
90 1 Tobias Brunner
export QUILT_REFRESH_ARGS="-p ab --no-timestamps --no-index"
91 1 Tobias Brunner
quilt new speed-opensslconf.patch
92 1 Tobias Brunner
quilt add apps/speed.c
93 1 Tobias Brunner
</pre>
94 1 Tobias Brunner
95 1 Tobias Brunner
Add the following in @apps/speed.c@ right before the @#ifndef OPENSSL_NO_SPEED@ line. So it looks like this:
96 1 Tobias Brunner
<pre>
97 1 Tobias Brunner
#include <openssl/opensslconf.h>
98 1 Tobias Brunner
#ifndef OPENSSL_NO_SPEED
99 1 Tobias Brunner
</pre>
100 1 Tobias Brunner
101 1 Tobias Brunner
Update the patch:
102 1 Tobias Brunner
<pre>
103 1 Tobias Brunner
quilt refresh
104 1 Tobias Brunner
</pre>
105 1 Tobias Brunner
106 1 Tobias Brunner
To update the changelog use the following (the values are examples, i.e. what we currently use):
107 1 Tobias Brunner
108 1 Tobias Brunner
<pre>
109 1 Tobias Brunner
export DEBFULLNAME="strongSwan Testing"
110 1 Tobias Brunner
export DEBEMAIL=debian@strongswan.org
111 1 Tobias Brunner
dch --local strongswan --distribution <release>
112 1 Tobias Brunner
</pre>
113 1 Tobias Brunner
114 1 Tobias Brunner
The version number doesn't really matter as the local repository is pinned in the testing environment so even if there is a newer version in the main repository our version should get installed. But it could still get set to a value that is always higher than minor revisions of the packages (e.g. instead of @1.0.1e-2+deb7u17@ use @1.0.1e-strongswan1~2+deb7u17@).
115 1 Tobias Brunner
116 1 Tobias Brunner
Now a new source package may be built:
117 1 Tobias Brunner
118 1 Tobias Brunner
<pre>
119 1 Tobias Brunner
debuild --no-lintian -S -sa -us -uc -I -i
120 1 Tobias Brunner
cd ..
121 1 Tobias Brunner
</pre>
122 1 Tobias Brunner
123 1 Tobias Brunner
Based on that the binary packages can be built using sbuild:
124 1 Tobias Brunner
125 1 Tobias Brunner
<pre>
126 1 Tobias Brunner
sudo sbuild -d <release> openssl_xxx-strongswan1-xxx.dsc
127 1 Tobias Brunner
</pre>
128 1 Tobias Brunner
129 1 Tobias Brunner
h2. APT Repository
130 1 Tobias Brunner
131 1 Tobias Brunner
"Our custom repository"://download.strongswan.org/testing/repos/ is currently managed with @reprepro@. To add the new binary packages something like the following may be used:
132 1 Tobias Brunner
133 1 Tobias Brunner
<pre>
134 1 Tobias Brunner
reprepro -b /path/to/debian/repo includedeb <release> <debfile>
135 1 Tobias Brunner
</pre>