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
- OletxDependentTransaction.cs
- OpenTypeCommon.cs
- DynamicValidator.cs
- NameSpaceExtractor.cs
- CultureTableRecord.cs
- LoadRetryStrategyFactory.cs
- OdbcUtils.cs
- XmlNodeReader.cs
- BamlLocalizableResourceKey.cs
- ResizeGrip.cs
- CodeTypeMemberCollection.cs
- HandlerBase.cs
- WindowsScroll.cs
- SimpleRecyclingCache.cs
- SqlMultiplexer.cs
- ModuleBuilderData.cs
- TemplateEditingService.cs
- ProtectedConfiguration.cs
- AxParameterData.cs
- IteratorFilter.cs
- EndEvent.cs
- BuildProviderAppliesToAttribute.cs
- DocumentPage.cs
- XmlQualifiedNameTest.cs
- DataGridViewMethods.cs
- ContextProperty.cs
- ProfilePropertySettings.cs
- TextServicesDisplayAttributePropertyRanges.cs
- WebControl.cs
- ItemList.cs
- Size.cs
- DBSchemaRow.cs
- ConfigXmlCDataSection.cs
- ReflectEventDescriptor.cs
- OptimalTextSource.cs
- PrincipalPermission.cs
- TableLayout.cs
- WebBrowser.cs
- Condition.cs
- SqlMetaData.cs
- SignatureDescription.cs
- StrokeSerializer.cs
- IgnoreFlushAndCloseStream.cs
- AssociationType.cs
- Transform3DCollection.cs
- FormsAuthenticationTicket.cs
- ToolStripItemRenderEventArgs.cs
- XmlNode.cs
- OleStrCAMarshaler.cs
- XmlSchemaComplexContentRestriction.cs
- ThreadPool.cs
- CodeFieldReferenceExpression.cs
- XmlSchemaGroupRef.cs
- UpdateTracker.cs
- BinaryExpressionHelper.cs
- XmlValidatingReaderImpl.cs
- Line.cs
- WebHttpSecurityModeHelper.cs
- StackSpiller.Generated.cs
- RecipientInfo.cs
- EventListener.cs
- MemberRelationshipService.cs
- SqlMethodCallConverter.cs
- EFAssociationProvider.cs
- DataMisalignedException.cs
- ContainerVisual.cs
- DrawingContextWalker.cs
- WebPartConnectVerb.cs
- CustomAttributeFormatException.cs
- Viewport2DVisual3D.cs
- OdbcPermission.cs
- Debugger.cs
- OdbcDataAdapter.cs
- ConfigurationManagerHelperFactory.cs
- StateFinalizationDesigner.cs
- AdPostCacheSubstitution.cs
- UnsafeNativeMethods.cs
- ServiceObjectContainer.cs
- VectorAnimationBase.cs
- NonSerializedAttribute.cs
- WebPartConnectionsCancelEventArgs.cs
- Utility.cs
- SecurityException.cs
- Camera.cs
- DesignerSelectionListAdapter.cs
- ValueSerializerAttribute.cs
- WindowsRebar.cs
- DataControlFieldCell.cs
- IItemContainerGenerator.cs
- CancellationScope.cs
- ParagraphVisual.cs
- DataGridViewMethods.cs
- ClassHandlersStore.cs
- DbResourceAllocator.cs
- ApplicationInfo.cs
- GeneratedContractType.cs
- TransformProviderWrapper.cs
- MetafileHeaderWmf.cs
- TemplateField.cs
- List.cs