protected override void Act()

            {
                var packedHashConverter = new PackedHashConverter();

                _actualPackedHash = packedHashConverter.GetPackedHash(_base64String);
            }
            protected override void Arrange()
            {
                var packedHashConverter = new PackedHashConverter();

                var originalHashAlgorithm = 1495316179;

                var packedHash = new PackedHash
                {
                    Format        = 0,
                    HashAlgorithm = originalHashAlgorithm,
                    HashBytes     = new byte[]
                    {
                        246, 198, 84, 57, 46, 87, 69, 64, 36, 89, 195, 42, 154,
                        103, 212, 113, 134, 129, 0, 29, 59, 36, 38, 212, 67, 32,
                        67, 113, 96, 103, 22, 129
                    },
                    Iterations = 100,
                    Salt       = new byte[] { 5, 8, 4, 2, 3, 6, 12, 34 }
                };

                _configProvider = new DefaultHashConfigurationProvider();

                _apiClientSecret = new ApiClientSecret
                {
                    IsHashed = true,

                    // GetHashCode is consistent
                    Secret = "ANO2IFlkAAAACAAAAAUIBAIDBgwi9sZUOS5XRUAkWcMqmmfUcYaBAB07JCbUQyBDcWBnFoE="
                };

                _apiClientSecretProvider = Stub <IApiClientSecretProvider>();

                var secureHasher   = new Pbkdf2HmacSha1SecureHasher();
                var originalHasher = A.Fake <ISecureHasher>();

                A.CallTo(() => originalHasher.AlgorithmHashCode).Returns(originalHashAlgorithm);
                A.CallTo(() => originalHasher.ComputeHash(A <string> ._, A <int> ._, A <int> ._, A <byte[]> ._)).Returns(packedHash);

                var next = new SecureHashAwareSecretVerifier(
                    packedHashConverter, new SecureHasherProvider(
                        new List <ISecureHasher>
                {
                    secureHasher,
                    originalHasher
                }));

                _securePackedHashProvider = Stub <ISecurePackedHashProvider>();

                _autoUpgradingHashedSecretVerifierDecorator = new AutoUpgradingHashedSecretVerifierDecorator(
                    _apiClientSecretProvider, next, packedHashConverter, _securePackedHashProvider, _configProvider);
            }
Beispiel #3
0
            protected override void Arrange()
            {
                var packedHashConverter = new PackedHashConverter();

                var packedHash = new PackedHash
                {
                    Format        = 0,
                    HashAlgorithm = "GOOD".GetHashCode(), // simulation of a hash routine that used GetHashCode
                    HashBytes     = new byte[]
                    {
                        246, 198, 84, 57, 46, 87, 69, 64, 36, 89, 195, 42, 154,
                        103, 212, 113, 134, 129, 0, 29, 59, 36, 38, 212, 67, 32,
                        67, 113, 96, 103, 22, 129
                    },
                    Iterations = 100,
                    Salt       = new byte[] { 5, 8, 4, 2, 3, 6, 12, 34 }
                };

                _configProvider = new DefaultHashConfigurationProvider();

                _apiClientSecret = new ApiClientSecret
                {
                    IsHashed = true,

                    // GetHashCode is consistent
                    Secret = "ANO2IFlkAAAACAAAAAUIBAIDBgwi9sZUOS5XRUAkWcMqmmfUcYaBAB07JCbUQyBDcWBnFoE="
                };

                _apiClientSecretProvider = Stub <IApiClientSecretProvider>();

                var secureHasher = new Pbkdf2HmacSha1SecureHasher(null);
                var next         = new SecureHashAwareSecretVerifier(packedHashConverter, secureHasher);

                _securePackedHashProvider = Stub <ISecurePackedHashProvider>();

                _autoUpgradingHashedSecretVerifierDecorator = new AutoUpgradingHashedSecretVerifierDecorator(
                    _apiClientSecretProvider, next, packedHashConverter, _securePackedHashProvider, _configProvider);
            }
            protected override void Act()
            {
                var packedHashConverter = new PackedHashConverter();

                _actualBase64String = packedHashConverter.GetBase64String(_packedHash);
            }