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
- AdapterUtil.cs
- XPathAxisIterator.cs
- DynamicPhysicalDiscoSearcher.cs
- SecureConversationDriver.cs
- EmulateRecognizeCompletedEventArgs.cs
- _LoggingObject.cs
- ThreadAbortException.cs
- RepeaterItemCollection.cs
- MemoryFailPoint.cs
- StatusBarItemAutomationPeer.cs
- RC2.cs
- ClaimComparer.cs
- Table.cs
- NamespaceInfo.cs
- InstanceDescriptor.cs
- Vertex.cs
- CompoundFileIOPermission.cs
- XhtmlBasicObjectListAdapter.cs
- FamilyTypeface.cs
- BaseResourcesBuildProvider.cs
- HttpResponseHeader.cs
- SqlStream.cs
- GridView.cs
- EditBehavior.cs
- MimeTypeMapper.cs
- ResourceKey.cs
- QilTernary.cs
- TraceListeners.cs
- ADConnectionHelper.cs
- AdRotatorDesigner.cs
- UrlMappingsModule.cs
- DispatchWrapper.cs
- BooleanAnimationUsingKeyFrames.cs
- RunClient.cs
- SqlMetaData.cs
- UpdatePanel.cs
- ContentDisposition.cs
- IndicCharClassifier.cs
- ProcessHostMapPath.cs
- EdmType.cs
- StrokeNodeData.cs
- ChangePassword.cs
- MethodBuilderInstantiation.cs
- SynchronizingStream.cs
- MetadataSource.cs
- VariableDesigner.xaml.cs
- BufferedGraphicsContext.cs
- Parser.cs
- IRCollection.cs
- Binding.cs
- KerberosSecurityTokenParameters.cs
- QueueException.cs
- XPathParser.cs
- PerSessionInstanceContextProvider.cs
- GPRECTF.cs
- RegistrySecurity.cs
- ProxyWebPartManagerDesigner.cs
- MetadataCache.cs
- HttpConfigurationContext.cs
- SchemaNotation.cs
- ConsoleKeyInfo.cs
- XmlSchemaException.cs
- RootBrowserWindow.cs
- TargetControlTypeAttribute.cs
- ReflectTypeDescriptionProvider.cs
- IsolationInterop.cs
- ChangePassword.cs
- XmlWriter.cs
- DurableServiceAttribute.cs
- MetadataItemEmitter.cs
- ClientSideQueueItem.cs
- MachineSettingsSection.cs
- SelectionPatternIdentifiers.cs
- NetTcpBinding.cs
- InlineObject.cs
- ImageMap.cs
- WriteFileContext.cs
- XmlConvert.cs
- WebPartEditorCancelVerb.cs
- NativeRightsManagementAPIsStructures.cs
- Hyperlink.cs
- RegexParser.cs
- CodeSubDirectoriesCollection.cs
- DesignColumnCollection.cs
- AppDomainAttributes.cs
- DesignerTextBoxAdapter.cs
- GreenMethods.cs
- WebPartsPersonalization.cs
- WsdlHelpGeneratorElement.cs
- CompositeFontFamily.cs
- ClientUtils.cs
- DoubleAverageAggregationOperator.cs
- GraphicsPath.cs
- UInt64.cs
- codemethodreferenceexpression.cs
- SendContent.cs
- TemplateParser.cs
- CompiledRegexRunner.cs
- RichTextBox.cs
- PtsPage.cs