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:
Milan Broz
2011-07-18 13:03:15 +00:00
parent 9c71c74d59
commit 261d0d05a5
7 changed files with 26 additions and 20 deletions

View File

@@ -1,6 +1,7 @@
2011-07-07 Milan Broz <mbroz@redhat.com>
* Remove old API functions (all functions using crypt_options).
* 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>
* Add --shared option for creating non-overlapping crypt segments.

View File

@@ -98,7 +98,6 @@ int PLAIN_activate(struct crypt_device *cd,
const char *name,
struct volume_key *vk,
uint64_t size,
uint64_t iv_offset,
uint32_t flags);
#endif /* INTERNAL_H */

View File

@@ -160,7 +160,7 @@ const char *crypt_get_type(struct crypt_device *cd);
struct crypt_params_plain {
const char *hash; /* password hash function */
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 */
};
@@ -172,7 +172,7 @@ struct crypt_params_luks1 {
struct crypt_params_loopaes {
const char *hash; /* key hash function */
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.
@@ -540,6 +540,7 @@ int crypt_dump(struct crypt_device *cd);
* uuid - device UUID or NULL if not 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)
* iv_offset - IV offset in sectors (skip)
* volume_key_size - size (in bytes) of volume key for crypt device
*/
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_device_name(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);
/**

View File

@@ -36,6 +36,7 @@ CRYPTSETUP_1.0 {
crypt_get_cipher_mode;
crypt_get_uuid;
crypt_get_data_offset;
crypt_get_iv_offset;
crypt_get_volume_key_size;
crypt_get_device_name;

View File

@@ -185,7 +185,6 @@ int LOOPAES_activate(struct crypt_device *cd,
const char *base_cipher,
unsigned int keys_count,
struct volume_key *vk,
uint64_t skip,
uint32_t flags)
{
char *cipher = NULL;
@@ -197,7 +196,7 @@ int LOOPAES_activate(struct crypt_device *cd,
.uuid = crypt_get_uuid(cd),
.vk = vk,
.offset = crypt_get_data_offset(cd),
.iv_offset = skip,
.iv_offset = crypt_get_iv_offset(cd),
.size = 0,
.flags = flags
};

View File

@@ -21,6 +21,5 @@ int LOOPAES_activate(struct crypt_device *cd,
const char *base_cipher,
unsigned int keys_count,
struct volume_key *vk,
uint64_t skip,
uint32_t flags);
#endif

View File

@@ -216,7 +216,6 @@ int PLAIN_activate(struct crypt_device *cd,
const char *name,
struct volume_key *vk,
uint64_t size,
uint64_t iv_offset,
uint32_t flags)
{
int r;
@@ -227,7 +226,7 @@ int PLAIN_activate(struct crypt_device *cd,
.uuid = crypt_get_uuid(cd),
.vk = vk,
.offset = crypt_get_data_offset(cd),
.iv_offset = iv_offset,
.iv_offset = crypt_get_iv_offset(cd),
.size = size,
.flags = flags
};
@@ -1328,9 +1327,7 @@ int crypt_activate_by_passphrase(struct crypt_device *cd,
if (r < 0)
goto out;
r = PLAIN_activate(cd, name, vk,
cd->plain_hdr.size,
cd->plain_hdr.skip, flags);
r = PLAIN_activate(cd, name, vk, cd->plain_hdr.size, flags);
keyslot = 0;
} else if (isLUKS(cd->type)) {
/* provided passphrase, do not retry */
@@ -1400,9 +1397,7 @@ int crypt_activate_by_keyfile(struct crypt_device *cd,
if (r < 0)
goto out;
r = PLAIN_activate(cd, name, vk,
cd->plain_hdr.size,
cd->plain_hdr.skip, flags);
r = PLAIN_activate(cd, name, vk, cd->plain_hdr.size, flags);
} else if (isLUKS(cd->type)) {
r = key_from_file(cd, _("Enter passphrase: "), &passphrase_read,
&passphrase_size_read, keyfile, keyfile_size);
@@ -1431,9 +1426,7 @@ int crypt_activate_by_keyfile(struct crypt_device *cd,
goto out;
if (name)
r = LOOPAES_activate(cd, name, cd->loopaes_cipher,
key_count, vk,
cd->loopaes_hdr.skip,
flags);
key_count, vk, flags);
} else
r = -EINVAL;
@@ -1481,9 +1474,7 @@ int crypt_activate_by_volume_key(struct crypt_device *cd,
if (!vk)
return -ENOMEM;
r = PLAIN_activate(cd, name, vk,
cd->plain_hdr.size,
cd->plain_hdr.skip, flags);
r = PLAIN_activate(cd, name, vk, cd->plain_hdr.size, flags);
} else if (isLUKS(cd->type)) {
/* If key is not provided, try to use internal key */
if (!volume_key) {
@@ -1816,6 +1807,20 @@ uint64_t crypt_get_data_offset(struct crypt_device *cd)
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)
{
if (!isLUKS(cd->type)) {