Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / clr / src / BCL / System / Security / Cryptography / RijndaelManaged.cs / 1 / RijndaelManaged.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
//
// RijndaelManaged.cs
//
namespace System.Security.Cryptography
{
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class RijndaelManaged : Rijndael {
public RijndaelManaged () {
if (Utils.FipsAlgorithmPolicy == 1)
throw new InvalidOperationException(Environment.GetResourceString("Cryptography_NonCompliantFIPSAlgorithm"));
}
public override ICryptoTransform CreateEncryptor (byte[] rgbKey, byte[] rgbIV) {
return NewEncryptor (rgbKey, ModeValue, rgbIV, FeedbackSizeValue, RijndaelManagedTransformMode.Encrypt);
}
public override ICryptoTransform CreateDecryptor (byte[] rgbKey, byte[] rgbIV) {
return NewEncryptor (rgbKey, ModeValue, rgbIV, FeedbackSizeValue, RijndaelManagedTransformMode.Decrypt);
}
public override void GenerateKey () {
KeyValue = new byte[KeySizeValue/8];
Utils.StaticRandomNumberGenerator.GetBytes(KeyValue);
}
public override void GenerateIV () {
IVValue = new byte[BlockSizeValue/8];
Utils.StaticRandomNumberGenerator.GetBytes(IVValue);
}
private ICryptoTransform NewEncryptor (byte[] rgbKey,
CipherMode mode,
byte[] rgbIV,
int feedbackSize,
RijndaelManagedTransformMode encryptMode) {
// Build the key if one does not already exist
if (rgbKey == null) {
rgbKey = new byte[KeySizeValue/8];
Utils.StaticRandomNumberGenerator.GetBytes(rgbKey);
}
// If not ECB mode, make sure we have an IV
if (mode != CipherMode.ECB) {
if (rgbIV == null) {
rgbIV = new byte[BlockSizeValue/8];
Utils.StaticRandomNumberGenerator.GetBytes(rgbIV);
}
}
// Create the encryptor/decryptor object
return new RijndaelManagedTransform (rgbKey,
mode,
rgbIV,
BlockSizeValue,
feedbackSize,
PaddingValue,
encryptMode);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
//
// RijndaelManaged.cs
//
namespace System.Security.Cryptography
{
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class RijndaelManaged : Rijndael {
public RijndaelManaged () {
if (Utils.FipsAlgorithmPolicy == 1)
throw new InvalidOperationException(Environment.GetResourceString("Cryptography_NonCompliantFIPSAlgorithm"));
}
public override ICryptoTransform CreateEncryptor (byte[] rgbKey, byte[] rgbIV) {
return NewEncryptor (rgbKey, ModeValue, rgbIV, FeedbackSizeValue, RijndaelManagedTransformMode.Encrypt);
}
public override ICryptoTransform CreateDecryptor (byte[] rgbKey, byte[] rgbIV) {
return NewEncryptor (rgbKey, ModeValue, rgbIV, FeedbackSizeValue, RijndaelManagedTransformMode.Decrypt);
}
public override void GenerateKey () {
KeyValue = new byte[KeySizeValue/8];
Utils.StaticRandomNumberGenerator.GetBytes(KeyValue);
}
public override void GenerateIV () {
IVValue = new byte[BlockSizeValue/8];
Utils.StaticRandomNumberGenerator.GetBytes(IVValue);
}
private ICryptoTransform NewEncryptor (byte[] rgbKey,
CipherMode mode,
byte[] rgbIV,
int feedbackSize,
RijndaelManagedTransformMode encryptMode) {
// Build the key if one does not already exist
if (rgbKey == null) {
rgbKey = new byte[KeySizeValue/8];
Utils.StaticRandomNumberGenerator.GetBytes(rgbKey);
}
// If not ECB mode, make sure we have an IV
if (mode != CipherMode.ECB) {
if (rgbIV == null) {
rgbIV = new byte[BlockSizeValue/8];
Utils.StaticRandomNumberGenerator.GetBytes(rgbIV);
}
}
// Create the encryptor/decryptor object
return new RijndaelManagedTransform (rgbKey,
mode,
rgbIV,
BlockSizeValue,
feedbackSize,
PaddingValue,
encryptMode);
}
}
}
// 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
- loginstatus.cs
- DataGridViewCellValidatingEventArgs.cs
- ToolStripHighContrastRenderer.cs
- DrawingContext.cs
- ConversionHelper.cs
- DateTimeOffset.cs
- ViewgenGatekeeper.cs
- DataGridClipboardHelper.cs
- _AcceptOverlappedAsyncResult.cs
- ToolConsole.cs
- Rule.cs
- RolePrincipal.cs
- ManifestResourceInfo.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- BitmapEffectGroup.cs
- OracleConnectionFactory.cs
- BuildManagerHost.cs
- CodeParameterDeclarationExpression.cs
- Effect.cs
- ProvidersHelper.cs
- DataControlPagerLinkButton.cs
- GB18030Encoding.cs
- Suspend.cs
- DbModificationCommandTree.cs
- listviewsubitemcollectioneditor.cs
- AsyncPostBackTrigger.cs
- SelectionEditor.cs
- XmlExtensionFunction.cs
- WhiteSpaceTrimStringConverter.cs
- QilFactory.cs
- ContentDisposition.cs
- RadioButton.cs
- PropertyInfoSet.cs
- MethodBuilderInstantiation.cs
- DefaultProxySection.cs
- GenericsInstances.cs
- TypeConverterHelper.cs
- _NativeSSPI.cs
- PtsCache.cs
- PageVisual.cs
- ToolboxItemAttribute.cs
- HttpRequest.cs
- StateDesignerConnector.cs
- CodeMethodInvokeExpression.cs
- IdentitySection.cs
- SerializationException.cs
- XmlDataSourceNodeDescriptor.cs
- OracleParameterCollection.cs
- XmlAnyAttributeAttribute.cs
- VarRemapper.cs
- DesignerLoader.cs
- ListArgumentProvider.cs
- BrowserCapabilitiesFactory35.cs
- DesignerAutoFormatCollection.cs
- LogReservationCollection.cs
- ImageCodecInfo.cs
- AsyncOperationManager.cs
- WinInet.cs
- Internal.cs
- QueryOperator.cs
- ListViewPagedDataSource.cs
- FunctionNode.cs
- FtpWebRequest.cs
- XmlRawWriterWrapper.cs
- LowerCaseStringConverter.cs
- NegationPusher.cs
- GridViewSortEventArgs.cs
- JsonXmlDataContract.cs
- UIAgentAsyncParams.cs
- CheckBoxList.cs
- HttpValueCollection.cs
- SqlMethodCallConverter.cs
- SynchronizationLockException.cs
- DataSourceControlBuilder.cs
- RegexCompiler.cs
- IItemContainerGenerator.cs
- x509store.cs
- DateTimeValueSerializer.cs
- DataGridState.cs
- SkewTransform.cs
- CodeDirectionExpression.cs
- SQLDoubleStorage.cs
- Crc32.cs
- SerializationFieldInfo.cs
- WasEndpointConfigContainer.cs
- StrictAndMessageFilter.cs
- ApplicationDirectory.cs
- NumericUpDownAccelerationCollection.cs
- BitmapScalingModeValidation.cs
- IsolatedStorageException.cs
- SQLMembershipProvider.cs
- HiddenFieldDesigner.cs
- Transform.cs
- InputBindingCollection.cs
- AncestorChangedEventArgs.cs
- LoadGrammarCompletedEventArgs.cs
- EmbeddedMailObject.cs
- Single.cs
- SynchronizedPool.cs
- KeyedHashAlgorithm.cs