Ejemplo n.º 1
0
        private HashedByteIdGenerator GetSut(IFastHasher hasher = null, ISafeRandom random = null,
                                             IMemoryProtectedBytes sessionSalt = null)
        {
            if (hasher == null)
            {
                var mockHasher = new Mock <IFastHasher>();
                mockHasher.Setup(m => m.ComputeFast(It.IsAny <byte[]>()))
#if !(NETCOREAPP3_1 || NETCOREAPP3_0)
                .Returns((byte[] b) => b[b.Length - 1]);
 private HashedByteIdGenerator GetSut(IFastHasher hasher = null, ISafeRandom random = null, IByteArrayProtector protector = null)
 {
     if (hasher == null)
     {
         var mockHasher = new Mock <IFastHasher>();
         mockHasher.Setup(m => m.ComputeFast(It.IsAny <byte[]>())).Returns((byte[] b) => b[b.Length - 1]);
         hasher = mockHasher.Object;
     }
     return(new HashedByteIdGenerator(hasher, random ?? Stubs.Get <ISafeRandom>(), protector ?? Mock.Of <IByteArrayProtector>()));
 }
Ejemplo n.º 3
0
 internal HashedByteIdGenerator(IFastHasher fastHasher, ISafeRandom safeRandom,
                                IMemoryProtectedBytes sessionSalt)
 {
     if (sessionSalt == null)
     {
         throw new ArgumentNullException(nameof(sessionSalt));
     }
     _fastHasher  = fastHasher ?? throw new ArgumentNullException(nameof(fastHasher));
     _safeRandom  = safeRandom ?? throw new ArgumentNullException(nameof(safeRandom));
     _sessionSalt = new AsyncLazy <IMemoryProtectedBytes>(() => InitializeSaltAsync(sessionSalt));
 }
Ejemplo n.º 4
0
 internal HashedByteIdGenerator(IFastHasher fastHasher, ISafeRandom safeRandom,
                                IByteArrayProtector memoryProtector)
 {
     if (fastHasher == null)
     {
         throw new ArgumentNullException(nameof(fastHasher));
     }
     if (safeRandom == null)
     {
         throw new ArgumentNullException(nameof(safeRandom));
     }
     if (memoryProtector == null)
     {
         throw new ArgumentNullException(nameof(memoryProtector));
     }
     _fastHasher      = fastHasher;
     _safeRandom      = safeRandom;
     _memoryProtector = memoryProtector;
 }