diff --git a/lib/libcryptsetup.h b/lib/libcryptsetup.h index a3b69996..f1cd6e40 100644 --- a/lib/libcryptsetup.h +++ b/lib/libcryptsetup.h @@ -424,6 +424,13 @@ int crypt_get_metadata_size(struct crypt_device *cd, */ const char *crypt_get_type(struct crypt_device *cd); +/** + * Get device default LUKS type + * + * @return string according to device type (CRYPT_LUKS1 or CRYPT_LUKS2). + */ +const char *crypt_get_default_type(void); + /** * * Structure used as parameter for PLAIN device type. diff --git a/lib/libcryptsetup.sym b/lib/libcryptsetup.sym index 8d401037..7da7d515 100644 --- a/lib/libcryptsetup.sym +++ b/lib/libcryptsetup.sym @@ -81,6 +81,7 @@ CRYPTSETUP_2.0 { crypt_get_sector_size; crypt_get_type; + crypt_get_default_type; crypt_get_active_device; crypt_get_active_integrity_failures; crypt_persistent_flags_set; diff --git a/lib/setup.c b/lib/setup.c index 15d15e1a..8d747f0a 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -4810,6 +4810,11 @@ const char *crypt_get_type(struct crypt_device *cd) return cd ? cd->type : NULL; } +const char *crypt_get_default_type(void) +{ + return DEFAULT_LUKS_FORMAT; +} + int crypt_get_verity_info(struct crypt_device *cd, struct crypt_params_verity *vp) { diff --git a/src/cryptsetup.c b/src/cryptsetup.c index 5094289f..08fa4f1e 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -1038,7 +1038,7 @@ static int action_luksFormat(void) type = luksType(opt_type); if (!type) - type = DEFAULT_LUKS_FORMAT; + type = crypt_get_default_type(); if (!strcmp(type, CRYPT_LUKS2)) { params = ¶ms2; @@ -2418,7 +2418,7 @@ static void help(poptContext popt_context, crypt_get_dir()); log_std(_("\nDefault compiled-in metadata format is %s (for luksFormat action).\n"), - DEFAULT_LUKS_FORMAT); + crypt_get_default_type()); pbkdf_luks1 = crypt_get_pbkdf_default(CRYPT_LUKS1); pbkdf_luks2 = crypt_get_pbkdf_default(CRYPT_LUKS2); diff --git a/src/cryptsetup_reencrypt.c b/src/cryptsetup_reencrypt.c index c34ff810..6579612e 100644 --- a/src/cryptsetup_reencrypt.c +++ b/src/cryptsetup_reencrypt.c @@ -148,7 +148,7 @@ static const char *luksType(const char *type) return CRYPT_LUKS1; if (!type || !strcmp(type, "luks")) - return DEFAULT_LUKS_FORMAT; + return crypt_get_default_type(); return NULL; }