public void Aes256_GCM_Stream()
        {
            var hashKey = _hashingProvider.GetHashKey(Passphrase, Salt, 32);

            _output.WriteLine(Encoding.UTF8.GetString(hashKey));
            _output.WriteLine($"HashKey: {Encoding.UTF8.GetString(hashKey)}");

            var encryptionProvider = new BouncyAesGcmEncryptionProvider(hashKey);
            var encryptedStream    = encryptionProvider.Encrypt(new MemoryStream(_data));
            var decryptedStream    = encryptionProvider.Decrypt(encryptedStream);

            Assert.Equal(_data, decryptedStream.ToArray());
        }
        public void Setup()
        {
            XorShift = new XorShift(true);
            Payload  = XorShift.GetRandomBytes(1024);

            HashProvider = new Argon2ID_HashingProvider();

            HashKey = HashProvider.GetHashKey(Passphrase, Salt, KeySize);

            EncryptionProvider           = new AesGcmEncryptionProvider(HashKey);
            RecyclableEncryptionProvider = new RecyclableAesGcmEncryptionProvider(HashKey);

            //RecyclableManager.ConfigureNewStaticManagerWithDefaults();

            EncryptedPayload = EncryptionProvider.Encrypt(Payload).ToArray();
        }
Beispiel #3
0
        public void Setup()
        {
            XorShift = new XorShift(true);
            Payload1 = XorShift.GetRandomBytes(1024);
            Payload2 = XorShift.GetRandomBytes(2048);
            Payload3 = XorShift.GetRandomBytes(4096);
            Payload4 = XorShift.GetRandomBytes(8192);

            HashProvider = new Argon2ID_HashingProvider();

            HashKey = HashProvider.GetHashKey(Passphrase, Salt, KeySize);

            EncryptionProvider = new BouncyAesGcmEncryptionProvider(HashKey);
            EncryptedPayload1  = EncryptionProvider.Encrypt(Payload1).ToArray();
            EncryptedPayload2  = EncryptionProvider.Encrypt(Payload2).ToArray();
            EncryptedPayload3  = EncryptionProvider.Encrypt(Payload3).ToArray();
            EncryptedPayload4  = EncryptionProvider.Encrypt(Payload4).ToArray();
        }
Beispiel #4
0
        public RabbitFixture()
        {
            CompressionProvider   = new GzipProvider();
            HashingProvider       = new Argon2ID_HashingProvider();
            HashKey               = HashingProvider.GetHashKey(Passphrase, Salt, 32);
            EncryptionProvider    = new AesGcmEncryptionProvider(HashKey);
            SerializationProvider = new Utf8JsonProvider();

            Options = JsonFileReader.ReadFileAsync <RabbitOptions>("RabbitMQ\\TestConfig.json").GetAwaiter().GetResult();

            RabbitService = new RabbitService(
                Options,
                SerializationProvider,
                EncryptionProvider,
                CompressionProvider,
                LoggerFactory
                .Create(
                    builder => builder.AddConsole().SetMinimumLevel(LogLevel.Information)));

            ChannelPool = RabbitService.ChannelPool;
            Topologer   = RabbitService.Topologer;
            Publisher   = RabbitService.Publisher;
        }
        public void Aes256_GCM()
        {
            var hashKey = _hashingProvider.GetHashKey(Passphrase, Salt, 32);

            _output.WriteLine(Encoding.UTF8.GetString(hashKey));
            _output.WriteLine($"HashKey: {Encoding.UTF8.GetString(hashKey)}");

            var encryptionProvider = new AesGcmEncryptionProvider(hashKey);

            var encryptedData = encryptionProvider.Encrypt(_data);

            _output.WriteLine($"Encrypted: {Encoding.UTF8.GetString(encryptedData)}");

            var decryptedData = encryptionProvider.Decrypt(encryptedData);

            _output.WriteLine($"Data: {Encoding.UTF8.GetString(_data)}");
            _output.WriteLine($"Decrypted: {Encoding.UTF8.GetString(decryptedData)}");

            Assert.Equal(_data, decryptedData);
        }