Code:
/ DotNET / DotNET / 8.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
- WindowsListBox.cs
- OleDbDataAdapter.cs
- XmlElementAttributes.cs
- FontWeights.cs
- SystemParameters.cs
- EventLogEntry.cs
- ProjectionAnalyzer.cs
- XsdBuildProvider.cs
- RemoveStoryboard.cs
- WebPartDisplayModeCollection.cs
- HeaderUtility.cs
- DataConnectionHelper.cs
- ControlAdapter.cs
- FormViewUpdatedEventArgs.cs
- WhitespaceReader.cs
- RoleGroup.cs
- XmlResolver.cs
- ZipIOExtraFieldElement.cs
- AttributedMetaModel.cs
- ConstructorBuilder.cs
- X509CertificateClaimSet.cs
- SmtpFailedRecipientException.cs
- WebServiceMethodData.cs
- ToolStripContainerDesigner.cs
- StylusPointPropertyId.cs
- recordstatefactory.cs
- BamlWriter.cs
- ComNativeDescriptor.cs
- SoapAttributeOverrides.cs
- DiagnosticsConfigurationHandler.cs
- FixedSOMElement.cs
- GridPattern.cs
- FileUtil.cs
- WindowsFormsSynchronizationContext.cs
- EventProvider.cs
- Permission.cs
- FileRecordSequenceHelper.cs
- SemaphoreSecurity.cs
- RectKeyFrameCollection.cs
- DataGridHeadersVisibilityToVisibilityConverter.cs
- BindingExpressionUncommonField.cs
- SqlUserDefinedTypeAttribute.cs
- TextRangeProviderWrapper.cs
- BindingManagerDataErrorEventArgs.cs
- SiteMapNodeCollection.cs
- MatrixAnimationBase.cs
- TaiwanCalendar.cs
- RegexNode.cs
- WebPartEditorCancelVerb.cs
- IDQuery.cs
- graph.cs
- LineGeometry.cs
- EnumValidator.cs
- GlyphInfoList.cs
- DataObjectSettingDataEventArgs.cs
- ListViewItemCollectionEditor.cs
- SecurityPermission.cs
- PackageRelationship.cs
- VirtualPathUtility.cs
- URLIdentityPermission.cs
- TypedRowHandler.cs
- XmlSignificantWhitespace.cs
- CheckBoxAutomationPeer.cs
- NumberSubstitution.cs
- LocalFileSettingsProvider.cs
- ObjectStateManager.cs
- ServiceOperationListItem.cs
- documentsequencetextcontainer.cs
- XmlSortKey.cs
- ConfigurationSectionCollection.cs
- WorkflowPageSetupDialog.cs
- Maps.cs
- FileSystemWatcher.cs
- PropertyItemInternal.cs
- TemplatedAdorner.cs
- Timer.cs
- XmlAttributeCollection.cs
- WebBrowserNavigatingEventHandler.cs
- WebBrowserProgressChangedEventHandler.cs
- WebPartEditorApplyVerb.cs
- DispatchWrapper.cs
- OraclePermission.cs
- DataGridViewDataConnection.cs
- ThemeableAttribute.cs
- CompositeKey.cs
- HtmlForm.cs
- Lasso.cs
- ToolStrip.cs
- DebugView.cs
- WebPartExportVerb.cs
- TypeDescriptor.cs
- TrustLevelCollection.cs
- FixedTextView.cs
- ping.cs
- UInt16Storage.cs
- EntityContainer.cs
- HandlerBase.cs
- QuaternionIndependentAnimationStorage.cs
- SrgsElementList.cs
- HtmlPanelAdapter.cs