|
|
@ -58,6 +58,7 @@ typedef struct odf12
|
|
|
|
u32 iv[4];
|
|
|
|
u32 iv[4];
|
|
|
|
u32 checksum[8];
|
|
|
|
u32 checksum[8];
|
|
|
|
u32 encrypted_data[256];
|
|
|
|
u32 encrypted_data[256];
|
|
|
|
|
|
|
|
int encrypted_len;
|
|
|
|
|
|
|
|
|
|
|
|
} odf12_t;
|
|
|
|
} odf12_t;
|
|
|
|
|
|
|
|
|
|
|
@ -166,18 +167,19 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
|
|
|
token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH
|
|
|
|
token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH
|
|
|
|
| TOKEN_ATTR_VERIFY_DIGIT;
|
|
|
|
| TOKEN_ATTR_VERIFY_DIGIT;
|
|
|
|
|
|
|
|
|
|
|
|
token.len[11] = 2048;
|
|
|
|
token.len_min[11] = 16;
|
|
|
|
token.attr[11] = TOKEN_ATTR_FIXED_LENGTH
|
|
|
|
token.len_max[11] = 2048;
|
|
|
|
|
|
|
|
token.sep[11] = '*';
|
|
|
|
|
|
|
|
token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH
|
|
|
|
| TOKEN_ATTR_VERIFY_HEX;
|
|
|
|
| TOKEN_ATTR_VERIFY_HEX;
|
|
|
|
|
|
|
|
|
|
|
|
const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token);
|
|
|
|
const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token);
|
|
|
|
|
|
|
|
|
|
|
|
if (rc_tokenizer != PARSER_OK) return (rc_tokenizer);
|
|
|
|
if (rc_tokenizer != PARSER_OK) return (rc_tokenizer);
|
|
|
|
|
|
|
|
|
|
|
|
const u8 *checksum = token.buf[5];
|
|
|
|
const u8 *checksum = token.buf[5];
|
|
|
|
const u8 *iv = token.buf[7];
|
|
|
|
const u8 *iv = token.buf[7];
|
|
|
|
const u8 *salt_buf = token.buf[9];
|
|
|
|
const u8 *salt_buf = token.buf[9];
|
|
|
|
const u8 *encrypted_data = token.buf[11];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const u32 cipher_type = strtol ((const char *) token.buf[1], NULL, 10);
|
|
|
|
const u32 cipher_type = strtol ((const char *) token.buf[1], NULL, 10);
|
|
|
|
const u32 checksum_type = strtol ((const char *) token.buf[2], NULL, 10);
|
|
|
|
const u32 checksum_type = strtol ((const char *) token.buf[2], NULL, 10);
|
|
|
@ -207,15 +209,19 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
|
|
|
odf12->checksum[6] = hex_to_u32 (&checksum[48]);
|
|
|
|
odf12->checksum[6] = hex_to_u32 (&checksum[48]);
|
|
|
|
odf12->checksum[7] = hex_to_u32 (&checksum[56]);
|
|
|
|
odf12->checksum[7] = hex_to_u32 (&checksum[56]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// iv
|
|
|
|
|
|
|
|
|
|
|
|
odf12->iv[0] = hex_to_u32 (&iv[0]);
|
|
|
|
odf12->iv[0] = hex_to_u32 (&iv[0]);
|
|
|
|
odf12->iv[1] = hex_to_u32 (&iv[8]);
|
|
|
|
odf12->iv[1] = hex_to_u32 (&iv[8]);
|
|
|
|
odf12->iv[2] = hex_to_u32 (&iv[16]);
|
|
|
|
odf12->iv[2] = hex_to_u32 (&iv[16]);
|
|
|
|
odf12->iv[3] = hex_to_u32 (&iv[24]);
|
|
|
|
odf12->iv[3] = hex_to_u32 (&iv[24]);
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0, j = 0; i < 256; i += 1, j += 8)
|
|
|
|
// ct
|
|
|
|
{
|
|
|
|
|
|
|
|
odf12->encrypted_data[i] = hex_to_u32 (&encrypted_data[j]);
|
|
|
|
const int ct_len = token.len[11];
|
|
|
|
}
|
|
|
|
const u8 *ct_pos = token.buf[11];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
odf12->encrypted_len = hex_decode (ct_pos, ct_len, (u8 *) odf12->encrypted_data);
|
|
|
|
|
|
|
|
|
|
|
|
// salt
|
|
|
|
// salt
|
|
|
|
|
|
|
|
|
|
|
@ -248,7 +254,19 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const odf12_t *odf12 = (const odf12_t *) esalt_buf;
|
|
|
|
const odf12_t *odf12 = (const odf12_t *) esalt_buf;
|
|
|
|
|
|
|
|
|
|
|
|
int out_len = snprintf (line_buf, line_size, "%s*1*1*%u*32*%08x%08x%08x%08x%08x%08x%08x%08x*16*%08x%08x%08x%08x*16*%08x%08x%08x%08x*0*",
|
|
|
|
// ct
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
u32 ct_buf[256];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 256; i++) ct_buf[i] = byte_swap_32 (odf12->encrypted_data[i]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
u8 ct_buf8[(256 * 4 * 2) + 1];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const int ct_len = hex_encode ((const u8 *) ct_buf, odf12->encrypted_len, ct_buf8);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ct_buf8[ct_len] = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const int out_len = snprintf (line_buf, line_size, "%s*1*1*%u*32*%08x%08x%08x%08x%08x%08x%08x%08x*16*%08x%08x%08x%08x*16*%08x%08x%08x%08x*0*%s",
|
|
|
|
SIGNATURE_ODF,
|
|
|
|
SIGNATURE_ODF,
|
|
|
|
odf12->iterations,
|
|
|
|
odf12->iterations,
|
|
|
|
byte_swap_32 (odf12->checksum[0]),
|
|
|
|
byte_swap_32 (odf12->checksum[0]),
|
|
|
@ -266,14 +284,8 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
|
|
|
byte_swap_32 (salt->salt_buf[0]),
|
|
|
|
byte_swap_32 (salt->salt_buf[0]),
|
|
|
|
byte_swap_32 (salt->salt_buf[1]),
|
|
|
|
byte_swap_32 (salt->salt_buf[1]),
|
|
|
|
byte_swap_32 (salt->salt_buf[2]),
|
|
|
|
byte_swap_32 (salt->salt_buf[2]),
|
|
|
|
byte_swap_32 (salt->salt_buf[3]));
|
|
|
|
byte_swap_32 (salt->salt_buf[3]),
|
|
|
|
|
|
|
|
(char *) ct_buf8);
|
|
|
|
u8 *out_buf = (u8 *) line_buf;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 256; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
u32_to_hex (odf12->encrypted_data[i], out_buf + out_len); out_len += 8;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return out_len;
|
|
|
|
return out_len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|