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
- QilFactory.cs
- PointConverter.cs
- SectionUpdates.cs
- SurrogateEncoder.cs
- DesignerOptions.cs
- EdmSchemaError.cs
- ErrorWebPart.cs
- SingleKeyFrameCollection.cs
- WindowsUpDown.cs
- ProxySimple.cs
- VisualBrush.cs
- ForEachAction.cs
- unsafeIndexingFilterStream.cs
- MetaDataInfo.cs
- SizeLimitedCache.cs
- PropertyGridView.cs
- Cloud.cs
- GroupStyle.cs
- Listbox.cs
- ShapeTypeface.cs
- PropertyGridEditorPart.cs
- XmlSerializerNamespaces.cs
- ControlValuePropertyAttribute.cs
- HtmlTableCell.cs
- MsmqChannelFactoryBase.cs
- ADRoleFactory.cs
- DesignerVerbCollection.cs
- MobileCategoryAttribute.cs
- ServiceThrottlingBehavior.cs
- InputGestureCollection.cs
- ThreadInterruptedException.cs
- CreateUserWizardAutoFormat.cs
- HtmlValidationSummaryAdapter.cs
- SingleTagSectionHandler.cs
- ClientScriptManager.cs
- TdsParserSafeHandles.cs
- RadioButton.cs
- HealthMonitoringSectionHelper.cs
- MemberDomainMap.cs
- MemberJoinTreeNode.cs
- ToolStripItemBehavior.cs
- NameValueSectionHandler.cs
- CodeDirectionExpression.cs
- AppModelKnownContentFactory.cs
- OdbcConnectionPoolProviderInfo.cs
- VectorCollectionValueSerializer.cs
- PolicyManager.cs
- InputProcessorProfiles.cs
- XPathScanner.cs
- CurrencyWrapper.cs
- QueryReaderSettings.cs
- BackgroundFormatInfo.cs
- View.cs
- ToolStripSettings.cs
- StylusPointCollection.cs
- BamlBinaryReader.cs
- FormatException.cs
- DSASignatureDeformatter.cs
- SerializableTypeCodeDomSerializer.cs
- CollectionView.cs
- ResourcePool.cs
- TextProviderWrapper.cs
- ThemeableAttribute.cs
- FaultPropagationQuery.cs
- XmlILOptimizerVisitor.cs
- NamedPermissionSet.cs
- AliasExpr.cs
- NameValueFileSectionHandler.cs
- ImportContext.cs
- DataGridViewRow.cs
- Point3DKeyFrameCollection.cs
- TextComposition.cs
- PlatformCulture.cs
- ListBoxItem.cs
- RoutedEventValueSerializer.cs
- WSAddressing10ProblemHeaderQNameFault.cs
- SamlAttribute.cs
- StylusEventArgs.cs
- Activator.cs
- PersonalizationEntry.cs
- PropertyGridView.cs
- PagedDataSource.cs
- __TransparentProxy.cs
- NegationPusher.cs
- DiscoveryProxy.cs
- TypeConverterAttribute.cs
- BaseUriHelper.cs
- DictionarySectionHandler.cs
- DispatcherExceptionEventArgs.cs
- DataViewListener.cs
- FontWeight.cs
- ClientSponsor.cs
- SemanticResultValue.cs
- LambdaCompiler.Binary.cs
- ParamArrayAttribute.cs
- WebPartConnectionsConfigureVerb.cs
- ListViewContainer.cs
- LayoutExceptionEventArgs.cs
- Rect.cs
- DataGridLengthConverter.cs