public RemoveKeyVaultKeyTests()
        {
            base.SetupTest();

            cmdlet = new RemoveAzureKeyVaultKey()
            {
                CommandRuntime = commandRuntimeMock.Object,
                DataServiceClient = keyVaultClientMock.Object,
                VaultName = VaultName
            };

            keyAttributes = new KeyAttributes(true, DateTime.Now, DateTime.Now, "HSM", new string[]{"All"});
            webKey = new WebKey.JsonWebKey();
            keyBundle = new KeyBundle() { Attributes = keyAttributes, Key = webKey, Name = KeyName, VaultName = VaultName };
        }
        public RemoveKeyVaultKeyTests()
        {
            base.SetupTest();

            cmdlet = new RemoveAzureKeyVaultKey()
            {
                CommandRuntime    = commandRuntimeMock.Object,
                DataServiceClient = keyVaultClientMock.Object,
                VaultName         = VaultName
            };

            keyAttributes = new KeyAttributes(true, DateTime.Now, DateTime.Now, "HSM", new string[] { "All" });
            webKey        = new WebKey.JsonWebKey();
            keyBundle     = new KeyBundle()
            {
                Attributes = keyAttributes, Key = webKey, Name = KeyName, VaultName = VaultName
            };
        }
        public SetKeyVaultKeyTests()
        {
            base.SetupTest();

            keyAttributes = new KeyAttributes(true, DateTime.Now, DateTime.Now, null, null);
            webKey = new WebKey.JsonWebKey();
            keyBundle = new KeyBundle() { Attributes = keyAttributes, Key = webKey, Name = KeyName, VaultName = VaultName, Version = KeyVersion };

            cmdlet = new SetAzureKeyVaultKey()
            {
                CommandRuntime = commandRuntimeMock.Object,
                DataServiceClient = keyVaultClientMock.Object,
                VaultName = VaultName,
                Enable = (bool)keyAttributes.Enabled,
                Expires = keyAttributes.Expires,
                NotBefore = keyAttributes.NotBefore,
                Name = KeyName
            };
        }
        public SetKeyVaultKeyTests()
        {
            base.SetupTest();

            keyAttributes = new KeyAttributes(true, DateTime.Now, DateTime.Now, null, null);
            webKey        = new WebKey.JsonWebKey();
            keyBundle     = new KeyBundle()
            {
                Attributes = keyAttributes, Key = webKey, Name = KeyName, VaultName = VaultName, Version = KeyVersion
            };

            cmdlet = new SetAzureKeyVaultKey()
            {
                CommandRuntime    = commandRuntimeMock.Object,
                DataServiceClient = keyVaultClientMock.Object,
                VaultName         = VaultName,
                Enable            = (bool)keyAttributes.Enabled,
                Expires           = keyAttributes.Expires,
                NotBefore         = keyAttributes.NotBefore,
                Name = KeyName
            };
        }
예제 #5
0
 private bool IsEqualOctet(JsonWebKey other)
 {
     return(K.SequenceEqual(other.K));
 }
예제 #6
0
        private bool IsEqualRsaHsm( JsonWebKey other )
        {
            if ( ( T != null && other.T == null ) || ( T == null && other.T != null ) )
                return false;

            if ( T != null && !T.SequenceEqual( other.T ) )
                return false;

            return IsEqualRsa( other );
        }
예제 #7
0
        private bool IsEqualRsa( JsonWebKey other )
        {
            // Public parameters
            if ( !N.SequenceEqual( other.N ) )
                return false;

            if ( !E.SequenceEqual( other.E ) )
                return false;

            // Private parameters
            var privateKey = HasPrivateKey();

            if ( privateKey && privateKey == other.HasPrivateKey() )
            {
                if ( !D.SequenceEqual( other.D ) )
                    return false;

                if ( !DP.SequenceEqual( other.DP ) )
                    return false;

                if ( !DQ.SequenceEqual( other.DQ ) )
                    return false;

                if ( !IQ.SequenceEqual( other.IQ ) )
                    return false;

                if ( !P.SequenceEqual( other.P ) )
                    return false;

                if ( !Q.SequenceEqual( other.Q ) )
                    return false;
            }

            return true;
        }
예제 #8
0
 private bool IsEqualOctet( JsonWebKey other )
 {
     return K.SequenceEqual( other.K );
 }
예제 #9
0
        public bool Equals( JsonWebKey other )
        {
            if ( other == null )
                return false;

            if ( string.Equals( Kty, other.Kty ) )
            {
                switch ( Kty )
                {
                    case JsonWebKeyType.EllipticCurve:
                        break;

                    case JsonWebKeyType.Octet:
                        return IsEqualOctet( other );

                    case JsonWebKeyType.Rsa:
                        return IsEqualRsa( other );

                    case JsonWebKeyType.RsaHsm:
                        return IsEqualRsaHsm( other );
                }
            }

            return false;
        }
예제 #10
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public KeyBundle()
 {
     Key = new JsonWebKey();
     Attributes = new KeyAttributes();
 }
        public KeyBundle ImportKey(string vaultName, string keyName, KeyAttributes keyAttributes, JsonWebKey webKey, bool? importToHsm)
        {
            if (string.IsNullOrEmpty(vaultName))
            {
                throw new ArgumentNullException("vaultName");
            }
            if (string.IsNullOrEmpty(keyName))
            {
                throw new ArgumentNullException("keyName");
            }
            if (keyAttributes == null)
            {
                throw new ArgumentNullException("keyAttributes");
            }
            if (webKey == null)
            {
                throw new ArgumentNullException("webKey");
            }

            string vaultAddress = this.vaultUriHelper.CreateVaultAddress(vaultName);

            Client.KeyAttributes clientAttributes = (Client.KeyAttributes)keyAttributes;

            webKey.KeyOps = keyAttributes.KeyOps;
            Client.KeyBundle clientKeyBundle = new Client.KeyBundle()
            {
                Attributes = clientAttributes,
                Key = webKey
            };

            try
            {
                clientKeyBundle = this.keyVaultClient.ImportKeyAsync(vaultAddress, keyName, clientKeyBundle, importToHsm).GetAwaiter().GetResult();
            }
            catch (Exception ex)
            {
                throw GetInnerException(ex);
            }

            return new KeyBundle(clientKeyBundle, this.vaultUriHelper);
        }