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
- MSAANativeProvider.cs
- Material.cs
- DeploymentSectionCache.cs
- SqlClientWrapperSmiStreamChars.cs
- DataControlImageButton.cs
- TextSelectionHelper.cs
- SymbolMethod.cs
- DataContractSet.cs
- EditorZone.cs
- RenderOptions.cs
- DbProviderConfigurationHandler.cs
- DataRowChangeEvent.cs
- GZipDecoder.cs
- XhtmlConformanceSection.cs
- nulltextcontainer.cs
- StructuredTypeEmitter.cs
- InitializerFacet.cs
- HitTestResult.cs
- SizeAnimationBase.cs
- InputQueueChannel.cs
- ProjectionQueryOptionExpression.cs
- PropertyCondition.cs
- AssociatedControlConverter.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- GC.cs
- SelectorItemAutomationPeer.cs
- WindowsSolidBrush.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- SqlTriggerContext.cs
- WorkItem.cs
- ReadingWritingEntityEventArgs.cs
- PropertyInformation.cs
- LoginCancelEventArgs.cs
- ObjectTypeMapping.cs
- BoolExpressionVisitors.cs
- CryptoConfig.cs
- FloaterParaClient.cs
- ReflectTypeDescriptionProvider.cs
- Registry.cs
- PropertyGridCommands.cs
- GregorianCalendarHelper.cs
- DecimalAnimation.cs
- RealizationContext.cs
- MimeObjectFactory.cs
- XmlSchemaGroupRef.cs
- ActivityPreviewDesigner.cs
- OrderPreservingPipeliningSpoolingTask.cs
- returneventsaver.cs
- XPathPatternBuilder.cs
- CodeDomSerializerException.cs
- HebrewCalendar.cs
- SoapExtensionImporter.cs
- StreamGeometry.cs
- OdbcErrorCollection.cs
- XmlDocumentFragment.cs
- PathBox.cs
- TextBoxLine.cs
- ConnectionPoint.cs
- PropertyIdentifier.cs
- StringUtil.cs
- SettingsProviderCollection.cs
- DesignTimeParseData.cs
- DayRenderEvent.cs
- BasePropertyDescriptor.cs
- Encoder.cs
- CompiledQueryCacheEntry.cs
- TrustManager.cs
- WindowsPen.cs
- MetricEntry.cs
- XmlCharCheckingReader.cs
- DataGridColumn.cs
- MessageTraceRecord.cs
- XmlTypeAttribute.cs
- DetailsViewInsertEventArgs.cs
- AppSettingsExpressionBuilder.cs
- ThicknessKeyFrameCollection.cs
- FixedDSBuilder.cs
- DropShadowEffect.cs
- RequestQueryParser.cs
- wmiprovider.cs
- DeviceContext2.cs
- BindingListCollectionView.cs
- FilterableAttribute.cs
- URIFormatException.cs
- UITypeEditor.cs
- DiscoveryInnerClientAdhocCD1.cs
- DataObjectEventArgs.cs
- JobDuplex.cs
- NumericExpr.cs
- FactoryMaker.cs
- SynchronizedPool.cs
- AssertUtility.cs
- Rights.cs
- CheckBoxPopupAdapter.cs
- DtdParser.cs
- AmbiguousMatchException.cs
- mactripleDES.cs
- HttpRuntime.cs
- ApplicationServiceHelper.cs
- ConfigXmlWhitespace.cs