sharkal | 13 Jun 2012 12:15
Favicon
Gravatar

TripleDESCryptoServiceProvider _NewEncryptor returns null

Hi,
i think mono has a bug with the private method "_NewEncryptor", since i get
null, when i want to get the method by "GetMethod":

         TripleDES tripleDESalg = TripleDES.Create();
          TripleDESCryptoServiceProvider sm = tripleDESalg as
TripleDESCryptoServiceProvider;
          sm.Mode = CipherMode.ECB;
          sm.Padding = PaddingMode.None;
          *MethodInfo mi = sm.GetType().GetMethod("_NewEncryptor",
BindingFlags.NonPublic | BindingFlags.Instance);*
          if (mi != null)
          {
             object[] Par = { keyValue, sm.Mode, iVValue, sm.FeedbackSize, 0
};          // encrypt 0
             ICryptoTransform trans = mi.Invoke(sm, Par) as
ICryptoTransform;
             // CreateEnrypt doesn't work for Weak Keys
             //ICryptoTransform trans = sm.CreateEncryptor(keyValue,
iVValue);  
             byte[] resultArray = trans.TransformFinalBlock(bytes, 0,
bytes.Length);
             return resultArray;
          }
          else
          {
              throw new Exception("Decryption failed. Method _NewEncryptor
not found");
          }

(Continue reading)


Gmane