mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-11 19:00:02 +01:00
Add hashMode parameter in CryptSetup_luksFormat()
This commit is contained in:
committed by
Milan Broz
parent
9da67b701d
commit
36419b25aa
@@ -70,7 +70,7 @@ r = c.isLuks()
|
|||||||
print("isLuks :", r)
|
print("isLuks :", r)
|
||||||
c.askyes(message = "Is there anybody out there?")
|
c.askyes(message = "Is there anybody out there?")
|
||||||
c.log(priority = pycryptsetup.CRYPT_LOG_ERROR, message = "Nobody there...\n")
|
c.log(priority = pycryptsetup.CRYPT_LOG_ERROR, message = "Nobody there...\n")
|
||||||
c.luksFormat(cipher = "aes", cipherMode= "xts-plain64", keysize = 512)
|
c.luksFormat(cipher = "aes", cipherMode= "xts-plain64", keysize = 512, hashMode = "sha256")
|
||||||
print("isLuks :", c.isLuks())
|
print("isLuks :", c.isLuks())
|
||||||
print("luksUUID:", c.luksUUID())
|
print("luksUUID:", c.luksUUID())
|
||||||
print("addKeyVK:", c.addKeyByVolumeKey(newPassphrase = PASSWORD, slot = 2))
|
print("addKeyVK:", c.addKeyByVolumeKey(newPassphrase = PASSWORD, slot = 2))
|
||||||
|
|||||||
@@ -366,22 +366,26 @@ static PyObject *CryptSetup_Info(CryptSetupObject* self, PyObject *args, PyObjec
|
|||||||
static char
|
static char
|
||||||
CryptSetup_luksFormat_HELP[] =
|
CryptSetup_luksFormat_HELP[] =
|
||||||
"Format device to enable LUKS\n\n\
|
"Format device to enable LUKS\n\n\
|
||||||
luksFormat(cipher = 'aes', cipherMode = 'cbc-essiv:sha256', keysize = 256)\n\n\
|
luksFormat(cipher = 'aes', cipherMode = 'cbc-essiv:sha256', keysize = 256, hashMode = 'sha256')\n\n\
|
||||||
cipher - cipher specification, e.g. aes, serpent\n\
|
cipher - cipher specification, e.g. aes, serpent\n\
|
||||||
cipherMode - cipher mode specification, e.g. cbc-essiv:sha256, xts-plain64\n\
|
cipherMode - cipher mode specification, e.g. cbc-essiv:sha256, xts-plain64\n\
|
||||||
keysize - key size in bits";
|
keysize - key size in bits\n\
|
||||||
|
hashMode - hash specification, e.g. sha256";
|
||||||
|
|
||||||
static PyObject *CryptSetup_luksFormat(CryptSetupObject* self, PyObject *args, PyObject *kwds)
|
static PyObject *CryptSetup_luksFormat(CryptSetupObject* self, PyObject *args, PyObject *kwds)
|
||||||
{
|
{
|
||||||
static const char *kwlist[] = {"cipher", "cipherMode", "keysize", NULL};
|
static const char *kwlist[] = {"cipher", "cipherMode", "keysize", "hashMode", NULL};
|
||||||
char *cipher_mode = NULL, *cipher = NULL;
|
char *cipher_mode = NULL, *cipher = NULL, *hashMode = NULL;
|
||||||
int keysize = 256;
|
int keysize = 256;
|
||||||
PyObject *keysize_object = NULL;
|
PyObject *keysize_object = NULL;
|
||||||
|
struct crypt_params_luks1 params = {};
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|zzO", CONST_CAST(char**)kwlist,
|
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|zzOz", CONST_CAST(char**)kwlist,
|
||||||
&cipher, &cipher_mode, &keysize_object))
|
&cipher, &cipher_mode, &keysize_object,
|
||||||
|
&hashMode))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
params.hash = hashMode;
|
||||||
if (!keysize_object || keysize_object == Py_None) {
|
if (!keysize_object || keysize_object == Py_None) {
|
||||||
/* use default value */
|
/* use default value */
|
||||||
} else if (!PyInt_Check(keysize_object)) {
|
} else if (!PyInt_Check(keysize_object)) {
|
||||||
@@ -399,7 +403,7 @@ static PyObject *CryptSetup_luksFormat(CryptSetupObject* self, PyObject *args, P
|
|||||||
// FIXME use #defined defaults
|
// FIXME use #defined defaults
|
||||||
return PyObjectResult(crypt_format(self->device, CRYPT_LUKS1,
|
return PyObjectResult(crypt_format(self->device, CRYPT_LUKS1,
|
||||||
cipher ?: "aes", cipher_mode ?: "cbc-essiv:sha256",
|
cipher ?: "aes", cipher_mode ?: "cbc-essiv:sha256",
|
||||||
NULL, NULL, keysize / 8, NULL));
|
NULL, NULL, keysize / 8, ¶ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
static char
|
static char
|
||||||
|
|||||||
Reference in New Issue
Block a user