public Blake2BHasher(Blake2BConfig config) { if (config == null) { config = DefaultConfig; } this.core = new Blake2BCore(config.LockMemoryPolicy); this.rawConfig = Blake2IvBuilder.ConfigB(config, null); if (config.Key != null && config.Key.Length != 0) { this.key = new SecureArray <byte>(128); Array.Copy(config.Key, this.key.Buffer, config.Key.Length); } this.outputSizeInBytes = config.OutputSizeInBytes; this.defaultOutputBuffer = config.Result64ByteBuffer; this.Init(); }
public Blake2BHasher(Blake2BConfig config, SecureArrayCall secureArrayCall) { if (config == null) { config = DefaultConfig; } this.core = new Blake2BCore(secureArrayCall, config.LockMemoryPolicy); this.rawConfig = Blake2IvBuilder.ConfigB(config, null, secureArrayCall); if (config.Key != null && config.Key.Length != 0) { switch (config.LockMemoryPolicy) { case LockMemoryPolicy.None: this.key = new SecureArray <byte>(128, SecureArrayType.ZeroedAndPinned, secureArrayCall); break; case LockMemoryPolicy.BestEffort: try { this.key = new SecureArray <byte>(128, SecureArrayType.ZeroedPinnedAndNoSwap, secureArrayCall); } catch (LockFailException e) { this.key = new SecureArray <byte>(128, SecureArrayType.ZeroedAndPinned, secureArrayCall); } break; default: this.key = new SecureArray <byte>(128, SecureArrayType.ZeroedPinnedAndNoSwap, secureArrayCall); break; } Array.Copy(config.Key, this.key.Buffer, config.Key.Length); } this.outputSizeInBytes = config.OutputSizeInBytes; this.defaultOutputBuffer = config.Result64ByteBuffer; this.Init(); }