Skip to content

Commit e9d4b88

Browse files
committed
resolve,import: always use openssl
This deprecate cryptolib meson option.
1 parent 0baf937 commit e9d4b88

22 files changed

+80
-602
lines changed

.github/workflows/build_test.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fatal() { echo >&2 -e "\033[31;1m$1\033[0m"; exit 1; }
1010
success() { echo >&2 -e "\033[32;1m$1\033[0m"; }
1111

1212
ARGS=(
13-
"--optimization=0 -Dopenssl=disabled -Dcryptolib=gcrypt -Dtpm=true -Dtpm2=enabled"
13+
"--optimization=0 -Dopenssl=disabled -Dtpm=true -Dtpm2=enabled"
1414
"--optimization=s -Dutmp=false"
1515
"--optimization=2 -Dc_args=-Wmaybe-uninitialized -Ddns-over-tls=openssl"
1616
"--optimization=3 -Db_lto=true -Ddns-over-tls=false"
@@ -67,7 +67,6 @@ PACKAGES=(
6767
COMPILER="${COMPILER:?}"
6868
COMPILER_VERSION="${COMPILER_VERSION:?}"
6969
LINKER="${LINKER:?}"
70-
CRYPTOLIB="${CRYPTOLIB:?}"
7170
RELEASE="$(lsb_release -cs)"
7271

7372
# Note: As we use postfixed clang/gcc binaries, we need to override $AR
@@ -150,7 +149,7 @@ for args in "${ARGS[@]}"; do
150149
CXX="$CXX" CXX_LD="$LINKER" CXXFLAGS="$CXXFLAGS" \
151150
meson setup \
152151
-Dtests=unsafe -Dslow-tests=true -Dfuzz-tests=true --werror \
153-
-Dnobody-group=nogroup -Dcryptolib="${CRYPTOLIB:?}" -Ddebug=false \
152+
-Dnobody-group=nogroup -Ddebug=false \
154153
$args build; then
155154

156155
cat build/meson-logs/meson-log.txt

.github/workflows/build_test.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ jobs:
2525
fail-fast: false
2626
matrix:
2727
env:
28-
- { COMPILER: "gcc", COMPILER_VERSION: "11", LINKER: "bfd", CRYPTOLIB: "gcrypt" }
29-
- { COMPILER: "gcc", COMPILER_VERSION: "13", LINKER: "mold", CRYPTOLIB: "openssl" }
30-
- { COMPILER: "clang", COMPILER_VERSION: "14", LINKER: "mold", CRYPTOLIB: "gcrypt" }
31-
- { COMPILER: "clang", COMPILER_VERSION: "16", LINKER: "bfd", CRYPTOLIB: "openssl" }
32-
- { COMPILER: "clang", COMPILER_VERSION: "18", LINKER: "lld", CRYPTOLIB: "auto" }
28+
- { COMPILER: "gcc", COMPILER_VERSION: "11", LINKER: "bfd" }
29+
- { COMPILER: "gcc", COMPILER_VERSION: "13", LINKER: "mold" }
30+
- { COMPILER: "clang", COMPILER_VERSION: "14", LINKER: "mold" }
31+
- { COMPILER: "clang", COMPILER_VERSION: "16", LINKER: "bfd" }
32+
- { COMPILER: "clang", COMPILER_VERSION: "18", LINKER: "lld" }
3333
env: ${{ matrix.env }}
3434
steps:
3535
- name: Repository checkout

.github/workflows/unit_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function run_meson() {
4141

4242
set -ex
4343

44-
MESON_ARGS=(-Dcryptolib=${CRYPTOLIB:-auto})
44+
MESON_ARGS=()
4545

4646
# (Re)set the current oom-{score-}adj. For some reason root on GH actions is able to _decrease_
4747
# its oom-score even after dropping all capabilities (including CAP_SYS_RESOURCE), until the

.github/workflows/unit_tests.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,15 @@ jobs:
1616
build:
1717
runs-on: ubuntu-24.04
1818
concurrency:
19-
group: ${{ github.workflow }}-${{ matrix.run_phase }}-${{ matrix.cryptolib }}-${{ github.ref }}
19+
group: ${{ github.workflow }}-${{ matrix.run_phase }}-${{ github.ref }}
2020
cancel-in-progress: true
2121
strategy:
2222
fail-fast: false
2323
matrix:
2424
run_phase: [GCC, GCC_ASAN_UBSAN, CLANG, CLANG_RELEASE, CLANG_ASAN_UBSAN, CLANG_ASAN_UBSAN_NO_DEPS]
25-
cryptolib: [auto]
2625
include:
2726
- run_phase: GCC
28-
cryptolib: openssl
2927
- run_phase: CLANG
30-
cryptolib: gcrypt
3128
steps:
3229
- name: Repository checkout
3330
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
@@ -38,8 +35,6 @@ jobs:
3835
sudo sed -i '/^XDG_/d' /etc/environment
3936
# Pass only specific env variables through sudo, to avoid having
4037
# the already existing XDG_* stuff on the "other side"
41-
sudo --preserve-env=CRYPTOLIB,GITHUB_ACTIONS,CI .github/workflows/unit_tests.sh SETUP
38+
sudo --preserve-env=GITHUB_ACTIONS,CI .github/workflows/unit_tests.sh SETUP
4239
- name: Build & test
43-
run: sudo --preserve-env=CRYPTOLIB,GITHUB_ACTIONS,CI .github/workflows/unit_tests.sh RUN_${{ matrix.run_phase }}
44-
env:
45-
CRYPTOLIB: ${{ matrix.cryptolib }}
40+
run: sudo --preserve-env=GITHUB_ACTIONS,CI .github/workflows/unit_tests.sh RUN_${{ matrix.run_phase }}

meson.build

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,18 +1475,6 @@ endif
14751475
dmi_arches = ['x86', 'x86_64', 'aarch64', 'arm', 'ia64', 'loongarch64', 'mips', 'riscv64']
14761476
conf.set10('HAVE_DMI', host_machine.cpu_family() in dmi_arches)
14771477

1478-
# We support one or the other. If gcrypt is available, we assume it's there to
1479-
# be used, and use it in preference.
1480-
opt = get_option('cryptolib')
1481-
if opt == 'openssl' and conf.get('HAVE_OPENSSL') == 0
1482-
error('openssl requested as the default cryptolib, but not available')
1483-
endif
1484-
conf.set10('PREFER_OPENSSL',
1485-
opt == 'openssl' or (opt == 'auto' and conf.get('HAVE_OPENSSL') == 1 and conf.get('HAVE_GCRYPT') == 0))
1486-
conf.set10('HAVE_OPENSSL_OR_GCRYPT',
1487-
conf.get('HAVE_OPENSSL') == 1 or conf.get('HAVE_GCRYPT') == 1)
1488-
lib_openssl_or_gcrypt = conf.get('PREFER_OPENSSL') == 1 ? [libopenssl] : [libgcrypt, libgpg_error]
1489-
14901478
dns_over_tls = get_option('dns-over-tls')
14911479
have_openssl = conf.get('HAVE_OPENSSL') == 1
14921480
if dns_over_tls == 'false'
@@ -1525,8 +1513,8 @@ have = get_option('repart').require(
15251513
conf.set10('ENABLE_REPART', have)
15261514

15271515
default_dnssec = get_option('default-dnssec')
1528-
if default_dnssec != 'no' and conf.get('HAVE_OPENSSL_OR_GCRYPT') == 0
1529-
message('default-dnssec cannot be set to yes or allow-downgrade openssl and gcrypt are disabled. Setting default-dnssec to no.')
1516+
if default_dnssec != 'no' and conf.get('HAVE_OPENSSL') == 0
1517+
message('default-dnssec cannot be set to yes or allow-downgrade when openssl is disabled. Setting default-dnssec to no.')
15301518
default_dnssec = 'no'
15311519
endif
15321520
conf.set('DEFAULT_DNSSEC_MODE',
@@ -1557,7 +1545,7 @@ conf.set10('ENABLE_STORAGETM', get_option('storagetm'))
15571545

15581546
have = get_option('importd').require(
15591547
conf.get('HAVE_LIBCURL') == 1 and
1560-
conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and
1548+
conf.get('HAVE_OPENSSL') == 1 and
15611549
conf.get('HAVE_ZLIB') == 1 and
15621550
conf.get('HAVE_XZ') == 1,
15631551
error_message : 'curl, openssl/grypt, zlib and xz required').allowed()
@@ -3125,14 +3113,6 @@ else
31253113
found += 'static-libudev(@0@)'.format(static_libudev)
31263114
endif
31273115

3128-
if conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1 and conf.get('PREFER_OPENSSL') == 1
3129-
found += 'cryptolib(openssl)'
3130-
elif conf.get('HAVE_OPENSSL_OR_GCRYPT') == 1
3131-
found += 'cryptolib(gcrypt)'
3132-
else
3133-
missing += 'cryptolib'
3134-
endif
3135-
31363116
summary({
31373117
'enabled' : ', '.join(found),
31383118
'disabled' : ', '.join(missing)},

meson_options.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,8 @@ option('gnutls', type : 'feature', deprecated : { 'true' : 'enabled', 'false' :
439439
description : 'gnutls support')
440440
option('openssl', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' },
441441
description : 'openssl support')
442-
option('cryptolib', type : 'combo', choices : ['auto', 'openssl', 'gcrypt'],
443-
description : 'whether to use openssl or gcrypt where both are supported')
442+
option('cryptolib', type : 'combo', choices : ['auto', 'openssl'],
443+
description : 'This option is deprecated and will be removed in a future release')
444444
option('p11kit', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' },
445445
description : 'p11kit support')
446446
option('libfido2', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' },

src/basic/gcrypt-util.c

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -105,39 +105,4 @@ int initialize_libgcrypt(bool secmem) {
105105

106106
return 0;
107107
}
108-
109-
# if !PREFER_OPENSSL
110-
int string_hashsum(const char *s, size_t len, int md_algorithm, char **out) {
111-
_cleanup_(sym_gcry_md_closep) gcry_md_hd_t md = NULL;
112-
gcry_error_t err;
113-
size_t hash_size;
114-
void *hash;
115-
char *enc;
116-
int r;
117-
118-
r = initialize_libgcrypt(false);
119-
if (r < 0)
120-
return r;
121-
122-
hash_size = sym_gcry_md_get_algo_dlen(md_algorithm);
123-
assert(hash_size > 0);
124-
125-
err = sym_gcry_md_open(&md, md_algorithm, 0);
126-
if (gcry_err_code(err) != GPG_ERR_NO_ERROR || !md)
127-
return -EIO;
128-
129-
sym_gcry_md_write(md, s, len);
130-
131-
hash = sym_gcry_md_read(md, 0);
132-
if (!hash)
133-
return -EIO;
134-
135-
enc = hexmem(hash, hash_size);
136-
if (!enc)
137-
return -ENOMEM;
138-
139-
*out = enc;
140-
return 0;
141-
}
142-
# endif
143108
#endif

src/basic/gcrypt-util.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,25 +63,3 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(gcry_md_hd_t, gcry_md_close, NULL);
6363
(h__)->buf[(h__)->bufpos++] = (c) & 0xff; \
6464
} while(false)
6565
#endif
66-
67-
#if !PREFER_OPENSSL
68-
# if HAVE_GCRYPT
69-
int string_hashsum(const char *s, size_t len, int md_algorithm, char **out);
70-
# endif
71-
72-
static inline int string_hashsum_sha224(const char *s, size_t len, char **out) {
73-
# if HAVE_GCRYPT
74-
return string_hashsum(s, len, GCRY_MD_SHA224, out);
75-
# else
76-
return -EOPNOTSUPP;
77-
# endif
78-
}
79-
80-
static inline int string_hashsum_sha256(const char *s, size_t len, char **out) {
81-
# if HAVE_GCRYPT
82-
return string_hashsum(s, len, GCRY_MD_SHA256, out);
83-
# else
84-
return -EOPNOTSUPP;
85-
# endif
86-
}
87-
#endif

src/import/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ executables += [
7878
'sources' : systemd_pull_sources,
7979
'link_with' : common_libs,
8080
'dependencies' : common_deps + [
81-
lib_openssl_or_gcrypt,
81+
libopenssl,
8282
],
8383
},
8484
libexec_template + {

src/import/pull-job.c

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "alloc-util.h"
88
#include "fd-util.h"
99
#include "format-util.h"
10-
#include "gcrypt-util.h"
1110
#include "hexdecoct.h"
1211
#include "import-util.h"
1312
#include "io-util.h"
@@ -42,11 +41,7 @@ PullJob* pull_job_unref(PullJob *j) {
4241
import_compress_free(&j->compress);
4342

4443
if (j->checksum_ctx)
45-
#if PREFER_OPENSSL
4644
EVP_MD_CTX_free(j->checksum_ctx);
47-
#else
48-
gcry_md_close(j->checksum_ctx);
49-
#endif
5045

5146
free(j->url);
5247
free(j->etag);
@@ -107,11 +102,7 @@ static int pull_job_restart(PullJob *j, const char *new_url) {
107102
import_compress_free(&j->compress);
108103

109104
if (j->checksum_ctx) {
110-
#if PREFER_OPENSSL
111105
EVP_MD_CTX_free(j->checksum_ctx);
112-
#else
113-
gcry_md_close(j->checksum_ctx);
114-
#endif
115106
j->checksum_ctx = NULL;
116107
}
117108

@@ -210,7 +201,6 @@ void pull_job_curl_on_finished(CurlGlue *g, CURL *curl, CURLcode result) {
210201

211202
if (j->checksum_ctx) {
212203
unsigned checksum_len;
213-
#if PREFER_OPENSSL
214204
uint8_t k[EVP_MAX_MD_SIZE];
215205

216206
r = EVP_DigestFinal_ex(j->checksum_ctx, k, &checksum_len);
@@ -219,17 +209,6 @@ void pull_job_curl_on_finished(CurlGlue *g, CURL *curl, CURLcode result) {
219209
goto finish;
220210
}
221211
assert(checksum_len <= sizeof k);
222-
#else
223-
const uint8_t *k;
224-
225-
k = gcry_md_read(j->checksum_ctx, GCRY_MD_SHA256);
226-
if (!k) {
227-
r = log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to get checksum.");
228-
goto finish;
229-
}
230-
231-
checksum_len = gcry_md_get_algo_dlen(GCRY_MD_SHA256);
232-
#endif
233212

234213
j->checksum = hexmem(k, checksum_len);
235214
if (!j->checksum) {
@@ -380,14 +359,10 @@ static int pull_job_write_compressed(PullJob *j, void *p, size_t sz) {
380359
"Content length incorrect.");
381360

382361
if (j->checksum_ctx) {
383-
#if PREFER_OPENSSL
384362
r = EVP_DigestUpdate(j->checksum_ctx, p, sz);
385363
if (r == 0)
386364
return log_error_errno(SYNTHETIC_ERRNO(EIO),
387365
"Could not hash chunk.");
388-
#else
389-
gcry_md_write(j->checksum_ctx, p, sz);
390-
#endif
391366
}
392367

393368
r = import_uncompress(&j->compress, p, sz, pull_job_write_uncompressed, j);
@@ -421,7 +396,6 @@ static int pull_job_open_disk(PullJob *j) {
421396
}
422397

423398
if (j->calc_checksum) {
424-
#if PREFER_OPENSSL
425399
j->checksum_ctx = EVP_MD_CTX_new();
426400
if (!j->checksum_ctx)
427401
return log_oom();
@@ -430,15 +404,6 @@ static int pull_job_open_disk(PullJob *j) {
430404
if (r == 0)
431405
return log_error_errno(SYNTHETIC_ERRNO(EIO),
432406
"Failed to initialize hash context.");
433-
#else
434-
r = initialize_libgcrypt(false);
435-
if (r < 0)
436-
return log_error_errno(r, "Failed to load libgcrypt: %m");
437-
438-
if (gcry_md_open(&j->checksum_ctx, GCRY_MD_SHA256, 0) != 0)
439-
return log_error_errno(SYNTHETIC_ERRNO(EIO),
440-
"Failed to initialize hash context.");
441-
#endif
442407
}
443408

444409
return 0;

0 commit comments

Comments
 (0)