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
- LinkedResource.cs
- SchemaImporterExtensionElementCollection.cs
- ZipIOModeEnforcingStream.cs
- CollectionBuilder.cs
- DoubleLinkListEnumerator.cs
- MultiPageTextView.cs
- WebControlsSection.cs
- ZoneIdentityPermission.cs
- EntityClassGenerator.cs
- DataGridViewLinkColumn.cs
- Scheduling.cs
- NamedPipeHostedTransportConfiguration.cs
- ProtocolException.cs
- HtmlElementErrorEventArgs.cs
- FieldDescriptor.cs
- InputElement.cs
- sqlcontext.cs
- SubclassTypeValidatorAttribute.cs
- ModelItemDictionary.cs
- UnsettableComboBox.cs
- assertwrapper.cs
- CodeDomLocalizationProvider.cs
- mediaeventshelper.cs
- XmlAggregates.cs
- RelatedEnd.cs
- Line.cs
- storagemappingitemcollection.viewdictionary.cs
- UIElementParaClient.cs
- LogSwitch.cs
- MSAAEventDispatcher.cs
- COAUTHIDENTITY.cs
- ObjectDataSourceView.cs
- UmAlQuraCalendar.cs
- TextBreakpoint.cs
- FormatSettings.cs
- RelationalExpressions.cs
- BaseServiceProvider.cs
- WebPartZone.cs
- WindowsRichEditRange.cs
- CheckBoxList.cs
- FactoryGenerator.cs
- TextTrailingWordEllipsis.cs
- WorkflowInstanceExtensionProvider.cs
- Soap11ServerProtocol.cs
- ObjectIDGenerator.cs
- VSWCFServiceContractGenerator.cs
- WebPartZone.cs
- DoubleAnimationBase.cs
- UncommonField.cs
- DataSetViewSchema.cs
- TopClause.cs
- SafeMILHandle.cs
- HttpVersion.cs
- FutureFactory.cs
- DataSourceHelper.cs
- CheckBoxPopupAdapter.cs
- DataViewManager.cs
- MessageParameterAttribute.cs
- DesignerLinkAdapter.cs
- DES.cs
- basevalidator.cs
- AnnotationHighlightLayer.cs
- SelfIssuedAuthRSAPKCS1SignatureDeformatter.cs
- SmiMetaData.cs
- SynchronizationFilter.cs
- OleDbConnectionFactory.cs
- IisTraceListener.cs
- RequestStatusBarUpdateEventArgs.cs
- UpDownEvent.cs
- PasswordValidationException.cs
- StylusPoint.cs
- httpapplicationstate.cs
- ScriptReferenceEventArgs.cs
- NativeMethodsOther.cs
- ObjectListDataBindEventArgs.cs
- InternalResources.cs
- ReceiveActivityValidator.cs
- TypeForwardedToAttribute.cs
- LowerCaseStringConverter.cs
- HScrollProperties.cs
- InkPresenterAutomationPeer.cs
- ContentElement.cs
- DropDownList.cs
- StatusBarPanel.cs
- ListViewDesigner.cs
- SystemKeyConverter.cs
- InputBinder.cs
- Filter.cs
- ResolveDuplex11AsyncResult.cs
- NotificationContext.cs
- MultiSelector.cs
- VirtualPathProvider.cs
- WebServiceErrorEvent.cs
- AbstractDataSvcMapFileLoader.cs
- Helpers.cs
- OleDbReferenceCollection.cs
- ByteAnimation.cs
- AddingNewEventArgs.cs
- EntityDataSourceWrapper.cs
- ContextQuery.cs