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
- SecurityVerifiedMessage.cs
- Logging.cs
- HostedImpersonationContext.cs
- ApplicationSecurityInfo.cs
- OdbcConnection.cs
- ResolveNameEventArgs.cs
- DuplicateWaitObjectException.cs
- CellCreator.cs
- InfoCardSymmetricCrypto.cs
- FrugalList.cs
- NCryptSafeHandles.cs
- BuildResult.cs
- SettingsSavedEventArgs.cs
- AutoGeneratedField.cs
- BaseEntityWrapper.cs
- DbXmlEnabledProviderManifest.cs
- LabelAutomationPeer.cs
- MonitoringDescriptionAttribute.cs
- CoTaskMemHandle.cs
- MergeEnumerator.cs
- AnchoredBlock.cs
- ColumnReorderedEventArgs.cs
- HttpListener.cs
- GradientBrush.cs
- ExeConfigurationFileMap.cs
- ActivationServices.cs
- DiscoveryClientChannelFactory.cs
- ClassicBorderDecorator.cs
- CompositeScriptReferenceEventArgs.cs
- DbDataReader.cs
- InvalidWMPVersionException.cs
- documentsequencetextcontainer.cs
- ContentDisposition.cs
- SafeFileHandle.cs
- OdbcInfoMessageEvent.cs
- CodeVariableDeclarationStatement.cs
- ProviderConnectionPointCollection.cs
- UncommonField.cs
- SmiContext.cs
- ExceptionTrace.cs
- BindingFormattingDialog.cs
- QilLoop.cs
- EnumerableCollectionView.cs
- GAC.cs
- SamlEvidence.cs
- ScrollEventArgs.cs
- XPathSingletonIterator.cs
- List.cs
- XmlDataLoader.cs
- DBCommand.cs
- GridViewRow.cs
- FixUp.cs
- ParserOptions.cs
- ElementMarkupObject.cs
- securestring.cs
- MemoryFailPoint.cs
- columnmapfactory.cs
- SkewTransform.cs
- XXXInfos.cs
- ParameterModifier.cs
- WithParamAction.cs
- DataGridHeaderBorder.cs
- ProcessModelInfo.cs
- DynamicEntity.cs
- RealProxy.cs
- TreeNodeBindingCollection.cs
- ScrollItemProviderWrapper.cs
- DurableInstanceContextProvider.cs
- CustomErrorsSection.cs
- LicenseException.cs
- ModelItemDictionaryImpl.cs
- assemblycache.cs
- SurrogateEncoder.cs
- ColumnPropertiesGroup.cs
- DrawingContextWalker.cs
- SpanIndex.cs
- CounterCreationDataCollection.cs
- NetCodeGroup.cs
- ChameleonKey.cs
- SqlDataSourceQueryEditorForm.cs
- sqlcontext.cs
- IndexedGlyphRun.cs
- WindowsGraphics.cs
- TableLayoutPanel.cs
- FormViewRow.cs
- Component.cs
- MailBnfHelper.cs
- TypePropertyEditor.cs
- PanelStyle.cs
- SiteOfOriginPart.cs
- ToolBar.cs
- Latin1Encoding.cs
- SqlTypesSchemaImporter.cs
- MulticastDelegate.cs
- DistributedTransactionPermission.cs
- OracleException.cs
- PropertyConverter.cs
- ComponentChangedEvent.cs
- SecurityUtils.cs
- UTF7Encoding.cs