static int setup_leave(struct setup_backend *backend)[cryptsetup-1.0.5/lib/setup.c] September 19, 2007
Posted by Wildan Maulana in cryptsetup.2 comments
static int setup_leave(struct setup_backend *backend)
{
const char *error;if (backend)
backend->exit();/* dangerous, we can’t wipe all the memory */
if (!memory_unsafe)
munlockall();return 0;
}
static int setup_enter() [cryptsetup-1.0.5/lib/setup.c] September 19, 2007
Posted by Wildan Maulana in cryptsetup.1 comment so far
static int setup_enter(struct setup_backend *backend)
{int r;
/*
* from here we could have sensible data in memory
* so protect it from being swapped out
*/
r = mlockall(MCL_CURRENT | MCL_FUTURE);
if (r < 0) {
perror(“mlockall failed”);
fprintf(stderr, “WARNING!!! Possibly insecure memory. Are you root?\n”);
memory_unsafe = 1;
}set_error(NULL);
if (backend) {
r = backend->init();
if (r < 0)
return r;
if (r > 0)
memory_unsafe = 1;
}
return 0;
}
cryptsetup-1.0.5/lib/backends.c September 19, 2007
Posted by Wildan Maulana in cryptsetup.1 comment so far
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>#include “libcryptsetup.h”
#include “internal.h”extern struct hash_backend hash_gcrypt_backend;
extern struct setup_backend setup_libdevmapper_backend;#ifdef USE_PLUGINS
static void init_plugins(void)
{
}
#else /* USE_PLUGINS */
# define init_plugins() do { } while(0)
#endif /* USE_PLUGINS */static struct hash_backend *hash_backends[] = {
#ifdef BUILTIN_GCRYPT
&hash_gcrypt_backend,
#endif
NULL
};static struct setup_backend *setup_backends[] = {
#ifdef BUILTIN_LIBDEVMAPPER
&setup_libdevmapper_backend,
#endif
NULL
};struct hash_backend *get_hash_backend(const char *name)
{
struct hash_backend **backend;init_plugins();
for(backend = hash_backends; *backend; backend++)
if (!name || strcmp(name, (*backend)->name) == 0)
break;return *backend;
}void put_hash_backend(struct hash_backend *backend)
{
}int hash(const char *backend_name, const char *hash_name,
char *result, size_t size,
const char *passphrase, size_t sizep)
{
struct hash_backend *backend;
struct hash_type *hashes = NULL, *hash;
char hash_name_buf[256], *s;
size_t pad = 0;
int r = -ENOENT;if (strlen(hash_name) >= sizeof(hash_name_buf)) {
set_error(“hash name too long: %s”, hash_name);
return -ENAMETOOLONG;
}if ((s = strchr(hash_name, ‘:’))) {
size_t hlen;
strcpy(hash_name_buf, hash_name);
hash_name_buf[s-hash_name] = ”;
hash_name = hash_name_buf;
hlen = atoi(++s);
if (hlen > size) {
set_error(“requested hash length (%zd) > key length (%zd)”, hlen, size);
return -EINVAL;
}
pad = size-hlen;
size = hlen;
}backend = get_hash_backend(backend_name);
if (!backend) {
set_error(“No hash backend found”);
return -ENOSYS;
}hashes = backend->get_hashes();
if (!hashes) {
set_error(“No hash functions available”);
goto out;
}for(hash = hashes; hash->name; hash++)
if (strcmp(hash->name, hash_name) == 0)
break;
if (!hash->name) {
set_error(“Unknown hash type %s”, hash_name);
goto out;
}r = hash->fn(hash->private, size, result, sizep, passphrase);
if (r < 0) {
set_error(“Error hashing passphrase”);
goto out;
}if (pad) {
memset(result+size, 0, pad);
}out:
if (hashes)
backend->free_hashes(hashes);
put_hash_backend(backend);return r;
}struct setup_backend *get_setup_backend(const char *name)
{
struct setup_backend **backend;init_plugins();
for(backend = setup_backends; *backend; backend++)
if (!name || strcmp(name, (*backend)->name) == 0)
break;return *backend;
}void put_setup_backend(struct setup_backend *backend)
{
#ifdef USE_PLUGINS
#endif
}
crypt_job() [cryptsetup-1.0.5/lib/setup.c] September 19, 2007
Posted by Wildan Maulana in cryptsetup.1 comment so far
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;
}
static void show_status(int errcode) [cryptsetup-1.0.5/src/cryptsetup.c] September 19, 2007
Posted by Wildan Maulana in cryptsetup.1 comment so far
static void show_status(int errcode)
{
char error[256];if(!errcode) {
fprintf(stderr, _(“Command successful.\n”));
return;
}crypt_get_error(error, sizeof(error));
if (!opt_verbose) {
char *error_ = strerror_r(errcode, error, sizeof(error));
if (error_ != error) {
strncpy(error, error_, sizeof(error));
error[sizeof error – 1] = ”;
}
}fprintf(stderr, _(“Command failed”));
if (*error)
fprintf(stderr, “: %s\n”, error);
else
fputs(“.\n”, stderr);
return;
}
Junk Code Result …[2] September 19, 2007
Posted by Wildan Maulana in cryptsetup.add a comment
Without –cipher aes option …
bash-3.2# cryptsetup luksOpen /dev/mmcblk0p2 rahasia
Before entering passphrase
Entering … –> get_key function
Entering spot 5 , fd = options->passphrase_fd = 0
Entering spot 6
Entering interactive_pass()…
Masukkan LUKS passphrase:
spot 1 @ interactive_pass()Entering untimed_read()….
fd = 4
pass =
maxlen = 512
<<Entering passphrase here …>>
read(fd, pass, maxlen) = 6
End of untimed_read() with return value = 0
NOT failed on …: interactive_pass()
spot 2 @ interactive_pass()
Pass = 12345
failed variable value = 0
Entering spot 8
passLen value = 2143919188
key Value =
Entering spot 14 = 1
Password value @setup.c:
Entering LUKS_open_any_key(), chek the parameters Value …:
Device = /dev/mmcblk0p2
Password = 12345
i = 0
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 0
password = 12345
passwordLen = 5
————————
AFEKSize = 64000
AfKey value = ø
PBKDF2_HMAC_SHA1() Parameter value …, BEGIN :
password = 12345
passwordLen = 5
hdr->keyblock[keyIndex].passwordSalt = €¬Ö™½çö–KÍÆËÖ@ù¿^
LUKS_SALTSIZE = 32
hdr->keyblock[keyIndex].passwordIterations = 55328
derivedKey = *¬>ü
hdr->keyBytes = 16
PBKDF2_HMAC_SHA1() Parameter value …, END
Entering PBKDF2_HMAC_SHA1, BEGIN
Entering LUKS_decrypt_from_storage()…
LUKS_decrypt_from_storage() value = 0Entering AF_merge() function …
End of AF_merge() function …
r = AF_merge() ==> 0
Entering PBKDF2_HMAC_SHA1, BEGIN
r = (memcmp) ==> -1
End of LUKS_open_key()… with r value = r
The return value of LUKS_open_key() = -1
i = 1
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 1
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 2
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 2
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 3
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 3
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 4
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 4
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 5
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 5
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 6
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 6
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 7
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 7
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
End of LUKS_open_any_key() function
Before entering passphrase
Entering … –> get_key function
Entering spot 5 , fd = options->passphrase_fd = 0
Entering spot 6
Entering interactive_pass()…
Masukkan LUKS passphrase:
spot 1 @ interactive_pass()Entering untimed_read()….
fd = 3
pass =
maxlen = 512
read(fd, pass, maxlen) = 6
End of untimed_read() with return value = 0
NOT failed on …: interactive_pass()
spot 2 @ interactive_pass()
Pass = 12345
failed variable value = 0
Entering spot 8
passLen value = 2143919188
key Value =
Entering spot 14 = 1
Password value @setup.c:
Entering LUKS_open_any_key(), chek the parameters Value …:
Device = /dev/mmcblk0p2
Password = 12345
i = 0
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 0
password = 12345
passwordLen = 5
————————
AFEKSize = 64000
AfKey value = €
PBKDF2_HMAC_SHA1() Parameter value …, BEGIN :
password = 12345
passwordLen = 5
hdr->keyblock[keyIndex].passwordSalt = €¬Ö™½çö–KÍÆËÖ@ù¿^
LUKS_SALTSIZE = 32
hdr->keyblock[keyIndex].passwordIterations = 55328
derivedKey = *¬>ü
hdr->keyBytes = 16
PBKDF2_HMAC_SHA1() Parameter value …, END
Entering PBKDF2_HMAC_SHA1, BEGIN
Entering LUKS_decrypt_from_storage()…
LUKS_decrypt_from_storage() value = 0Entering AF_merge() function …
End of AF_merge() function …
r = AF_merge() ==> 0
Entering PBKDF2_HMAC_SHA1, BEGIN
r = (memcmp) ==> -1
End of LUKS_open_key()… with r value = r
The return value of LUKS_open_key() = -1
i = 1
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 1
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 2
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 2
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 3
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 3
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 4
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 4
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 5
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 5
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 6
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 6
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 7
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 7
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
End of LUKS_open_any_key() function
Before entering passphrase
Entering … –> get_key function
Entering spot 5 , fd = options->passphrase_fd = 0
Entering spot 6
Entering interactive_pass()…
Masukkan LUKS passphrase:
spot 1 @ interactive_pass()Entering untimed_read()….
fd = 3
pass = *°’”
maxlen = 512
read(fd, pass, maxlen) = 6
End of untimed_read() with return value = 0
NOT failed on …: interactive_pass()
spot 2 @ interactive_pass()
Pass = 12345
failed variable value = 0
Entering spot 8
passLen value = 2143919188
key Value =
Entering spot 14 = 1
Password value @setup.c:
Entering LUKS_open_any_key(), chek the parameters Value …:
Device = /dev/mmcblk0p2
Password = 12345
i = 0
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 0
password = 12345
passwordLen = 5
————————
AFEKSize = 64000
AfKey value =
PBKDF2_HMAC_SHA1() Parameter value …, BEGIN :
password = 12345
passwordLen = 5
hdr->keyblock[keyIndex].passwordSalt = €¬Ö™½çö–KÍÆËÖ@ù¿^
LUKS_SALTSIZE = 32
hdr->keyblock[keyIndex].passwordIterations = 55328
derivedKey = *¬>ü
hdr->keyBytes = 16
PBKDF2_HMAC_SHA1() Parameter value …, END
Entering PBKDF2_HMAC_SHA1, BEGIN
Entering LUKS_decrypt_from_storage()…
LUKS_decrypt_from_storage() value = 0Entering AF_merge() function …
End of AF_merge() function …
r = AF_merge() ==> 0
Entering PBKDF2_HMAC_SHA1, BEGIN
r = (memcmp) ==> -1
End of LUKS_open_key()… with r value = r
The return value of LUKS_open_key() = -1
i = 1
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 1
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 2
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 2
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 3
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 3
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 4
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 4
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 5
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 5
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 6
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 6
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 7
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 7
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
End of LUKS_open_any_key() function
Command failed: No key available with this passphrase.bash-3.2#
Junk Code Result … September 18, 2007
Posted by Wildan Maulana in cryptsetup.1 comment so far
For personal doc only … 🙂 :
bash-3.2# cryptsetup –cipher aes luksOpen /dev/mmcblk0p2 rahasia
Before entering passphrase
Entering … –> get_key function
Entering spot 5 , fd = options->passphrase_fd = 0
Entering spot 6
Entering interactive_pass()…
Masukkan LUKS passphrase:
spot 1 @ interactive_pass()Entering untimed_read()….
fd = 4
pass =
maxlen = 512
<!— Enter Passphrase –>
read(fd, pass, maxlen) = 6
End of untimed_read() with return value = 0
NOT failed on …: interactive_pass()
spot 2 @ interactive_pass()
Pass = 12345
failed variable value = 0
Entering spot 8
passLen value = 2140294212
key Value =
Entering spot 14 = 1
Password value @setup.c:
Entering LUKS_open_any_key(), chek the parameters Value …:
Device = /dev/mmcblk0p2
Password = 12345
i = 0
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 0
password = 12345
passwordLen = 5
————————
AFEKSize = 64000
AfKey value = P
PBKDF2_HMAC_SHA1() Parameter value …, BEGIN :
password = 12345
passwordLen = 5
hdr->keyblock[keyIndex].passwordSalt = €¬Ö™½çö–KÍÆËÖ@ù¿^
LUKS_SALTSIZE = 32
hdr->keyblock[keyIndex].passwordIterations = 55328
derivedKey = *¬>ü
hdr->keyBytes = 16
PBKDF2_HMAC_SHA1() Parameter value …, END
Entering PBKDF2_HMAC_SHA1, BEGIN
Entering LUKS_decrypt_from_storage()…
LUKS_decrypt_from_storage() value = 0Entering AF_merge() function …
End of AF_merge() function …
r = AF_merge() ==> 0
Entering PBKDF2_HMAC_SHA1, BEGIN
r = (memcmp) ==> -1
End of LUKS_open_key()… with r value = r
The return value of LUKS_open_key() = -1
i = 1
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 1
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 2
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 2
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 3
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 3
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 4
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 4
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 5
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 5
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 6
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 6
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 7
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 7
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
End of LUKS_open_any_key() function
Before entering passphrase
Entering … –> get_key function
Entering spot 5 , fd = options->passphrase_fd = 0
Entering spot 6
Entering interactive_pass()…
Masukkan LUKS passphrase:
spot 1 @ interactive_pass()Entering untimed_read()….
fd = 3
pass =
maxlen = 512
<!— Enter Passphrase 2 –>
read(fd, pass, maxlen) = 6
End of untimed_read() with return value = 0
NOT failed on …: interactive_pass()
spot 2 @ interactive_pass()
Pass = 12345
failed variable value = 0
Entering spot 8
passLen value = 2140294212
key Value =
Entering spot 14 = 1
Password value @setup.c:
Entering LUKS_open_any_key(), chek the parameters Value …:
Device = /dev/mmcblk0p2
Password = 12345
i = 0
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 0
password = 12345
passwordLen = 5
————————
AFEKSize = 64000
AfKey value = Ø
PBKDF2_HMAC_SHA1() Parameter value …, BEGIN :
password = 12345
passwordLen = 5
hdr->keyblock[keyIndex].passwordSalt = €¬Ö™½çö–KÍÆËÖ@ù¿^
LUKS_SALTSIZE = 32
hdr->keyblock[keyIndex].passwordIterations = 55328
derivedKey = *¬>ü
hdr->keyBytes = 16
PBKDF2_HMAC_SHA1() Parameter value …, END
Entering PBKDF2_HMAC_SHA1, BEGIN
Entering LUKS_decrypt_from_storage()…
LUKS_decrypt_from_storage() value = 0Entering AF_merge() function …
End of AF_merge() function …
r = AF_merge() ==> 0
Entering PBKDF2_HMAC_SHA1, BEGIN
r = (memcmp) ==> -1
End of LUKS_open_key()… with r value = r
The return value of LUKS_open_key() = -1
i = 1
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 1
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 2
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 2
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 3
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 3
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 4
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 4
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 5
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 5
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 6
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 6
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 7
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 7
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
End of LUKS_open_any_key() function
Before entering passphrase
Entering … –> get_key function
Entering spot 5 , fd = options->passphrase_fd = 0
Entering spot 6
Entering interactive_pass()…
Masukkan LUKS passphrase:
spot 1 @ interactive_pass()Entering untimed_read()….
fd = 3
pass = *°’”
maxlen = 512
read(fd, pass, maxlen) = 6
End of untimed_read() with return value = 0
NOT failed on …: interactive_pass()
spot 2 @ interactive_pass()
Pass = 12345
failed variable value = 0
Entering spot 8
passLen value = 2140294212
key Value =
Entering spot 14 = 1
Password value @setup.c:
Entering LUKS_open_any_key(), chek the parameters Value …:
Device = /dev/mmcblk0p2
Password = 12345
i = 0
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 0
password = 12345
passwordLen = 5
————————
AFEKSize = 64000
AfKey value = `
PBKDF2_HMAC_SHA1() Parameter value …, BEGIN :
password = 12345
passwordLen = 5
hdr->keyblock[keyIndex].passwordSalt = €¬Ö™½çö–KÍÆËÖ@ù¿^
LUKS_SALTSIZE = 32
hdr->keyblock[keyIndex].passwordIterations = 55328
derivedKey = *¬>ü
hdr->keyBytes = 16
PBKDF2_HMAC_SHA1() Parameter value …, END
Entering PBKDF2_HMAC_SHA1, BEGIN
Entering LUKS_decrypt_from_storage()…
LUKS_decrypt_from_storage() value = 0Entering AF_merge() function …
End of AF_merge() function …
r = AF_merge() ==> 0
Entering PBKDF2_HMAC_SHA1, BEGIN
r = (memcmp) ==> -1
End of LUKS_open_key()… with r value = r
The return value of LUKS_open_key() = -1
i = 1
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 1
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 2
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 2
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 3
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 3
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 4
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 4
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 5
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 5
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 6
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 6
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
i = 7
Entering loop @LUKS_open_any_key()
lUKS_NUMKEYS Value = 8
Entering LUKS_open_key()…
Print paramater value …
————————
device = /dev/mmcblk0p2
keyIndex = 7
password = 12345
passwordLen = 5
————————
The return value of LUKS_open_key() = -22
End of LUKS_open_any_key() function
Command failed: No key available with this passphrase.bash-3.2#
untimed_read() [cryptsetup-1.0.5/lib/setup.c] September 18, 2007
Posted by Wildan Maulana in cryptsetup.1 comment so far
static int untimed_read(int fd, char *pass, size_t maxlen)
{
ssize_t i;i = read(fd, pass, maxlen);
if (i > 0) {
pass[i-1] = ”;
i = 0;
} else if (i == 0) { /* EOF */
*pass = 0;
i = -1;
}
return i;
}
cryptsetup-1.0.5/luks/af.c September 18, 2007
Posted by Wildan Maulana in cryptsetup.1 comment so far
/*
* AFsplitter – Anti forensic information splitter
* Copyright 2004, Clemens Fruhwirth <clemens@endorphin.org>
*
* AFsplitter diffuses information over a large stripe of data,
* therefor supporting secure data destruction.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place – Suite 330, Boston, MA 02111-1307, USA.
*/#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <errno.h>
#include “sha1.h”
#include “XORblock.h”/* diffuse: Information spreading over the whole dataset with
* the help of sha512.
*/static void diffuse(unsigned char *src, unsigned char *dst, size_t size)
{
sha1_ctx ctx;
uint32_t i;
uint32_t IV; /* host byte order independend hash IV */unsigned int fullblocks = size / SHA1_DIGEST_SIZE;
unsigned int padding = size % SHA1_DIGEST_SIZE;
unsigned char final[SHA1_DIGEST_SIZE];/* hash block the whole data set with different IVs to produce
* more than just a single data block
*/
for (i=0; i < fullblocks; i++) {
sha1_begin(&ctx);
IV = htonl(i);
sha1_hash((const unsigned char *) &IV, sizeof(IV), &ctx);
sha1_hash(src + SHA1_DIGEST_SIZE * i, SHA1_DIGEST_SIZE, &ctx);
sha1_end(dst + SHA1_DIGEST_SIZE * i, &ctx);
}if(padding) {
sha1_begin(&ctx);
IV = htonl(i);
sha1_hash((const unsigned char *) &IV, sizeof(IV), &ctx);
sha1_hash(src + SHA1_DIGEST_SIZE * i, padding, &ctx);
sha1_end(final, &ctx);
memcpy(dst + SHA1_DIGEST_SIZE * i, final, padding);
}
}/*
* Information splitting. The amount of data is multiplied by
* blocknumbers. The same blocksize and blocknumbers values
* must be supplied to AF_merge to recover information.
*/int AF_split(char *src, char *dst, size_t blocksize, unsigned int blocknumbers)
{
unsigned int i;
char *bufblock;
int r = -EINVAL;if((bufblock = calloc(blocksize, 1)) == NULL) return -ENOMEM;
/* process everything except the last block */
for(i=0; i<blocknumbers-1; i++) {
r = getRandom(dst+(blocksize*i),blocksize);
if(r < 0) goto out;XORblock(dst+(blocksize*i),bufblock,bufblock,blocksize);
diffuse(bufblock,bufblock,blocksize);
}
/* the last block is computed */
XORblock(src,bufblock,dst+(i*blocksize),blocksize);
r = 0;
out:
free(bufblock);
return r;
}int AF_merge(char *src, char *dst, size_t blocksize, unsigned int blocknumbers)
{
printf(“\n Entering AF_merge() function … \n”);
unsigned int i;
char *bufblock;if((bufblock = calloc(blocksize, 1)) == NULL) return -ENOMEM;
memset(bufblock,0,blocksize);
for(i=0; i<blocknumbers-1; i++) {
XORblock(src+(blocksize*i),bufblock,bufblock,blocksize);
diffuse(bufblock,bufblock,blocksize);
}
XORblock(src + blocksize * i, bufblock, dst, blocksize);free(bufblock);
printf(“\n End of AF_merge() function … \n”);
return 0;
}
cryptsetup-1.0.5/luks/keyencryption.c September 18, 2007
Posted by Wildan Maulana in cryptsetup.1 comment so far
/*
* LUKS – Linux Unified Key Setup
*
* Copyright (C) 2004-2006, Clemens Fruhwirth <clemens@endorphin.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>#include “luks.h”
#include “../lib/libcryptsetup.h”
#include “../lib/internal.h”
#include “../lib/blockdev.h”#define div_round_up(a,b) ({ \
typeof(a) __a = (a); \
typeof(b) __b = (b); \
(__a – 1) / __b + 1; \
})static int setup_mapping(const char *cipher, const char *name,
const char *device, unsigned int payloadOffset,
const char *key, size_t keyLength,
unsigned int sector, size_t srcLength,
struct setup_backend *backend,
int mode)
{
struct crypt_options k;
struct crypt_options *options = &k;
int device_sector_size = sector_size_for_device(device);
int r;/*
* we need to round this to nearest multiple of the underlying
* device’s sector size, otherwise the mapping will be refused.
*/
if(device_sector_size < 0) {
fprintf(stderr,_(“Unable to obtain sector size for %s”),device);
return -EINVAL;
}
options->size = round_up_modulo(srcLength,device_sector_size)/SECTOR_SIZE;options->offset = sector;
options->cipher = cipher;
options->key_size = keyLength;
options->skip = 0;
options->flags = 0;
options->name = name;
options->device = device;if (mode == O_RDONLY) {
options->flags |= CRYPT_FLAG_READONLY;
}r = backend->create(0, options, key);
if (r <= 0)
set_error(NULL);return r;
}static int clear_mapping(const char *name, struct setup_backend *backend)
{
struct crypt_options options;
options.name=name;
return backend->remove(&options);
}static int LUKS_endec_template(char *src, size_t srcLength,
struct luks_phdr *hdr,
char *key, size_t keyLength,
const char *device,
unsigned int sector, struct setup_backend *backend,
ssize_t (*func)(int, void *, size_t),
int mode)
{
int devfd;
char *name = NULL;
char *fullpath = NULL;
char *dmCipherSpec = NULL;
const char *dmDir = backend->dir();
int r = -1;if(dmDir == NULL) {
fputs(_(“Failed to obtain device mapper directory.”), stderr);
return -1;
}
if(asprintf(&name,”temporary-cryptsetup-%d”,getpid()) == -1 ||
asprintf(&fullpath,”%s/%s”,dmDir,name) == -1 ||
asprintf(&dmCipherSpec,”%s-%s”,hdr->cipherName, hdr->cipherMode) == -1) {
r = -ENOMEM;
goto out1;
}r = setup_mapping(dmCipherSpec,name,device,hdr->payloadOffset,key,keyLength,sector,srcLength,backend,mode);
if(r < 0) {
fprintf(stderr,”Failed to setup dm-crypt key mapping.\nCheck kernel for support for the %s cipher spec and verify that %s contains at least %d sectors.\n”,
dmCipherSpec,
device,
sector + div_round_up(srcLength,SECTOR_SIZE));
r = -EIO;
goto out1;
}devfd = open(fullpath, mode | O_DIRECT | O_SYNC);
if(devfd == -1) { r = -EIO; goto out2; }r = func(devfd,src,srcLength);
if(r < 0) { r = -EIO; goto out3; }r = 0;
out3:
close(devfd);
out2:
clear_mapping(name,backend);
out1:
free(dmCipherSpec);
free(fullpath);
free(name);
return r;
}int LUKS_encrypt_to_storage(char *src, size_t srcLength,
struct luks_phdr *hdr,
char *key, size_t keyLength,
const char *device,
unsigned int sector, struct setup_backend *backend)
{return LUKS_endec_template(src,srcLength,hdr,key,keyLength, device, sector, backend,
(ssize_t (*)(int, void *, size_t)) write_blockwise, O_RDWR);
}int LUKS_decrypt_from_storage(char *dst, size_t dstLength,
struct luks_phdr *hdr,
char *key, size_t keyLength,
const char *device,
unsigned int sector, struct setup_backend *backend)
{
return LUKS_endec_template(dst,dstLength,hdr,key,keyLength, device, sector, backend, read_blockwise, O_RDONLY);
}