Пример #1
0
        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;
            }
        }
Пример #2
0
 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());
 }
Пример #3
0
 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());
 }
Пример #4
0
        private static void InitializeTypeFactories()
        {
            RuntimeEnvironment.RegisterTypeFactories();

            IEnumerable <Assembly> assemblies = LoadFromFiles(GetExecutingDirectory().GetFiles("*.dll"));

            Resolve.RegisterTypeFactories(assemblies);

            TypeMap.Register.Singleton <IEmailParser>(() => new RegexEmailParser());
            TypeMap.Register.Singleton <ISettingsStore>(() => new TransientSettingsStore());
            TypeMap.Register.Singleton <INow>(() => new Now());
            TypeMap.Register.Singleton <IInternetState>(() => new AlwaysOnInternetState());

            TypeMap.Register.New <RandomNumberGenerator>(() => PortableFactory.RandomNumberGenerator());
            TypeMap.Register.New <AxCryptHMACSHA1>(() => PortableFactory.AxCryptHMACSHA1());
            TypeMap.Register.New <HMACSHA512>(() => PortableFactory.HMACSHA512());
            TypeMap.Register.New <Aes>(() => new Axantum.AxCrypt.Mono.Cryptography.AesWrapper(new System.Security.Cryptography.AesCryptoServiceProvider()));
            TypeMap.Register.New <Sha1>(() => PortableFactory.SHA1Managed());
            TypeMap.Register.New <Sha256>(() => PortableFactory.SHA256Managed());
            TypeMap.Register.New <CryptoStreamBase>(() => PortableFactory.CryptoStream());
        }
Пример #5
0
 public static void Setup()
 {
     TypeMap.Register.Singleton <IPortableFactory>(() => new PortableFactory());
     TypeMap.Register.New <HMACSHA512>(() => PortableFactory.HMACSHA512());
 }