public void WhenAuthorizingAnExistingWrongMasterKey_ADifferentHmacShouldBeComputed()
        {
            // Given
            var existingMasterKey = new MasterKey("Wrong Password", KnownSalt, KnownIterations, CreatePbkdf2());

            // When
            var existingAuthorization = new Authorization(existingMasterKey, KnownInitializationVector, CreateAes(), CreateHmacSha256());

            // Then
            existingAuthorization.Hmac.Should().NotBeEquivalentTo(KnownHmac);
        }
        public void WhenCreatingANewAuthorizationTwiceWithTheSameMasterKey_ADifferentHashShouldBeGeneratedBecauseTheInitializationVectorIsDifferent()
        {
            // Given
            var newMasterKey = new MasterKey(KnownPassword, KnownIterations, CreatePbkdf2());

            // When
            var firstNewAuthorization = new Authorization(newMasterKey, CreateAes(), CreateHmacSha256());
            var secondNewAuthorization = new Authorization(newMasterKey, CreateAes(), CreateHmacSha256());

            // Then
            firstNewAuthorization.Hmac.Should().NotBeEquivalentTo(secondNewAuthorization.Hmac);
        }
        public void WhenAuthorizingAnExistingCorrectMasterKey_TheCorrectHmacShouldBeComputer()
        {
            // Given
            var existingMasterKey = new MasterKey(KnownPassword, KnownSalt, KnownIterations, CreatePbkdf2());

            // When
            var existingAuthorization = new Authorization(existingMasterKey, KnownInitializationVector, CreateAes(), CreateHmacSha256());

            // Then
            existingAuthorization.InitializationVector.Should().BeEquivalentTo(KnownInitializationVector);
            existingAuthorization.Hmac.Should().BeEquivalentTo(KnownHmac);
        }
        public void WhenCreatingANewAuthorization_ItShouldBeCreated()
        {
            // Given
            var newMasterKey = new MasterKey(KnownPassword, KnownIterations, CreatePbkdf2());

            // When
            var newAuthorization = new Authorization(newMasterKey, CreateAes(), CreateHmacSha256());

            // Then
            newAuthorization.InitializationVector.Length.Should().Be(Aes.BlockSizeInBits / 8);
            newAuthorization.InitializationVector.Should().NotBeEmpty();
            newAuthorization.Hmac.Length.Should().Be(HmacSha256.HmacSizeInBits / 8);
            newAuthorization.Hmac.Should().NotBeEmpty();
        }
        public void WhenCreatingTwiceTheAuthorizationWithTheSameInitializationVector_ItShouldBeTheSame()
        {
            // Given
            var newMasterKey = new MasterKey(KnownPassword, KnownIterations, CreatePbkdf2());

            // When
            var newAuthorization = new Authorization(newMasterKey, CreateAes(), CreateHmacSha256());
            var existingAuthorization = new Authorization(newMasterKey, newAuthorization.InitializationVector,
                CreateAes(), CreateHmacSha256());

            // Then
            newAuthorization.Hmac.Should().BeEquivalentTo(existingAuthorization.Hmac);
        }