Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- XmlDictionaryReaderQuotas.cs
- LineInfo.cs
- FileNotFoundException.cs
- FormatException.cs
- ReferenceConverter.cs
- ToolStripSettings.cs
- LineServicesCallbacks.cs
- SBCSCodePageEncoding.cs
- OracleSqlParser.cs
- CompModSwitches.cs
- TcpSocketManager.cs
- SoapAttributeAttribute.cs
- Simplifier.cs
- RegistryExceptionHelper.cs
- ViewManager.cs
- TemplateInstanceAttribute.cs
- TransformerInfo.cs
- FlowDocumentReader.cs
- XamlSerializerUtil.cs
- MessageHeaderException.cs
- _NetworkingPerfCounters.cs
- SqlNodeTypeOperators.cs
- IsolatedStorageFilePermission.cs
- DecryptRequest.cs
- ProviderUtil.cs
- xmlfixedPageInfo.cs
- ScriptServiceAttribute.cs
- CharEntityEncoderFallback.cs
- ExceptionValidationRule.cs
- BookmarkScopeInfo.cs
- CommandDesigner.cs
- TypeExtensionConverter.cs
- PageTheme.cs
- TableRowCollection.cs
- StickyNoteHelper.cs
- UseAttributeSetsAction.cs
- uribuilder.cs
- ResourceSet.cs
- CommandBindingCollection.cs
- FileAuthorizationModule.cs
- PersonalizablePropertyEntry.cs
- AuthenticationService.cs
- PrimitiveDataContract.cs
- SettingsPropertyWrongTypeException.cs
- AsyncSerializedWorker.cs
- X509Utils.cs
- RelationshipFixer.cs
- WebPart.cs
- ShapingWorkspace.cs
- RuleSettings.cs
- EmbeddedMailObjectsCollection.cs
- DbMetaDataCollectionNames.cs
- ProcessHostConfigUtils.cs
- LinqDataSourceSelectEventArgs.cs
- CounterCreationData.cs
- LinkLabel.cs
- XPathMultyIterator.cs
- ExpandCollapsePattern.cs
- ItemChangedEventArgs.cs
- LinkDescriptor.cs
- Int16Storage.cs
- TouchDevice.cs
- ReliabilityContractAttribute.cs
- ParseElementCollection.cs
- UnhandledExceptionEventArgs.cs
- SchemaMerger.cs
- SmtpLoginAuthenticationModule.cs
- DotExpr.cs
- HighContrastHelper.cs
- SortDescription.cs
- ScriptComponentDescriptor.cs
- BindingContext.cs
- ObfuscationAttribute.cs
- UrlPath.cs
- DynamicPropertyReader.cs
- SpecialTypeDataContract.cs
- MetadataItem_Static.cs
- LoadMessageLogger.cs
- CodeValidator.cs
- ClientScriptManager.cs
- WebPartZoneCollection.cs
- AvTrace.cs
- IQueryable.cs
- XsltArgumentList.cs
- TableSectionStyle.cs
- AbandonedMutexException.cs
- SocketException.cs
- MediaPlayerState.cs
- CallInfo.cs
- DataServiceHost.cs
- BaseCollection.cs
- indexingfiltermarshaler.cs
- SharedUtils.cs
- ReaderWriterLock.cs
- GeometryValueSerializer.cs
- DirtyTextRange.cs
- XpsThumbnail.cs
- SwitchElementsCollection.cs
- _SecureChannel.cs
- Compiler.cs