2002-11-17 Sebastien Pouliot <spouliot@videotron.ca>
[mono.git] / mcs / class / corlib / System.Security.Cryptography / RSAPKCS1KeyExchangeDeformatter.cs
index ae21654fb3ba5b9f650cd39fb020175f80c0e855..d9ae1ccbeadc95615663a0115cbb313f3dd589ee 100644 (file)
@@ -41,28 +41,7 @@ public class RSAPKCS1KeyExchangeDeformatter : AsymmetricKeyExchangeDeformatter {
        {
                if (rsa == null)
                        throw new CryptographicException ();
-               byte[] mask = rsa.DecryptValue (rgbData);
-               // it's normal if length = expected length - 1
-               // because the first byte is 0x00 and, as such, is ignored
-               // as a BigInteger
-               // First byte will be 0x02 (because 0x00 was ignored by BigInteger)
-               if (mask[0] != 0x02)
-                       return null;
-               // Next will be nonzero random octets(at least 8 bytes)
-               // 0x00 marker
-               int i = 1;
-               for (; i < mask.Length; i++) {
-                       if (mask[i] == 0x00)
-                               break;
-               }
-               byte[] secret = null;
-               // Last bytes will be the secret
-               if (mask[i] == 0x00) {
-                       int len = mask.Length - i;
-                       secret = new byte [len];
-                       Array.Copy (mask, i, secret, 0, len);
-               }
-               return secret;
+               return PKCS1.Decrypt_v15 (rsa, rgbData);
        }
 
        public override void SetKey (AsymmetricAlgorithm key)