private void DesBegin(byte[] inputBuffer, int inputOffset, out uint L, out uint R) { ulong p = BitPacking.UInt64FromBEBytes(inputBuffer, inputOffset); ulong pp = Permute(IP, p, 64); p = 0; L = (uint)(pp >> 32); R = (uint)pp; }
void ExpandKey(byte[] key) { Dispose(); int[] pc1 = PC1, rotations = Rotations, pc2 = PC2; uint[] c = new uint[16], d = new uint[16]; ulong[] kex = new ulong[16]; ulong k = BitPacking.UInt64FromBEBytes(key, 0); ulong kp = Permute(PC1, k, 64); k = 0; uint cn = (uint)(kp >> 28); uint dn = (uint)(kp & 0xfffffff); kp = 0; for (int i = 0; i < c.Length; i++) { c[i] = cn = R(cn, rotations[i]); } cn = 0; for (int i = 0; i < c.Length; i++) { d[i] = dn = R(dn, rotations[i]); } dn = 0; for (int i = 0; i < kex.Length; i++) { ulong cd = (ulong)c[i] << 28 | d[i]; kex[i] = Permute(PC2, cd, 56); cd = 0; } Security.Clear(c); Security.Clear(d); Kex = kex; }