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