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
- LocationUpdates.cs
- ViewBase.cs
- TextViewBase.cs
- StorageComplexPropertyMapping.cs
- PropertyGeneratedEventArgs.cs
- WebHttpSecurityElement.cs
- Options.cs
- SendSecurityHeaderElementContainer.cs
- LinqDataSourceContextEventArgs.cs
- WindowsTreeView.cs
- XPathChildIterator.cs
- Span.cs
- AutoScrollExpandMessageFilter.cs
- BitmapEffectDrawingContent.cs
- MarkupWriter.cs
- StreamInfo.cs
- XNodeValidator.cs
- RMEnrollmentPage1.cs
- XmlEncodedRawTextWriter.cs
- HttpServerUtilityBase.cs
- Duration.cs
- XmlImplementation.cs
- TextDecorationCollectionConverter.cs
- ImmutableObjectAttribute.cs
- ImageButton.cs
- VirtualPathData.cs
- PropertyValueUIItem.cs
- NetworkInformationException.cs
- TrustLevelCollection.cs
- NTAccount.cs
- ObjectListTitleAttribute.cs
- ScalarConstant.cs
- MetadataArtifactLoaderResource.cs
- TransformCryptoHandle.cs
- CodeTypeMember.cs
- TextElement.cs
- HtmlControl.cs
- IArgumentProvider.cs
- DetailsViewUpdateEventArgs.cs
- ConfigurationStrings.cs
- PeerApplication.cs
- ModelToObjectValueConverter.cs
- KeyTime.cs
- XmlSchemaComplexContentRestriction.cs
- PartialCachingControl.cs
- WebControl.cs
- COM2PropertyDescriptor.cs
- DataChangedEventManager.cs
- dataobject.cs
- FileInfo.cs
- SettingsSavedEventArgs.cs
- IgnoreFileBuildProvider.cs
- MessageFilterTable.cs
- CreateUserWizard.cs
- HwndSourceParameters.cs
- ApplicationSecurityManager.cs
- Panel.cs
- RegexNode.cs
- ContentElement.cs
- CompilerScopeManager.cs
- WebBrowsableAttribute.cs
- RegexCapture.cs
- RelationshipEndMember.cs
- TypeExtensions.cs
- RawMouseInputReport.cs
- PathStreamGeometryContext.cs
- OleAutBinder.cs
- ArgumentsParser.cs
- DbMetaDataFactory.cs
- TreePrinter.cs
- PersistenceContextEnlistment.cs
- validationstate.cs
- AssemblyHash.cs
- DockAndAnchorLayout.cs
- XmlCustomFormatter.cs
- Pair.cs
- SqlError.cs
- AuthStoreRoleProvider.cs
- SqlException.cs
- DomainLiteralReader.cs
- SecurityHeader.cs
- DataObjectMethodAttribute.cs
- AnnouncementEndpoint.cs
- WindowPatternIdentifiers.cs
- SpellerInterop.cs
- JournalEntry.cs
- AttributeSetAction.cs
- Attributes.cs
- UIElementHelper.cs
- indexingfiltermarshaler.cs
- FormsAuthenticationTicket.cs
- CommandBindingCollection.cs
- PropertyRecord.cs
- Addressing.cs
- ServicePointManager.cs
- BackgroundWorker.cs
- DetailsViewRowCollection.cs
- FunctionImportMapping.ReturnTypeRenameMapping.cs
- TdsParser.cs
- XmlSerializer.cs