Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Security / Cryptography / SHA256CryptoServiceProvider.cs / 1305376 / SHA256CryptoServiceProvider.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
using System;
using System.Diagnostics.Contracts;
namespace System.Security.Cryptography {
///
/// Wrapper around the CAPI implementation of the SHA-256 hashing algorithm
///
[System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
public sealed class SHA256CryptoServiceProvider : SHA256 {
private CapiHashAlgorithm m_hashAlgorithm;
//
//
//
[System.Security.SecurityCritical]
public SHA256CryptoServiceProvider() {
Contract.Ensures(m_hashAlgorithm != null);
m_hashAlgorithm = new CapiHashAlgorithm(CapiNative.ProviderNames.MicrosoftEnhancedRsaAes,
CapiNative.ProviderType.RsaAes,
CapiNative.AlgorithmId.Sha256);
}
//
//
//
[System.Security.SecurityCritical]
protected override void Dispose(bool disposing) {
try {
if (disposing) {
m_hashAlgorithm.Dispose();
}
}
finally {
base.Dispose(disposing);
}
}
///
/// Reset the hash algorithm to begin hashing a new set of data
///
//
//
//
[System.Security.SecurityCritical]
public override void Initialize() {
Contract.Assert(m_hashAlgorithm != null);
m_hashAlgorithm.Initialize();
}
///
/// Hash a block of data
///
//
//
//
[System.Security.SecurityCritical]
protected override void HashCore(byte[] array, int ibStart, int cbSize) {
Contract.Assert(m_hashAlgorithm != null);
m_hashAlgorithm.HashCore(array, ibStart, cbSize);
}
///
/// Complete the hash, returning its value
///
//
//
//
[System.Security.SecurityCritical]
protected override byte[] HashFinal() {
Contract.Assert(m_hashAlgorithm != null);
return m_hashAlgorithm.HashFinal();
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
using System;
using System.Diagnostics.Contracts;
namespace System.Security.Cryptography {
///
/// Wrapper around the CAPI implementation of the SHA-256 hashing algorithm
///
[System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
public sealed class SHA256CryptoServiceProvider : SHA256 {
private CapiHashAlgorithm m_hashAlgorithm;
//
//
//
[System.Security.SecurityCritical]
public SHA256CryptoServiceProvider() {
Contract.Ensures(m_hashAlgorithm != null);
m_hashAlgorithm = new CapiHashAlgorithm(CapiNative.ProviderNames.MicrosoftEnhancedRsaAes,
CapiNative.ProviderType.RsaAes,
CapiNative.AlgorithmId.Sha256);
}
//
//
//
[System.Security.SecurityCritical]
protected override void Dispose(bool disposing) {
try {
if (disposing) {
m_hashAlgorithm.Dispose();
}
}
finally {
base.Dispose(disposing);
}
}
///
/// Reset the hash algorithm to begin hashing a new set of data
///
//
//
//
[System.Security.SecurityCritical]
public override void Initialize() {
Contract.Assert(m_hashAlgorithm != null);
m_hashAlgorithm.Initialize();
}
///
/// Hash a block of data
///
//
//
//
[System.Security.SecurityCritical]
protected override void HashCore(byte[] array, int ibStart, int cbSize) {
Contract.Assert(m_hashAlgorithm != null);
m_hashAlgorithm.HashCore(array, ibStart, cbSize);
}
///
/// Complete the hash, returning its value
///
//
//
//
[System.Security.SecurityCritical]
protected override byte[] HashFinal() {
Contract.Assert(m_hashAlgorithm != null);
return m_hashAlgorithm.HashFinal();
}
}
}
// 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
- DataPagerField.cs
- SqlUserDefinedAggregateAttribute.cs
- ObjectDataSourceFilteringEventArgs.cs
- ContainerParaClient.cs
- ConvertBinder.cs
- FloaterParagraph.cs
- XmlAggregates.cs
- SqlParameterCollection.cs
- SizeAnimationClockResource.cs
- ReadOnlyDataSourceView.cs
- arabicshape.cs
- ZipIORawDataFileBlock.cs
- TypeUtil.cs
- AutomationPatternInfo.cs
- MonitorWrapper.cs
- PropertyInfoSet.cs
- HMACMD5.cs
- TypeConverterHelper.cs
- Panel.cs
- TypedMessageConverter.cs
- ServiceContractListItemList.cs
- HTMLTextWriter.cs
- EntitySqlException.cs
- DataPointer.cs
- BaseTemplatedMobileComponentEditor.cs
- PropertyContainer.cs
- SiteMapPath.cs
- TemplateParser.cs
- SchemaLookupTable.cs
- FileAuthorizationModule.cs
- EndpointInstanceProvider.cs
- HighlightVisual.cs
- ProxyWebPartManager.cs
- Rotation3D.cs
- UIAgentCrashedException.cs
- CssStyleCollection.cs
- HandleTable.cs
- ReadOnlyTernaryTree.cs
- remotingproxy.cs
- Trigger.cs
- GACIdentityPermission.cs
- XmlSerializableWriter.cs
- ManagementNamedValueCollection.cs
- PerfService.cs
- ReflectionPermission.cs
- SocketException.cs
- OleDbConnectionInternal.cs
- RecognizerBase.cs
- TiffBitmapEncoder.cs
- WebPartZoneBase.cs
- TagMapCollection.cs
- UnknownBitmapDecoder.cs
- XmlElementAttributes.cs
- StringCollectionMarkupSerializer.cs
- ScrollBar.cs
- UInt64Storage.cs
- FormViewUpdateEventArgs.cs
- Parameter.cs
- EastAsianLunisolarCalendar.cs
- ContractNamespaceAttribute.cs
- DataGridComboBoxColumn.cs
- DependencyPropertyKey.cs
- ModelFunction.cs
- CodePageUtils.cs
- IgnoreFileBuildProvider.cs
- VisualStyleRenderer.cs
- EndpointAddressProcessor.cs
- UnitControl.cs
- ChangeBlockUndoRecord.cs
- BinaryKeyIdentifierClause.cs
- WmlLabelAdapter.cs
- BaseResourcesBuildProvider.cs
- HtmlShimManager.cs
- FileSecurity.cs
- PanelStyle.cs
- InheritanceContextHelper.cs
- ApplicationInfo.cs
- DesigntimeLicenseContextSerializer.cs
- CfgParser.cs
- AbstractDataSvcMapFileLoader.cs
- Expression.DebuggerProxy.cs
- ObjectSecurityT.cs
- TemplateField.cs
- Setter.cs
- ProxyHwnd.cs
- PageAdapter.cs
- _SSPIWrapper.cs
- ImageInfo.cs
- TemplateInstanceAttribute.cs
- ValidationHelpers.cs
- ReadOnlyHierarchicalDataSourceView.cs
- WizardForm.cs
- coordinatorfactory.cs
- XmlTextWriter.cs
- CollectionViewGroup.cs
- LayoutInformation.cs
- InheritanceAttribute.cs
- TemplateNodeContextMenu.cs
- WinHttpWebProxyFinder.cs
- DbProviderServices.cs