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
- SqlTrackingQuery.cs
- RadioButton.cs
- SqlSelectStatement.cs
- HttpWebResponse.cs
- Asn1Utilities.cs
- ComponentEditorForm.cs
- OneOfTypeConst.cs
- AttributeQuery.cs
- CatalogZoneBase.cs
- IndependentAnimationStorage.cs
- TcpDuplicateContext.cs
- DataDesignUtil.cs
- XmlDataImplementation.cs
- PropertyGridEditorPart.cs
- RawKeyboardInputReport.cs
- CheckBoxField.cs
- Math.cs
- WMIGenerator.cs
- SizeAnimationClockResource.cs
- SelectionRange.cs
- DotNetATv1WindowsLogEntrySerializer.cs
- DataServiceQueryContinuation.cs
- Selector.cs
- FileDialogCustomPlace.cs
- ValueTypeFixupInfo.cs
- ProxyWebPartManager.cs
- FederatedMessageSecurityOverHttp.cs
- ReferenceSchema.cs
- ConfigXmlComment.cs
- EndpointNotFoundException.cs
- ResourceProviderFactory.cs
- PieceDirectory.cs
- TiffBitmapDecoder.cs
- IntellisenseTextBox.cs
- GridViewRowPresenterBase.cs
- ToolStripCustomTypeDescriptor.cs
- PnrpPeerResolver.cs
- ContainsRowNumberChecker.cs
- ModelMemberCollection.cs
- Object.cs
- BuiltInPermissionSets.cs
- ProjectedSlot.cs
- SessionKeyExpiredException.cs
- FunctionDetailsReader.cs
- COM2DataTypeToManagedDataTypeConverter.cs
- Font.cs
- StyleSheetComponentEditor.cs
- XmlSigningNodeWriter.cs
- SelectionWordBreaker.cs
- DeliveryStrategy.cs
- XmlDeclaration.cs
- Utils.cs
- NTAccount.cs
- SerializationStore.cs
- RelativeSource.cs
- ConfigurationValues.cs
- MachineKeySection.cs
- FileUpload.cs
- ReadonlyMessageFilter.cs
- TargetException.cs
- DataRow.cs
- BaseValidatorDesigner.cs
- DesignTimeType.cs
- VirtualPathProvider.cs
- CompilationUnit.cs
- FixedSOMGroup.cs
- PersonalizationProvider.cs
- AuthorizationSection.cs
- WebFaultClientMessageInspector.cs
- WindowVisualStateTracker.cs
- BufferBuilder.cs
- InputScopeConverter.cs
- MetadataArtifactLoaderFile.cs
- TimeoutValidationAttribute.cs
- Win32NamedPipes.cs
- GridViewPageEventArgs.cs
- ComplexBindingPropertiesAttribute.cs
- EntityParameterCollection.cs
- ImageButton.cs
- _AutoWebProxyScriptWrapper.cs
- DragSelectionMessageFilter.cs
- DataGridViewElement.cs
- ApplicationCommands.cs
- CryptoKeySecurity.cs
- OracleBoolean.cs
- XmlIlGenerator.cs
- AssociationEndMember.cs
- InvokeGenerator.cs
- ClassImporter.cs
- ComponentManagerBroker.cs
- Types.cs
- TemplateControlBuildProvider.cs
- MultiView.cs
- DataGridrowEditEndingEventArgs.cs
- Panel.cs
- CompressEmulationStream.cs
- Int32Rect.cs
- DiscoveryViaBehavior.cs
- CfgRule.cs
- OutputCacheSettingsSection.cs