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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WebPartCollection.cs
- FormViewInsertedEventArgs.cs
- ParameterExpression.cs
- DataControlFieldHeaderCell.cs
- XmlAttributeHolder.cs
- CommentAction.cs
- PersistenceTypeAttribute.cs
- RectangleHotSpot.cs
- XmlUtil.cs
- Span.cs
- IdentityNotMappedException.cs
- ParameterEditorUserControl.cs
- DeobfuscatingStream.cs
- MaskedTextProvider.cs
- SafeEventHandle.cs
- Cell.cs
- PersonalizationStateInfo.cs
- BrushConverter.cs
- ApplicationManager.cs
- CopyOnWriteList.cs
- HyperLinkColumn.cs
- LinqExpressionNormalizer.cs
- LoginName.cs
- _SslState.cs
- ProgressChangedEventArgs.cs
- DefaultSection.cs
- _SSPISessionCache.cs
- EventManager.cs
- Decoder.cs
- EastAsianLunisolarCalendar.cs
- WhitespaceRuleReader.cs
- BamlLocalizabilityResolver.cs
- ExpressionBinding.cs
- MetadataArtifactLoaderComposite.cs
- SessionStateContainer.cs
- DeploymentSection.cs
- UpdateExpressionVisitor.cs
- ObjectTypeMapping.cs
- ListView.cs
- TimeSpanSecondsConverter.cs
- SapiInterop.cs
- Errors.cs
- TextElementEnumerator.cs
- DeploymentSection.cs
- AnnotationResource.cs
- LogWriteRestartAreaAsyncResult.cs
- RoamingStoreFile.cs
- ImageField.cs
- ColorMatrix.cs
- EntityDataSourceWrapperPropertyDescriptor.cs
- EventArgs.cs
- StaticResourceExtension.cs
- NullableConverter.cs
- TrackingParticipant.cs
- CompiledQueryCacheEntry.cs
- BinaryWriter.cs
- SecurityChannelFactory.cs
- SqlServer2KCompatibilityAnnotation.cs
- ProcessModelSection.cs
- URIFormatException.cs
- TreeNode.cs
- WebPartConnectionsCancelEventArgs.cs
- BamlBinaryReader.cs
- _BasicClient.cs
- EmbeddedObject.cs
- ControlUtil.cs
- SafeTokenHandle.cs
- DbConnectionPoolGroup.cs
- EventsTab.cs
- DataKey.cs
- OracleParameterCollection.cs
- TdsParserHelperClasses.cs
- PinnedBufferMemoryStream.cs
- TreeNodeCollectionEditorDialog.cs
- GridErrorDlg.cs
- FileLevelControlBuilderAttribute.cs
- DesignOnlyAttribute.cs
- ThicknessAnimation.cs
- _StreamFramer.cs
- DynamicEndpoint.cs
- ToolboxItemCollection.cs
- EventDescriptorCollection.cs
- LogExtentCollection.cs
- InvariantComparer.cs
- BinaryObjectWriter.cs
- Matrix3DStack.cs
- IPAddress.cs
- ImageDrawing.cs
- AppliesToBehaviorDecisionTable.cs
- AnnotationHighlightLayer.cs
- RadioButtonStandardAdapter.cs
- WorkflowNamespace.cs
- PathNode.cs
- AssociationSetEnd.cs
- StrokeCollection.cs
- StretchValidation.cs
- TreeViewBindingsEditor.cs
- StringWriter.cs
- DesignerActionItem.cs
- FormatConvertedBitmap.cs