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
- Command.cs
- KeyValueConfigurationElement.cs
- LayoutEngine.cs
- StatusBarPanel.cs
- ApplicationActivator.cs
- UpdateException.cs
- ResolvePPIDRequest.cs
- OletxEnlistment.cs
- HttpApplicationFactory.cs
- ComponentChangedEvent.cs
- DataGridHeaderBorder.cs
- TreeNodeCollectionEditor.cs
- DbDeleteCommandTree.cs
- DiagnosticTraceSource.cs
- RegexNode.cs
- DeviceSpecificChoiceCollection.cs
- InvalidPrinterException.cs
- TextRangeAdaptor.cs
- SpeechAudioFormatInfo.cs
- PageThemeCodeDomTreeGenerator.cs
- ModuleBuilderData.cs
- DataListAutoFormat.cs
- NamedElement.cs
- RelationshipType.cs
- CheckBoxRenderer.cs
- ReaderWriterLock.cs
- SourceChangedEventArgs.cs
- GifBitmapDecoder.cs
- adornercollection.cs
- XMLUtil.cs
- BoundingRectTracker.cs
- URIFormatException.cs
- MetadataUtil.cs
- TrailingSpaceComparer.cs
- ConfigurationElementProperty.cs
- FontSourceCollection.cs
- DataGrid.cs
- VectorAnimationUsingKeyFrames.cs
- FileChangesMonitor.cs
- HandlerFactoryCache.cs
- TextTrailingWordEllipsis.cs
- CodeExpressionCollection.cs
- OracleSqlParser.cs
- QueryOptionExpression.cs
- HttpRequestBase.cs
- EntityParameterCollection.cs
- NativeWindow.cs
- ContainerUtilities.cs
- EventMappingSettingsCollection.cs
- ExceptionHelpers.cs
- SelectionProviderWrapper.cs
- ParserHooks.cs
- TemplateKeyConverter.cs
- XmlChoiceIdentifierAttribute.cs
- ToolStripSplitButton.cs
- MsmqMessageProperty.cs
- Size.cs
- StringFreezingAttribute.cs
- BufferedReadStream.cs
- TransformCollection.cs
- OutputScopeManager.cs
- MappingModelBuildProvider.cs
- DoWorkEventArgs.cs
- Version.cs
- ResolveDuplex11AsyncResult.cs
- DBParameter.cs
- GeneralTransformGroup.cs
- TransformGroup.cs
- MimeWriter.cs
- TemplateControlParser.cs
- SiteMapNodeItem.cs
- _ConnectionGroup.cs
- ExtensionDataObject.cs
- ListViewCommandEventArgs.cs
- ConditionalExpression.cs
- BrowserDefinition.cs
- HttpHandlersSection.cs
- TerminateWorkflow.cs
- TileModeValidation.cs
- DataReceivedEventArgs.cs
- FlatButtonAppearance.cs
- Win32SafeHandles.cs
- RuleAttributes.cs
- HttpBrowserCapabilitiesWrapper.cs
- MethodImplAttribute.cs
- ExtractorMetadata.cs
- SeekableReadStream.cs
- EmptyControlCollection.cs
- PenContexts.cs
- mactripleDES.cs
- ConfigurationValidatorAttribute.cs
- SocketAddress.cs
- ActivityDesignerLayoutSerializers.cs
- DbDeleteCommandTree.cs
- PropertyTab.cs
- CachingHintValidation.cs
- PEFileEvidenceFactory.cs
- SplashScreenNativeMethods.cs
- Signature.cs
- TextEditorLists.cs