private static ISafeBytes GetSut(ISafeByteCollection collection = null, ISafeByteFactory factory = null, IFactory <ISafeBytes> safeBytesFactory = null) { return(new SafeBytes( factory ?? Stubs.Get <ISafeByteFactory>(), safeBytesFactory ?? Stubs.GetFactory <ISafeBytes>(), Stubs.GetFactory(collection))); }
internal SafeBytes( ISafeByteFactory safeByteFactory, IFactory <ISafeBytes> safeBytesFactory, IFactory <ISafeByteCollection> safeByteCollectionFactory) { _safeByteFactory = safeByteFactory ?? throw new ArgumentNullException(nameof(safeByteFactory)); _safeBytesFactory = safeBytesFactory ?? throw new ArgumentNullException(nameof(safeBytesFactory)); _safeByteCollection = safeByteCollectionFactory.Create(); }
internal EncryptedSafeByteCollection(IFastEncryptor encryptor, IByteArrayProtector memoryProtector, IFastRandom fastRandom, ISafeByteFactory safeByteFactory) { if (encryptor == null) { throw new ArgumentNullException(nameof(encryptor)); } if (memoryProtector == null) { throw new ArgumentNullException(nameof(memoryProtector)); } if (safeByteFactory == null) { throw new ArgumentNullException(nameof(safeByteFactory)); } _encryptor = encryptor; _memoryProtector = memoryProtector; _safeByteFactory = safeByteFactory; _encryptionKey = fastRandom.GetBytes(_memoryProtector.BlockSizeInBytes); _memoryProtector.Protect(_encryptionKey); }
internal EncryptedSafeByteCollection( IFastEncryptor encryptor, IMemoryProtectedBytes encryptionKey, ICryptoRandom fastRandom, ISafeByteFactory safeByteFactory, IByteIdListSerializer <int> serializer) { if (fastRandom == null) { throw new ArgumentNullException(nameof(fastRandom)); } _encryptionKey = new AsyncLazy <IMemoryProtectedBytes>(async() => { await encryptionKey.InitializeAsync(fastRandom.GetBytes(encryptionKey.BlockSizeInBytes)) .ConfigureAwait(false); return(encryptionKey); }); _encryptor = encryptor ?? throw new ArgumentNullException(nameof(encryptor)); _safeByteFactory = safeByteFactory ?? throw new ArgumentNullException(nameof(safeByteFactory)); _serializer = serializer; _salt = fastRandom.GetBytes(encryptor.BlockSizeInBits / 8); }
internal SafeBytes( IFastRandom fastRandom, ISafeByteFactory safeByteFactory, IFactory <ISafeBytes> safeBytesFactory, IFactory <ISafeByteCollection> safeByteCollectionFactory) { if (fastRandom == null) { throw new ArgumentNullException(nameof(fastRandom)); } if (safeByteFactory == null) { throw new ArgumentNullException(nameof(safeByteFactory)); } if (safeBytesFactory == null) { throw new ArgumentNullException(nameof(safeBytesFactory)); } _fastRandom = fastRandom; _safeByteFactory = safeByteFactory; _safeBytesInstantiator = safeBytesFactory; _safeByteCollection = safeByteCollectionFactory.Create(); }
public async Task Init() { _sut = new MemoryCachedSafeByteFactory(); await _sut.InitializeAsync(); }
public void Init() { _sut = GetSut(); }
public void Init() { _sut = new MemoryCachedSafeByteFactory(); _sut.Initialize(); }