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
- ThousandthOfEmRealPoints.cs
- OleDbParameter.cs
- ExpressionBuilderCollection.cs
- BamlVersionHeader.cs
- RtfControlWordInfo.cs
- SegmentInfo.cs
- WindowsStatic.cs
- CodeSnippetExpression.cs
- AttributeProviderAttribute.cs
- ObjectNavigationPropertyMapping.cs
- Tool.cs
- GridSplitterAutomationPeer.cs
- Int16AnimationUsingKeyFrames.cs
- DictionarySectionHandler.cs
- UiaCoreTypesApi.cs
- PropertyState.cs
- PrintDocument.cs
- PropertyTabChangedEvent.cs
- BmpBitmapEncoder.cs
- linebase.cs
- HwndPanningFeedback.cs
- CodeIndexerExpression.cs
- KnownIds.cs
- Gdiplus.cs
- SQLGuidStorage.cs
- FigureParaClient.cs
- DiagnosticTrace.cs
- ScrollItemProviderWrapper.cs
- Renderer.cs
- ComboBox.cs
- SqlParameterCollection.cs
- UnsafeNativeMethods.cs
- Brushes.cs
- Baml2006KnownTypes.cs
- EdmRelationshipRoleAttribute.cs
- ClientBuildManager.cs
- EntityDataSourceState.cs
- RegexRunner.cs
- _DomainName.cs
- ExpressionVisitor.cs
- AppearanceEditorPart.cs
- ItemContainerGenerator.cs
- EnumBuilder.cs
- Grant.cs
- StrokeDescriptor.cs
- RuntimeCompatibilityAttribute.cs
- Model3DGroup.cs
- SmtpFailedRecipientsException.cs
- X509Certificate2.cs
- JoinTreeNode.cs
- KoreanCalendar.cs
- PagerSettings.cs
- UnknownBitmapEncoder.cs
- XmlSignatureProperties.cs
- FixedDocumentPaginator.cs
- Menu.cs
- WebServiceErrorEvent.cs
- ContentHostHelper.cs
- DataGridViewHeaderCell.cs
- StringHelper.cs
- DataBindingValueUIHandler.cs
- AsymmetricSignatureFormatter.cs
- SmtpFailedRecipientsException.cs
- Constraint.cs
- NamespaceQuery.cs
- SynchronizedMessageSource.cs
- SqlDataSourceSummaryPanel.cs
- SimpleType.cs
- SQLByteStorage.cs
- TypedDatasetGenerator.cs
- TrustLevelCollection.cs
- ProcessInfo.cs
- TraceData.cs
- ButtonBaseAutomationPeer.cs
- AspNetPartialTrustHelpers.cs
- QilExpression.cs
- XmlMtomReader.cs
- CachedPathData.cs
- ReferenceService.cs
- ModuleBuilderData.cs
- AutoGeneratedFieldProperties.cs
- Visitors.cs
- ReadonlyMessageFilter.cs
- WsatTransactionFormatter.cs
- SortedDictionary.cs
- LoginView.cs
- AdRotatorDesigner.cs
- ViewPort3D.cs
- CloseSequence.cs
- WindowsGrip.cs
- RuntimeHelpers.cs
- MaskInputRejectedEventArgs.cs
- PageCodeDomTreeGenerator.cs
- StateMachineWorkflow.cs
- OperatingSystem.cs
- SafeNativeMethodsMilCoreApi.cs
- PathFigureCollectionValueSerializer.cs
- ImportContext.cs
- IISMapPath.cs
- TraceContextRecord.cs