public static void Setup() { TypeMap.Register.Singleton <IRuntimeEnvironment>(() => new FakeRuntimeEnvironment()); TypeMap.Register.Singleton <IRandomGenerator>(() => new FakeRandomGenerator()); TypeMap.Register.Singleton <IPortableFactory>(() => new PortableFactory()); TypeMap.Register.New <Aes>(() => PortableFactory.AesManaged()); }
public static void AssemblySetupCrypto(CryptoImplementation cryptoImplementation) { switch (cryptoImplementation) { case CryptoImplementation.Mono: TypeMap.Register.New <AxCryptHMACSHA1>(() => PortableFactory.AxCryptHMACSHA1()); TypeMap.Register.New <HMACSHA512>(() => PortableFactory.HMACSHA512()); TypeMap.Register.New <Aes>(() => PortableFactory.AesManaged()); TypeMap.Register.New <CryptoStreamBase>(() => PortableFactory.CryptoStream()); TypeMap.Register.New <Sha1>(() => PortableFactory.SHA1Managed()); TypeMap.Register.New <Sha256>(() => PortableFactory.SHA256Managed()); break; case CryptoImplementation.WindowsDesktop: TypeMap.Register.New <AxCryptHMACSHA1>(() => PortableFactory.AxCryptHMACSHA1()); TypeMap.Register.New <HMACSHA512>(() => new Mono.Cryptography.HMACSHA512Wrapper(new Axantum.AxCrypt.Desktop.Cryptography.HMACSHA512CryptoServiceProvider())); TypeMap.Register.New <Aes>(() => new Mono.Cryptography.AesWrapper(new System.Security.Cryptography.AesCryptoServiceProvider())); TypeMap.Register.New <CryptoStreamBase>(() => PortableFactory.CryptoStream()); TypeMap.Register.New <Sha1>(() => PortableFactory.SHA1Managed()); TypeMap.Register.New <Sha256>(() => PortableFactory.SHA256Managed()); break; case CryptoImplementation.BouncyCastle: TypeMap.Register.New <AxCryptHMACSHA1>(() => BouncyCastleCryptoFactory.AxCryptHMACSHA1()); TypeMap.Register.New <HMACSHA512>(() => BouncyCastleCryptoFactory.HMACSHA512()); TypeMap.Register.New <Aes>(() => BouncyCastleCryptoFactory.Aes()); TypeMap.Register.New <CryptoStreamBase>(() => BouncyCastleCryptoFactory.CryptoStream()); TypeMap.Register.New <Sha1>(() => BouncyCastleCryptoFactory.Sha1()); TypeMap.Register.New <Sha256>(() => BouncyCastleCryptoFactory.Sha256()); break; } }
public static void Setup() { TypeMap.Register.Singleton <IPortableFactory>(() => new PortableFactory()); TypeMap.Register.Singleton <CryptoFactory>(() => CreateCryptoFactory()); TypeMap.Register.New <ICryptoPolicy>(() => new ProCryptoPolicy()); TypeMap.Register.New <HMACSHA512>(() => PortableFactory.HMACSHA512()); TypeMap.Register.New <Aes>(() => PortableFactory.AesManaged()); }
public static void Setup() { TypeMap.Register.Singleton <IRuntimeEnvironment>(() => new FakeRuntimeEnvironment()); TypeMap.Register.Singleton <IPortableFactory>(() => new PortableFactory()); TypeMap.Register.Singleton <CryptoFactory>(() => SetupAssembly.CreateCryptoFactory()); TypeMap.Register.New <HMACSHA512>(() => PortableFactory.HMACSHA512()); TypeMap.Register.New <ICryptoPolicy>(() => new ProCryptoPolicy()); TypeMap.Register.New <Aes>(() => PortableFactory.AesManaged()); }
public static void Setup() { TypeMap.Register.Singleton <IAsymmetricFactory>(() => new FakeAsymmetricFactory("MD5")); TypeMap.Register.Singleton <IPortableFactory>(() => new PortableFactory()); TypeMap.Register.New <IStringSerializer>(() => new StringSerializer(New <IAsymmetricFactory>().GetSerializers())); TypeMap.Register.Singleton <IRandomGenerator>(() => new FakeRandomGenerator()); TypeMap.Register.Singleton <IRuntimeEnvironment>(() => new FakeRuntimeEnvironment()); TypeMap.Register.Singleton <IEmailParser>(() => new EmailParser()); TypeMap.Register.New <Aes>(() => PortableFactory.AesManaged()); }
public static void TestClone() { TypeMap.Register.Singleton <IRandomGenerator>(() => new FakeRandomGenerator()); TypeMap.Register.Singleton <IRuntimeEnvironment>(() => new FakeRuntimeEnvironment()); TypeMap.Register.Singleton <IPortableFactory>(() => new PortableFactory()); TypeMap.Register.New <Aes>(() => PortableFactory.AesManaged()); V2CompressionEncryptedHeaderBlock compressionHeaderBlock = new V2CompressionEncryptedHeaderBlock(new V2AesCrypto(SymmetricKey.Zero256, SymmetricIV.Zero128, 0)); compressionHeaderBlock.IsCompressed = false; Assert.That(compressionHeaderBlock.IsCompressed, Is.False); compressionHeaderBlock.IsCompressed = true; V2CompressionEncryptedHeaderBlock clone = (V2CompressionEncryptedHeaderBlock)compressionHeaderBlock.Clone(); Assert.That(clone.IsCompressed, Is.True); TypeMap.Register.Clear(); }