29 Commits

Author SHA1 Message Date
Ondrej Kozina
6ee76934fa Harden and limit access to volume key internals.
The volume key structure may often be in configuration
where 'key' member does not contain real data. Some
examples:

- volume key acquired by querring device-mapper where key
  was originaly passed by kernel keyring reference.

- volume key allocated by crypt_alloc_volume_key(size, NULL)

With this patch access to internal 'uninitialized' data result
in failed assert().

For use cases where key data are not needed (keyring reference wrapper,
key length info only) we do not have to allocate and lock the safe
buffer in memory.

Further improvements might to completely hide the volume key internals
and access only via setter and getter functions.
2025-02-16 18:00:20 +00:00
Ondrej Kozina
54d937dfc7 Switch away from accessing volume key internals directly.
Switch current code to use following volume key helpers
for accessing internal properties:

crypt_volume_key_length(), crypt_volume_key_get_key(),
crypt_volume_key_description() and crypt_volume_key_kernel_key_type()

Remaining direct access to volume key internals will be dealt with in
later commits since it requires some further changes.
2025-02-16 18:00:20 +00:00
Ondrej Kozina
5ee549de1e Remove volume_key struct from fvault2 code.
No volume_key feature is used in the code and it
will make further changes easier.
2025-02-06 11:30:18 +01:00
Milan Broz
ff3e2c6a43 libdevmapper: Support dm-crypt integrity_key_size option
This patch implement support for setting specific integrity key size
option in dm-crypt, available since dm-crypt version 1.28.0.

This can be used for setting non-standard HMAC key length.

Mostly based on code from Ingo Franzki <ifranzki@linux.ibm.com>
2024-12-03 20:25:54 +01:00
Ondrej Kozina
3c5aa4ef59 Remove unused code.
Due to complete shift to device activation via keyslot context,
remove all remaining internal code activating device by passphrase
or by token.
2024-11-08 15:46:28 +01:00
Ondrej Kozina
7db83f8fb3 Simplify fvault activation by volume key. 2024-10-30 13:28:56 +00:00
Ondrej Kozina
00b89c4862 Export expected fvault2 volume key size. 2024-10-30 13:28:56 +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
40e5c7d095 Use crypt_safe_memcpy for operations with key. 2024-05-03 11:52:09 +00:00
Milan Broz
482c819ea2 fvault2: fix compilatioon with very old uuid.h
UUID_STR_LEN is undefined for old headers, just
use internal definition (both are 37 bytes).
2023-01-17 13:32:29 +00:00
Milan Broz
c7bbae01a6 Fix some strings for translations.
No need to translate debug strings.
Fix spaces in key slot queries.
2022-11-20 12:36:26 +01:00
Milan Broz
6c2e64bf75 fvault2: fix typo 2022-11-18 22:25:31 +01:00
Milan Broz
faf3b27f51 fvault2: reduce debug log, do not print ignored metadata blocks 2022-11-18 14:31:25 +01:00
Ondrej Kozina
81c56a8395 Move assert include in internal header files. 2022-11-16 16:54:33 +01:00
Milan Broz
3333f3e9bb Fix some warning detected by Coverity.
The FVAULT2 block is always 8192 bytes (for CRC), but used
struct is smaller. Let's not confuse struct size with whole block.
2022-11-15 10:47:22 +01:00
Milan Broz
b086430877 fvault2: Move messages to debug level and add more debug log. 2022-11-14 21:50:18 +01:00
Milan Broz
01f3f3e66c fvault2: volume size can be unsigned 64bit 2022-11-14 21:50:18 +01:00
Milan Broz
e37d8bdf91 fvault2: harden device offset check
Check if value overflows and do not allow reading
metadata block exceeding fixed offset.
2022-11-14 21:50:18 +01:00
Milan Broz
8b4a5e5931 fvault2: some more code cleanup. 2022-11-14 21:50:18 +01:00
Milan Broz
33d8d19408 fvault2: passphr -> passphrase 2022-11-14 21:50:18 +01:00
Milan Broz
9bb98d49c0 fvault2: some minor code reformatting changes. 2022-11-14 21:50:18 +01:00
Pavel Tobias
1c5fd5ae10 Fvault2: add basic error logs 2022-11-14 21:50:18 +01:00
Milan Broz
3d1b965c46 fvault2: fix --test-passphrase option 2022-11-14 21:50:18 +01:00
Pavel Tobias
cd5bd1c773 Fvault2: store UUIDs in text format 2022-11-14 21:50:18 +01:00
Pavel Tobias
cb9deaf354 Fvault2: implement open 2022-11-14 21:50:18 +01:00
Pavel Tobias
0ce5de9c1c Fvault2: implement dump 2022-11-14 21:50:18 +01:00
Pavel Tobias
35071c6d50 Fvault2: derive volume key 2022-11-14 21:50:18 +01:00
Pavel Tobias
af6ea01997 Fvault2: read all relevant metadata from device 2022-11-14 21:50:18 +01:00
Pavel Tobias
1ffc9d967c Fvault2: prepare module in libcryptsetup 2022-11-14 21:50:18 +01:00