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
- ScrollableControl.cs
- ErrorStyle.cs
- HeaderedContentControl.cs
- AssemblyBuilder.cs
- DataViewManager.cs
- StructuredTypeInfo.cs
- SchemaInfo.cs
- BooleanAnimationUsingKeyFrames.cs
- CodePageUtils.cs
- HttpGetClientProtocol.cs
- odbcmetadatacollectionnames.cs
- FixedSOMElement.cs
- SHA512CryptoServiceProvider.cs
- NumericExpr.cs
- AssemblyEvidenceFactory.cs
- HtmlDocument.cs
- Storyboard.cs
- InternalTypeHelper.cs
- sortedlist.cs
- linebase.cs
- AdapterDictionary.cs
- GorillaCodec.cs
- EncodingTable.cs
- AppearanceEditorPart.cs
- OracleNumber.cs
- ListViewHitTestInfo.cs
- CompilerScopeManager.cs
- ArrayElementGridEntry.cs
- TraceInternal.cs
- ValidationPropertyAttribute.cs
- SettingsContext.cs
- MethodToken.cs
- IItemContainerGenerator.cs
- TransformerInfoCollection.cs
- AdPostCacheSubstitution.cs
- AccessDataSource.cs
- GradientSpreadMethodValidation.cs
- SmiEventStream.cs
- EntityDataSourceViewSchema.cs
- InfocardExtendedInformationEntry.cs
- GridViewPageEventArgs.cs
- SponsorHelper.cs
- FileCodeGroup.cs
- LinearKeyFrames.cs
- KeyboardEventArgs.cs
- ToolStripDesignerAvailabilityAttribute.cs
- WindowsToolbarItemAsMenuItem.cs
- Perspective.cs
- Flattener.cs
- ImageCodecInfoPrivate.cs
- PackageFilter.cs
- NativeMethods.cs
- SortDescriptionCollection.cs
- AppDomainUnloadedException.cs
- CheckoutException.cs
- PointHitTestResult.cs
- XmlWriterSettings.cs
- ModelFunction.cs
- EventMappingSettings.cs
- SmtpSection.cs
- SecurityMessageProperty.cs
- SectionVisual.cs
- DebugInfoExpression.cs
- ScrollProperties.cs
- DataBoundLiteralControl.cs
- SimpleMailWebEventProvider.cs
- TextRangeBase.cs
- Screen.cs
- TagPrefixCollection.cs
- SqlConnectionPoolGroupProviderInfo.cs
- MessageBox.cs
- SpecialNameAttribute.cs
- AsymmetricSignatureDeformatter.cs
- TypeUnloadedException.cs
- PropertyValue.cs
- WinFormsSpinner.cs
- SafeRightsManagementSessionHandle.cs
- DeferredTextReference.cs
- HtmlDocument.cs
- DeploymentExceptionMapper.cs
- IconHelper.cs
- ISessionStateStore.cs
- SuppressMergeCheckAttribute.cs
- Vector3DCollection.cs
- NumericPagerField.cs
- BinaryFormatter.cs
- EventLogPermissionEntry.cs
- ConfigXmlCDataSection.cs
- SaveFileDialog.cs
- DetailsViewUpdatedEventArgs.cs
- Query.cs
- DataSourceHelper.cs
- SuppressMessageAttribute.cs
- OdbcStatementHandle.cs
- XmlSchemaSequence.cs
- UnicastIPAddressInformationCollection.cs
- DeviceSpecificDesigner.cs
- OperatorExpressions.cs
- EditorZoneBase.cs
- ListViewDeleteEventArgs.cs