Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- OdbcStatementHandle.cs
- XmlNamespaceDeclarationsAttribute.cs
- Baml6Assembly.cs
- StyleCollection.cs
- XmlAnyAttributeAttribute.cs
- UnmanagedMemoryStream.cs
- XPathNodeHelper.cs
- UnsettableComboBox.cs
- TrackBarRenderer.cs
- CqlWriter.cs
- StringCollection.cs
- DocumentCollection.cs
- DBDataPermissionAttribute.cs
- NetworkCredential.cs
- ComEventsSink.cs
- XamlPoint3DCollectionSerializer.cs
- ProxyManager.cs
- ProviderMetadata.cs
- ResXFileRef.cs
- LeaseManager.cs
- AuthenticationModuleElement.cs
- RedistVersionInfo.cs
- ComNativeDescriptor.cs
- FrameworkObject.cs
- WpfXamlMember.cs
- LazyTextWriterCreator.cs
- MissingMethodException.cs
- DataGridTableCollection.cs
- MouseEvent.cs
- DesignTimeVisibleAttribute.cs
- PanelDesigner.cs
- ETagAttribute.cs
- TreeView.cs
- ObjectDataSourceSelectingEventArgs.cs
- TextSpan.cs
- MetadataPropertyvalue.cs
- CheckBox.cs
- XmlSchemaSimpleTypeList.cs
- FormsIdentity.cs
- X509ScopedServiceCertificateElement.cs
- AttributeCollection.cs
- UnsafeNativeMethods.cs
- ObjectHelper.cs
- _DisconnectOverlappedAsyncResult.cs
- ExpressionBinding.cs
- SoapObjectWriter.cs
- AdRotator.cs
- KeySplineConverter.cs
- ConstraintConverter.cs
- ManipulationPivot.cs
- X509Certificate2.cs
- StatusBarDrawItemEvent.cs
- AppLevelCompilationSectionCache.cs
- SchemaMapping.cs
- PublisherMembershipCondition.cs
- UrlMapping.cs
- SqlClientWrapperSmiStream.cs
- ZipFileInfo.cs
- XamlTreeBuilderBamlRecordWriter.cs
- util.cs
- ReadOnlyDictionary.cs
- ObjectComplexPropertyMapping.cs
- QueryReaderSettings.cs
- FaultContractAttribute.cs
- CompoundFileDeflateTransform.cs
- MyContact.cs
- LocalizabilityAttribute.cs
- SqlRowUpdatingEvent.cs
- WorkflowDefinitionDispenser.cs
- _CookieModule.cs
- OdbcConnectionOpen.cs
- VirtualPath.cs
- HttpListenerTimeoutManager.cs
- CodeCatchClause.cs
- InputScopeNameConverter.cs
- ResXResourceWriter.cs
- XNodeNavigator.cs
- XmlILStorageConverter.cs
- ElapsedEventArgs.cs
- RectangleConverter.cs
- SqlTrackingService.cs
- DbProviderSpecificTypePropertyAttribute.cs
- AppDomainUnloadedException.cs
- OdbcConnectionFactory.cs
- ValueQuery.cs
- SeparatorAutomationPeer.cs
- HtmlTableRow.cs
- TextFormatterHost.cs
- EqualityComparer.cs
- RelationshipNavigation.cs
- InkPresenter.cs
- NamedPipeTransportSecurity.cs
- Parsers.cs
- PartManifestEntry.cs
- PropertyCollection.cs
- XmlSchemaInclude.cs
- MediaContextNotificationWindow.cs
- Compiler.cs
- DesignerTransactionCloseEvent.cs
- SendingRequestEventArgs.cs