private static async Task SetupAsync() { var letterTemplate = new Letter("", "TestRabbitServiceQueue", null, new LetterMetadata()); var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole().SetMinimumLevel(LogLevel)); _logger = loggerFactory.CreateLogger <ConsumerDataflow <WorkState> >(); _hashingProvider = new Argon2ID_HashingProvider(); var hashKey = await _hashingProvider.GetHashKeyAsync("passwordforencryption", "saltforencryption", 32).ConfigureAwait(false); _metricsProvider = new NullMetricsProvider(); _encryptionProvider = new AesGcmEncryptionProvider(hashKey); _compressionProvider = new LZ4PickleProvider(); _serializationProvider = new Utf8JsonProvider(); _rabbitService = new RabbitService( "Config.json", _serializationProvider, _encryptionProvider, _compressionProvider, loggerFactory); await _rabbitService .Topologer .CreateQueueAsync("TestRabbitServiceQueue") .ConfigureAwait(false); }
public async Task Aes256_GCM_StreamAsync() { var hashKey = await _hashingProvider .GetHashKeyAsync(Passphrase, Salt, 32) .ConfigureAwait(false); _output.WriteLine(Encoding.UTF8.GetString(hashKey)); _output.WriteLine($"HashKey: {Encoding.UTF8.GetString(hashKey)}"); var encryptionProvider = new AesGcmEncryptionProvider(hashKey); var encryptedStream = await encryptionProvider.EncryptAsync(new MemoryStream(_data)); var decryptedStream = encryptionProvider.Decrypt(encryptedStream); Assert.Equal(_data, decryptedStream.ToArray()); }
public async Task Argon2ID_Hash_256bit() { var hashKey = await _provider .GetHashKeyAsync(_passphrase, _salt, 32) .ConfigureAwait(false); Assert.True(hashKey.Length == 32); }
public async Task Aes256_GCM_BouncyCastle() { var hashKey = await _hashingProvider .GetHashKeyAsync(Passphrase, Salt, 32) .ConfigureAwait(false); _output.WriteLine(Encoding.UTF8.GetString(hashKey)); _output.WriteLine($"HashKey: {Encoding.UTF8.GetString(hashKey)}"); var encryptionProvider = new AesGcmEncryptionProvider(hashKey, _hashingProvider.Type); 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); }
public static async Task Main() { _hashingProvider = new Argon2IDHasher(); var hashKey = await _hashingProvider.GetHashKeyAsync("passwordforencryption", "saltforencryption", 32).ConfigureAwait(false); _encryptionProvider = new AesGcmEncryptionProvider(hashKey, _hashingProvider.Type); _compressionProvider = new GzipProvider(); _serializationProvider = new Utf8JsonProvider(StandardResolver.Default); LogHelper.LoggerFactory = LoggerFactory.Create(builder => builder.AddConsole().SetMinimumLevel(LogLevel.Information)); await Console.Out.WriteLineAsync("CookedRabbit.Core StressTest v1.00").ConfigureAwait(false); await Console.Out.WriteLineAsync("- StressTest setting everything up...").ConfigureAwait(false); var setupFailed = false; try { await SetupAsync().ConfigureAwait(false); } catch (Exception ex) { setupFailed = true; await Console.Out.WriteLineAsync($"- StressTest failed with exception {ex.Message}.").ConfigureAwait(false); } if (!setupFailed) { await Console.Out.WriteLineAsync("- StressTest starting!").ConfigureAwait(false); try { await StartStressTestAsync() .ConfigureAwait(false); } catch (Exception ex) { await Console.Out.WriteLineAsync($"- StressTest failed with exception {ex.Message}.").ConfigureAwait(false); } } await Console.Out.WriteLineAsync($"- Press any key to begin shutdown.").ConfigureAwait(false); Console.ReadKey(); await ShutdownAsync(); await Console.Out.WriteLineAsync($"- Press any key to close.").ConfigureAwait(false); Console.ReadKey(); }
private async Task <RabbitService> SetupAsync() { _hashingProvider = new Argon2IDHasher(); var hashKey = await _hashingProvider.GetHashKeyAsync("passwordforencryption", "saltforencryption", 32).ConfigureAwait(false); _encryptionProvider = new AesGcmEncryptionProvider(hashKey, _hashingProvider.Type); _compressionProvider = new GzipProvider(); _serializationProvider = new Utf8JsonProvider(StandardResolver.Default); var letterTemplate = new Letter("", "TestRabbitServiceQueue", null, new LetterMetadata()); var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole().SetMinimumLevel(Program.LogLevel)); _logger = loggerFactory.CreateLogger <ConsumerPipelineMicroservice>(); var rabbitService = new RabbitService( "Config.json", _serializationProvider, _encryptionProvider, _compressionProvider, loggerFactory); await rabbitService .Topologer .CreateQueueAsync("TestRabbitServiceQueue") .ConfigureAwait(false); for (var i = 0L; i < _targetCount; i++) { var letter = letterTemplate.Clone(); letter.Body = JsonSerializer.SerializeToUtf8Bytes(new Message { StringMessage = $"Sensitive ReceivedLetter {i}", MessageId = i }); letter.LetterId = (ulong)i; await rabbitService .Publisher .PublishAsync(letter, true, true) .ConfigureAwait(false); } return(rabbitService); }
public static async Task Main() { _hashingProvider = new Argon2IDHasher(); var hashKey = await _hashingProvider.GetHashKeyAsync("passwordforencryption", "saltforencryption", 32).ConfigureAwait(false); _encryptionProvider = new AesGcmEncryptionProvider(hashKey, _hashingProvider.Type); _compressionProvider = new GzipProvider(); _serializationProvider = new Utf8JsonProvider(StandardResolver.Default); _rabbitService = new RabbitService( "Config.json", _serializationProvider, _encryptionProvider, _compressionProvider, null); await RunSimpleClientWithEncryptionAsync() .ConfigureAwait(false); await RunDataExecutionEngineAsync() .ConfigureAwait(false); }
private static async Task SetupAsync() { var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole().SetMinimumLevel(LogLevel)); _hashingProvider = new Argon2IDHasher(); var hashKey = await _hashingProvider.GetHashKeyAsync("passwordforencryption", "saltforencryption", 32).ConfigureAwait(false); _encryptionProvider = new AesGcmEncryptionProvider(hashKey, _hashingProvider.Type); _compressionProvider = new LZ4PickleProvider(); _serializationProvider = new Utf8JsonProvider(); _rabbitService = new RabbitService( "Config.json", _serializationProvider, _encryptionProvider, _compressionProvider, loggerFactory); await _rabbitService .Topologer .CreateQueueAsync("TestRabbitServiceQueue") .ConfigureAwait(false); }
public RabbitFixture() { CompressionProvider = new GzipProvider(); HashingProvider = new Argon2IDHasher(); HashKey = HashingProvider.GetHashKeyAsync(Passphrase, Salt, 32).GetAwaiter().GetResult(); EncryptionProvider = new AesGcmEncryptionProvider(HashKey, HashingProvider.Type); SerializationProvider = new Utf8JsonProvider(); Options = JsonFileReader.ReadFileAsync <Options>("Config.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 async Task CreateArgonHashKeyAsync() { var hashKey = await HashProvider .GetHashKeyAsync(Passphrase, Salt, KeySize) .ConfigureAwait(false); }