Code:
/ FX-1434 / FX-1434 / 1.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
- ProjectionQueryOptionExpression.cs
- SecurityProtocolCorrelationState.cs
- MetabaseSettings.cs
- AQNBuilder.cs
- DateTimeConverter2.cs
- BooleanExpr.cs
- DataControlFieldsEditor.cs
- TextRunTypographyProperties.cs
- PathTooLongException.cs
- ISAPIApplicationHost.cs
- XmlTextReaderImpl.cs
- X509ChainElement.cs
- NameValueCollection.cs
- OptionUsage.cs
- DiscardableAttribute.cs
- XmlDocumentFragment.cs
- MemberHolder.cs
- BaseParser.cs
- SystemThemeKey.cs
- MimeWriter.cs
- RowTypePropertyElement.cs
- wmiutil.cs
- ComponentEvent.cs
- HeaderUtility.cs
- QilInvokeLateBound.cs
- ReadOnlyCollection.cs
- DataGridColumn.cs
- TextDecoration.cs
- PagesSection.cs
- AutomationPatternInfo.cs
- contentDescriptor.cs
- ObjectPersistData.cs
- DataSourceSelectArguments.cs
- DataPagerFieldCommandEventArgs.cs
- SymmetricAlgorithm.cs
- ScriptResourceAttribute.cs
- DocumentViewer.cs
- AudienceUriMode.cs
- CheckBoxPopupAdapter.cs
- XPathSingletonIterator.cs
- DataGridViewColumnHeaderCell.cs
- ConnectionPoolManager.cs
- TemplateColumn.cs
- UpdatePanelControlTrigger.cs
- SlotInfo.cs
- CheckBoxFlatAdapter.cs
- SocketElement.cs
- FamilyCollection.cs
- DocumentViewerAutomationPeer.cs
- Funcletizer.cs
- SslStream.cs
- XmlNodeChangedEventArgs.cs
- Triplet.cs
- ParseHttpDate.cs
- Light.cs
- ApplicationFileParser.cs
- BuildResult.cs
- TextReturnReader.cs
- Util.cs
- InboundActivityHelper.cs
- AnnouncementInnerClient11.cs
- XmlMemberMapping.cs
- DynamicResourceExtensionConverter.cs
- XhtmlBasicValidatorAdapter.cs
- ObjectKeyFrameCollection.cs
- ByteConverter.cs
- SocketException.cs
- CodeCommentStatement.cs
- Stylesheet.cs
- FormViewModeEventArgs.cs
- DataGridViewColumnStateChangedEventArgs.cs
- LocalBuilder.cs
- ObjectManager.cs
- DataGridColumnStyleMappingNameEditor.cs
- sortedlist.cs
- BindingCollection.cs
- smtpconnection.cs
- CodeDirectoryCompiler.cs
- DataGridViewRowConverter.cs
- StrokeCollectionConverter.cs
- HelpInfo.cs
- PathData.cs
- EDesignUtil.cs
- FormsAuthenticationConfiguration.cs
- WebPartDisplayModeCancelEventArgs.cs
- ProfilePropertySettings.cs
- HtmlTextArea.cs
- HtmlInputReset.cs
- Attachment.cs
- RoleBoolean.cs
- XslAst.cs
- ConfigurationManagerInternalFactory.cs
- ReferencedAssembly.cs
- SqlCacheDependencyDatabaseCollection.cs
- DocumentReferenceCollection.cs
- DataViewManager.cs
- MinimizableAttributeTypeConverter.cs
- SecondaryViewProvider.cs
- TransformerInfoCollection.cs
- TargetException.cs