lalala
[mono.git] / mcs / class / corlib / System.Security.Cryptography / RSAOAEPKeyExchangeDeformatter.cs
index 31540254df70ae5092fbdfc0eef96c697d8846c7..beb1407a2987b7b74dceb5db631537bccd317d0a 100644 (file)
@@ -8,47 +8,46 @@
 //
 
 using System;
+using Mono.Security.Cryptography;
 
 namespace System.Security.Cryptography { 
 
-public class RSAOAEPKeyExchangeDeformatter : AsymmetricKeyExchangeDeformatter {
-
-       private RSA rsa;
-       private string param;
-
-       public RSAOAEPKeyExchangeDeformatter ()
-       {
-               rsa = null;
-       }
-
-       public RSAOAEPKeyExchangeDeformatter (AsymmetricAlgorithm key) 
-       {
-               SetKey (key);
-       }
-
-       public override string Parameters {
-               get { return param; }
-               set { param = value; }
-       }
-
-       public override byte[] DecryptKeyExchange (byte[] rgbData) 
-       {
-               if (rsa == null)
-                       throw new CryptographicException ();
-               byte[] mask = rsa.DecryptValue (rgbData);
-               byte[] secret = null;
-               // TODO retreive key from mask
-               return secret;
-       }
-
-       public override void SetKey (AsymmetricAlgorithm key) 
-       {
-               if (key is RSA) {
-                       rsa = (RSA)key;
+       public class RSAOAEPKeyExchangeDeformatter : AsymmetricKeyExchangeDeformatter {
+       
+               private RSA rsa;
+               private string param;
+       
+               public RSAOAEPKeyExchangeDeformatter ()
+               {
+                       rsa = null;
+               }
+       
+               public RSAOAEPKeyExchangeDeformatter (AsymmetricAlgorithm key) 
+               {
+                       SetKey (key);
+               }
+       
+               public override string Parameters {
+                       get { return param; }
+                       set { param = value; }
+               }
+       
+               public override byte[] DecryptKeyExchange (byte[] rgbData) 
+               {
+                       if (rsa == null)
+                               throw new CryptographicException ();
+       
+                       SHA1 sha1 = SHA1.Create ();
+                       return PKCS1.Decrypt_OAEP (rsa, sha1, rgbData);
+               }
+       
+               public override void SetKey (AsymmetricAlgorithm key) 
+               {
+                       if (key is RSA) {
+                               rsa = (RSA)key;
+                       }
+                       else
+                               throw new CryptographicException ();
                }
-               else
-                       throw new CryptographicException ();
        }
 }
-
-}