/// <summary>
        /// Runs a Kerberos implemented RC4 Encryption
        /// </summary>
        /// <param name="xConfounder">Outputs new Confounder</param>
        /// <param name="xPayload">Outputs the payload</param>
        /// <param name="x">RC4 Reference</param>
        /// <returns></returns>
        public static byte[] KerberosEncrypt(this RC4 x, ref byte[] xConfounder, ref byte[] xPayload)
        {
            List <byte> xIn = new List <byte>();

            xIn.AddRange(xConfounder);
            xIn.AddRange(xPayload);
            return(x.RunAlgorithm(xIn.ToArray()));
        }
 /// <summary>
 /// Runs a Kerberos implemented RC4 decryption
 /// </summary>
 /// <param name="xConfounder">The confounder input</param>
 /// <param name="xPayload">The payload input</param>
 /// <param name="x">RC4 reference</param>
 /// <param name="xData">Data to be decrypted</param>
 /// <param name="xConLen">Length of the Confounder</param>
 /// <returns></returns>
 public static bool KerberosDecrypt(this RC4 x, byte[] xData, out byte[] xConfounder, int xConLen, out byte[] xPayload)
 {
     xPayload    = new byte[0];
     xConfounder = new byte[0];
     try
     {
         DJsIO xOut = new DJsIO(x.RunAlgorithm(xData), true);
         xOut.Position = 0;
         xConfounder   = xOut.ReadBytes(xConLen);
         xPayload      = xOut.ReadBytes(xData.Length - xConLen);
         xOut.Dispose();
     }
     catch { return(false); }
     return(true);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Runs an RC4 on the specified data using the specified key
 /// </summary>
 /// <param name="xKey"></param>
 /// <param name="xData"></param>
 /// <returns></returns>
 public static byte[] RunAlgorithm(byte[] xKey, byte[] xData)
 {
     RC4 xrc4 = new RC4(xKey);
     return xrc4.RunAlgorithm(xData);
 }