mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-11 19:00:02 +01:00
Add crypt_get_hw_encryption_type API call.
This commit is contained in:
committed by
Luca Boccassi
parent
446ad76011
commit
5716f959a7
@@ -450,6 +450,27 @@ const char *crypt_get_type(struct crypt_device *cd);
|
|||||||
*/
|
*/
|
||||||
const char *crypt_get_default_type(void);
|
const char *crypt_get_default_type(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup crypt-hw-encryption-types HW encryption type
|
||||||
|
* @addtogroup crypt-hw-encryption-types
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/** SW encryption, no OPAL encryption in place (default) */
|
||||||
|
#define CRYPT_SW_ONLY INT16_C(0)
|
||||||
|
/** OPAL HW encryption only (no SW encryption!) */
|
||||||
|
#define CRYPT_OPAL_HW_ONLY INT16_C(1)
|
||||||
|
/** SW encryption stacked over OPAL HW encryption */
|
||||||
|
#define CRYPT_SW_AND_OPAL_HW INT16_C(2)
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get OPAL HW encryption type
|
||||||
|
*
|
||||||
|
* @return HW encryption type (see @link crypt-hw-encryption-types @endlink)
|
||||||
|
* or negative errno otherwise.
|
||||||
|
*/
|
||||||
|
int crypt_get_hw_encryption_type(struct crypt_device *cd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Structure used as parameter for PLAIN device type.
|
* Structure used as parameter for PLAIN device type.
|
||||||
|
|||||||
@@ -169,4 +169,5 @@ CRYPTSETUP_2.6 {
|
|||||||
CRYPTSETUP_2.7 {
|
CRYPTSETUP_2.7 {
|
||||||
global:
|
global:
|
||||||
crypt_format_luks2_opal;
|
crypt_format_luks2_opal;
|
||||||
|
crypt_get_hw_encryption_type;
|
||||||
} CRYPTSETUP_2.6;
|
} CRYPTSETUP_2.6;
|
||||||
|
|||||||
19
lib/setup.c
19
lib/setup.c
@@ -6267,6 +6267,25 @@ const char *crypt_get_default_type(void)
|
|||||||
return DEFAULT_LUKS_FORMAT;
|
return DEFAULT_LUKS_FORMAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int crypt_get_hw_encryption_type(struct crypt_device *cd)
|
||||||
|
{
|
||||||
|
uint32_t opal_segment_number;
|
||||||
|
const char *cipher;
|
||||||
|
|
||||||
|
if (!cd)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (isLUKS2(cd->type) &&
|
||||||
|
!LUKS2_get_opal_segment_number(&cd->u.luks2.hdr, CRYPT_DEFAULT_SEGMENT, &opal_segment_number)) {
|
||||||
|
cipher = crypt_get_cipher(cd);
|
||||||
|
if (!cipher || !strcmp(cipher, "cipher_null"))
|
||||||
|
return CRYPT_OPAL_HW_ONLY;
|
||||||
|
return CRYPT_SW_AND_OPAL_HW;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CRYPT_SW_ONLY;
|
||||||
|
}
|
||||||
|
|
||||||
int crypt_get_verity_info(struct crypt_device *cd,
|
int crypt_get_verity_info(struct crypt_device *cd,
|
||||||
struct crypt_params_verity *vp)
|
struct crypt_params_verity *vp)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user