Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / IdentityModel / System / IdentityModel / HashStream.cs / 1 / 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. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- login.cs
- ImagingCache.cs
- OutputScope.cs
- XamlToRtfParser.cs
- DesignerAttribute.cs
- HtmlInputControl.cs
- IteratorFilter.cs
- CompressionTracing.cs
- SecurityIdentifierElementCollection.cs
- QuinticEase.cs
- UnhandledExceptionEventArgs.cs
- ListSortDescriptionCollection.cs
- StorageFunctionMapping.cs
- AppDomain.cs
- OleDbError.cs
- GZipObjectSerializer.cs
- BinaryObjectReader.cs
- SqlDataReaderSmi.cs
- Page.cs
- TripleDES.cs
- DataControlPagerLinkButton.cs
- StringBuilder.cs
- ProviderSettingsCollection.cs
- MsmqOutputChannel.cs
- RadioButtonFlatAdapter.cs
- HtmlInputButton.cs
- StringInfo.cs
- TableItemProviderWrapper.cs
- TextEncodedRawTextWriter.cs
- UpdatePanel.cs
- OleDbErrorCollection.cs
- OptimizerPatterns.cs
- BamlLocalizer.cs
- securestring.cs
- ClientTarget.cs
- TextServicesProperty.cs
- ToolBarTray.cs
- InputChannelAcceptor.cs
- CodeDomSerializerBase.cs
- KeyTimeConverter.cs
- CollectionViewGroup.cs
- OracleBinary.cs
- SHA1Managed.cs
- SoapHeaderAttribute.cs
- UnsupportedPolicyOptionsException.cs
- StringExpressionSet.cs
- InvalidProgramException.cs
- SendMessageRecord.cs
- EntityContainerRelationshipSet.cs
- TextSearch.cs
- FunctionParameter.cs
- SkipStoryboardToFill.cs
- HighlightVisual.cs
- Matrix.cs
- DBNull.cs
- IncrementalReadDecoders.cs
- UnsafeNativeMethods.cs
- DataGridViewImageColumn.cs
- TransformProviderWrapper.cs
- infer.cs
- EntityDataSourceUtil.cs
- safex509handles.cs
- SystemDropShadowChrome.cs
- DataControlFieldCell.cs
- EncoderBestFitFallback.cs
- DictionarySectionHandler.cs
- RewritingPass.cs
- DummyDataSource.cs
- UserControl.cs
- EntityCodeGenerator.cs
- StyleSheetDesigner.cs
- SelectedDatesCollection.cs
- DrawingContextWalker.cs
- DispatcherFrame.cs
- ServicePrincipalNameElement.cs
- ResourceExpression.cs
- PeerContact.cs
- UserControl.cs
- SmtpSection.cs
- Gdiplus.cs
- ArrayElementGridEntry.cs
- DataObject.cs
- DesignerCalendarAdapter.cs
- PeerEndPoint.cs
- HtmlTableCellCollection.cs
- NavigationHelper.cs
- MethodBody.cs
- ItemContainerGenerator.cs
- RoutedCommand.cs
- SendingRequestEventArgs.cs
- ControlBindingsCollection.cs
- VisualStateChangedEventArgs.cs
- Selector.cs
- ProviderCommandInfoUtils.cs
- SqlClientMetaDataCollectionNames.cs
- Point3DAnimationUsingKeyFrames.cs
- WS2007FederationHttpBinding.cs
- DependencyObjectType.cs
- RectKeyFrameCollection.cs
- EntityDataSourceStatementEditorForm.cs