Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WSHttpBindingCollectionElement.cs
- DataListCommandEventArgs.cs
- SimpleFieldTemplateFactory.cs
- DesignOnlyAttribute.cs
- ErrorTableItemStyle.cs
- DoubleAnimationBase.cs
- ExecutedRoutedEventArgs.cs
- AdornerDecorator.cs
- SqlBooleanizer.cs
- COM2ComponentEditor.cs
- ServiceDescriptionImporter.cs
- TileBrush.cs
- SourceInterpreter.cs
- AsymmetricSignatureFormatter.cs
- AggregateException.cs
- WebPartsPersonalization.cs
- BatchParser.cs
- WebContext.cs
- DbTransaction.cs
- ListView.cs
- basevalidator.cs
- ipaddressinformationcollection.cs
- PassportAuthentication.cs
- TransactionInformation.cs
- EntityModelBuildProvider.cs
- TaskExtensions.cs
- QuadraticBezierSegment.cs
- DataGridViewCellCancelEventArgs.cs
- ViewCellRelation.cs
- ToolStripDropDown.cs
- XmlSchemaImport.cs
- CompositeCollection.cs
- MouseOverProperty.cs
- DataSetFieldSchema.cs
- FullTextState.cs
- CodeTypeParameter.cs
- XmlObjectSerializerWriteContextComplexJson.cs
- XmlParserContext.cs
- IsolatedStorageFile.cs
- COM2FontConverter.cs
- ParseHttpDate.cs
- ImageList.cs
- InheritablePropertyChangeInfo.cs
- SerializationFieldInfo.cs
- Pair.cs
- UnauthorizedWebPart.cs
- VirtualPath.cs
- FontClient.cs
- WebPartTransformerAttribute.cs
- IDQuery.cs
- BasePattern.cs
- JumpList.cs
- Helpers.cs
- RightsManagementEncryptionTransform.cs
- LogPolicy.cs
- WorkflowWebService.cs
- Color.cs
- MexTcpBindingCollectionElement.cs
- ColorPalette.cs
- DocumentViewerHelper.cs
- TextParaClient.cs
- GetWinFXPath.cs
- ByteStorage.cs
- PassportIdentity.cs
- BinaryMessageFormatter.cs
- DesignerValidatorAdapter.cs
- StringFreezingAttribute.cs
- BamlLocalizableResource.cs
- VerificationAttribute.cs
- SelectionProviderWrapper.cs
- SqlBooleanizer.cs
- WbemException.cs
- WebPartExportVerb.cs
- XmlWellformedWriter.cs
- DocumentViewerBase.cs
- HttpProxyTransportBindingElement.cs
- FormCollection.cs
- PageWrapper.cs
- ToolStripDropDownItem.cs
- HealthMonitoringSectionHelper.cs
- QueryOperationResponseOfT.cs
- DataServiceRequestOfT.cs
- DataGridViewTopRowAccessibleObject.cs
- DrawingState.cs
- TriggerBase.cs
- FileStream.cs
- DataServiceStreamResponse.cs
- TemplateControlParser.cs
- validation.cs
- SchemaCompiler.cs
- CryptoApi.cs
- InstanceContext.cs
- SqlDependency.cs
- AppDomainUnloadedException.cs
- BufferBuilder.cs
- OdbcInfoMessageEvent.cs
- InstanceLockQueryResult.cs
- HttpResponse.cs
- ZipFileInfo.cs
- RuntimeResourceSet.cs