Print this page
pass 2
@@ -80,11 +80,10 @@
Blowfish_encipher(c, xl, xr)
blf_ctx *c;
uint32_t *xl;
uint32_t *xr;
{
-/* CRYPT DELETE START */
uint32_t Xl;
uint32_t Xr;
uint32_t *s = c->S[0];
uint32_t *p = c->P;
@@ -101,20 +100,18 @@
BLFRND(s, p, Xr, Xl, 13); BLFRND(s, p, Xl, Xr, 14);
BLFRND(s, p, Xr, Xl, 15); BLFRND(s, p, Xl, Xr, 16);
*xl = Xr ^ p[17];
*xr = Xl;
-/* CRYPT DELETE END */
}
void
Blowfish_decipher(c, xl, xr)
blf_ctx *c;
uint32_t *xl;
uint32_t *xr;
{
-/* CRYPT DELETE START */
uint32_t Xl;
uint32_t Xr;
uint32_t *s = c->S[0];
uint32_t *p = c->P;
@@ -131,19 +128,16 @@
BLFRND(s, p, Xr, Xl, 4); BLFRND(s, p, Xl, Xr, 3);
BLFRND(s, p, Xr, Xl, 2); BLFRND(s, p, Xl, Xr, 1);
*xl = Xr ^ p[0];
*xr = Xl;
-/* CRYPT DELETE END */
}
void
Blowfish_initstate(c)
blf_ctx *c;
{
-/* CRYPT DELETE START */
-
/* P-box and S-box tables initialized with digits of Pi */
const blf_ctx initstate =
{ {
@@ -415,12 +409,10 @@
0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
0x9216d5d9, 0x8979fb1b
} };
*c = initstate;
-
-/* CRYPT DELETE END */
}
uint32_t
Blowfish_stream2word(const uint8_t *data, uint16_t databytes, uint16_t *current)
{
@@ -427,28 +419,25 @@
uint8_t i;
uint16_t j;
uint32_t temp;
temp = 0x00000000;
-/* CRYPT DELETE START */
j = *current;
for (i = 0; i < 4; i++, j++) {
if (j >= databytes)
j = 0;
temp = (temp << 8) | data[j];
}
*current = j;
-/* CRYPT DELETE END */
return temp;
}
void
Blowfish_expand0state(blf_ctx *c, const uint8_t *key, uint16_t keybytes)
{
-/* CRYPT DELETE START */
uint16_t i;
uint16_t j;
uint16_t k;
uint32_t temp;
uint32_t datal;
@@ -477,19 +466,17 @@
c->S[i][k] = datal;
c->S[i][k + 1] = datar;
}
}
-/* CRYPT DELETE END */
}
void
Blowfish_expandstate(blf_ctx *c, const uint8_t *data, uint16_t databytes,
const uint8_t *key, uint16_t keybytes)
{
-/* CRYPT DELETE START */
uint16_t i;
uint16_t j;
uint16_t k;
uint32_t temp;
uint32_t datal;
@@ -522,60 +509,51 @@
c->S[i][k] = datal;
c->S[i][k + 1] = datar;
}
}
-
-/* CRYPT DELETE END */
}
void
blf_key(blf_ctx *c, const uint8_t *k, uint16_t len)
{
-/* CRYPT DELETE START */
/* Initialize S-boxes and subkeys with Pi */
Blowfish_initstate(c);
/* Transform S-boxes and subkeys with key */
Blowfish_expand0state(c, k, len);
-/* CRYPT DELETE END */
}
void
blf_enc(blf_ctx *c, uint32_t *data, uint16_t blocks)
{
-/* CRYPT DELETE START */
uint32_t *d;
uint16_t i;
d = data;
for (i = 0; i < blocks; i++) {
Blowfish_encipher(c, d, d + 1);
d += 2;
}
-/* CRYPT DELETE END */
}
void
blf_dec(blf_ctx *c, uint32_t *data, uint16_t blocks)
{
-/* CRYPT DELETE START */
uint32_t *d;
uint16_t i;
d = data;
for (i = 0; i < blocks; i++) {
Blowfish_decipher(c, d, d + 1);
d += 2;
}
-/* CRYPT DELETE END */
}
void
blf_ecb_encrypt(blf_ctx *c, uint8_t *data, uint32_t len)
{
-/* CRYPT DELETE START */
uint32_t l, r;
uint32_t i;
for (i = 0; i < len; i += 8) {
l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
@@ -589,17 +567,15 @@
data[5] = r >> 16 & 0xff;
data[6] = r >> 8 & 0xff;
data[7] = r & 0xff;
data += 8;
}
-/* CRYPT DELETE END */
}
void
blf_ecb_decrypt(blf_ctx *c, uint8_t *data, uint32_t len)
{
-/* CRYPT DELETE START */
uint32_t l, r;
uint32_t i;
for (i = 0; i < len; i += 8) {
l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
@@ -613,17 +589,15 @@
data[5] = r >> 16 & 0xff;
data[6] = r >> 8 & 0xff;
data[7] = r & 0xff;
data += 8;
}
-/* CRYPT DELETE END */
}
void
blf_cbc_encrypt(blf_ctx *c, uint8_t *iv, uint8_t *data, uint32_t len)
{
-/* CRYPT DELETE START */
uint32_t l, r;
uint32_t i, j;
for (i = 0; i < len; i += 8) {
for (j = 0; j < 8; j++)
@@ -640,17 +614,15 @@
data[6] = r >> 8 & 0xff;
data[7] = r & 0xff;
iv = data;
data += 8;
}
-/* CRYPT DELETE END */
}
void
blf_cbc_decrypt(blf_ctx *c, uint8_t *iva, uint8_t *data, uint32_t len)
{
-/* CRYPT DELETE START */
uint32_t l, r;
uint8_t *iv;
uint32_t i, j;
iv = data + len - 16;
@@ -683,14 +655,12 @@
data[5] = r >> 16 & 0xff;
data[6] = r >> 8 & 0xff;
data[7] = r & 0xff;
for (j = 0; j < 8; j++)
data[j] ^= iva[j];
-/* CRYPT DELETE END */
}
-/* CRYPT DELETE START */
#if 0
void
report(uint32_t data[], uint16_t len)
{
uint16_t i;
@@ -730,6 +700,5 @@
report(data2, 2);
blf_dec(&c, data2, 1);
report(data2, 2);
}
#endif
-/* CRYPT DELETE END */