2 // RSAPKCS1KeyExchangeFormatter.cs: Handles PKCS#1 v.1.5 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 System.Globalization;
13 using Mono.Security.Cryptography;
15 namespace System.Security.Cryptography {
17 // LAMESPEC: There seems no way to select a hash algorithm. The default
18 // algorithm, is SHA1 because the class use the PKCS1MaskGenerationMethod -
19 // which default to SHA1.
20 public class RSAPKCS1KeyExchangeFormatter: AsymmetricKeyExchangeFormatter
23 private RandomNumberGenerator random;
25 public RSAPKCS1KeyExchangeFormatter ()
29 public RSAPKCS1KeyExchangeFormatter (AsymmetricAlgorithm key)
34 public RandomNumberGenerator Rng
36 get { return random; }
37 set { random = value; }
40 public override string Parameters
42 get { return "<enc:KeyEncryptionMethod enc:Algorithm=\"http://www.microsoft.com/xml/security/algorithm/PKCS1-v1.5-KeyEx\" xmlns:enc=\"http://www.microsoft.com/xml/security/encryption/v1.0\" />"; }
45 public override byte[] CreateKeyExchange (byte[] rgbData)
48 random = RandomNumberGenerator.Create (); // create default
49 return PKCS1.Encrypt_v15 (rsa, random, rgbData);
52 public override byte[] CreateKeyExchange (byte[] rgbData, Type symAlgType)
54 // documentation says that symAlgType is not used !?!
55 return CreateKeyExchange (rgbData);
58 public override void SetKey (AsymmetricAlgorithm key)