Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / HashStream.cs / 1305376 / HashStream.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.IdentityModel { using System.IO; using System.Security.Cryptography; using System.IdentityModel.Diagnostics; sealed class HashStream : Stream { HashAlgorithm hash; long length; bool hashNeedsReset; MemoryStream logStream; public HashStream(HashAlgorithm hash) { if (hash == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("hash"); Reset(hash); } public override bool CanRead { get { return false; } } public override bool CanWrite { get { return true; } } public override bool CanSeek { get { return false; } } public HashAlgorithm Hash { get { return this.hash; } } public override long Length { get { return this.length; } } public override long Position { get { return this.length; } set { // PreSharp Bug: Property get methods should not throw exceptions. #pragma warning suppress 56503 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); } } public override void Flush() { } public void FlushHash() { this.hash.TransformFinalBlock(CryptoHelper.EmptyBuffer, 0, 0); if (DigestTraceRecordHelper.ShouldTraceDigest) DigestTraceRecordHelper.TraceDigest(this.logStream, this.hash); } public byte[] FlushHashAndGetValue() { FlushHash(); return this.hash.Hash; } public override int Read(byte[] buffer, int offset, int count) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); } public void Reset() { if (this.hashNeedsReset) { this.hash.Initialize(); this.hashNeedsReset = false; } this.length = 0; if (DigestTraceRecordHelper.ShouldTraceDigest) this.logStream = new MemoryStream(); } public void Reset(HashAlgorithm hash) { this.hash = hash; this.hashNeedsReset = false; this.length = 0; if (DigestTraceRecordHelper.ShouldTraceDigest) this.logStream = new MemoryStream(); } public override void Write(byte[] buffer, int offset, int count) { this.hash.TransformBlock(buffer, offset, count, buffer, offset); this.length += count; this.hashNeedsReset = true; if (DigestTraceRecordHelper.ShouldTraceDigest) this.logStream.Write(buffer, offset, count); } public override long Seek(long offset, SeekOrigin origin) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); } public override void SetLength(long length) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- VarRemapper.cs
- QueryOperatorEnumerator.cs
- filewebrequest.cs
- DocumentDesigner.cs
- SrgsRulesCollection.cs
- PathGeometry.cs
- InvokeAction.cs
- FontNamesConverter.cs
- WorkflowView.cs
- CancelAsyncOperationRequest.cs
- srgsitem.cs
- ExternalCalls.cs
- ComboBox.cs
- WebPartDescription.cs
- HtmlProps.cs
- ListViewGroupItemCollection.cs
- AutomationElementIdentifiers.cs
- IntPtr.cs
- FileLoadException.cs
- Transactions.cs
- Baml6Assembly.cs
- SqlUDTStorage.cs
- DoubleKeyFrameCollection.cs
- FunctionQuery.cs
- ToolboxService.cs
- RSAProtectedConfigurationProvider.cs
- WebPartEditorOkVerb.cs
- TripleDESCryptoServiceProvider.cs
- TextAnchor.cs
- _LocalDataStore.cs
- CodeLabeledStatement.cs
- SizeKeyFrameCollection.cs
- DockingAttribute.cs
- DataListItemCollection.cs
- UiaCoreTypesApi.cs
- RectangleF.cs
- CategoryAttribute.cs
- SynchronizedDispatch.cs
- Content.cs
- ConstructorArgumentAttribute.cs
- ByeMessage11.cs
- SqlGenericUtil.cs
- ApplicationCommands.cs
- CodeParameterDeclarationExpression.cs
- OpenTypeCommon.cs
- Button.cs
- ProjectionCamera.cs
- SqlWebEventProvider.cs
- UpdateException.cs
- MetadataArtifactLoaderFile.cs
- AuthenticationService.cs
- EllipseGeometry.cs
- Constant.cs
- IOThreadTimer.cs
- WindowsRichEdit.cs
- KeyboardNavigation.cs
- EntityAdapter.cs
- PagerSettings.cs
- UIAgentInitializationException.cs
- StringValueConverter.cs
- ConvertersCollection.cs
- DataShape.cs
- FieldTemplateFactory.cs
- Transform3DGroup.cs
- MethodRental.cs
- SqlCacheDependencySection.cs
- DataAdapter.cs
- DispatcherProcessingDisabled.cs
- TextCharacters.cs
- CompletedAsyncResult.cs
- SoapAttributeOverrides.cs
- CustomCredentialPolicy.cs
- Evidence.cs
- BindingValueChangedEventArgs.cs
- EditorPartDesigner.cs
- NoResizeSelectionBorderGlyph.cs
- ErrorHandler.cs
- DesigntimeLicenseContext.cs
- XPathParser.cs
- HtmlInputButton.cs
- FullTextBreakpoint.cs
- ZipIOExtraFieldPaddingElement.cs
- control.ime.cs
- LinqDataSourceUpdateEventArgs.cs
- GPRECT.cs
- TableAdapterManagerMethodGenerator.cs
- EventLevel.cs
- NameValueConfigurationCollection.cs
- ZipIOExtraFieldZip64Element.cs
- PropertyPathConverter.cs
- XPathNavigator.cs
- RemotingClientProxy.cs
- ResourceDisplayNameAttribute.cs
- AlignmentXValidation.cs
- CSharpCodeProvider.cs
- PreviewPageInfo.cs
- TemplatePropertyEntry.cs
- MulticastDelegate.cs
- KnownBoxes.cs
- StyleHelper.cs