31 private const string MachineConfigFilename =
"machine.config";
33 private static volatile string version =
null;
35 private static volatile bool s_fipsAlgorithmPolicy;
37 private static volatile bool s_haveFipsAlgorithmPolicy;
39 private static object s_InternalSyncObject;
46 [SecuritySafeCritical]
49 if (!s_haveFipsAlgorithmPolicy)
51 if (Utils._GetEnforceFipsPolicySetting())
56 uint num = Win32Native.BCryptGetFipsAlgorithmMode(out pfEnabled);
57 bool flag = num == 0 || num == 3221225524u;
58 s_fipsAlgorithmPolicy = (!flag | pfEnabled);
59 s_haveFipsAlgorithmPolicy =
true;
63 s_fipsAlgorithmPolicy = Utils.ReadLegacyFipsPolicy();
64 s_haveFipsAlgorithmPolicy =
true;
69 s_fipsAlgorithmPolicy =
false;
70 s_haveFipsAlgorithmPolicy =
true;
73 return s_fipsAlgorithmPolicy;
90 private static object InternalSyncObject
94 if (s_InternalSyncObject ==
null)
96 object value =
new object();
99 return s_InternalSyncObject;
107 if (defaultOidHT ==
null)
110 dictionary.Add(
"SHA",
"1.3.14.3.2.26");
111 dictionary.Add(
"SHA1",
"1.3.14.3.2.26");
112 dictionary.Add(
"System.Security.Cryptography.SHA1",
"1.3.14.3.2.26");
113 dictionary.Add(
"System.Security.Cryptography.SHA1CryptoServiceProvider",
"1.3.14.3.2.26");
114 dictionary.Add(
"System.Security.Cryptography.SHA1Cng",
"1.3.14.3.2.26");
115 dictionary.Add(
"System.Security.Cryptography.SHA1Managed",
"1.3.14.3.2.26");
116 dictionary.Add(
"SHA256",
"2.16.840.1.101.3.4.2.1");
117 dictionary.Add(
"System.Security.Cryptography.SHA256",
"2.16.840.1.101.3.4.2.1");
118 dictionary.Add(
"System.Security.Cryptography.SHA256CryptoServiceProvider",
"2.16.840.1.101.3.4.2.1");
119 dictionary.Add(
"System.Security.Cryptography.SHA256Cng",
"2.16.840.1.101.3.4.2.1");
120 dictionary.Add(
"System.Security.Cryptography.SHA256Managed",
"2.16.840.1.101.3.4.2.1");
121 dictionary.Add(
"SHA384",
"2.16.840.1.101.3.4.2.2");
122 dictionary.Add(
"System.Security.Cryptography.SHA384",
"2.16.840.1.101.3.4.2.2");
123 dictionary.Add(
"System.Security.Cryptography.SHA384CryptoServiceProvider",
"2.16.840.1.101.3.4.2.2");
124 dictionary.Add(
"System.Security.Cryptography.SHA384Cng",
"2.16.840.1.101.3.4.2.2");
125 dictionary.Add(
"System.Security.Cryptography.SHA384Managed",
"2.16.840.1.101.3.4.2.2");
126 dictionary.Add(
"SHA512",
"2.16.840.1.101.3.4.2.3");
127 dictionary.Add(
"System.Security.Cryptography.SHA512",
"2.16.840.1.101.3.4.2.3");
128 dictionary.Add(
"System.Security.Cryptography.SHA512CryptoServiceProvider",
"2.16.840.1.101.3.4.2.3");
129 dictionary.Add(
"System.Security.Cryptography.SHA512Cng",
"2.16.840.1.101.3.4.2.3");
130 dictionary.Add(
"System.Security.Cryptography.SHA512Managed",
"2.16.840.1.101.3.4.2.3");
131 dictionary.Add(
"RIPEMD160",
"1.3.36.3.2.1");
132 dictionary.Add(
"System.Security.Cryptography.RIPEMD160",
"1.3.36.3.2.1");
133 dictionary.Add(
"System.Security.Cryptography.RIPEMD160Managed",
"1.3.36.3.2.1");
134 dictionary.Add(
"MD5",
"1.2.840.113549.2.5");
135 dictionary.Add(
"System.Security.Cryptography.MD5",
"1.2.840.113549.2.5");
136 dictionary.Add(
"System.Security.Cryptography.MD5CryptoServiceProvider",
"1.2.840.113549.2.5");
137 dictionary.Add(
"System.Security.Cryptography.MD5Managed",
"1.2.840.113549.2.5");
138 dictionary.Add(
"TripleDESKeyWrap",
"1.2.840.113549.1.9.16.3.6");
139 dictionary.Add(
"RC2",
"1.2.840.113549.3.2");
140 dictionary.Add(
"System.Security.Cryptography.RC2CryptoServiceProvider",
"1.2.840.113549.3.2");
141 dictionary.Add(
"DES",
"1.3.14.3.2.7");
142 dictionary.Add(
"System.Security.Cryptography.DESCryptoServiceProvider",
"1.3.14.3.2.7");
143 dictionary.Add(
"TripleDES",
"1.2.840.113549.3.7");
144 dictionary.Add(
"System.Security.Cryptography.TripleDESCryptoServiceProvider",
"1.2.840.113549.3.7");
145 defaultOidHT = dictionary;
155 if (defaultNameHT ==
null)
158 Type typeFromHandle = typeof(SHA1CryptoServiceProvider);
159 Type typeFromHandle2 = typeof(MD5CryptoServiceProvider);
160 Type typeFromHandle3 = typeof(RIPEMD160Managed);
161 Type typeFromHandle4 = typeof(HMACMD5);
162 Type typeFromHandle5 = typeof(HMACRIPEMD160);
163 Type typeFromHandle6 = typeof(HMACSHA1);
164 Type typeFromHandle7 = typeof(HMACSHA256);
165 Type typeFromHandle8 = typeof(HMACSHA384);
166 Type typeFromHandle9 = typeof(HMACSHA512);
167 Type typeFromHandle10 = typeof(MACTripleDES);
168 Type typeFromHandle11 = typeof(RSACryptoServiceProvider);
169 Type typeFromHandle12 = typeof(DSACryptoServiceProvider);
170 Type typeFromHandle13 = typeof(DESCryptoServiceProvider);
171 Type typeFromHandle14 = typeof(TripleDESCryptoServiceProvider);
172 Type typeFromHandle15 = typeof(RC2CryptoServiceProvider);
173 Type typeFromHandle16 = typeof(RijndaelManaged);
174 Type typeFromHandle17 = typeof(DSASignatureDescription);
175 Type typeFromHandle18 = typeof(RSAPKCS1SHA1SignatureDescription);
176 Type typeFromHandle19 = typeof(RSAPKCS1SHA256SignatureDescription);
177 Type typeFromHandle20 = typeof(RSAPKCS1SHA384SignatureDescription);
178 Type typeFromHandle21 = typeof(RSAPKCS1SHA512SignatureDescription);
179 Type typeFromHandle22 = typeof(RNGCryptoServiceProvider);
180 string value =
"System.Security.Cryptography.AesCryptoServiceProvider, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
181 string value2 =
"System.Security.Cryptography.AesManaged, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
182 string value3 =
"System.Security.Cryptography.ECDiffieHellmanCng, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
183 string value4 =
"System.Security.Cryptography.ECDsaCng, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
184 string value5 =
"System.Security.Cryptography.MD5Cng, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
185 string value6 =
"System.Security.Cryptography.SHA1Cng, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
186 string text =
"System.Security.Cryptography.SHA256Cng, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
187 string value7 =
"System.Security.Cryptography.SHA256CryptoServiceProvider, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
188 string text2 =
"System.Security.Cryptography.SHA384Cng, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
189 string value8 =
"System.Security.Cryptography.SHA384CryptoServiceProvider, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
190 string text3 =
"System.Security.Cryptography.SHA512Cng, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
191 string value9 =
"System.Security.Cryptography.SHA512CryptoServiceProvider, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
193 object value10 = typeof(SHA256Managed);
194 if (allowOnlyFipsAlgorithms)
198 object value11 = allowOnlyFipsAlgorithms ? ((object)text2) : ((object)typeof(SHA384Managed));
199 object value12 = allowOnlyFipsAlgorithms ? ((object)text3) : ((object)typeof(SHA512Managed));
200 string value13 =
"System.Security.Cryptography.DpapiDataProtector, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
201 dictionary.Add(
"RandomNumberGenerator", typeFromHandle22);
202 dictionary.Add(
"System.Security.Cryptography.RandomNumberGenerator", typeFromHandle22);
203 dictionary.Add(
"SHA", typeFromHandle);
204 dictionary.Add(
"SHA1", typeFromHandle);
205 dictionary.Add(
"System.Security.Cryptography.SHA1", typeFromHandle);
206 dictionary.Add(
"System.Security.Cryptography.SHA1Cng", value6);
207 dictionary.Add(
"System.Security.Cryptography.HashAlgorithm", typeFromHandle);
208 dictionary.Add(
"MD5", typeFromHandle2);
209 dictionary.Add(
"System.Security.Cryptography.MD5", typeFromHandle2);
210 dictionary.Add(
"System.Security.Cryptography.MD5Cng", value5);
211 dictionary.Add(
"SHA256", value10);
212 dictionary.Add(
"SHA-256", value10);
213 dictionary.Add(
"System.Security.Cryptography.SHA256", value10);
214 dictionary.Add(
"System.Security.Cryptography.SHA256Cng", text);
215 dictionary.Add(
"System.Security.Cryptography.SHA256CryptoServiceProvider", value7);
216 dictionary.Add(
"SHA384", value11);
217 dictionary.Add(
"SHA-384", value11);
218 dictionary.Add(
"System.Security.Cryptography.SHA384", value11);
219 dictionary.Add(
"System.Security.Cryptography.SHA384Cng", text2);
220 dictionary.Add(
"System.Security.Cryptography.SHA384CryptoServiceProvider", value8);
221 dictionary.Add(
"SHA512", value12);
222 dictionary.Add(
"SHA-512", value12);
223 dictionary.Add(
"System.Security.Cryptography.SHA512", value12);
224 dictionary.Add(
"System.Security.Cryptography.SHA512Cng", text3);
225 dictionary.Add(
"System.Security.Cryptography.SHA512CryptoServiceProvider", value9);
226 dictionary.Add(
"RIPEMD160", typeFromHandle3);
227 dictionary.Add(
"RIPEMD-160", typeFromHandle3);
228 dictionary.Add(
"System.Security.Cryptography.RIPEMD160", typeFromHandle3);
229 dictionary.Add(
"System.Security.Cryptography.RIPEMD160Managed", typeFromHandle3);
230 dictionary.Add(
"System.Security.Cryptography.HMAC", typeFromHandle6);
231 dictionary.Add(
"System.Security.Cryptography.KeyedHashAlgorithm", typeFromHandle6);
232 dictionary.Add(
"HMACMD5", typeFromHandle4);
233 dictionary.Add(
"System.Security.Cryptography.HMACMD5", typeFromHandle4);
234 dictionary.Add(
"HMACRIPEMD160", typeFromHandle5);
235 dictionary.Add(
"System.Security.Cryptography.HMACRIPEMD160", typeFromHandle5);
236 dictionary.Add(
"HMACSHA1", typeFromHandle6);
237 dictionary.Add(
"System.Security.Cryptography.HMACSHA1", typeFromHandle6);
238 dictionary.Add(
"HMACSHA256", typeFromHandle7);
239 dictionary.Add(
"System.Security.Cryptography.HMACSHA256", typeFromHandle7);
240 dictionary.Add(
"HMACSHA384", typeFromHandle8);
241 dictionary.Add(
"System.Security.Cryptography.HMACSHA384", typeFromHandle8);
242 dictionary.Add(
"HMACSHA512", typeFromHandle9);
243 dictionary.Add(
"System.Security.Cryptography.HMACSHA512", typeFromHandle9);
244 dictionary.Add(
"MACTripleDES", typeFromHandle10);
245 dictionary.Add(
"System.Security.Cryptography.MACTripleDES", typeFromHandle10);
246 dictionary.Add(
"RSA", typeFromHandle11);
247 dictionary.Add(
"System.Security.Cryptography.RSA", typeFromHandle11);
248 dictionary.Add(
"System.Security.Cryptography.AsymmetricAlgorithm", typeFromHandle11);
249 dictionary.Add(
"DSA", typeFromHandle12);
250 dictionary.Add(
"System.Security.Cryptography.DSA", typeFromHandle12);
251 dictionary.Add(
"ECDsa", value4);
252 dictionary.Add(
"ECDsaCng", value4);
253 dictionary.Add(
"System.Security.Cryptography.ECDsaCng", value4);
254 dictionary.Add(
"ECDH", value3);
255 dictionary.Add(
"ECDiffieHellman", value3);
256 dictionary.Add(
"ECDiffieHellmanCng", value3);
257 dictionary.Add(
"System.Security.Cryptography.ECDiffieHellmanCng", value3);
258 dictionary.Add(
"DES", typeFromHandle13);
259 dictionary.Add(
"System.Security.Cryptography.DES", typeFromHandle13);
260 dictionary.Add(
"3DES", typeFromHandle14);
261 dictionary.Add(
"TripleDES", typeFromHandle14);
262 dictionary.Add(
"Triple DES", typeFromHandle14);
263 dictionary.Add(
"System.Security.Cryptography.TripleDES", typeFromHandle14);
264 dictionary.Add(
"RC2", typeFromHandle15);
265 dictionary.Add(
"System.Security.Cryptography.RC2", typeFromHandle15);
266 dictionary.Add(
"Rijndael", typeFromHandle16);
267 dictionary.Add(
"System.Security.Cryptography.Rijndael", typeFromHandle16);
268 dictionary.Add(
"System.Security.Cryptography.SymmetricAlgorithm", typeFromHandle16);
269 dictionary.Add(
"AES", value);
270 dictionary.Add(
"AesCryptoServiceProvider", value);
271 dictionary.Add(
"System.Security.Cryptography.AesCryptoServiceProvider", value);
272 dictionary.Add(
"AesManaged", value2);
273 dictionary.Add(
"System.Security.Cryptography.AesManaged", value2);
274 dictionary.Add(
"DpapiDataProtector", value13);
275 dictionary.Add(
"System.Security.Cryptography.DpapiDataProtector", value13);
276 dictionary.Add(
"http://www.w3.org/2000/09/xmldsig#dsa-sha1", typeFromHandle17);
277 dictionary.Add(
"System.Security.Cryptography.DSASignatureDescription", typeFromHandle17);
278 dictionary.Add(
"http://www.w3.org/2000/09/xmldsig#rsa-sha1", typeFromHandle18);
279 dictionary.Add(
"System.Security.Cryptography.RSASignatureDescription", typeFromHandle18);
280 dictionary.Add(
"http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", typeFromHandle19);
281 dictionary.Add(
"http://www.w3.org/2001/04/xmldsig-more#rsa-sha384", typeFromHandle20);
282 dictionary.Add(
"http://www.w3.org/2001/04/xmldsig-more#rsa-sha512", typeFromHandle21);
283 dictionary.Add(
"http://www.w3.org/2000/09/xmldsig#sha1", typeFromHandle);
284 dictionary.Add(
"http://www.w3.org/2001/04/xmlenc#sha256", value10);
285 dictionary.Add(
"http://www.w3.org/2001/04/xmlenc#sha512", value12);
286 dictionary.Add(
"http://www.w3.org/2001/04/xmlenc#ripemd160", typeFromHandle3);
287 dictionary.Add(
"http://www.w3.org/2001/04/xmlenc#des-cbc", typeFromHandle13);
288 dictionary.Add(
"http://www.w3.org/2001/04/xmlenc#tripledes-cbc", typeFromHandle14);
289 dictionary.Add(
"http://www.w3.org/2001/04/xmlenc#kw-tripledes", typeFromHandle14);
290 dictionary.Add(
"http://www.w3.org/2001/04/xmlenc#aes128-cbc", typeFromHandle16);
291 dictionary.Add(
"http://www.w3.org/2001/04/xmlenc#kw-aes128", typeFromHandle16);
292 dictionary.Add(
"http://www.w3.org/2001/04/xmlenc#aes192-cbc", typeFromHandle16);
293 dictionary.Add(
"http://www.w3.org/2001/04/xmlenc#kw-aes192", typeFromHandle16);
294 dictionary.Add(
"http://www.w3.org/2001/04/xmlenc#aes256-cbc", typeFromHandle16);
295 dictionary.Add(
"http://www.w3.org/2001/04/xmlenc#kw-aes256", typeFromHandle16);
296 dictionary.Add(
"http://www.w3.org/TR/2001/REC-xml-c14n-20010315",
"System.Security.Cryptography.Xml.XmlDsigC14NTransform, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
297 dictionary.Add(
"http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments",
"System.Security.Cryptography.Xml.XmlDsigC14NWithCommentsTransform, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
298 dictionary.Add(
"http://www.w3.org/2001/10/xml-exc-c14n#",
"System.Security.Cryptography.Xml.XmlDsigExcC14NTransform, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
299 dictionary.Add(
"http://www.w3.org/2001/10/xml-exc-c14n#WithComments",
"System.Security.Cryptography.Xml.XmlDsigExcC14NWithCommentsTransform, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
300 dictionary.Add(
"http://www.w3.org/2000/09/xmldsig#base64",
"System.Security.Cryptography.Xml.XmlDsigBase64Transform, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
301 dictionary.Add(
"http://www.w3.org/TR/1999/REC-xpath-19991116",
"System.Security.Cryptography.Xml.XmlDsigXPathTransform, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
302 dictionary.Add(
"http://www.w3.org/TR/1999/REC-xslt-19991116",
"System.Security.Cryptography.Xml.XmlDsigXsltTransform, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
303 dictionary.Add(
"http://www.w3.org/2000/09/xmldsig#enveloped-signature",
"System.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
304 dictionary.Add(
"http://www.w3.org/2002/07/decrypt#XML",
"System.Security.Cryptography.Xml.XmlDecryptionTransform, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
305 dictionary.Add(
"urn:mpeg:mpeg21:2003:01-REL-R-NS:licenseTransform",
"System.Security.Cryptography.Xml.XmlLicenseTransform, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
306 dictionary.Add(
"http://www.w3.org/2000/09/xmldsig# X509Data",
"System.Security.Cryptography.Xml.KeyInfoX509Data, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
307 dictionary.Add(
"http://www.w3.org/2000/09/xmldsig# KeyName",
"System.Security.Cryptography.Xml.KeyInfoName, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
308 dictionary.Add(
"http://www.w3.org/2000/09/xmldsig# KeyValue/DSAKeyValue",
"System.Security.Cryptography.Xml.DSAKeyValue, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
309 dictionary.Add(
"http://www.w3.org/2000/09/xmldsig# KeyValue/RSAKeyValue",
"System.Security.Cryptography.Xml.RSAKeyValue, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
310 dictionary.Add(
"http://www.w3.org/2000/09/xmldsig# RetrievalMethod",
"System.Security.Cryptography.Xml.KeyInfoRetrievalMethod, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
311 dictionary.Add(
"http://www.w3.org/2001/04/xmlenc# EncryptedKey",
"System.Security.Cryptography.Xml.KeyInfoEncryptedKey, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
312 dictionary.Add(
"http://www.w3.org/2000/09/xmldsig#hmac-sha1", typeFromHandle6);
313 dictionary.Add(
"http://www.w3.org/2001/04/xmldsig-more#md5", typeFromHandle2);
314 dictionary.Add(
"http://www.w3.org/2001/04/xmldsig-more#sha384", value11);
315 dictionary.Add(
"http://www.w3.org/2001/04/xmldsig-more#hmac-md5", typeFromHandle4);
316 dictionary.Add(
"http://www.w3.org/2001/04/xmldsig-more#hmac-ripemd160", typeFromHandle5);
317 dictionary.Add(
"http://www.w3.org/2001/04/xmldsig-more#hmac-sha256", typeFromHandle7);
318 dictionary.Add(
"http://www.w3.org/2001/04/xmldsig-more#hmac-sha384", typeFromHandle8);
319 dictionary.Add(
"http://www.w3.org/2001/04/xmldsig-more#hmac-sha512", typeFromHandle9);
320 dictionary.Add(
"2.5.29.10",
"System.Security.Cryptography.X509Certificates.X509BasicConstraintsExtension, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
321 dictionary.Add(
"2.5.29.19",
"System.Security.Cryptography.X509Certificates.X509BasicConstraintsExtension, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
322 dictionary.Add(
"2.5.29.14",
"System.Security.Cryptography.X509Certificates.X509SubjectKeyIdentifierExtension, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
323 dictionary.Add(
"2.5.29.15",
"System.Security.Cryptography.X509Certificates.X509KeyUsageExtension, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
324 dictionary.Add(
"2.5.29.37",
"System.Security.Cryptography.X509Certificates.X509EnhancedKeyUsageExtension, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
325 dictionary.Add(
"X509Chain",
"System.Security.Cryptography.X509Certificates.X509Chain, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
326 dictionary.Add(
"1.2.840.113549.1.9.3",
"System.Security.Cryptography.Pkcs.Pkcs9ContentType, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
327 dictionary.Add(
"1.2.840.113549.1.9.4",
"System.Security.Cryptography.Pkcs.Pkcs9MessageDigest, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
328 dictionary.Add(
"1.2.840.113549.1.9.5",
"System.Security.Cryptography.Pkcs.Pkcs9SigningTime, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
329 dictionary.Add(
"1.3.6.1.4.1.311.88.2.1",
"System.Security.Cryptography.Pkcs.Pkcs9DocumentName, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
330 dictionary.Add(
"1.3.6.1.4.1.311.88.2.2",
"System.Security.Cryptography.Pkcs.Pkcs9DocumentDescription, System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
331 defaultNameHT = dictionary;
333 return defaultNameHT;
338 private static void InitializeConfigInfo()
340 if (machineNameHT ==
null)
342 lock (InternalSyncObject)
344 if (machineNameHT ==
null)
346 ConfigNode configNode = OpenCryptoConfig();
347 if (configNode !=
null)
349 foreach (ConfigNode child
in configNode.Children)
351 if (machineNameHT !=
null && machineOidHT !=
null)
355 if (machineNameHT ==
null &&
string.Compare(child.Name,
"cryptoNameMapping",
StringComparison.Ordinal) == 0)
357 machineNameHT = InitializeNameMappings(child);
359 else if (machineOidHT ==
null &&
string.Compare(child.Name,
"oidMap",
StringComparison.Ordinal) == 0)
361 machineOidHT = InitializeOidMappings(child);
365 if (machineNameHT ==
null)
369 if (machineOidHT ==
null)
387 if (algorithm ==
null)
399 string[] array =
new string[names.Length];
401 string[] array2 = array;
402 foreach (
string value
in array2)
404 if (
string.IsNullOrEmpty(value))
409 lock (InternalSyncObject)
411 string[] array3 = array;
412 foreach (
string key
in array3)
414 appNameHT[key] = algorithm;
425 [SecuritySafeCritical]
433 InitializeConfigInfo();
434 lock (InternalSyncObject)
436 type = appNameHT.GetValueOrDefault(name);
440 string valueOrDefault = machineNameHT.GetValueOrDefault(name);
441 if (valueOrDefault !=
null)
443 type =
Type.
GetType(valueOrDefault, throwOnError:
false, ignoreCase:
false);
452 object valueOrDefault2 = DefaultNameHT.GetValueOrDefault(name);
453 if (valueOrDefault2 !=
null)
455 if (valueOrDefault2 is
Type)
457 type = (
Type)valueOrDefault2;
459 else if (valueOrDefault2 is
string)
461 type =
Type.
GetType((
string)valueOrDefault2, throwOnError:
false, ignoreCase:
false);
471 type =
Type.
GetType(name, throwOnError:
false, ignoreCase:
false);
481 RuntimeType runtimeType = type as RuntimeType;
482 if (runtimeType ==
null)
488 args =
new object[0];
491 if (constructors ==
null)
496 foreach (
MethodBase methodBase
in constructors)
500 list.Add(methodBase);
507 constructors = list.ToArray();
510 if (runtimeConstructorInfo ==
null || typeof(
Delegate).IsAssignableFrom(runtimeConstructorInfo.DeclaringType))
538 public static void AddOID(
string oid, params
string[] names)
548 string[] array =
new string[names.Length];
550 string[] array2 = array;
551 foreach (
string value
in array2)
553 if (
string.IsNullOrEmpty(value))
558 lock (InternalSyncObject)
560 string[] array3 = array;
561 foreach (
string key
in array3)
577 [SecuritySafeCritical]
584 InitializeConfigInfo();
586 lock (InternalSyncObject)
588 text = appOidHT.GetValueOrDefault(name);
592 text = machineOidHT.GetValueOrDefault(name);
596 text = DefaultOidHT.GetValueOrDefault(name);
600 text = X509Utils.GetOidFromFriendlyName(name, oidGroup);
616 char[] separator =
new char[1]
620 string[] array = str.Split(separator);
621 uint[] array2 =
new uint[array.Length];
622 for (
int i = 0; i < array.Length; i++)
626 byte[] array3 =
new byte[array2.Length * 5];
628 if (array2.Length < 2)
632 uint dwValue = array2[0] * 40 + array2[1];
633 byte[] array4 = EncodeSingleOIDNum(dwValue);
634 Array.
Copy(array4, 0, array3, num, array4.Length);
635 num += array4.Length;
636 for (
int j = 2; j < array2.Length; j++)
638 array4 = EncodeSingleOIDNum(array2[j]);
639 Buffer.InternalBlockCopy(array4, 0, array3, num, array4.Length);
640 num += array4.Length;
646 array4 =
new byte[num + 2];
648 array4[1] = (byte)num;
649 Buffer.InternalBlockCopy(array3, 0, array4, 2, num);
653 private static byte[] EncodeSingleOIDNum(uint dwValue)
655 if ((
int)dwValue < 128)
666 (byte)((dwValue >> 7) | 0x80),
667 (
byte)(dwValue & 0x7F)
670 if (dwValue < 2097152)
674 (byte)((dwValue >> 14) | 0x80),
675 (
byte)((dwValue >> 7) | 0x80),
676 (byte)(dwValue & 0x7F)
679 if (dwValue < 268435456)
683 (byte)((dwValue >> 21) | 0x80),
684 (
byte)((dwValue >> 14) | 0x80),
685 (byte)((dwValue >> 7) | 0x80),
686 (
byte)(dwValue & 0x7F)
691 (byte)((dwValue >> 28) | 0x80),
692 (
byte)((dwValue >> 21) | 0x80),
693 (byte)((dwValue >> 14) | 0x80),
694 (
byte)((dwValue >> 7) | 0x80),
695 (byte)(dwValue & 0x7F)
703 foreach (ConfigNode child
in nameMappingNode.Children)
705 if (
string.Compare(child.Name,
"cryptoClasses",
StringComparison.Ordinal) == 0)
707 foreach (ConfigNode child2
in child.Children)
709 if (
string.Compare(child2.Name,
"cryptoClass",
StringComparison.Ordinal) == 0 && child2.Attributes.Count > 0)
712 dictionary2.
Add((
string)dictionaryEntry.
Key, (
string)dictionaryEntry.
Value);
716 else if (
string.Compare(child.Name,
"nameEntry",
StringComparison.Ordinal) == 0)
724 text = (string)attribute.
Value;
728 text2 = (string)attribute.
Value;
731 if (text !=
null && text2 !=
null)
733 string valueOrDefault = dictionary2.GetValueOrDefault(text2);
734 if (valueOrDefault !=
null)
736 dictionary.Add(text, valueOrDefault);
747 foreach (ConfigNode child
in oidMappingNode.Children)
757 text = (string)attribute.
Value;
761 text2 = (string)attribute.
Value;
764 if (text2 !=
null && text !=
null)
766 dictionary.Add(text2, text);
774 private static ConfigNode OpenCryptoConfig()
776 string text = Config.MachineDirectory +
"machine.config";
782 CodeAccessPermission.RevertAssert();
783 ConfigTreeParser configTreeParser =
new ConfigTreeParser();
784 ConfigNode configNode = configTreeParser.Parse(text,
"configuration", skipSecurityStuff:
true);
785 if (configNode ==
null)
789 ConfigNode configNode2 =
null;
790 foreach (ConfigNode child
in configNode.Children)
812 if (configNode2 !=
null)
817 if (configNode2 ==
null)
821 foreach (ConfigNode child2
in configNode2.Children)
823 if (
string.Compare(child2.Name,
"cryptographySettings",
StringComparison.Ordinal) == 0)
static CultureInfo InvariantCulture
Gets the T:System.Globalization.CultureInfo object that is culture-independent (invariant).
bool IsVisible
Gets a value indicating whether the T:System.Type can be accessed by code outside the assembly.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
static void AddOID(string oid, params string[] names)
Adds a set of names to object identifier (OID) mappings to be used for the current application domain...
FileIOPermissionAccess
Specifies the type of file access requested.
static bool Exists(string path)
Determines whether the specified file exists.
abstract object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
When overridden in a derived class, invokes the reflected method or constructor with the given parame...
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
BindingFlags
Specifies flags that control binding and the way in which the search for members and types is conduct...
static object CreateFromName(string name, params object[] args)
Creates a new instance of the specified cryptographic object with the specified arguments.
static OperatingSystem OSVersion
Gets an T:System.OperatingSystem object that contains the current platform identifier and version num...
abstract void ReorderArgumentArray(ref object[] args, object state)
Upon returning from M:System.Reflection.Binder.BindToMethod(System.Reflection.BindingFlags,...
OidGroup
Identifies Windows cryptographic object identifier (OID) groups.
static Binder DefaultBinder
Gets a reference to the default binder, which implements internal rules for selecting the appropriate...
Version Version
Gets a T:System.Version object that identifies the operating system.
override string ToString()
Converts the value of the current T:System.Version object to its equivalent T:System....
Provides information about, and means to manipulate, the current environment and platform....
static void AddAlgorithm(Type algorithm, params string[] names)
Adds a set of names to algorithm mappings to be used for the current application domain.
int Major
Gets the value of the major component of the version number for the current T:System....
Accesses the cryptography configuration information.
static int CompareExchange(ref int location1, int value, int comparand)
Compares two 32-bit signed integers for equality and, if they are equal, replaces the first value.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Represents a delegate, which is a data structure that refers to a static method or to a class instanc...
Represents type declarations: class types, interface types, array types, value types,...
Represents the version number of an assembly, operating system, or the common language runtime....
Provides information about methods and constructors.
static byte [] EncodeOID(string str)
Encodes the specified object identifier (OID).
The exception that is thrown when one of the arguments provided to a method is not valid.
static void Copy(Array sourceArray, Array destinationArray, int length)
Copies a range of elements from an T:System.Array starting at the first element and pastes them into ...
static bool AllowOnlyFipsAlgorithms
Indicates whether the runtime should enforce the policy to create only Federal Information Processing...
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
static string MapNameToOID(string name)
Gets the object identifier (OID) of the algorithm corresponding to the specified simple name.
object Value
Gets or sets the value in the key/value pair.
static StringComparer OrdinalIgnoreCase
Gets a T:System.StringComparer object that performs a case-insensitive ordinal string comparison.
Provides static methods for the creation, copying, deletion, moving, and opening of a single file,...
Manipulates arrays of primitive types.
void Add(TKey key, TValue value)
Adds the specified key and value to the dictionary.
static Type GetType(string typeName, bool throwOnError, bool ignoreCase)
Gets the T:System.Type with the specified name, specifying whether to throw an exception if the type ...
object Key
Gets or sets the key in the key/value pair.
static object CreateFromName(string name)
Creates a new instance of the specified cryptographic object.
The exception that is thrown when an unexpected operation occurs during a cryptographic operation.
void Assert()
Declares that the calling code can access the resource protected by a permission demand through the c...
Provides information about a specific culture (called a locale for unmanaged code development)....
Controls the ability to access files and folders. This class cannot be inherited.
abstract MethodBase BindToMethod(BindingFlags bindingAttr, MethodBase[] match, ref object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] names, out object state)
Selects a method to invoke from the given set of methods, based on the supplied arguments.
Defines a dictionary key/value pair that can be set or retrieved.
Provides atomic operations for variables that are shared by multiple threads.
Represents a string comparison operation that uses specific case and culture-based or ordinal compari...
abstract ParameterInfo [] GetParameters()
When overridden in a derived class, gets the parameters of the specified method or constructor.