Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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); } } }
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- EntityFrameworkVersions.cs
- CodeCompiler.cs
- CssStyleCollection.cs
- HostedNamedPipeTransportManager.cs
- SortableBindingList.cs
- EntityDataSourceChangingEventArgs.cs
- QilExpression.cs
- RequestCache.cs
- DesignTable.cs
- AtomServiceDocumentSerializer.cs
- SqlFactory.cs
- RbTree.cs
- KeyGestureConverter.cs
- ResourceDictionary.cs
- TextTreeText.cs
- Environment.cs
- DotNetATv1WindowsLogEntrySerializer.cs
- DoubleConverter.cs
- DataContractFormatAttribute.cs
- BaseValidatorDesigner.cs
- ComponentEvent.cs
- IsolatedStorage.cs
- PageParser.cs
- XDeferredAxisSource.cs
- IIS7WorkerRequest.cs
- SByte.cs
- FacetDescriptionElement.cs
- PathFigure.cs
- DataGridParentRows.cs
- ParserExtension.cs
- ToolBarOverflowPanel.cs
- ProfileParameter.cs
- InputQueueChannel.cs
- TokenizerHelper.cs
- SqlBooleanizer.cs
- ToolBarPanel.cs
- TypedDataSetSchemaImporterExtensionFx35.cs
- NativeMethods.cs
- DefaultBinder.cs
- DPCustomTypeDescriptor.cs
- EntityViewContainer.cs
- ToolBarOverflowPanel.cs
- UseAttributeSetsAction.cs
- MarkupObject.cs
- SecurityImpersonationBehavior.cs
- TraceListener.cs
- ComponentSerializationService.cs
- WebPartEditorOkVerb.cs
- ProcessHostServerConfig.cs
- Char.cs
- WebPermission.cs
- Delegate.cs
- XmlSerializerNamespaces.cs
- RankException.cs
- ETagAttribute.cs
- DesignerSerializationOptionsAttribute.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- ClockGroup.cs
- PerspectiveCamera.cs
- TemplateApplicationHelper.cs
- XmlSerializableReader.cs
- WebPartConnectionsCancelEventArgs.cs
- ObjectPersistData.cs
- ToolStripDropDownClosedEventArgs.cs
- TextAction.cs
- CookielessHelper.cs
- WindowsImpersonationContext.cs
- DataGridViewBand.cs
- SqlMetaData.cs
- KoreanCalendar.cs
- SqlBuilder.cs
- InkCollectionBehavior.cs
- DefaultTextStoreTextComposition.cs
- Attribute.cs
- BitmapFrameEncode.cs
- EntitySetBaseCollection.cs
- SubstitutionResponseElement.cs
- LoginUtil.cs
- AuthenticationService.cs
- ListBindingHelper.cs
- PackageRelationshipSelector.cs
- FragmentQueryProcessor.cs
- IisTraceWebEventProvider.cs
- DeviceContexts.cs
- ValidationRule.cs
- Qualifier.cs
- MessageEncodingBindingElementImporter.cs
- InstanceDescriptor.cs
- ResourceKey.cs
- RegistryPermission.cs
- OptimalTextSource.cs
- PlanCompilerUtil.cs
- UnmanagedHandle.cs
- SoapElementAttribute.cs
- BaseValidator.cs
- BindingCollection.cs
- RenderingBiasValidation.cs
- ArcSegment.cs
- ToolStripPanelCell.cs
- FixedSOMTable.cs