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
- HwndKeyboardInputProvider.cs
- RichTextBoxContextMenu.cs
- MaterialGroup.cs
- ValidationErrorCollection.cs
- HtmlButton.cs
- smtpconnection.cs
- ListItemCollection.cs
- RuntimeEnvironment.cs
- TextElementEnumerator.cs
- DataServiceProviderMethods.cs
- ImageField.cs
- SpStreamWrapper.cs
- TextCollapsingProperties.cs
- FacetDescription.cs
- QuaternionAnimationBase.cs
- EditCommandColumn.cs
- ProfileSettings.cs
- SamlSubject.cs
- ResourceLoader.cs
- PropertyExpression.cs
- QueuePathEditor.cs
- KeyGesture.cs
- NamedPermissionSet.cs
- TreeView.cs
- TextServicesCompartmentEventSink.cs
- ServiceModelReg.cs
- ToolTipAutomationPeer.cs
- SqlDependency.cs
- ApplicationManager.cs
- UserValidatedEventArgs.cs
- AssemblyUtil.cs
- XmlNamespaceManager.cs
- RepeatInfo.cs
- TextEncodedRawTextWriter.cs
- DataSourceHelper.cs
- ManifestSignatureInformation.cs
- XmlObjectSerializerWriteContextComplexJson.cs
- DocumentViewerBaseAutomationPeer.cs
- System.Data.OracleClient_BID.cs
- LoadWorkflowByInstanceKeyCommand.cs
- CacheVirtualItemsEvent.cs
- StoreUtilities.cs
- Paragraph.cs
- SubclassTypeValidator.cs
- DaylightTime.cs
- DictionarySectionHandler.cs
- InitializationEventAttribute.cs
- TargetException.cs
- SuppressIldasmAttribute.cs
- Block.cs
- AlternateViewCollection.cs
- MediaScriptCommandRoutedEventArgs.cs
- GrammarBuilderBase.cs
- InvalidCardException.cs
- Rectangle.cs
- OutgoingWebResponseContext.cs
- TableLayoutColumnStyleCollection.cs
- wpf-etw.cs
- ChannelManagerBase.cs
- HTMLTextWriter.cs
- SpellerStatusTable.cs
- ColorMap.cs
- InkSerializer.cs
- PolyQuadraticBezierSegment.cs
- DecoderReplacementFallback.cs
- MediaTimeline.cs
- DynamicRenderer.cs
- ObjectCloneHelper.cs
- DispatchWrapper.cs
- OleDbFactory.cs
- ReflectTypeDescriptionProvider.cs
- BitmapMetadataEnumerator.cs
- SqlDataSourceQueryEditorForm.cs
- HeaderedContentControl.cs
- PixelShader.cs
- OleDbDataReader.cs
- Substitution.cs
- StdValidatorsAndConverters.cs
- EpmTargetPathSegment.cs
- ParamArrayAttribute.cs
- DefaultHttpHandler.cs
- GetPageNumberCompletedEventArgs.cs
- ComEventsMethod.cs
- MenuAutomationPeer.cs
- dataobject.cs
- ToolStripMenuItemDesigner.cs
- EventDrivenDesigner.cs
- RoleManagerModule.cs
- WSSecureConversationDec2005.cs
- MimeMapping.cs
- TextLineBreak.cs
- EventArgs.cs
- BitmapEffectDrawingContextState.cs
- AppDomainGrammarProxy.cs
- FormsAuthentication.cs
- CounterCreationData.cs
- XmlNodeList.cs
- ObjectDataSourceDisposingEventArgs.cs
- ApplicationSecurityManager.cs
- AsymmetricAlgorithm.cs