You've already forked linux-packaging-mono
Imported Upstream version 4.8.0.309
Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
parent
ee1447783b
commit
94b2861243
@@ -14,7 +14,7 @@ namespace Xamarin {
|
||||
|
||||
public static class CommonCryptor {
|
||||
|
||||
static public void Generate (string namespaceName, string typeName, string baseTypeName, string ccAlgorithmName, string feedbackSize = "8", string ctorInitializers = null)
|
||||
static public void Generate (string namespaceName, string typeName, string baseTypeName, string ccAlgorithmName, string feedbackSize = "8", string ctorInitializers = null, string decryptorInitializers = null, string encryptorInitializers = null, string properties = null)
|
||||
{
|
||||
string template = @"// Generated file to bind CommonCrypto cipher algorithms - DO NOT EDIT
|
||||
//
|
||||
@@ -38,7 +38,9 @@ namespace %NAMESPACE% {
|
||||
FeedbackSizeValue = %FEEDBACKSIZE%;
|
||||
%CTOR_INIT%
|
||||
}
|
||||
|
||||
|
||||
%PROPERTIES%
|
||||
|
||||
public override void GenerateIV ()
|
||||
{
|
||||
IVValue = KeyBuilder.IV (BlockSizeValue >> 3);
|
||||
@@ -51,6 +53,8 @@ namespace %NAMESPACE% {
|
||||
|
||||
public override ICryptoTransform CreateDecryptor (byte[] rgbKey, byte[] rgbIV)
|
||||
{
|
||||
%CREATEDECRYPTOR_INIT%
|
||||
|
||||
IntPtr decryptor = IntPtr.Zero;
|
||||
switch (Mode) {
|
||||
case CipherMode.CBC:
|
||||
@@ -74,6 +78,8 @@ namespace %NAMESPACE% {
|
||||
|
||||
public override ICryptoTransform CreateEncryptor (byte[] rgbKey, byte[] rgbIV)
|
||||
{
|
||||
%CREATEENCRYPTOR_INIT%
|
||||
|
||||
IntPtr encryptor = IntPtr.Zero;
|
||||
switch (Mode) {
|
||||
case CipherMode.CBC:
|
||||
@@ -98,6 +104,9 @@ namespace %NAMESPACE% {
|
||||
|
||||
File.WriteAllText (typeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
|
||||
Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).Replace("%FEEDBACKSIZE%", feedbackSize).Replace ("%CTOR_INIT%", ctorInitializers).
|
||||
Replace ("%CREATEDECRYPTOR_INIT%", decryptorInitializers).
|
||||
Replace ("%CREATEENCRYPTOR_INIT%", encryptorInitializers).
|
||||
Replace ("%PROPERTIES%", properties).
|
||||
Replace ("%CCALGORITHM%", ccAlgorithmName.ToString ()));
|
||||
}
|
||||
}
|
||||
|
@@ -42,7 +42,13 @@ namespace Xamarin {
|
||||
// mscorlib replacements
|
||||
CommonCryptor.Generate ("System.Security.Cryptography", "DESCryptoServiceProvider", "DES", "DES");
|
||||
CommonCryptor.Generate ("System.Security.Cryptography", "TripleDESCryptoServiceProvider", "TripleDES", "TripleDES");
|
||||
CommonCryptor.Generate ("System.Security.Cryptography", "RC2CryptoServiceProvider", "RC2", "RC2", ctorInitializers: "LegalKeySizesValue = new[] { new KeySizes(40, 128, 8) };");
|
||||
|
||||
const string checkUseSalt = "if (UseSalt) throw new NotImplementedException (\"UseSalt=true is not implemented on Mono yet\");";
|
||||
CommonCryptor.Generate ("System.Security.Cryptography", "RC2CryptoServiceProvider", "RC2", "RC2",
|
||||
ctorInitializers: "LegalKeySizesValue = new[] { new KeySizes(40, 128, 8) };",
|
||||
decryptorInitializers: checkUseSalt,
|
||||
encryptorInitializers: checkUseSalt,
|
||||
properties: "public bool UseSalt { get; set; }");
|
||||
// Rijndael supports block sizes that are not available in AES - as such it does not use the same generated code
|
||||
// but has it's own version, using AES (128 bits block size) and falling back to managed (192/256 bits block size)
|
||||
|
||||
|
Reference in New Issue
Block a user