using System.Security.Cryptography;
using System.Security.Permissions;
using System.Runtime.InteropServices;
+using System.Runtime.Serialization;
using Mono.Security;
using Mono.Security.Cryptography;
namespace System.Reflection {
-#if NET_2_0
[ComVisible (true)]
-#endif
[Serializable]
-public class StrongNameKeyPair
+public class StrongNameKeyPair : ISerializable, IDeserializationCallback
{
private byte[] _publicKey;
private string _keyPairContainer;
_keyPairContainer = keyPairContainer;
GetRSA ();
}
-
+ protected StrongNameKeyPair (SerializationInfo info, StreamingContext context)
+ {
+ _publicKey = (byte []) info.GetValue ("_publicKey", typeof (byte []));
+ _keyPairContainer = info.GetString ("_keyPairContainer");
+ _keyPairExported = info.GetBoolean ("_keyPairExported");
+ _keyPairArray = (byte []) info.GetValue ("_keyPairArray", typeof (byte []));
+ }
+
+ void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)
+ {
+ info.AddValue ("_publicKey", _publicKey, typeof (byte []));
+ info.AddValue ("_keyPairContainer", _keyPairContainer);
+ info.AddValue ("_keyPairExported", _keyPairExported);
+ info.AddValue ("_keyPairArray", _keyPairArray, typeof (byte []));
+ }
+
+ void IDeserializationCallback.OnDeserialization (object sender)
+ {
+ }
+
private RSA GetRSA ()
{
if (_rsa != null) return _rsa;
_keyPairArray = null;
}
}
+#if !NET_2_1
else if (_keyPairContainer != null) {
CspParameters csp = new CspParameters ();
csp.KeyContainerName = _keyPairContainer;
_rsa = new RSACryptoServiceProvider (csp);
}
+#endif
return _rsa;
}