Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- CommandField.cs
- HtmlInputReset.cs
- DependencyPropertyChangedEventArgs.cs
- ContextBase.cs
- util.cs
- XmlLanguage.cs
- ContentElement.cs
- StorageScalarPropertyMapping.cs
- ProviderUtil.cs
- Utils.cs
- LayoutUtils.cs
- XamlValidatingReader.cs
- ClientConfigPaths.cs
- ETagAttribute.cs
- Decimal.cs
- HybridObjectCache.cs
- _SslStream.cs
- IRCollection.cs
- ArrayConverter.cs
- odbcmetadatacolumnnames.cs
- XmlDictionary.cs
- StatusBar.cs
- InvalidProgramException.cs
- Configuration.cs
- Package.cs
- PerspectiveCamera.cs
- RuntimeHelpers.cs
- HwndKeyboardInputProvider.cs
- DataBoundControlDesigner.cs
- WSDualHttpSecurityMode.cs
- DefaultPrintController.cs
- CodeIterationStatement.cs
- ContainerUIElement3D.cs
- Double.cs
- XslUrlEditor.cs
- DataControlReferenceCollection.cs
- NativeObjectSecurity.cs
- SkipQueryOptionExpression.cs
- IsolatedStorageException.cs
- DataRecordInternal.cs
- _NetworkingPerfCounters.cs
- EdmError.cs
- SessionParameter.cs
- ToolStripOverflowButton.cs
- SynchronizationLockException.cs
- ExpressionBuilder.cs
- GlyphsSerializer.cs
- DataGridSortCommandEventArgs.cs
- Camera.cs
- InstalledFontCollection.cs
- MexHttpsBindingElement.cs
- UnsafeMethods.cs
- OperationResponse.cs
- Variable.cs
- PixelFormats.cs
- Size3DConverter.cs
- ColorContext.cs
- SqlTransaction.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- ObjectTag.cs
- SmtpTransport.cs
- PersonalizationProvider.cs
- MetadataAssemblyHelper.cs
- COM2EnumConverter.cs
- TrackingServices.cs
- XmlSchemaAnnotation.cs
- BufferAllocator.cs
- Certificate.cs
- PageResolution.cs
- JournalEntryStack.cs
- ResetableIterator.cs
- CompilerTypeWithParams.cs
- PersonalizationStateInfo.cs
- HttpCookie.cs
- SupportsEventValidationAttribute.cs
- ModifierKeysValueSerializer.cs
- EntityDataSourceValidationException.cs
- StreamInfo.cs
- infer.cs
- Visual.cs
- DataPager.cs
- ManualResetEvent.cs
- CustomAttributeBuilder.cs
- MimeMultiPart.cs
- ChannelManagerBase.cs
- NonSerializedAttribute.cs
- SelectedPathEditor.cs
- Metafile.cs
- IDispatchConstantAttribute.cs
- _CommandStream.cs
- DetailsViewActionList.cs
- XsdDuration.cs
- ConsumerConnectionPointCollection.cs
- DesignerVerbToolStripMenuItem.cs
- HtmlDocument.cs
- NameValueSectionHandler.cs
- PanelDesigner.cs
- AssociationEndMember.cs
- LayoutTable.cs
- DefaultDiscoveryService.cs