Example #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;
            }
        }
Example #2
0
        private static void RegisterTypeFactories(string startPath)
        {
            IEnumerable <Assembly> extraAssemblies = LoadFromFiles(new DirectoryInfo(Path.GetDirectoryName(startPath)).GetFiles("*.dll"));

            Resolve.RegisterTypeFactories(_workFolderPath, extraAssemblies);
            RuntimeEnvironment.RegisterTypeFactories();
            DesktopFactory.RegisterTypeFactories();

            TypeMap.Register.New <IProtectedData>(() => new ProtectedDataImplementation(System.Security.Cryptography.DataProtectionScope.CurrentUser));
            TypeMap.Register.New <ILauncher>(() => new Launcher());
            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 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());
            TypeMap.Register.New <RandomNumberGenerator>(() => PortableFactory.RandomNumberGenerator());
            TypeMap.Register.New <LogOnIdentity, IAccountService>((LogOnIdentity identity) => new CachingAccountService(new DeviceAccountService(new LocalAccountService(identity, Resolve.WorkFolder.FileInfo), new ApiAccountService(new AxCryptApiClient(identity.ToRestIdentity(), Resolve.UserSettings.RestApiBaseUrl, Resolve.UserSettings.ApiTimeout)))));
            TypeMap.Register.New <GlobalApiClient>(() => new GlobalApiClient(Resolve.UserSettings.RestApiBaseUrl, Resolve.UserSettings.ApiTimeout));
            TypeMap.Register.New <AxCryptApiClient>(() => new AxCryptApiClient(Resolve.KnownIdentities.DefaultEncryptionIdentity.ToRestIdentity(), Resolve.UserSettings.RestApiBaseUrl, Resolve.UserSettings.ApiTimeout));
            TypeMap.Register.New <ISystemCryptoPolicy>(() => new ProCryptoPolicy());
            TypeMap.Register.New <ICryptoPolicy>(() => New <LicensePolicy>().Capabilities.CryptoPolicy);

            TypeMap.Register.Singleton <LicensePolicy>(() => new LicensePolicy());
            TypeMap.Register.Singleton <FontLoader>(() => new FontLoader());
            TypeMap.Register.Singleton <IEmailParser>(() => new EmailParser());
            TypeMap.Register.Singleton <KeyPairService>(() => new KeyPairService(0, 0, New <UserSettings>().AsymmetricKeyBits));
            TypeMap.Register.Singleton <ICache>(() => new ItemCache());
            TypeMap.Register.Singleton <DummyReferencedType>(() => new DummyReferencedType());
            TypeMap.Register.Singleton <AxCryptOnlineState>(() => new AxCryptOnlineState());
            TypeMap.Register.Singleton <IVersion>(() => new DesktopVersion());
            TypeMap.Register.Singleton <PasswordStrengthEvaluator>(() => new PasswordStrengthEvaluator(100, 8));
            TypeMap.Register.Singleton <IKnownFoldersDiscovery>(() => new KnownFoldersDiscovery());
            TypeMap.Register.Singleton <IBrowser>(() => new Browser());
            TypeMap.Register.Singleton <ILicenseAuthority>(() => new PublicLicenseAuthority());
            TypeMap.Register.Singleton <PremiumManager>(() => new PremiumManagerWithAutoTrial());
            TypeMap.Register.Singleton <AboutAssembly>(() => new AboutAssembly(Assembly.GetExecutingAssembly()));
            TypeMap.Register.Singleton <FileLocker>(() => new FileLocker());
            TypeMap.Register.Singleton <IProgressDialog>(() => new ProgressDialog());
            TypeMap.Register.Singleton <CultureNameMapper>(() => new CultureNameMapper(New <GlobalApiClient>().GetCultureInfoListAsync));
        }
Example #3
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());
        }