mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-15 12:50:06 +01:00
Split salt from other requests in RNG backend.
This commit is contained in:
@@ -97,7 +97,7 @@ void get_topology_alignment(const char *device,
|
||||
unsigned long *alignment_offset, /* bytes */
|
||||
unsigned long default_alignment);
|
||||
|
||||
enum { CRYPT_RND_NORMAL = 0, CRYPT_RND_KEY = 1 };
|
||||
enum { CRYPT_RND_NORMAL = 0, CRYPT_RND_KEY = 1, CRYPT_RND_SALT = 2 };
|
||||
int crypt_random_init(struct crypt_device *ctx);
|
||||
int crypt_random_get(struct crypt_device *ctx, char *buf, size_t len, int quality);
|
||||
void crypt_random_exit(void);
|
||||
|
||||
@@ -635,7 +635,7 @@ int LUKS_generate_phdr(struct luks_phdr *header,
|
||||
header->version, header->hashSpec ,header->cipherName, header->cipherMode,
|
||||
header->keyBytes);
|
||||
|
||||
r = crypt_random_get(ctx, header->mkDigestSalt, LUKS_SALTSIZE, CRYPT_RND_NORMAL);
|
||||
r = crypt_random_get(ctx, header->mkDigestSalt, LUKS_SALTSIZE, CRYPT_RND_SALT);
|
||||
if(r < 0) {
|
||||
log_err(ctx, _("Cannot create LUKS header: reading random salt failed.\n"));
|
||||
return r;
|
||||
@@ -752,7 +752,7 @@ int LUKS_set_key(const char *device, unsigned int keyIndex,
|
||||
return -ENOMEM;
|
||||
|
||||
r = crypt_random_get(ctx, hdr->keyblock[keyIndex].passwordSalt,
|
||||
LUKS_SALTSIZE, CRYPT_RND_NORMAL);
|
||||
LUKS_SALTSIZE, CRYPT_RND_SALT);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -176,6 +176,9 @@ int crypt_random_get(struct crypt_device *ctx, char *buf, size_t len, int qualit
|
||||
case CRYPT_RND_NORMAL:
|
||||
status = _get_urandom(ctx, buf, len);
|
||||
break;
|
||||
case CRYPT_RND_SALT:
|
||||
status = _get_urandom(ctx, buf, len);
|
||||
break;
|
||||
case CRYPT_RND_KEY:
|
||||
rng_type = ctx ? crypt_get_rng_type(ctx) :
|
||||
crypt_random_default_key_rng();
|
||||
|
||||
Reference in New Issue
Block a user