mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-13 11:50:10 +01:00
Add crypt_get_iv_offset() function to API.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@573 36d66b0a-2a48-0410-832c-cd162a569da5
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
2011-07-07 Milan Broz <mbroz@redhat.com>
|
2011-07-07 Milan Broz <mbroz@redhat.com>
|
||||||
* Remove old API functions (all functions using crypt_options).
|
* Remove old API functions (all functions using crypt_options).
|
||||||
* Add --enable-discards option to allow discards/TRIM requests.
|
* Add --enable-discards option to allow discards/TRIM requests.
|
||||||
|
* Add crypt_get_iv_offset() function to API.
|
||||||
|
|
||||||
2011-07-01 Milan Broz <mbroz@redhat.com>
|
2011-07-01 Milan Broz <mbroz@redhat.com>
|
||||||
* Add --shared option for creating non-overlapping crypt segments.
|
* Add --shared option for creating non-overlapping crypt segments.
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ int PLAIN_activate(struct crypt_device *cd,
|
|||||||
const char *name,
|
const char *name,
|
||||||
struct volume_key *vk,
|
struct volume_key *vk,
|
||||||
uint64_t size,
|
uint64_t size,
|
||||||
uint64_t iv_offset,
|
|
||||||
uint32_t flags);
|
uint32_t flags);
|
||||||
|
|
||||||
#endif /* INTERNAL_H */
|
#endif /* INTERNAL_H */
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ const char *crypt_get_type(struct crypt_device *cd);
|
|||||||
struct crypt_params_plain {
|
struct crypt_params_plain {
|
||||||
const char *hash; /* password hash function */
|
const char *hash; /* password hash function */
|
||||||
uint64_t offset; /* offset in sectors */
|
uint64_t offset; /* offset in sectors */
|
||||||
uint64_t skip; /* IV initilisation sector */
|
uint64_t skip; /* IV offset / initialisation sector */
|
||||||
uint64_t size; /* size of mapped device or 0 for autodetection */
|
uint64_t size; /* size of mapped device or 0 for autodetection */
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ struct crypt_params_luks1 {
|
|||||||
struct crypt_params_loopaes {
|
struct crypt_params_loopaes {
|
||||||
const char *hash; /* key hash function */
|
const char *hash; /* key hash function */
|
||||||
uint64_t offset; /* offset in sectors */
|
uint64_t offset; /* offset in sectors */
|
||||||
uint64_t skip; /* IV initilisation sector */
|
uint64_t skip; /* IV offset / initialisation sector */
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Create (format) new crypt device (and possible header on-disk) but not activates it.
|
* Create (format) new crypt device (and possible header on-disk) but not activates it.
|
||||||
@@ -540,6 +540,7 @@ int crypt_dump(struct crypt_device *cd);
|
|||||||
* uuid - device UUID or NULL if not set
|
* uuid - device UUID or NULL if not set
|
||||||
* device_name - underlying device name or NULL if not yet set
|
* device_name - underlying device name or NULL if not yet set
|
||||||
* data_offset - device offset in sectors where real data starts on underlying device)
|
* data_offset - device offset in sectors where real data starts on underlying device)
|
||||||
|
* iv_offset - IV offset in sectors (skip)
|
||||||
* volume_key_size - size (in bytes) of volume key for crypt device
|
* volume_key_size - size (in bytes) of volume key for crypt device
|
||||||
*/
|
*/
|
||||||
const char *crypt_get_cipher(struct crypt_device *cd);
|
const char *crypt_get_cipher(struct crypt_device *cd);
|
||||||
@@ -547,6 +548,7 @@ const char *crypt_get_cipher_mode(struct crypt_device *cd);
|
|||||||
const char *crypt_get_uuid(struct crypt_device *cd);
|
const char *crypt_get_uuid(struct crypt_device *cd);
|
||||||
const char *crypt_get_device_name(struct crypt_device *cd);
|
const char *crypt_get_device_name(struct crypt_device *cd);
|
||||||
uint64_t crypt_get_data_offset(struct crypt_device *cd);
|
uint64_t crypt_get_data_offset(struct crypt_device *cd);
|
||||||
|
uint64_t crypt_get_iv_offset(struct crypt_device *cd);
|
||||||
int crypt_get_volume_key_size(struct crypt_device *cd);
|
int crypt_get_volume_key_size(struct crypt_device *cd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ CRYPTSETUP_1.0 {
|
|||||||
crypt_get_cipher_mode;
|
crypt_get_cipher_mode;
|
||||||
crypt_get_uuid;
|
crypt_get_uuid;
|
||||||
crypt_get_data_offset;
|
crypt_get_data_offset;
|
||||||
|
crypt_get_iv_offset;
|
||||||
crypt_get_volume_key_size;
|
crypt_get_volume_key_size;
|
||||||
crypt_get_device_name;
|
crypt_get_device_name;
|
||||||
|
|
||||||
|
|||||||
@@ -185,7 +185,6 @@ int LOOPAES_activate(struct crypt_device *cd,
|
|||||||
const char *base_cipher,
|
const char *base_cipher,
|
||||||
unsigned int keys_count,
|
unsigned int keys_count,
|
||||||
struct volume_key *vk,
|
struct volume_key *vk,
|
||||||
uint64_t skip,
|
|
||||||
uint32_t flags)
|
uint32_t flags)
|
||||||
{
|
{
|
||||||
char *cipher = NULL;
|
char *cipher = NULL;
|
||||||
@@ -197,7 +196,7 @@ int LOOPAES_activate(struct crypt_device *cd,
|
|||||||
.uuid = crypt_get_uuid(cd),
|
.uuid = crypt_get_uuid(cd),
|
||||||
.vk = vk,
|
.vk = vk,
|
||||||
.offset = crypt_get_data_offset(cd),
|
.offset = crypt_get_data_offset(cd),
|
||||||
.iv_offset = skip,
|
.iv_offset = crypt_get_iv_offset(cd),
|
||||||
.size = 0,
|
.size = 0,
|
||||||
.flags = flags
|
.flags = flags
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,6 +21,5 @@ int LOOPAES_activate(struct crypt_device *cd,
|
|||||||
const char *base_cipher,
|
const char *base_cipher,
|
||||||
unsigned int keys_count,
|
unsigned int keys_count,
|
||||||
struct volume_key *vk,
|
struct volume_key *vk,
|
||||||
uint64_t skip,
|
|
||||||
uint32_t flags);
|
uint32_t flags);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
33
lib/setup.c
33
lib/setup.c
@@ -216,7 +216,6 @@ int PLAIN_activate(struct crypt_device *cd,
|
|||||||
const char *name,
|
const char *name,
|
||||||
struct volume_key *vk,
|
struct volume_key *vk,
|
||||||
uint64_t size,
|
uint64_t size,
|
||||||
uint64_t iv_offset,
|
|
||||||
uint32_t flags)
|
uint32_t flags)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
@@ -227,7 +226,7 @@ int PLAIN_activate(struct crypt_device *cd,
|
|||||||
.uuid = crypt_get_uuid(cd),
|
.uuid = crypt_get_uuid(cd),
|
||||||
.vk = vk,
|
.vk = vk,
|
||||||
.offset = crypt_get_data_offset(cd),
|
.offset = crypt_get_data_offset(cd),
|
||||||
.iv_offset = iv_offset,
|
.iv_offset = crypt_get_iv_offset(cd),
|
||||||
.size = size,
|
.size = size,
|
||||||
.flags = flags
|
.flags = flags
|
||||||
};
|
};
|
||||||
@@ -1328,9 +1327,7 @@ int crypt_activate_by_passphrase(struct crypt_device *cd,
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
r = PLAIN_activate(cd, name, vk,
|
r = PLAIN_activate(cd, name, vk, cd->plain_hdr.size, flags);
|
||||||
cd->plain_hdr.size,
|
|
||||||
cd->plain_hdr.skip, flags);
|
|
||||||
keyslot = 0;
|
keyslot = 0;
|
||||||
} else if (isLUKS(cd->type)) {
|
} else if (isLUKS(cd->type)) {
|
||||||
/* provided passphrase, do not retry */
|
/* provided passphrase, do not retry */
|
||||||
@@ -1400,9 +1397,7 @@ int crypt_activate_by_keyfile(struct crypt_device *cd,
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
r = PLAIN_activate(cd, name, vk,
|
r = PLAIN_activate(cd, name, vk, cd->plain_hdr.size, flags);
|
||||||
cd->plain_hdr.size,
|
|
||||||
cd->plain_hdr.skip, flags);
|
|
||||||
} else if (isLUKS(cd->type)) {
|
} else if (isLUKS(cd->type)) {
|
||||||
r = key_from_file(cd, _("Enter passphrase: "), &passphrase_read,
|
r = key_from_file(cd, _("Enter passphrase: "), &passphrase_read,
|
||||||
&passphrase_size_read, keyfile, keyfile_size);
|
&passphrase_size_read, keyfile, keyfile_size);
|
||||||
@@ -1431,9 +1426,7 @@ int crypt_activate_by_keyfile(struct crypt_device *cd,
|
|||||||
goto out;
|
goto out;
|
||||||
if (name)
|
if (name)
|
||||||
r = LOOPAES_activate(cd, name, cd->loopaes_cipher,
|
r = LOOPAES_activate(cd, name, cd->loopaes_cipher,
|
||||||
key_count, vk,
|
key_count, vk, flags);
|
||||||
cd->loopaes_hdr.skip,
|
|
||||||
flags);
|
|
||||||
} else
|
} else
|
||||||
r = -EINVAL;
|
r = -EINVAL;
|
||||||
|
|
||||||
@@ -1481,9 +1474,7 @@ int crypt_activate_by_volume_key(struct crypt_device *cd,
|
|||||||
if (!vk)
|
if (!vk)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
r = PLAIN_activate(cd, name, vk,
|
r = PLAIN_activate(cd, name, vk, cd->plain_hdr.size, flags);
|
||||||
cd->plain_hdr.size,
|
|
||||||
cd->plain_hdr.skip, flags);
|
|
||||||
} else if (isLUKS(cd->type)) {
|
} else if (isLUKS(cd->type)) {
|
||||||
/* If key is not provided, try to use internal key */
|
/* If key is not provided, try to use internal key */
|
||||||
if (!volume_key) {
|
if (!volume_key) {
|
||||||
@@ -1816,6 +1807,20 @@ uint64_t crypt_get_data_offset(struct crypt_device *cd)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t crypt_get_iv_offset(struct crypt_device *cd)
|
||||||
|
{
|
||||||
|
if (isPLAIN(cd->type))
|
||||||
|
return cd->plain_hdr.skip;
|
||||||
|
|
||||||
|
if (isLUKS(cd->type))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (isLOOPAES(cd->type))
|
||||||
|
return cd->loopaes_hdr.skip;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
crypt_keyslot_info crypt_keyslot_status(struct crypt_device *cd, int keyslot)
|
crypt_keyslot_info crypt_keyslot_status(struct crypt_device *cd, int keyslot)
|
||||||
{
|
{
|
||||||
if (!isLUKS(cd->type)) {
|
if (!isLUKS(cd->type)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user