1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-22 08:08:10 +00:00

Backport current state of pure kernel rule engine to CPU

This commit is contained in:
jsteube 2017-08-20 12:27:19 +02:00
parent 508f1562f2
commit f63df45fca
2 changed files with 310 additions and 126 deletions

View File

@ -6,6 +6,6 @@
#ifndef _RP_KERNEL_ON_CPU_H
#define _RP_KERNEL_ON_CPU_H
int apply_rules (const u32 *cmds, u32 buf[64], const int in_len);
int apply_rules (const u32 *cmds, u32 *buf, const int in_len);
#endif // _RP_KERNEL_ON_CPU_H

View File

@ -9,104 +9,286 @@
#include "rp.h"
#include "rp_kernel_on_cpu.h"
static void upper_at (u8 *buf, const int pos)
static u64 hl32_to_64 (const u32 a, const u32 b)
{
const u8 c = buf[pos];
if ((c >= 'a') && (c <= 'z')) buf[pos] ^= 0x20;
return (((u64) a) << 32) | b;
}
static void lower_at (u8 *buf, const int pos)
static u32 l32_from_64_S (u64 a)
{
const u8 c = buf[pos];
const u32 r = (u32) (a);
if ((c >= 'A') && (c <= 'Z')) buf[pos] ^= 0x20;
return r;
}
static void toggle_at (u8 *buf, const int pos)
static u32 h32_from_64_S (u64 a)
{
const u8 c = buf[pos];
a >>= 32;
if ((c >= 'a') && (c <= 'z')) buf[pos] ^= 0x20;
if ((c >= 'A') && (c <= 'Z')) buf[pos] ^= 0x20;
const u32 r = (u32) (a);
return r;
}
static void mangle_switch (u8 *buf, const int l, const int r)
static u32 generate_cmask (const u32 value)
{
const u8 c = buf[r];
buf[r] = buf[l];
buf[l] = c;
const u32 rmask = ((value & 0x40404040u) >> 1u)
& ~((value & 0x80808080u) >> 2u);
const u32 hmask = (value & 0x1f1f1f1fu) + 0x05050505u;
const u32 lmask = (value & 0x1f1f1f1fu) + 0x1f1f1f1fu;
return rmask & ~hmask & lmask;
}
static int mangle_lrest (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len)
static void append_four_byte (const u32 *buf_src, const int off_src, u32 *buf_dst, const int off_dst)
{
for (int pos = 0; pos < len; pos++) lower_at (buf, pos);
const int sd = off_src / 4;
const int sm = off_src & 3;
const int sm8 = sm * 8;
return (len);
const int dd = off_dst / 4;
const int dm = off_dst & 3;
const int dm8 = dm * 8;
u64 t64 = hl32_to_64 (buf_src[sd + 1], buf_src[sd + 0]);
t64 >>= sm8;
t64 <<= dm8;
const u32 t0 = l32_from_64_S (t64);
const u32 t1 = h32_from_64_S (t64);
buf_dst[dd + 0] |= t0;
buf_dst[dd + 1] |= t1;
}
static int mangle_lrest_ufirst (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len)
static void append_three_byte (const u32 *buf_src, const int off_src, u32 *buf_dst, const int off_dst)
{
for (int pos = 0; pos < len; pos++) lower_at (buf, pos);
const int sd = off_src / 4;
const int sm = off_src & 3;
const int sm8 = sm * 8;
upper_at (buf, 0);
const int dd = off_dst / 4;
const int dm = off_dst & 3;
const int dm8 = dm * 8;
return (len);
u64 t64 = hl32_to_64 (buf_src[sd + 1], buf_src[sd + 0]);
t64 >>= sm8;
t64 &= 0x00ffffff;
t64 <<= dm8;
const u32 t0 = l32_from_64_S (t64);
const u32 t1 = h32_from_64_S (t64);
buf_dst[dd + 0] |= t0;
buf_dst[dd + 1] |= t1;
}
static int mangle_urest (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len)
static void append_two_byte (const u32 *buf_src, const int off_src, u32 *buf_dst, const int off_dst)
{
for (int pos = 0; pos < len; pos++) upper_at (buf, pos);
const int sd = off_src / 4;
const int sm = off_src & 3;
const int sm8 = sm * 8;
return (len);
const int dd = off_dst / 4;
const int dm = off_dst & 3;
const int dm8 = dm * 8;
u64 t64 = hl32_to_64 (buf_src[sd + 1], buf_src[sd + 0]);
t64 >>= sm8;
t64 &= 0x0000ffff;
t64 <<= dm8;
const u32 t0 = l32_from_64_S (t64);
const u32 t1 = h32_from_64_S (t64);
buf_dst[dd + 0] |= t0;
buf_dst[dd + 1] |= t1;
}
static int mangle_urest_lfirst (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len)
static void append_one_byte (const u32 *buf_src, const int off_src, u32 *buf_dst, const int off_dst)
{
for (int pos = 0; pos < len; pos++) upper_at (buf, pos);
const int sd = off_src / 4;
const int sm = off_src & 3;
const int sm8 = sm * 8;
lower_at (buf, 0);
const int dd = off_dst / 4;
const int dm = off_dst & 3;
const int dm8 = dm * 8;
return (len);
u32 t = buf_src[sd];
t >>= sm8;
t &= 0xff;
t <<= dm8;
buf_dst[dd] |= t;
}
static int mangle_trest (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len)
static void append_block (const u32 *buf_src, const int off_src, u32 *buf_dst, const int off_dst, const int len)
{
for (int pos = 0; pos < len; pos++) toggle_at (buf, pos);
int i;
return (len);
}
static int mangle_toggle_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len)
{
if (p0 >= len) return (len);
toggle_at (buf, p0);
return (len);
}
static int mangle_reverse (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len)
{
for (int l = 0; l < len / 2; l++)
for (i = 0; i < len - 4; i += 4)
{
const int r = len - 1 - l;
append_four_byte (buf_src, off_src + i, buf_dst, off_dst + i);
}
mangle_switch (buf, l, r);
const int left = len - i;
switch (left)
{
case 3: append_three_byte (buf_src, off_src + i, buf_dst, off_dst + i); break;
case 2: append_two_byte (buf_src, off_src + i, buf_dst, off_dst + i); break;
case 1: append_one_byte (buf_src, off_src + i, buf_dst, off_dst + i); break;
}
}
static void exchange_byte (u32 *buf, const int off_src, const int off_dst)
{
u8 *ptr = (u8 *) buf;
const u8 tmp = ptr[off_src];
ptr[off_src] = ptr[off_dst];
ptr[off_dst] = tmp;
/*
something tells me we do this faster
const int sd = off_src / 4;
const int sm = off_src & 3;
const int sm8 = sm * 8;
const int dd = off_dst / 4;
const int dm = off_dst & 3;
const int dm8 = dm * 8;
u32 ts = buf[sd];
u32 td = buf[dd];
ts >>= sm8;
td >>= dm8;
ts &= 0xff;
td &= 0xff;
const u32 x = ts ^ td;
const u32 xs = x << sm8;
const u32 xd = x << dm8;
buf[sd] ^= xs;
buf[dd] ^= xd;
*/
}
static int mangle_lrest (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len)
{
for (int i = 0, idx = 0; i < len; i += 4, idx += 1)
{
const u32 t = buf[idx];
buf[idx] = t | generate_cmask (t);
}
return (len);
}
static int mangle_dupeword (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len)
static int mangle_lrest_ufirst (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len)
{
for (int i = 0, idx = 0; i < len; i += 4, idx += 1)
{
const u32 t = buf[idx];
buf[idx] = t | generate_cmask (t);
}
const u32 t = buf[0];
buf[0] = t & ~(0x00000020 & generate_cmask (t));
return (len);
}
static int mangle_urest (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len)
{
for (int i = 0, idx = 0; i < len; i += 4, idx += 1)
{
const u32 t = buf[idx];
buf[idx] = t & ~(generate_cmask (t));
}
return (len);
}
static int mangle_urest_lfirst (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len)
{
for (int i = 0, idx = 0; i < len; i += 4, idx += 1)
{
const u32 t = buf[idx];
buf[idx] = t & ~(generate_cmask (t));
}
const u32 t = buf[0];
buf[0] = t | (0x00000020 & generate_cmask (t));
return (len);
}
static int mangle_trest (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len)
{
for (int i = 0, idx = 0; i < len; i += 4, idx += 1)
{
const u32 t = buf[idx];
buf[idx] = t ^ generate_cmask (t);
}
return (len);
}
static int mangle_toggle_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len)
{
if (p0 >= len) return (len);
const u8 p0d = p0 / 4;
const u8 p0m = p0 & 3;
const u32 tmp = 0x20u << (p0m * 8);
const u32 t = buf[p0d];
buf[p0d] = t ^ (generate_cmask (t) & tmp);
return (len);
}
static int mangle_reverse (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len)
{
for (int l = 0; l < len / 2; l++)
{
const int r = len - 1 - l;
exchange_byte (buf, l, r);
}
return (len);
}
static int mangle_dupeword (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len)
{
const int out_len = len * 2;
if (out_len >= RP_PASSWORD_SIZE) return (len);
u8 *out = buf + len;
for (int i = 0; i < len; i++) *out++ = *buf++;
append_block (buf, 0, buf, len, len);
return (out_len);
}
@ -124,15 +306,20 @@ static int mangle_dupeword_times (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u
return (out_len);
}
static int mangle_reflect (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len)
static int mangle_reflect (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len)
{
const int out_len = len * 2;
if (out_len >= RP_PASSWORD_SIZE) return (len);
mangle_dupeword (p0, p1, buf, len);
append_block (buf, 0, buf, len, len);
mangle_reverse (p0, p1, buf + len, len);
for (int l = 0; l < len / 2; l++)
{
const int r = len - 1 - l;
exchange_byte (buf, len + l, len + r);
}
return out_len;
}
@ -164,21 +351,21 @@ static int mangle_prepend (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u
return (out_len);
}
static int mangle_rotate_left (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len)
static int mangle_rotate_left (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len)
{
for (int l = 0, r = len - 1; r > l; r--)
{
mangle_switch (buf, l, r);
exchange_byte (buf, l, r);
}
return (len);
}
static int mangle_rotate_right (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len)
static int mangle_rotate_right (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len)
{
for (int l = 0, r = len - 1; l < r; l++)
{
mangle_switch (buf, l, r);
exchange_byte (buf, l, r);
}
return (len);
@ -370,30 +557,30 @@ static int mangle_dupechar_all (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8
return (out_len);
}
static int mangle_switch_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len)
static int mangle_switch_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len)
{
if (len < 2) return (len);
mangle_switch (buf, 0, 1);
exchange_byte (buf, 0, 1);
return (len);
}
static int mangle_switch_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len)
static int mangle_switch_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len)
{
if (len < 2) return (len);
mangle_switch (buf, len - 2, len - 1);
exchange_byte (buf, len - 2, len - 1);
return (len);
}
static int mangle_switch_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len)
static int mangle_switch_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len)
{
if (p0 >= len) return (len);
if (p1 >= len) return (len);
mangle_switch (buf, p0, p1);
exchange_byte (buf, p0, p1);
return (len);
}
@ -490,86 +677,83 @@ static int mangle_dupeblock_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u
return (out_len);
}
static int mangle_title_sep (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int len)
static int mangle_title_sep (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len)
{
int upper_next = 1;
if ((len + 4) >= RP_PASSWORD_SIZE) return (len); // cheap way to not need to check for overflow of i + 1
for (int pos = 0; pos < len; pos++)
mangle_lrest_ufirst (0, 0, buf, len);
for (int i = 0, idx = 0; i < len; i += 4, idx += 1)
{
if (buf[pos] == p0)
{
upper_next = 1;
const u32 v = buf[idx];
continue;
}
u32 out0 = 0;
u32 out1 = 0;
if (upper_next)
{
upper_next = 0;
if (((v >> 0) & 0xff) == p0) out0 |= 0x0000ff00;
if (((v >> 8) & 0xff) == p0) out0 |= 0x00ff0000;
if (((v >> 16) & 0xff) == p0) out0 |= 0xff000000;
if (((v >> 24) & 0xff) == p0) out1 |= 0x000000ff;
upper_at (buf, pos);
}
else
{
lower_at (buf, pos);
}
buf[idx + 0] &= ~(generate_cmask (buf[idx + 0]) & out0);
buf[idx + 1] &= ~(generate_cmask (buf[idx + 1]) & out1);
}
return (len);
}
static int apply_rule (const u32 name, MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u8 *buf, const int in_len)
static int apply_rule (const u32 name, MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int in_len)
{
int out_len = in_len;
switch (name)
{
case RULE_OP_MANGLE_LREST: out_len = mangle_lrest (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_LREST_UFIRST: out_len = mangle_lrest_ufirst (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_UREST: out_len = mangle_urest (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_UREST_LFIRST: out_len = mangle_urest_lfirst (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_TREST: out_len = mangle_trest (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_TOGGLE_AT: out_len = mangle_toggle_at (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_REVERSE: out_len = mangle_reverse (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_DUPEWORD: out_len = mangle_dupeword (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_DUPEWORD_TIMES: out_len = mangle_dupeword_times (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_REFLECT: out_len = mangle_reflect (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_APPEND: out_len = mangle_append (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_PREPEND: out_len = mangle_prepend (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_ROTATE_LEFT: out_len = mangle_rotate_left (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_ROTATE_RIGHT: out_len = mangle_rotate_right (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_DELETE_FIRST: out_len = mangle_delete_first (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_DELETE_LAST: out_len = mangle_delete_last (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_DELETE_AT: out_len = mangle_delete_at (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_EXTRACT: out_len = mangle_extract (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_OMIT: out_len = mangle_omit (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_INSERT: out_len = mangle_insert (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_OVERSTRIKE: out_len = mangle_overstrike (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_TRUNCATE_AT: out_len = mangle_truncate_at (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_REPLACE: out_len = mangle_replace (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_PURGECHAR: out_len = mangle_purgechar (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_DUPECHAR_FIRST: out_len = mangle_dupechar_first (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_DUPECHAR_LAST: out_len = mangle_dupechar_last (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_DUPECHAR_ALL: out_len = mangle_dupechar_all (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_SWITCH_FIRST: out_len = mangle_switch_first (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_SWITCH_LAST: out_len = mangle_switch_last (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_SWITCH_AT: out_len = mangle_switch_at (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_CHR_SHIFTL: out_len = mangle_chr_shiftl (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_CHR_SHIFTR: out_len = mangle_chr_shiftr (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_CHR_INCR: out_len = mangle_chr_incr (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_CHR_DECR: out_len = mangle_chr_decr (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_REPLACE_NP1: out_len = mangle_replace_np1 (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_REPLACE_NM1: out_len = mangle_replace_nm1 (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_DUPEBLOCK_FIRST: out_len = mangle_dupeblock_first (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_DUPEBLOCK_LAST: out_len = mangle_dupeblock_last (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_TITLE_SEP: out_len = mangle_title_sep (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_TITLE: out_len = mangle_title_sep (' ', p1, buf, out_len); break;
case RULE_OP_MANGLE_LREST: out_len = mangle_lrest (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_LREST_UFIRST: out_len = mangle_lrest_ufirst (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_UREST: out_len = mangle_urest (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_UREST_LFIRST: out_len = mangle_urest_lfirst (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_TREST: out_len = mangle_trest (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_TOGGLE_AT: out_len = mangle_toggle_at (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_REVERSE: out_len = mangle_reverse (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_DUPEWORD: out_len = mangle_dupeword (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_DUPEWORD_TIMES: out_len = mangle_dupeword_times (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_REFLECT: out_len = mangle_reflect (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_APPEND: out_len = mangle_append (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_PREPEND: out_len = mangle_prepend (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_ROTATE_LEFT: out_len = mangle_rotate_left (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_ROTATE_RIGHT: out_len = mangle_rotate_right (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_DELETE_FIRST: out_len = mangle_delete_first (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_DELETE_LAST: out_len = mangle_delete_last (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_DELETE_AT: out_len = mangle_delete_at (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_EXTRACT: out_len = mangle_extract (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_OMIT: out_len = mangle_omit (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_INSERT: out_len = mangle_insert (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_OVERSTRIKE: out_len = mangle_overstrike (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_TRUNCATE_AT: out_len = mangle_truncate_at (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_REPLACE: out_len = mangle_replace (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_PURGECHAR: out_len = mangle_purgechar (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_DUPECHAR_FIRST: out_len = mangle_dupechar_first (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_DUPECHAR_LAST: out_len = mangle_dupechar_last (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_DUPECHAR_ALL: out_len = mangle_dupechar_all (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_SWITCH_FIRST: out_len = mangle_switch_first (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_SWITCH_LAST: out_len = mangle_switch_last (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_SWITCH_AT: out_len = mangle_switch_at (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_CHR_SHIFTL: out_len = mangle_chr_shiftl (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_CHR_SHIFTR: out_len = mangle_chr_shiftr (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_CHR_INCR: out_len = mangle_chr_incr (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_CHR_DECR: out_len = mangle_chr_decr (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_REPLACE_NP1: out_len = mangle_replace_np1 (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_REPLACE_NM1: out_len = mangle_replace_nm1 (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_DUPEBLOCK_FIRST: out_len = mangle_dupeblock_first (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_DUPEBLOCK_LAST: out_len = mangle_dupeblock_last (p0, p1, (u8 *) buf, out_len); break;
case RULE_OP_MANGLE_TITLE_SEP: out_len = mangle_title_sep (p0, p1, buf, out_len); break;
case RULE_OP_MANGLE_TITLE: out_len = mangle_title_sep (' ', p1, buf, out_len); break;
}
return out_len;
}
int apply_rules (const u32 *cmds, u32 buf[64], const int in_len)
int apply_rules (const u32 *cmds, u32 *buf, const int in_len)
{
int out_len = in_len;
@ -581,7 +765,7 @@ int apply_rules (const u32 *cmds, u32 buf[64], const int in_len)
const u8 p0 = (cmd >> 8) & 0xff;
const u8 p1 = (cmd >> 16) & 0xff;
out_len = apply_rule (name, p0, p1, (u8 *) buf, out_len);
out_len = apply_rule (name, p0, p1, buf, out_len);
}
return out_len;