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
- AlignmentYValidation.cs
- SecurityCriticalDataForSet.cs
- ViewPort3D.cs
- Source.cs
- TransformedBitmap.cs
- XPathBinder.cs
- TextElementAutomationPeer.cs
- TextRangeBase.cs
- RepeatBehavior.cs
- LayoutEditorPart.cs
- DeobfuscatingStream.cs
- UrlMappingsModule.cs
- PageHandlerFactory.cs
- KeySplineConverter.cs
- BitmapEffectGeneralTransform.cs
- SchemaNamespaceManager.cs
- SchemaNames.cs
- PageContent.cs
- EntityProviderServices.cs
- SqlGenericUtil.cs
- ConfigXmlAttribute.cs
- WebReferencesBuildProvider.cs
- RemotingHelper.cs
- IPAddress.cs
- CatalogZoneBase.cs
- CellIdBoolean.cs
- MsmqIntegrationAppDomainProtocolHandler.cs
- Stylesheet.cs
- TrackBarRenderer.cs
- GlyphCollection.cs
- SessionStateUtil.cs
- MarkupProperty.cs
- TaiwanLunisolarCalendar.cs
- ControlPaint.cs
- TextDecorationCollection.cs
- SQLDoubleStorage.cs
- ParameterToken.cs
- Instrumentation.cs
- CodeDomSerializerException.cs
- Util.cs
- MemberPathMap.cs
- GenericIdentity.cs
- UIElementIsland.cs
- PopupControlService.cs
- CodeExporter.cs
- WebBrowserProgressChangedEventHandler.cs
- WebColorConverter.cs
- AliasedExpr.cs
- ItemChangedEventArgs.cs
- linebase.cs
- CodeDomConfigurationHandler.cs
- EventTrigger.cs
- XmlSchemaObjectTable.cs
- DrawingGroupDrawingContext.cs
- LogicalExpr.cs
- XmlTextReaderImpl.cs
- NavigationService.cs
- Rectangle.cs
- MsdtcWrapper.cs
- Evidence.cs
- GridItemProviderWrapper.cs
- CreateRefExpr.cs
- SafeUserTokenHandle.cs
- AccessDataSourceView.cs
- SecondaryIndexList.cs
- NativeMethods.cs
- ResourceSet.cs
- AnnotationComponentManager.cs
- AQNBuilder.cs
- RuntimeConfigurationRecord.cs
- ListItemCollection.cs
- EmptyEnumerable.cs
- QueryGeneratorBase.cs
- DataList.cs
- WorkflowOperationAsyncResult.cs
- Utilities.cs
- ZipPackagePart.cs
- DefaultEventAttribute.cs
- Touch.cs
- DBDataPermissionAttribute.cs
- EdmComplexTypeAttribute.cs
- XslVisitor.cs
- DynamicObject.cs
- ArrayWithOffset.cs
- DrawingImage.cs
- DispatcherHooks.cs
- RequestTimeoutManager.cs
- ServerTooBusyException.cs
- TextMarkerSource.cs
- BuildProvider.cs
- TextServicesCompartmentContext.cs
- FilteredAttributeCollection.cs
- PropertyPushdownHelper.cs
- PersistenceContext.cs
- GeneralTransform3DTo2D.cs
- KerberosRequestorSecurityToken.cs
- InputLanguageManager.cs
- XsdBuildProvider.cs
- RoutedEventHandlerInfo.cs
- IncrementalReadDecoders.cs