Commit Graph

232 Commits

Author SHA1 Message Date
Ondrej Kozina
0328d61f29 Add crypt_token_set_external_path API.
It can be used to override system library where
libcryptsetup looks for external token handlers (plugins).

The parameter is required to be absolute path and it is set
per process context.

Fixes: #846.
2023-11-16 17:49:06 +01:00
Ondrej Kozina
89e0ef96c2 Add LUKS2 OPAL requirement flag. 2023-11-06 16:49:26 +01:00
Ondrej Kozina
2d54e0bc58 Drop unused and unreleased API. 2023-09-25 18:59:09 +00:00
Ondrej Kozina
51a1e218cf Split logic for uploading keys in kernel key service.
We can not link internal VK kernel key in custom user
keyring. There are two reasons for it:

The internal VK kernel key description can not be
acquired via API and it may change over time
(LUKS2 reencryption).

With recent SED OPAL support volume key becomes a 'blob'
containing up to two keys (dm-crypt key for SWE and key
for unlocking SED OPAL locking range). The internal
kernel key contains only dm-crypt (if required) but
custom user keyring needs to be provided with whole
volume key (blob).

Added user specified key description for the linked key
in custom user keyring. The linked key can be reached by
the specified description after successful activation (resume).
2023-09-25 18:59:09 +00:00
Ondrej Kozina
e43de57fac Switch crypt_activate_by_signed_key to keyslot context based activation.
It introduces new keyslot context type CRYPT_KC_TYPE_SIGNED_KEY.
2023-08-16 14:17:34 +02:00
Daniel Zatovic
6bcd9ed52c Add keyslot_context for volume key stored in a keyring. 2023-08-16 12:29:29 +02:00
Daniel Zatovic
1f2dac34d0 Support specifying keyring and key using keyctl syntax.
When using the --link-vk-to-keyring option, allow specifying the keyring
using the same syntax as keyctl (see "man keyctl"). E.g. "@u" for user
keyring and "%:testring" for a user-created keyring.
2023-08-16 12:29:29 +02:00
Daniel Zatovic
a674fb968c Support specifying volume key keyring type.
Currently only logon keyring type is supported. Add --volume-key-type to
allow specifying arbitrary type for the volume key.
2023-08-16 12:29:29 +02:00
Daniel Zatovic
138da3e73a Allow linking VK to a user-specified keyring.
Add a new API crypt_set_keyring_to_link nad CLI option
--link-vk-to-keyring. This allows the user to specify ID of the keyring
where the VK should be linked.
2023-08-16 12:29:29 +02:00
Daniel Zatovic
cb184bcbb8 Allow resume by keyslot context. 2023-08-16 12:29:29 +02:00
Daniel Zatovic
aea21309ed Add keyring keyslot_context. 2023-08-16 12:29:26 +02:00
Daniel Zatovic
58385d68d8 Allow activation via keyslot context. 2023-08-15 17:42:31 +02:00
Milan Broz
928061f1f0 Print better metadata dump and status info for OPAL segment. 2023-07-17 22:39:26 +01:00
Luca Boccassi
decbe09fb3 cryptsetup: support for hw-opal in luksErase
Wipe and disable the segment. Also support the factory reset ioctl for
a complete wipe of the entire drive with a specific argument.

Signed-off-by: Luca Boccassi <bluca@debian.org>
2023-07-17 22:39:26 +01:00
Milan Broz
5716f959a7 Add crypt_get_hw_encryption_type API call. 2023-07-17 22:39:26 +01:00
Luca Boccassi
b9cc0129c9 libcryptsetup: add OPAL type and params
Signed-off-by: Luca Boccassi <bluca@debian.org>
Co-authored-by: Ondrej Kozina <okozina@redhat.com>
2023-07-17 13:14:52 +02:00
Milan Broz
d173514b81 Do not decrease PBKDF parameters if a user forces them.
If a user explicitly specifies PBKDF parameters (like iterations,
used memory of threads), do not limit them, even if it can cause
resource exhaustion.

The only limits are hard limits per the PBKDF algorithm.

The force options were mostly used for decreasing parameters,
but it should work even opposite - despite the fact it can mean
shooting yourself in the foot (OOM).

Fixes: #812
2023-04-24 13:09:34 +02:00
Vojtech Trefny
bc426bba67 bitlk: Fix segfaults when attempting to test volume key
Also clarify that checking the volume key is not possible for
BITLK in the docstring and man page.

Fixes: #810
2023-04-18 16:38:58 +02:00
Milan Broz
72f799b393 Update Copyright year. 2023-02-09 17:11:18 +01:00
Ondrej Kozina
c018558f2d Remove unused define CRYPT_KC_TYPE_UNDEFINED.
The defined was not yet released in stable version.
2022-11-23 11:08:55 +01:00
Pavel Tobias
1ffc9d967c Fvault2: prepare module in libcryptsetup 2022-11-14 21:50:18 +01:00
Ondrej Kozina
55c39d7d16 Port crypt_volume_key_get internals to keyslot context variant. 2022-11-03 15:56:37 +01:00
Ondrej Kozina
f7e2ed956b Add crypt_volume_key_get_by_keyslot_context.
Extends avaiable methods for retrieving device volume key.
The volume key now may be extracted using passphrase, keyfile
(passphrase in a file) or token (LUKS2 only).

For LUKS devices, it returns generated volume key after
sucessfull crypt_format where new volume key got generated.

Fixes: #777.
2022-11-03 15:56:37 +01:00
Ondrej Kozina
01c16111d7 Fix copy/paste mistakes in API docs. 2022-11-02 09:49:49 +01:00
Ondrej Kozina
b867f0b578 Add new API for adding new LUKS keyslots.
The crypt_keyslot_add_by_keyslot_context & associated
helper functions allow more options when adding new
keyslot. For example there was no simple way of
adding new LUKS2 keyslot when the only active keyslot
could be unlocked by passphrase (KEK) provided by LUKS2 token
(plugin). Now all available options for unlocking keyslots
may also be used when creating new keyslot and it combine
as called needs.

The available methods (keyslot contexts) are:
passphrase, keyfile, key (binary representation) and LUSK2 token.
2022-09-21 17:36:28 +02:00
Milan Broz
b183bb25e2 Add support for dm-verity try_verify_in_tasklet option.
Available since kernel 6.0.
2022-08-25 08:01:07 +00:00
Milan Broz
88d9524e6c Mark crypt_memory_lock() API call deprecated.
And remove its implementation.
2022-08-16 19:56:32 +02:00
Ondrej Kozina
c36f9899cf Add support for LUKS2 decryption with datashift.
Adds support for LUKS2 decryption of devices with a
header put in the head of data device. During the initialization
header is exported to a file and first data segment
is moved to head of data device in place of original header.

The feature introduces several new resilience modes (combination
of existing modes datashift and "checksum" or "journal").
Where datashift resilience mode is applied for data moved towards
the first segment and first segment is decrypted in-place.

The mode is not backward compatible with prior LUKS2 reencryption
and therefor interrupted operation in progress can not be resumed
using older cryptsetup releases.

Fixes: #669.
2022-06-17 13:48:12 +02:00
Ondrej Kozina
692bb8a455 Properly define uint32_t constants in API.
We do not change any value but it was not declared properly
and limit values had to be type cast to avoid compiler warnings
with strict options.
2022-06-07 11:30:34 +02:00
Milan Broz
97a22c27dd Make crypt_load quiet if metadata is not detected.
Ths will allow automatic scan of known formats.

Errors are printed only if something is wrong with already detected metadata.

This change means that it is responsibility of the caller to print an error
message if needed.

Also fix some places without a message.

Fixes: #642
2022-05-26 10:17:32 +02:00
Milan Broz
5d9e362553 Make CRYPT_WIPE_ENCRYPTED_ZERO obsolete.
It was never implemented (the idea was to speed up wipe), but
with the recent RNG performance changes it makes no longer sense.
2022-05-18 16:39:53 +02:00
Ondrej Kozina
cc107ee20e Silent crypt_volume_key_verify call.
And moves the error message in tools instead.
2022-04-25 19:47:09 +00:00
Milan Broz
08aa2ca242 Replace master on a few more places. 2022-03-29 19:06:38 +00:00
Ondrej Kozina
ce6f6a48e8 Add crypt_resume_by_token_pin API. 2022-02-04 13:40:20 +01:00
Luca Boccassi
2938c1f077 Add crypt_get_label/subsystem
There's an API to set the label and subsystem, and they are
dumped with luksDump, but there's no programmatic interface
to query them.
2022-02-03 10:23:57 +00:00
Milan Broz
ab975bc1c4 Update copyright year.
And unify format in several places.
2022-01-29 10:43:02 +01:00
Ondrej Kozina
ea47937187 Add CRYPT_REENCRYPT_REPAIR_NEEDED flag.
crypt_reencrypt_status() returns this flag if old
online-reencrypt requirement is detected and reencryption
keyslot digest is missing.

crypt_reencrypt_init_by_passphrase() with same flag applied
repairs (upgrade) reencryption metadata so that
automatic reencryption recovery during activation
is again possible and reencryption operation can be resumed
post CVE-2021-4122 fix.
2022-01-12 18:38:17 +01:00
Milan Broz
84fa6ffbde Remove some Doxygen docs warnings. 2021-08-30 12:32:42 +02:00
Milan Broz
5d1972bb97 Use depreacated attribute compatible with old gcc. 2021-07-25 18:27:55 +02:00
Ondrej Kozina
06f132066b Add crypt_reencrypt_run superseding now deprecated crypt_reencrypt.
This reverts commit 367cb7a761
and retains original crypt_reencrypt() symbol marked as deprecated
in favour of new crypt_reencrypt_run(). This makes cryptsetup 2.4.0
release fully backward compatible.
2021-07-22 15:59:01 +02:00
Ondrej Kozina
4654e6f578 Add best effort try-loop for token based activation.
The loop is run only when token id in any of crypt_activate_by_token*
calls is set to CRYPT_ANY_TOKEN.
2021-07-22 13:55:19 +02:00
Ondrej Kozina
877afd2281 Replace original token activation retcode -EAGAIN with -ENOANO.
crypt_activate_by_token (and _pin variant) now returns -ENOANO
instead -EAGAIN in case token handler identifies specific token
requires PIN to sucessfully complete token based activation.

-EAGAIN is now used for special case when additional system
resources are missing (HW token, other device, system daemon,
etc).
2021-07-22 13:47:14 +02:00
Ondrej Kozina
6633fa626a Remove unused crypt_token_external_support.
API can expose same information with crypt_token_external_path.

Also add print out of external token in cryptsetup --help action
(if enabled)
2021-06-29 14:13:37 +00:00
Ondrej Kozina
df7a995fa2 Remove redundant (unreleased) API for token based activation.
Reverts commit 96d83455ca partially. It is not necessary to
have specific crypt_activate_by_token_type call. Users
may use crypt_activate_by_token_pin with pin argument set to NULL
and achieve same goal as with crypt_activate_by_token_type.
2021-06-29 14:13:37 +00:00
Ondrej Kozina
aea841eeb0 Add crypt_token_external_path. 2021-06-26 22:08:45 +02:00
Milan Broz
df5e54545e Add API and CLI option to disable token plugins.
This could be useful for debugging external plugins
or ot intentionally disable loading of a token library.
2021-06-13 23:22:44 +02:00
Ondrej Kozina
db44e9de22 Add api exposing external token handlers support. 2021-05-12 14:32:54 +02:00
Ondrej Kozina
b047b8ae20 Improvements to error code handling during token based activation. 2021-04-15 21:43:31 +02:00
Milan Broz
ec3a9746a9 integritysetup: add recalculate-reset flag.
The new dm-integrity option in kernel 5.13 can restart
recalculation from the beginning of the device.
It can be used to change the integrity checksum function.

This patch adds support to libcryptsetup for this flag
and adds --integrity-recalculate-rest option to integritysetup.

Fixes: #631.
2021-03-30 21:40:35 +02:00
Ondrej Kozina
8d0e90b90a Autodetect optimal encryption sector size on LUKS2 format. 2021-03-24 16:14:35 +01:00