Commit Graph

4222 Commits

Author SHA1 Message Date
Yiyuan Zhong
cb7b7fd863 Add Mbed-TLS crypto backend
Mbed-TLS is a tiny TLS implementation designed for embedded environment which
can greatly reduce the disk space requirement compared to OpenSSL. While we
already have crypto_kernel for this purpose and Mbed-TLS lacking hash/cipher
support can cause reduced functionality, there're situations where AF_ALG is
not available but we're fine with limited scenarios like LUKS2 only.
2024-07-14 17:12:03 +08:00
Milan Broz
4daf8ef0dc tests: skip reencryption test if non-AES ciphers fails in luksFormat 2024-07-12 21:08:05 +02:00
Milan Broz
2d041439bc tests: Print N/A visible in mode_test (LUKS2 userspace crypto) 2024-07-12 21:07:59 +02:00
Milan Broz
7fa19da140 tests: use crypto check tool in tests 2024-07-12 21:07:15 +02:00
Milan Broz
a9617c7c4a tests: Add crypto check program for crypto backend.
We use benchmark, but backend can implement different
set of ciphers than kernel crypto API.
2024-07-12 21:04:37 +02:00
Milan Broz
ce38d82025 Fix crypt_cipher_check_kernel to work with length-preserving modes too.
The check is currently used only with AEAD, but whould work also
with common block ciphers and modes.
2024-07-12 18:02:37 +00:00
Milan Broz
5e04a82e53 Fix wiping of hash struct in nss and nettle backend. 2024-07-12 16:38:56 +00:00
Milan Broz
3839e2bf98 Fix scan-build warnings in gcrypt backend 2024-07-12 16:38:56 +00:00
Milan Broz
8accd612a3 CI: Add fanalyzer and scan-build test for crypto backends 2024-07-12 16:38:56 +00:00
Frank Rehberger
fddec0f2d7 doc: build dependency update 2024-07-12 16:05:52 +00:00
Milan Broz
7a816abf82 TCRYPT: fix system encryption test if kernel does not support EFI partition
If kernel is mising CONFIG_EFI_PARTITION, the required partitons
are missing too.
Just skip the test if loop block device is not available.
2024-07-12 11:58:06 +00:00
Milan Broz
94f37efb57 Remove obsolete AC_PROG_GCC_TRADITIONAL macro.
As it causes warnings and does nothing for many years already.
2024-07-10 10:32:27 +02:00
Milan Broz
5fb6d711c1 Fix clang possible rh NULL dereference warning. 2024-07-10 09:48:10 +02:00
Milan Broz
b0be186f9e Fix leaked fd gcc analyzer warning.
These are actually false positives (fd 0 is always open as stdin),
but code is even more readable with this fix.
2024-07-10 09:48:08 +02:00
Milan Broz
b1cc660df3 Do not use assert() that depends on external data.
Just fail function. Also fixed gcc analyzer warning (leaked fd).
2024-07-10 09:48:05 +02:00
Milan Broz
35a9f08062 Fix warning about unitialized passwordLen.
THis is false positive, but fix is trivial.
2024-07-10 09:48:02 +02:00
Milan Broz
9c47812904 Use buffer functions and fix potential fd leak.
Use read/write buffer functions to avoid partial operation.

This also fixed leaked fd warning. Also fix error path
for context failure - if initialize_context() fails,
rc->log_fd is closed in context destructor, no need to close
it in open_log/parse_log.

Another fixed bug is in parse_log, where immediatelly after
creation we have to seek to the beginning of the file first.
2024-07-10 09:47:59 +02:00
Milan Broz
8b21b4b2ee Fix "allocated buffer size is not a multiple of the pointee's size" warning
No need to play games with void pointers, two separate functions are
much more readable.
2024-07-10 09:47:56 +02:00
Milan Broz
bf088de00f Update CI shared runner compiler versions. 2024-07-10 09:43:33 +02:00
Milan Broz
1423c6eac2 TCRYPT: make algorithms definitions static 2024-07-02 13:04:30 +00:00
Milan Broz
e5b430cdc1 TCRYPT: use bool instead of one bit integer 2024-07-02 13:04:30 +00:00
Milan Broz
a5e409c186 TCRYPT: update system encryption images and test. 2024-07-02 13:04:30 +00:00
Milan Broz
0cc686af59 TCRYPT: Clear mapping of system encrypted partitions.
TrueCrypt/VeraCrypt supports full system encryption (only a partition
table is not encrypted) or system partition encryption
(only a system partition is encrypted).
The metadata header then contains the offset and size of the encrypted area.
Cryptsetup needs to know the specific partition offset to calculate encryption parameters.
To properly map a partition, you must specify a real partition device so cryptsetup can calculate this offset.

As user can specify various combination, we need to determine the proper
IV and data offsets.

The logic for CRYPT_TCRYPT_SYSTEM_HEADER flag should be (in this order):
- if data device is a real partition, calculate offset from it.
- if --header is a real partition , calculate offset from it.
- if device is a real disk, try to search for partition using decrypted offset and size
(works only for system partition-only encryption).
- if data and metadata (header) device is the same, map whole encrypted area
(this is the ost confusing for user)
- if data and metadata (header) divice differs, expect data image contains
only partition (setting offset to 0, but using IV offset from header).

There are still situation that can end with wrong mapping, but user now has the option
to setup it properly.

Also this patch fixes use of stored encryption size in header,
so we do not map larger area.

Fixes:#889
2024-07-02 13:04:30 +00:00
Milan Broz
14fd0b5fc1 TCRYPT: Print all information from decrypted header.
Print also volume sizes (if present) and flags.
This inforamtion is useful mainly for setting systemd encryption
where size determines encrypted region.
2024-07-02 13:04:30 +00:00
Ondrej Kozina
9651d1f376 Fix a typo in valgrind test parameter. 2024-07-02 13:03:01 +00:00
Milan Broz
98b4243432 Add support for high-priority dm-crypt flag.
This patch add new --perf-high_priority cryptsetup option
for flga added in Linux kernel 6.10, dm-crypt target version 1.26.
2024-06-18 11:00:38 +00:00
Milan Broz
e32ea56b59 Update README for version 2.7.3. 2024-06-17 14:39:42 +02:00
Milan Broz
afee503e34 Add CONTRIBUTING.md file. 2024-06-17 11:52:56 +00:00
Milan Broz
7019f42ff1 Add release notes for 2.7.3. 2024-06-12 17:20:56 +02:00
Yuri Chornoivan
647b24f706 po: update uk.po (from translationproject.org) 2024-06-11 12:31:53 +02:00
Remus-Gabriel Chelu
0cff233af1 po: update ro.po (from translationproject.org) 2024-06-11 12:31:53 +02:00
Jakub Bogusz
8cb3b32070 po: update pl.po (from translationproject.org) 2024-06-11 12:31:53 +02:00
Hiroshi Takekawa
8109b10ea4 po: update ja.po (from translationproject.org) 2024-06-11 12:31:53 +02:00
Roland Illig
d9660cf221 po: update de.po (from translationproject.org) 2024-06-11 12:31:53 +02:00
Petr Pisar
29f1f71c67 po: update cs.po (from translationproject.org) 2024-06-11 12:31:53 +02:00
Daniel Zatovic
1d9a362113 CI: don't run parallel OPAL jobs 2024-06-07 13:56:46 +02:00
Daniel Zatovic
e92763a61c CI: run fips-mode-setup --check as a root 2024-06-07 13:52:50 +02:00
Daniel Zatovic
9bdb7fee34 CI: add RHEL10 runner 2024-06-07 12:21:32 +02:00
Milan Broz
51c672ea62 tests: Fix test numbers in compat-test2 again 2024-06-06 17:24:51 +00:00
Milan Broz
b19170e8fe Fix warning for printf argument. 2024-06-06 13:09:23 +02:00
Ondrej Kozina
97c5f47c94 Add opal test for detached header erase command. 2024-06-05 11:02:38 +02:00
Ondrej Kozina
494c510c34 Simplify LUKS2_wipe_header_areas.
For LUKS2 headers with non zero data offset LUKS2_wipe_header_areas
will always erase the smallest from following:

- metadata device size
- data offset value
- maximal LUKS2 metadata size (twice 2 MiBs json area including 128 MiB for
binary keyslot areas) even with detached header.

For zero value data offset (LUKS2 header can not be restored back to
data device), we erase up to smallest from the following values:

- metadata device size
- maximal LUKS2 metadata size (twice 2 MiBs json area including 128 MiB for
2024-06-05 10:49:08 +02:00
Milan Broz
2a13ef5dd8 Fix interactive query retry if LUKS2 unbound keyslot is present
If an unbound keyslot is present (e.g.. slot 0 usual slot, slot 1 unbound),
the query loop could return ENOENT (keyslot not valid for segment) and this
will stop epxected retry for slot quewry (--tries option).

If any previous slot rerutned EPERM (no valid passphrase), prefer
this return code.
2024-06-03 16:40:55 +00:00
Milan Broz
4708884d8c Allow "capi:" cipher format for benchmark command.
Note, currently AEAD modes are not supported.
2024-06-03 16:40:01 +00:00
Milan Broz
8f4a149ed3 Fix bad parsing of capi:xts(aes)-plain
Corrent logic confuses it with aes-plain (capi:xts(aes)-plain
does not work in luksFormat).
For CAPI format we need to skip this test.
2024-06-03 16:40:01 +00:00
Milan Broz
d590c74a0e Support aes-hctr2 mode.
The HCTR2 encryption was added to Linux kernel for fscrypt,
but as it is length-preserving mode (with sector tweak) it
can be easily used for disk encryption too.

As it need larger IV of size 32 bytes, we need to add exception
for aes-hctr2[-plain64] to be accepted in cryptsetup commands.

Fixes: #883
2024-06-03 16:39:06 +00:00
Milan Broz
1a6a611dff Reorganize license files.
This patch adds README.licensing describing used licenses.
The license text files are now in dosc/licenses.

The main COPYING document in root is the default license,
this also forces GitHub to properly identify default license.
2024-06-03 16:38:15 +00:00
Milan Broz
661f57def4 Use SPDX license identifiers.
This patch switches code to SPDX one-line license identifiers according to
https://spdx.dev/learn/handling-license-info/
and replacing long license text headers.

I used C++ format on the first line in style
// SPDX-License-Identifier: <id>
except exported libcryptsetup.h, when only C comments are used.

The only additional changes are:
- switch backend utf8.c from LGPL2+ to LGPL2.1+ (as in systemd)
- add some additional formatting lines.
2024-06-03 16:38:15 +00:00
Milan Broz
8448448aa2 Opal: Check for bogus logical size also in activation
For existing devices we only print warning, but the device is
probably completely misconfigured.
2024-06-03 11:14:27 +00:00
Milan Broz
329fa3c54e Opal: Require locking range attributes in range check function.
The check will be required mandatory in the next patch.
2024-06-03 11:14:27 +00:00