// we don't need no craftcontent! public Packet[] Decrypt(byte[] bKey, SymmetricAlgorithm saAlgo) { saAlgo.Mode = CipherMode.OpenPGP_CFB; saAlgo.Key = bKey; ICryptoTransform ictDecrypt = saAlgo.CreateDecryptor(); int iBS = saAlgo.BlockSize >> 3; int iLength = bBody.Length - iBS - 2; byte[] bOutput = new byte[bBody.Length]; ictDecrypt.TransformBlock(bBody, 0, bBody.Length, ref bOutput, 0); byte[] bFinal = new byte[iLength]; Array.Copy(bOutput, bFinal, iLength); Packet[] pReturn = Packet.ParsePackets(bFinal); return pReturn; }
public SymmetricTransform(SymmetricAlgorithm symmAlgo, bool encryption, byte[] rgbIV) { algo = symmAlgo; encrypt = encryption; BlockSizeByte = (algo.BlockSize >> 3); // mode buffers temp = new byte [BlockSizeByte]; Array.Copy (rgbIV, 0, temp, 0, BlockSizeByte); temp2 = new byte [BlockSizeByte]; FeedBackByte = (algo.FeedbackSize >> 3); FeedBackIter = (int) BlockSizeByte / FeedBackByte; //FeedBackIter = 1; // transform buffers workBuff = new byte [BlockSizeByte]; workout = new byte [BlockSizeByte]; //OpenPGP CFB needs an all zero IV if (algo.Mode == CipherMode.OpenPGP_CFB) { algo.IV = new byte[algo.BlockSize >> 3]; } // needed for openpgp's ciphertext feedback mode openPGPStart = new byte[(algo.BlockSize >> 3) + 2]; }
// Default constructor. internal DESTransform(SymmetricAlgorithm symmAlgo, bool encryption, byte[] key, byte[] iv) : base(symmAlgo, encryption, iv) { keySchedule = new byte [KEY_BYTE_SIZE * 16]; byteBuff = new byte [BLOCK_BYTE_SIZE]; dwordBuff = new uint [BLOCK_BYTE_SIZE / 4]; SetKey (key); }