Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- GridViewUpdateEventArgs.cs
- parserscommon.cs
- BasicAsyncResult.cs
- IntAverageAggregationOperator.cs
- LocalFileSettingsProvider.cs
- TriggerAction.cs
- WebBrowserBase.cs
- HttpFileCollectionBase.cs
- AstTree.cs
- CapabilitiesAssignment.cs
- XmlSchemaValidationException.cs
- ExtenderControl.cs
- AbstractDataSvcMapFileLoader.cs
- WebPartEditorCancelVerb.cs
- BrushMappingModeValidation.cs
- Overlapped.cs
- HtmlControl.cs
- PageBreakRecord.cs
- DocumentPage.cs
- WorkflowShape.cs
- WebPartConnectVerb.cs
- ISAPIApplicationHost.cs
- MaskedTextBox.cs
- BamlRecordWriter.cs
- SimpleExpression.cs
- SimpleBitVector32.cs
- OutOfProcStateClientManager.cs
- PageAsyncTaskManager.cs
- DataSysAttribute.cs
- PackageDigitalSignatureManager.cs
- AggregatePushdown.cs
- ConfigXmlElement.cs
- X509Certificate2.cs
- FileReservationCollection.cs
- BounceEase.cs
- UnsafeNativeMethods.cs
- SpeakInfo.cs
- DbProviderFactoriesConfigurationHandler.cs
- PassportAuthentication.cs
- CachedBitmap.cs
- InProcStateClientManager.cs
- XmlQueryType.cs
- HttpSessionStateWrapper.cs
- OperationGenerator.cs
- XPathScanner.cs
- AssemblyCacheEntry.cs
- TextElement.cs
- ReferentialConstraint.cs
- Odbc32.cs
- HttpGetProtocolReflector.cs
- DbgUtil.cs
- QueryCursorEventArgs.cs
- RangeValueProviderWrapper.cs
- SqlDataSourceConfigureFilterForm.cs
- PhysicalOps.cs
- ToolStripMenuItem.cs
- HexParser.cs
- SemanticResultKey.cs
- SerializerProvider.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- AnimationClock.cs
- UnknownBitmapDecoder.cs
- DateTimeConstantAttribute.cs
- HtmlAnchor.cs
- BitmapEffectDrawingContextWalker.cs
- RestClientProxyHandler.cs
- InvalidEnumArgumentException.cs
- dtdvalidator.cs
- TreePrinter.cs
- WebPartUserCapability.cs
- DocumentViewerBase.cs
- ListContractAdapter.cs
- EntityTransaction.cs
- ViewManager.cs
- XmlBufferReader.cs
- CompModSwitches.cs
- DropTarget.cs
- AssertSection.cs
- FontFamily.cs
- ForceCopyBuildProvider.cs
- CellConstant.cs
- UnsafeCollabNativeMethods.cs
- PrinterSettings.cs
- Glyph.cs
- DataServiceRequest.cs
- XmlQualifiedName.cs
- CompiledQueryCacheEntry.cs
- HttpAsyncResult.cs
- Binding.cs
- BitFlagsGenerator.cs
- TreeViewDataItemAutomationPeer.cs
- SingleObjectCollection.cs
- OdbcConnectionStringbuilder.cs
- ServiceReference.cs
- ExceptionTranslationTable.cs
- DataServiceHostFactory.cs
- SessionEndingCancelEventArgs.cs
- BuildProviderAppliesToAttribute.cs
- RichTextBox.cs
- TemplateApplicationHelper.cs