From 4505d0a36b64645ff0a87ed48933372b0c90b17d Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Mon, 14 Mar 2011 13:41:00 +0000 Subject: [PATCH] Add defaults to --help output. git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@460 36d66b0a-2a48-0410-832c-cd162a569da5 --- configure.in | 2 ++ lib/loopaes/loopaes.h | 2 -- man/cryptsetup.8 | 4 +++- src/cryptsetup.c | 8 +++++--- tests/loopaes-test | 10 +++++----- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/configure.in b/configure.in index 22414d59..a0e9d20e 100644 --- a/configure.in +++ b/configure.in @@ -250,6 +250,8 @@ CS_STR_WITH([luks1-cipher], [cipher for LUKS1], [aes]) CS_STR_WITH([luks1-mode], [cipher mode for LUKS1], [cbc-essiv:sha256]) CS_NUM_WITH([luks1-keybits],[key length in bits for LUKS1], [256]) +CS_STR_WITH([loopaes-cipher], [cipher for loop-AES mode], [aes]) +CS_NUM_WITH([loopaes-keybits],[key length in bits for loop-AES mode], [256]) dnl ========================================================================== diff --git a/lib/loopaes/loopaes.h b/lib/loopaes/loopaes.h index 4ea37c62..b984e922 100644 --- a/lib/loopaes/loopaes.h +++ b/lib/loopaes/loopaes.h @@ -5,8 +5,6 @@ #define LOOPAES_KEYFILE_MINSIZE 60 #define LOOPAES_KEYFILE_MAXSIZE 8000 -#define DEFAULT_LOOPAES_CIPHER "aes" - int LOOPAES_parse_keyfile(struct crypt_device *cd, struct volume_key **vk, unsigned int *keys_count, diff --git a/man/cryptsetup.8 b/man/cryptsetup.8 index 6cb262e6..f9d03c20 100644 --- a/man/cryptsetup.8 +++ b/man/cryptsetup.8 @@ -148,7 +148,7 @@ This command allows restoring header if device do not contain LUKS header or if For more information about LUKS, see \fBhttp://code.google.com/p/cryptsetup/wiki/Specification\fR -.SH Loop-AES EXTENSION +.SH loop-AES EXTENSION cryptsetup allows to map loop-AES encrypted partition using compatible dm-crypt mode. @@ -160,6 +160,8 @@ opens the loop-AES and sets up a mapping . N.B. If keyfile is in GPG encrypted format, you have to use \-\-key-file=- and decrypt it before use. gpg --decrypt | cryptsetup loopaesOpen \-\-key-file=- +Use \-\-key-file to specify proper key length, default compiled-in parameters are visible in \-\-help output. + \fB\fR can be [\-\-key-file, \-\-key-size, \-\-offset, \-\-readonly]. .PP \fIloopaesClose\fR diff --git a/src/cryptsetup.c b/src/cryptsetup.c index 4272d08e..bbb732de 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -265,7 +265,7 @@ static int action_loopaesOpen(int arg) .hash = opt_hash ?: NULL, // FIXME .offset = opt_offset, }; - unsigned int key_size = (opt_key_size ?: 128) / 8; + unsigned int key_size = (opt_key_size ?: DEFAULT_LOOPAES_KEYBITS) / 8; int r; if (!opt_key_file) { @@ -276,8 +276,8 @@ static int action_loopaesOpen(int arg) if ((r = crypt_init(&cd, action_argv[0]))) goto out; - r = crypt_format(cd, CRYPT_LOOPAES, NULL, NULL, NULL, NULL, - key_size, ¶ms); + r = crypt_format(cd, CRYPT_LOOPAES, opt_cipher ?: DEFAULT_LOOPAES_CIPHER, + NULL, NULL, NULL, key_size, ¶ms); if (r < 0) goto out; @@ -988,8 +988,10 @@ static void help(poptContext popt_context, enum poptCallbackReason reason, crypt_get_dir()); log_std(_("\nDefault compiled-in device cipher parameters:\n" + "\tloop-AES: %s, Key %d bits\n" "\tplain: %s, Key: %d bits, Password hashing: %s\n" "\tLUKS1: %s, Key: %d bits, LUKS header hashing: %s, RNG: %s\n"), + DEFAULT_LOOPAES_CIPHER, DEFAULT_LOOPAES_KEYBITS, DEFAULT_CIPHER(PLAIN), DEFAULT_PLAIN_KEYBITS, DEFAULT_PLAIN_HASH, DEFAULT_CIPHER(LUKS1), DEFAULT_LUKS1_KEYBITS, DEFAULT_LUKS1_HASH, DEFAULT_RNG); diff --git a/tests/loopaes-test b/tests/loopaes-test index 16dba8f9..99defae7 100755 --- a/tests/loopaes-test +++ b/tests/loopaes-test @@ -2,7 +2,7 @@ CRYPTSETUP=../src/cryptsetup -# try to validate using loop-aes losetup/kernel if available +# try to validate using loop-AES losetup/kernel if available LOSETUP_AES=/losetup-aes LOOP_DD_PARAM="bs=1k count=10000" @@ -84,7 +84,7 @@ function check_sum_losetup() # $key $alg { [ ! -x $LOSETUP_AES ] && echo && return - echo -n " Verification using Loop-AES: " + echo -n " Verification using loop-AES: " losetup -d $LOOPDEV >/dev/null 2>&1 cat $1 | $LOSETUP_AES -p 0 -e $2 $LOOPDEV $IMG @@ -94,7 +94,7 @@ function check_sum_losetup() # $key $alg echo "[OK]" else echo "[FAIL]" - echo " Expecting $EXPSUM got $VSUM (loop-aes)." + echo " Expecting $EXPSUM got $VSUM (loop-AES)." fail fi losetup -d $LOOPDEV >/dev/null 2>&1 @@ -116,13 +116,13 @@ function check_version() which uuencode >/dev/null || skip "WARNING: test require uuencode binary, test skipped." check_version || skip "Probably old kernel, test skipped." -# Loop-AES tests +# loop-AES tests KEY_SIZES="128 256" KEY_FILES="$KEYv1 $KEYv2 $KEYv3" for key_size in $KEY_SIZES ; do for key in $KEY_FILES ; do - prepare "Open Loop-AES $key / AES-$key_size" + prepare "Open loop-AES $key / AES-$key_size" $CRYPTSETUP loopaesOpen $LOOPDEV $DEV_NAME -s $key_size --key-file $key || fail check_exists check_sum $key $key_size