protected override BlockCipher EncryptBlock(BlockCipher block) { uint uint32_1 = BitConverter.ToUInt32(block.ToBytesArray(), 0); uint uint32_2 = BitConverter.ToUInt32(block.ToBytesArray(), 4); uint num1 = 0; uint num2 = 32; while (num2-- > 0U) { } return(new BlockCipher((DWord)uint32_1, (DWord)uint32_2)); }
protected override BlockCipher DecryptBlock(BlockCipher block) { uint uint32_1 = BitConverter.ToUInt32(block.ToBytesArray(), 0); uint uint32_2 = BitConverter.ToUInt32(block.ToBytesArray(), 4); uint num1 = 3337565984; uint num2 = 32; while (num2-- > 0U) { //uint32_2 -= (uint)(((int)uint32_1 << 4 ^ (int)(uint32_1 >> 5)) + (int)uint32_1 ^ (int)num1 + (int)this._realedKey[(IntPtr)(num1 >> 11 & 3U)]); //num1 -= 2654435769U; //uint32_1 -= (uint)(((int)uint32_2 << 4 ^ (int)(uint32_2 >> 5)) + (int)uint32_2 ^ (int)num1 + (int)this._realedKey[(IntPtr)(num1 & 3U)]); } return(new BlockCipher((DWord)uint32_1, (DWord)uint32_2)); }
protected override BlockCipher DecryptBlock(BlockCipher block) { uint uint32_1 = BitConverter.ToUInt32(block.ToBytesArray(), 0); uint uint32_2 = BitConverter.ToUInt32(block.ToBytesArray(), 4); uint ui1 = uint32_1 ^ this._pBox[17]; uint ui2 = uint32_2 ^ (this.F(ui1) ^ this._pBox[16]); uint ui3 = ui1 ^ (this.F(ui2) ^ this._pBox[15]); uint ui4 = ui2 ^ (this.F(ui3) ^ this._pBox[14]); uint ui5 = ui3 ^ (this.F(ui4) ^ this._pBox[13]); uint ui6 = ui4 ^ (this.F(ui5) ^ this._pBox[12]); uint ui7 = ui5 ^ (this.F(ui6) ^ this._pBox[11]); uint ui8 = ui6 ^ (this.F(ui7) ^ this._pBox[10]); uint ui9 = ui7 ^ (this.F(ui8) ^ this._pBox[9]); uint ui10 = ui8 ^ (this.F(ui9) ^ this._pBox[8]); uint ui11 = ui9 ^ (this.F(ui10) ^ this._pBox[7]); uint ui12 = ui10 ^ (this.F(ui11) ^ this._pBox[6]); uint ui13 = ui11 ^ (this.F(ui12) ^ this._pBox[5]); uint ui14 = ui12 ^ (this.F(ui13) ^ this._pBox[4]); uint ui15 = ui13 ^ (this.F(ui14) ^ this._pBox[3]); uint ui16 = ui14 ^ (this.F(ui15) ^ this._pBox[2]); uint num = ui15 ^ (this.F(ui16) ^ this._pBox[1]); return(new BlockCipher((DWord)(ui16 ^ this._pBox[0]), (DWord)num)); }
protected override void SetKey(byte[] key) { int count = key.Length; if (count > 56) { count = 56; } byte[] numArray = new byte[count]; Buffer.BlockCopy((Array)key, 0, (Array)numArray, 0, count); this._pBox = (uint[])BlowFish.PBox.Clone(); this._sBox = (uint[, ])BlowFish.SBox.Clone(); int index1 = 0; for (int index2 = 0; index2 < 18; ++index2) { uint num = 0; for (int index3 = 0; index3 < 4; ++index3) { num = num << 8 | (uint)numArray[index1]; if (++index1 == count) { index1 = 0; } } this._pBox[index2] = this._pBox[index2] ^ num; } BlockCipher block = new BlockCipher(64); int num1 = 0; while (num1 < 18) { block = this.EncryptBlock(block); uint[] pBox1 = this._pBox; int index2 = num1; int num2 = index2 + 1; int uint32_1 = (int)BitConverter.ToUInt32(block.ToBytesArray(), 0); pBox1[index2] = (uint)uint32_1; uint[] pBox2 = this._pBox; int index3 = num2; num1 = index3 + 1; int uint32_2 = (int)BitConverter.ToUInt32(block.ToBytesArray(), 4); pBox2[index3] = (uint)uint32_2; } for (int index2 = 0; index2 < 4; ++index2) { int num2 = 0; while (num2 < 256) { block = this.EncryptBlock(block); uint[,] sBox1 = this._sBox; int index3 = index2; int index4 = num2; int num3 = index4 + 1; int uint32_1 = (int)BitConverter.ToUInt32(block.ToBytesArray(), 0); sBox1[index3, index4] = (uint)uint32_1; uint[,] sBox2 = this._sBox; int index5 = index2; int index6 = num3; num2 = index6 + 1; int uint32_2 = (int)BitConverter.ToUInt32(block.ToBytesArray(), 4); sBox2[index5, index6] = (uint)uint32_2; } } }