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
- SqlBuffer.cs
- FormViewCommandEventArgs.cs
- DataStreamFromComStream.cs
- EnumerableWrapperWeakToStrong.cs
- DashStyle.cs
- InfoCardBinaryReader.cs
- NativeBuffer.cs
- PasswordTextContainer.cs
- SignedPkcs7.cs
- WebEventTraceProvider.cs
- BuilderElements.cs
- SymmetricAlgorithm.cs
- SwitchElementsCollection.cs
- SoapMessage.cs
- ResXResourceSet.cs
- ErrorProvider.cs
- ArrayElementGridEntry.cs
- ClientClassGenerator.cs
- DataGridViewCheckBoxCell.cs
- DateTimeOffsetConverter.cs
- TypeConverterHelper.cs
- NamespaceCollection.cs
- EdmValidator.cs
- ToolStripContainer.cs
- ErrorHandlerModule.cs
- Animatable.cs
- CompositeActivityTypeDescriptorProvider.cs
- GetCertificateRequest.cs
- HttpModuleAction.cs
- Validator.cs
- ListManagerBindingsCollection.cs
- ColumnTypeConverter.cs
- ContextMarshalException.cs
- ColumnMapCopier.cs
- CollectionViewGroupInternal.cs
- SQLSingle.cs
- FrameworkName.cs
- _SpnDictionary.cs
- SqlDataSourceConfigureSelectPanel.cs
- TableCell.cs
- XmlIncludeAttribute.cs
- Rotation3D.cs
- StrongNameMembershipCondition.cs
- MethodAccessException.cs
- MailAddressCollection.cs
- MetadataArtifactLoaderFile.cs
- PipeConnection.cs
- MsmqTransportSecurity.cs
- ByteAnimationUsingKeyFrames.cs
- RangeBaseAutomationPeer.cs
- SQLConvert.cs
- ExpressionPrinter.cs
- OracleTimeSpan.cs
- IChannel.cs
- XPathParser.cs
- LinkLabel.cs
- VectorCollection.cs
- ReadOnlyHierarchicalDataSourceView.cs
- ToolStripContentPanelRenderEventArgs.cs
- ToggleButtonAutomationPeer.cs
- SByteStorage.cs
- DataRecordInternal.cs
- CLSCompliantAttribute.cs
- BufferBuilder.cs
- CodeTypeReferenceCollection.cs
- SystemIPInterfaceStatistics.cs
- BaseTemplateParser.cs
- VerificationException.cs
- NamespaceInfo.cs
- ClassHandlersStore.cs
- MediaContext.cs
- SafeRightsManagementSessionHandle.cs
- XmlSchema.cs
- SchemaImporterExtensionsSection.cs
- PerformanceCounterLib.cs
- TemplateAction.cs
- SymmetricCryptoHandle.cs
- IntegerValidator.cs
- ServicesUtilities.cs
- TextStore.cs
- WebPartMovingEventArgs.cs
- NetNamedPipeSecurity.cs
- BatchWriter.cs
- LinearGradientBrush.cs
- Internal.cs
- WeakEventTable.cs
- HuffmanTree.cs
- GradientStopCollection.cs
- SqlMetaData.cs
- XmlException.cs
- ReverseInheritProperty.cs
- DataGridViewRow.cs
- SiteMapNodeCollection.cs
- While.cs
- XmlNodeComparer.cs
- MeasureData.cs
- SettingsPropertyValue.cs
- FormsAuthenticationUser.cs
- EmbeddedMailObject.cs
- CodePageUtils.cs