Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / 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); } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- QilGenerator.cs
- HttpProfileGroupBase.cs
- HostingPreferredMapPath.cs
- ProviderConnectionPoint.cs
- ResourceProviderFactory.cs
- StylusCollection.cs
- SQLRoleProvider.cs
- Int32Converter.cs
- ConfigPathUtility.cs
- SpellerStatusTable.cs
- listviewsubitemcollectioneditor.cs
- CustomError.cs
- WebPart.cs
- InvalidAsynchronousStateException.cs
- IsolatedStorageFileStream.cs
- OleDbEnumerator.cs
- DefaultValueTypeConverter.cs
- EventData.cs
- DocumentPaginator.cs
- PolyLineSegment.cs
- Win32SafeHandles.cs
- PagerSettings.cs
- XPathDocumentBuilder.cs
- TableRow.cs
- QueueTransferProtocol.cs
- RegexReplacement.cs
- WebPartsPersonalizationAuthorization.cs
- KeyToListMap.cs
- XpsFilter.cs
- QueryableDataSource.cs
- XmlHierarchyData.cs
- FileChangesMonitor.cs
- OpacityConverter.cs
- ToolStripDropDownMenu.cs
- Emitter.cs
- ChooseAction.cs
- EncodingTable.cs
- HtmlFormWrapper.cs
- CallbackValidator.cs
- ReflectTypeDescriptionProvider.cs
- CompilerHelpers.cs
- FontStretches.cs
- GPRECT.cs
- CodeAccessPermission.cs
- SwitchAttribute.cs
- DebugView.cs
- LocalizedNameDescriptionPair.cs
- XmlElement.cs
- XmlMemberMapping.cs
- UpdateCompiler.cs
- AsymmetricSignatureFormatter.cs
- SchemeSettingElement.cs
- NotSupportedException.cs
- ReachIDocumentPaginatorSerializerAsync.cs
- PngBitmapDecoder.cs
- HandlerFactoryWrapper.cs
- BaseServiceProvider.cs
- HttpRuntime.cs
- NamespaceList.cs
- UTF7Encoding.cs
- InfoCardSymmetricAlgorithm.cs
- GlyphInfoList.cs
- Synchronization.cs
- HttpListenerRequest.cs
- HostExecutionContextManager.cs
- TaskFormBase.cs
- PresentationTraceSources.cs
- XmlWrappingReader.cs
- SchemaCollectionPreprocessor.cs
- DefaultSerializationProviderAttribute.cs
- XmlBuffer.cs
- TextSearch.cs
- GZipStream.cs
- TypeInitializationException.cs
- followingquery.cs
- DataRecordInternal.cs
- SizeAnimationBase.cs
- ParentUndoUnit.cs
- CollectionContainer.cs
- ContourSegment.cs
- SQLRoleProvider.cs
- EDesignUtil.cs
- OdbcException.cs
- WebBrowserPermission.cs
- DesignerOptionService.cs
- PassportPrincipal.cs
- EndpointIdentityExtension.cs
- DataGridTableCollection.cs
- PersistenceTypeAttribute.cs
- TraceEventCache.cs
- PackagePart.cs
- FixedSOMElement.cs
- SendActivity.cs
- SchemaCollectionPreprocessor.cs
- HelloMessageCD1.cs
- NativeMethods.cs
- BaseValidator.cs
- AttributeSetAction.cs
- RtfToken.cs
- RichTextBoxConstants.cs