public override void Dispose() { base.Dispose(); temperature?.Dispose(); image?.Dispose(); }
public void Dispose() { PinnedBuffer <Foo> buffer = new PinnedBuffer <Foo>(42); buffer.Dispose(); Assert.True(buffer.IsDisposedOrLostArrayOwnership); }
protected virtual void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { } _dataBuffer?.Dispose(); _dataBuffer = null; SSourcePictureBuffer?.Dispose(); SSourcePictureBuffer = null; _disposed = true; }
protected virtual void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { _logger.LogInformation("[vst] stop"); CloseAsync().Wait(); _audioMaster.EffectMap.Remove(_aeffectPtr); _audioMasterCallBack?.Dispose(); _events?.Dispose(); _eventList?.Dispose(); } _disposed = true; }
internal PinnedBuffer DeriveKey() { var result = (PinnedBuffer)null; try { using (var controlToken = StateControl.Enter()) { if (DerivationMode == SecureSymmetricKeyDerivationMode.Pbkdf2) { try { // Perform PBKDF2 key-derivation. result = new PinnedBuffer(Pbkdf2Provider.GetBytes(DerivedKeyLength), true); } finally { Pbkdf2Provider.Reset(); } return(result); } result = new PinnedBuffer(DerivedKeyLength, true); using (var sourceWords = new PinnedStructureArray <UInt32>(KeySourceWordCount, true)) { KeySource.Access((PinnedBuffer buffer) => { // Convert the source buffer to an array of 32-bit words. Buffer.BlockCopy(buffer, 0, sourceWords, 0, KeySourceLengthInBytes); }); using (var transformedWords = new PinnedStructureArray <UInt32>(BlockWordCount, true)) { // Copy out the first block. If nothing further is done, this satisfies truncation mode. Array.Copy(sourceWords, transformedWords, BlockWordCount); switch (DerivationMode) { case SecureSymmetricKeyDerivationMode.Truncation: break; case SecureSymmetricKeyDerivationMode.XorLayering: for (var i = 1; i < BlockCount; i++) { for (var j = 0; j < BlockWordCount; j++) { // Perform the XOR layering operation. transformedWords[j] = (transformedWords[j] ^ sourceWords[(i * BlockWordCount) + j]); } } break; case SecureSymmetricKeyDerivationMode.XorLayeringWithSubstitution: for (var i = 1; i < BlockCount; i++) { for (var j = 0; j < BlockWordCount; j++) { // Perform the XOR layering operation with substitution. transformedWords[j] = (SubstituteWord(transformedWords[j]) ^ sourceWords[(i * BlockWordCount) + j]); } } break; default: throw new InvalidOperationException($"The specified key derivation mode, {DerivationMode}, is not supported."); } // Copy out the key bits. Buffer.BlockCopy(transformedWords, 0, result, 0, DerivedKeyLength); } } return(result); } } catch { result?.Dispose(); throw new SecurityException("Key derivation failed."); } }