Merge pull request #3715 from kumpera/fix-44707
[mono.git] / mcs / tools / commoncryptogenerator / generator.cs
1 //
2 // CommonCrypto Code Generator
3 //
4 // Authors:
5 //      Sebastien Pouliot  <sebastien@xamarin.com>
6 //
7 // Copyright 2012 Xamarin Inc.
8 //
9
10 using System;
11 using System.Collections.Generic;
12 using System.IO;
13 using System.Text;
14
15 namespace Xamarin {
16         
17         class Program {
18                 static void Main (string [] args)
19                 {
20                         // mscorlib replacements
21                         CommonDigest.Generate ("System.Security.Cryptography", "MD5CryptoServiceProvider", "MD5", 1000);
22                         CommonDigest.Generate ("System.Security.Cryptography", "SHA1CryptoServiceProvider", "SHA1", 1000);
23                         CommonDigest.Generate ("System.Security.Cryptography", "SHA1Managed", "SHA1", 1000);
24                         CommonDigest.Generate ("System.Security.Cryptography", "SHA256Managed", "SHA256", 1000);
25                         CommonDigest.Generate ("System.Security.Cryptography", "SHA384Managed", "SHA384", 1000);
26                         CommonDigest.Generate ("System.Security.Cryptography", "SHA512Managed", "SHA512", 1000);
27                         
28                         // System.Core replacements - not yet in MT profile (4.0 - functional dupes anyway)
29                         //CommonDigest.Generate ("System.Security.Cryptography", "MD5Cng", "MD5", 1000);
30                         //CommonDigest.Generate ("System.Security.Cryptography", "SHA256Cng", "SHA256", 1000);
31                         //CommonDigest.Generate ("System.Security.Cryptography", "SHA384Cng", "SHA384", 1000);
32                         //CommonDigest.Generate ("System.Security.Cryptography", "SHA512Cng", "SHA512", 1000);
33                         //CommonDigest.Generate ("System.Security.Cryptography", "SHA256CryptoServiceProvider", "SHA256", 1000);
34                         //CommonDigest.Generate ("System.Security.Cryptography", "SHA384CryptoServiceProvider", "SHA384", 1000);
35                         //CommonDigest.Generate ("System.Security.Cryptography", "SHA512CryptoServiceProvider", "SHA512", 1000);
36                         
37                         // Mono.Security replacements
38                         CommonDigest.Generate ("Mono.Security.Cryptography", "MD2Managed", "MD2", 1000, "#if !INSIDE_CORLIB", "#endif");
39                         CommonDigest.Generate ("Mono.Security.Cryptography", "MD4Managed", "MD4", 1000, "#if !INSIDE_CORLIB", "#endif");
40                         CommonDigest.Generate ("Mono.Security.Cryptography", "SHA224Managed", "SHA224", 1000);
41
42                         // mscorlib replacements
43                         CommonCryptor.Generate ("System.Security.Cryptography", "DESCryptoServiceProvider", "DES", "DES");
44                         CommonCryptor.Generate ("System.Security.Cryptography", "TripleDESCryptoServiceProvider", "TripleDES", "TripleDES");
45
46                         const string checkUseSalt = "if (UseSalt) throw new NotImplementedException (\"UseSalt=true is not implemented on Mono yet\");";
47                         CommonCryptor.Generate ("System.Security.Cryptography", "RC2CryptoServiceProvider", "RC2", "RC2",
48                                 ctorInitializers: "LegalKeySizesValue = new[] { new KeySizes(40, 128, 8) };",
49                                 decryptorInitializers: checkUseSalt,
50                                 encryptorInitializers: checkUseSalt,
51                                 properties: "public bool UseSalt { get; set; }");
52                         // Rijndael supports block sizes that are not available in AES - as such it does not use the same generated code
53                         // but has it's own version, using AES (128 bits block size) and falling back to managed (192/256 bits block size)
54
55                         // System.Core replacements
56                         CommonCryptor.Generate ("System.Security.Cryptography", "AesManaged", "Aes", "AES128", "128");
57                         CommonCryptor.Generate ("System.Security.Cryptography", "AesCryptoServiceProvider", "Aes", "AES128");
58
59                         // Mono.Security replacements
60                         // RC4 is a stream (not a block) cipher so it can not reuse the generated code
61                 }
62         }
63 }