Project

General

Profile

OpenSSL packages for the Testing Environment » History » Version 3

Tobias Brunner, 20.12.2018 14:12

1 1 Tobias Brunner
h1. OpenSSL packages for the Testing Environment
2 1 Tobias Brunner
3 3 Tobias Brunner
----
4 3 Tobias Brunner
5 3 Tobias Brunner
*Because OpenSSL's FIPS module is only compatible with OpenSSL 1.0.2 this is currently not used anymore.*
6 3 Tobias Brunner
7 3 Tobias Brunner
----
8 3 Tobias Brunner
9 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.
10 1 Tobias Brunner
11 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.
12 1 Tobias Brunner
13 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.
14 1 Tobias Brunner
15 1 Tobias Brunner
h2. sbuild
16 1 Tobias Brunner
17 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.
18 1 Tobias Brunner
19 1 Tobias Brunner
<pre>
20 1 Tobias Brunner
sudo apt-get install sbuild debian-archive-keyring
21 1 Tobias Brunner
sudo sbuild-createchroot <release> /path/to/chroot http://httpredir.debian.org/debian --keyring=/usr/share/keyrings/debian-archive-keyring.gpg
22 1 Tobias Brunner
</pre>
23 1 Tobias Brunner
24 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.
25 1 Tobias Brunner
26 1 Tobias Brunner
The following command provides a list of all schroot environments:
27 1 Tobias Brunner
28 1 Tobias Brunner
<pre>
29 1 Tobias Brunner
sudo schroot -l
30 1 Tobias Brunner
</pre>
31 1 Tobias Brunner
32 1 Tobias Brunner
A schroot environment may be entered with:
33 1 Tobias Brunner
34 1 Tobias Brunner
<pre>
35 1 Tobias Brunner
sudo schroot -c <release>-amd64-sbuild
36 1 Tobias Brunner
</pre>
37 1 Tobias Brunner
38 2 Tobias Brunner
h3. Only required with versions of sbuild < 0.67.0
39 2 Tobias Brunner
40 1 Tobias Brunner
To self-sign the binary packages a key pair has to be generated with:
41 1 Tobias Brunner
42 1 Tobias Brunner
<pre>
43 1 Tobias Brunner
sudo sbuild-update --keygen
44 1 Tobias Brunner
</pre>
45 1 Tobias Brunner
46 1 Tobias Brunner
h2. OpenSSL FIPS canister
47 1 Tobias Brunner
48 2 Tobias Brunner
Before the package can be built the sources for the FIPS canister have to be prepared:
49 1 Tobias Brunner
50 1 Tobias Brunner
<pre>
51 1 Tobias Brunner
mkdir -p ~/openssl-fips/canister
52 1 Tobias Brunner
cd ~/openssl-fips/canister
53 2 Tobias Brunner
wget https://www.openssl.org/source/openssl-fips-x.x.x.tar.gz
54 1 Tobias Brunner
tar xf openssl-fips-x.x.x.tar.gz
55 1 Tobias Brunner
cd openssl-fips-x.x.x/
56 1 Tobias Brunner
</pre>
57 1 Tobias Brunner
58 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):
59 2 Tobias Brunner
60 2 Tobias Brunner
<pre>
61 2 Tobias Brunner
sudo schroot -c source:<release>-amd64-sbuild
62 2 Tobias Brunner
</pre>
63 2 Tobias Brunner
64 1 Tobias Brunner
Then in the schroot:
65 1 Tobias Brunner
<pre>
66 1 Tobias Brunner
# ./config
67 1 Tobias Brunner
# make install
68 1 Tobias Brunner
# logout
69 1 Tobias Brunner
</pre>
70 1 Tobias Brunner
71 1 Tobias Brunner
72 1 Tobias Brunner
73 1 Tobias Brunner
h2. FIPS-enabled OpenSSL
74 1 Tobias Brunner
75 2 Tobias Brunner
*Note:* The current FIPS module (2.0) is not compatible with OpenSSL 1.1.0 and newer
76 2 Tobias Brunner
77 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.
78 1 Tobias Brunner
79 1 Tobias Brunner
<pre>
80 1 Tobias Brunner
mkdir -p ~/openssl-fips/openssl
81 1 Tobias Brunner
cd ~/openssl-fips/openssl
82 1 Tobias Brunner
dget -u http://http.debian.net/debian/pool/main/o/openssl/openssl_xxx.dsc
83 1 Tobias Brunner
cd openssl-xxx/
84 1 Tobias Brunner
</pre>
85 1 Tobias Brunner
86 1 Tobias Brunner
To build the packages with FIPS support the @debian/rules@ file has to be modified:
87 1 Tobias Brunner
88 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).
89 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@.
90 1 Tobias Brunner
91 1 Tobias Brunner
To patch the speed utility quilt is required:
92 1 Tobias Brunner
93 1 Tobias Brunner
<pre>
94 1 Tobias Brunner
sudo apt-get install quilt
95 1 Tobias Brunner
export QUILT_PATCHES=debian/patches
96 1 Tobias Brunner
export QUILT_REFRESH_ARGS="-p ab --no-timestamps --no-index"
97 1 Tobias Brunner
quilt new speed-opensslconf.patch
98 1 Tobias Brunner
quilt add apps/speed.c
99 1 Tobias Brunner
</pre>
100 1 Tobias Brunner
101 1 Tobias Brunner
Add the following in @apps/speed.c@ right before the @#ifndef OPENSSL_NO_SPEED@ line. So it looks like this:
102 1 Tobias Brunner
<pre>
103 1 Tobias Brunner
#include <openssl/opensslconf.h>
104 1 Tobias Brunner
#ifndef OPENSSL_NO_SPEED
105 1 Tobias Brunner
</pre>
106 1 Tobias Brunner
107 1 Tobias Brunner
Update the patch:
108 1 Tobias Brunner
<pre>
109 1 Tobias Brunner
quilt refresh
110 1 Tobias Brunner
</pre>
111 1 Tobias Brunner
112 1 Tobias Brunner
To update the changelog use the following (the values are examples, i.e. what we currently use):
113 1 Tobias Brunner
114 1 Tobias Brunner
<pre>
115 1 Tobias Brunner
export DEBFULLNAME="strongSwan Testing"
116 1 Tobias Brunner
export DEBEMAIL=debian@strongswan.org
117 1 Tobias Brunner
dch --local strongswan --distribution <release>
118 1 Tobias Brunner
</pre>
119 1 Tobias Brunner
120 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@).
121 1 Tobias Brunner
122 1 Tobias Brunner
Now a new source package may be built:
123 1 Tobias Brunner
124 1 Tobias Brunner
<pre>
125 1 Tobias Brunner
debuild --no-lintian -S -sa -us -uc -I -i
126 1 Tobias Brunner
cd ..
127 1 Tobias Brunner
</pre>
128 1 Tobias Brunner
129 1 Tobias Brunner
Based on that the binary packages can be built using sbuild:
130 1 Tobias Brunner
131 1 Tobias Brunner
<pre>
132 1 Tobias Brunner
sudo sbuild -d <release> openssl_xxx-strongswan1-xxx.dsc
133 1 Tobias Brunner
</pre>
134 1 Tobias Brunner
135 1 Tobias Brunner
h2. APT Repository
136 1 Tobias Brunner
137 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:
138 1 Tobias Brunner
139 1 Tobias Brunner
<pre>
140 1 Tobias Brunner
reprepro -b /path/to/debian/repo includedeb <release> <debfile>
141 1 Tobias Brunner
</pre>