2 // RSAOAEPKeyExchangeFormatter.cs - Handles OAEP keyex encryption.
5 // Sebastien Pouliot <sebastien@ximian.com>
7 // (C) 2002 Motus Technologies Inc. (http://www.motus.com)
8 // (C) 2004 Novell (http://www.novell.com)
12 using Mono.Security.Cryptography;
14 namespace System.Security.Cryptography {
16 public class RSAOAEPKeyExchangeFormatter : AsymmetricKeyExchangeFormatter {
19 private RandomNumberGenerator random;
22 public RSAOAEPKeyExchangeFormatter ()
27 public RSAOAEPKeyExchangeFormatter (AsymmetricAlgorithm key)
32 public byte[] Parameter {
34 set { param = value; }
37 public override string Parameters {
41 public RandomNumberGenerator Rng {
42 get { return random; }
43 set { random = value; }
46 public override byte[] CreateKeyExchange (byte[] rgbData)
49 random = RandomNumberGenerator.Create (); // create default
51 SHA1 sha1 = SHA1.Create ();
52 return PKCS1.Encrypt_OAEP (rsa, sha1, random, rgbData);
55 public override byte[] CreateKeyExchange (byte[] rgbData, Type symAlgType)
57 // documentation says that symAlgType is not used !?!
58 return CreateKeyExchange (rgbData);
61 public override void SetKey (AsymmetricAlgorithm key)