Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- ToolstripProfessionalRenderer.cs
- ScrollViewerAutomationPeer.cs
- TextFragmentEngine.cs
- entityreference_tresulttype.cs
- CounterCreationDataCollection.cs
- MasterPageParser.cs
- TableCell.cs
- ParentUndoUnit.cs
- recordstate.cs
- PropertyEmitter.cs
- LinkLabel.cs
- DataGridViewRowCollection.cs
- RootBrowserWindow.cs
- FigureHelper.cs
- ContentPresenter.cs
- OleDbError.cs
- DataObject.cs
- URLBuilder.cs
- MetafileHeaderWmf.cs
- DataGridViewSelectedCellCollection.cs
- FixedSOMImage.cs
- PenContexts.cs
- GradientStopCollection.cs
- DataObjectSettingDataEventArgs.cs
- ApplicationActivator.cs
- EncryptedPackageFilter.cs
- BypassElement.cs
- ElementMarkupObject.cs
- BamlBinaryWriter.cs
- NameValuePair.cs
- HtmlWindowCollection.cs
- PenLineCapValidation.cs
- COM2Properties.cs
- XamlParser.cs
- SoapObjectInfo.cs
- XmlAggregates.cs
- PropertyIDSet.cs
- SurrogateEncoder.cs
- DefaultAsyncDataDispatcher.cs
- InputScopeManager.cs
- SessionStateUtil.cs
- NamedPipeConnectionPool.cs
- MemberPathMap.cs
- Brush.cs
- EmissiveMaterial.cs
- PrivateUnsafeNativeCompoundFileMethods.cs
- XamlPathDataSerializer.cs
- DataBindingCollection.cs
- XmlSerializerObjectSerializer.cs
- SpotLight.cs
- UseAttributeSetsAction.cs
- Point3DAnimation.cs
- JumpList.cs
- InvalidTimeZoneException.cs
- DependencyPropertyConverter.cs
- PrintPageEvent.cs
- ContentElement.cs
- ServiceHttpModule.cs
- ZipIOExtraFieldElement.cs
- AsymmetricSignatureDeformatter.cs
- HelpInfo.cs
- SoapInteropTypes.cs
- CookielessHelper.cs
- SystemMulticastIPAddressInformation.cs
- DictionarySectionHandler.cs
- SerialPort.cs
- CommandConverter.cs
- SimpleTextLine.cs
- DependentList.cs
- SqlBulkCopyColumnMapping.cs
- UndirectedGraph.cs
- OutputScope.cs
- ToolStripButton.cs
- QuotedStringWriteStateInfo.cs
- SecurityUtils.cs
- TextEndOfParagraph.cs
- ChannelDispatcher.cs
- SafeNativeMethodsMilCoreApi.cs
- ControlBuilderAttribute.cs
- InstallerTypeAttribute.cs
- NameValueConfigurationElement.cs
- MarkerProperties.cs
- MouseButton.cs
- AddingNewEventArgs.cs
- NotFiniteNumberException.cs
- Validator.cs
- VolatileEnlistmentMultiplexing.cs
- ModuleConfigurationInfo.cs
- InstallerTypeAttribute.cs
- Msec.cs
- BaseParaClient.cs
- Run.cs
- ComponentFactoryHelpers.cs
- CodeAccessPermission.cs
- HtmlControlDesigner.cs
- ContractSearchPattern.cs
- ThreadSafeMessageFilterTable.cs
- VerticalAlignConverter.cs
- XmlSiteMapProvider.cs
- RequestCachingSection.cs