Example #1
0
        private void ProviderKeyInitialize(string providerName, string keyName, string algorithmName)
        {
            ManagedRSAEncryption managedRSA = new ManagedRSAEncryption();

            if (!managedRSA.TryGenerateLocalRSAKey(providerName, keyName))
            {
                //Delete and try again
                managedRSA.DestroyLocalRSAKey(providerName, keyName);
                managedRSA.TryGenerateLocalRSAKey(providerName, keyName);
            }
        }
        public void TestInitialize()
        {
            ManagedRSAEncryption managedRSA = new ManagedRSAEncryption();

            if (!managedRSA.TryGenerateLocalRSAKey(TestProvider, TestKeyName))
            {
                //Delete and try again
                managedRSA.DestroyLocalRSAKey(TestProvider, TestKeyName);
                managedRSA.TryGenerateLocalRSAKey(TestProvider, TestKeyName);
            }
        }
Example #3
0
        public void TestInitialize()
        {
            ManagedRSAEncryption utility = new ManagedRSAEncryption();

            //Create the test key

            if (!utility.TryGenerateLocalRSAKey(TestProvider, TestKeyName))
            {
                utility.DestroyLocalRSAKey(TestProvider, TestKeyName);
                utility.TryGenerateLocalRSAKey(TestProvider, TestKeyName);
            }
        }
        protected override void ProcessRecord()
        {
            ManagedRSAEncryption managedRSA = new ManagedRSAEncryption();

            if (managedRSA.TryGenerateLocalRSAKey(ProviderName, KeyName, KeyLength))
            {
                //Creation succeeded
            }
            else
            {
                //Creation failed, likely already exists
                this.WriteError(
                    new ErrorRecord(
                        new InvalidOperationException("Key Creation failed, it likely already exists"),
                        "KeyAlreadyExists",
                        ErrorCategory.InvalidOperation,
                        null));
            }
        }