2 // System.Security.Cryptography.CspParameters.cs
\r
5 // Thomas Neidhart (tome@sbox.tugraz.at)
\r
6 // Sebastien Pouliot <sebastien@ximian.com>
8 // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System.Runtime.InteropServices;
31 using System.Security.AccessControl;
33 namespace System.Security.Cryptography {
\r
36 public sealed class CspParameters {
38 private CspProviderFlags _Flags;
\r
40 public CspParameters ()
45 public CspParameters (int dwTypeIn)
46 : this (dwTypeIn, null)
50 public CspParameters (int dwTypeIn, string strProviderNameIn)
51 : this (dwTypeIn, null, null)
55 public CspParameters (int dwTypeIn, string strProviderNameIn, string strContainerNameIn)
\r
57 ProviderType = dwTypeIn;
\r
58 ProviderName = strProviderNameIn;
\r
59 KeyContainerName = strContainerNameIn;
\r
61 // not defined in specs, only tested from M$ impl
\r
65 public string KeyContainerName;
\r
67 public int KeyNumber;
\r
69 public string ProviderName;
\r
71 public int ProviderType;
\r
73 public CspProviderFlags Flags {
\r
74 get { return _Flags; }
\r
75 set { _Flags = value; }
\r
78 private SecureString _password;
79 private IntPtr _windowHandle;
81 public CspParameters (int providerType, string providerName, string keyContainerName,
82 CryptoKeySecurity cryptoKeySecurity, IntPtr parentWindowHandle)
83 : this (providerType, providerName, keyContainerName)
85 if (cryptoKeySecurity != null)
86 CryptoKeySecurity = cryptoKeySecurity;
87 _windowHandle = parentWindowHandle;
90 public CspParameters (int providerType, string providerName, string keyContainerName,
91 CryptoKeySecurity cryptoKeySecurity, SecureString keyPassword)
92 : this (providerType, providerName, keyContainerName)
94 if (cryptoKeySecurity != null)
95 CryptoKeySecurity = cryptoKeySecurity;
96 _password = keyPassword;
99 internal CspParameters(CspParameters parameters)
\r
100 : this(parameters.ProviderType, parameters.ProviderName, parameters.KeyContainerName)
\r
102 if (parameters.CryptoKeySecurity != null)
\r
103 CryptoKeySecurity = parameters.CryptoKeySecurity;
\r
105 _Flags = parameters.Flags;
\r
106 KeyNumber = parameters.KeyNumber;
\r
107 _password = parameters.KeyPassword;
\r
108 _windowHandle = parameters.ParentWindowHandle;
\r
111 [MonoTODO ("access control isn't implemented")]
112 public CryptoKeySecurity CryptoKeySecurity {
113 get { throw new NotImplementedException (); }
114 set { throw new NotImplementedException (); }
117 public SecureString KeyPassword {
118 get { return _password; }
119 set { _password = value; }
122 public IntPtr ParentWindowHandle {
123 get { return _windowHandle; }
124 set { _windowHandle = value; }