Posted by: Wildan Maulana | September 5, 2007

[Solved] Tracing cryptsetup error …

bash-3.2# cryptsetup -y –cipher aes-plain luksFormat /dev/loop0

WARNING!
========
This will overwrite data on /dev/loop0 irrevocably.

Are you sure? (Type uppercase yes): YES
Enter LUKS passphrase:
Verify passphrase:
device-mapper: table: 254:0: zero-length target
Failed to setup dm-crypt key mapping.
Check kernel for support for the aes-plain cipher spec and verify that /dev/loop0 contains at least 133 sectors.
Failed to write to key storage.

device-mapper: table: 254:0: zero-length target


Related C Code :

cryptsetup.c

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <errno.h>
#include <assert.h>

#include <libcryptsetup.h>
#include <popt.h>

#include “../config.h”

#include “cryptsetup.h”

static int action_luksFormat(int arg)
{
struct crypt_options options = {
.key_size = (opt_key_size != 0 ? opt_key_size : DEFAULT_LUKS_KEY_SIZE) / 8,
.device = action_argv[0],
.cipher = opt_cipher?opt_cipher:DEFAULT_LUKS_CIPHER,
.new_key_file = action_argc > 1 ? action_argv[1] : NULL,
.flags = opt_verify_passphrase ? CRYPT_FLAG_VERIFY : (!opt_batch_mode?CRYPT_FLAG_VERIFY_IF_POSSIBLE : 0),
.iteration_time = opt_iteration_time,
.timeout = opt_timeout,
.align_payload = opt_align_payload,
};

int r = 0; char *msg = NULL;

if(asprintf(&msg, _(“This will overwrite data on %s irrevocably.”), options.device) == -1) {
fputs(_(“memory allocation error in action_luksFormat”), stderr);
} else {
r = yesDialog(msg) ? crypt_luksFormat(&options) : –EINVAL;
free(msg);
show_status(-r);
}
return r;
}

setup.c

int crypt_luksFormat(struct crypt_options *options)
{
return crypt_job(__crypt_luks_format, 0, options);
}

setup.c

static int crypt_job(int (*job)(int arg, struct setup_backend *backend,
struct crypt_options *options),
int arg, struct crypt_options *options)
{
struct setup_backend *backend;
int r;

backend = get_setup_backend(default_backend);

setup_enter(backend);

if (!backend) {
set_error(“No setup backend available”);
r = -ENOSYS;
goto out;
}

r = job(arg, backend, options);
out:
setup_leave(backend);
if (backend)
put_setup_backend(backend);

if (r >= 0)set_error(NULL);

return r;
}


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: