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
- XmlAggregates.cs
- IndentedTextWriter.cs
- OptionalRstParameters.cs
- SQLDouble.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- WebDisplayNameAttribute.cs
- SynchronizedKeyedCollection.cs
- indexingfiltermarshaler.cs
- TraceSwitch.cs
- storepermission.cs
- XmlIncludeAttribute.cs
- ToolStripSplitStackLayout.cs
- GB18030Encoding.cs
- SocketPermission.cs
- XslAstAnalyzer.cs
- LogicalMethodInfo.cs
- FunctionMappingTranslator.cs
- ValidatingReaderNodeData.cs
- ApplicationServiceManager.cs
- InvokeDelegate.cs
- KernelTypeValidation.cs
- SymbolPair.cs
- Regex.cs
- RetrieveVirtualItemEventArgs.cs
- SafeThreadHandle.cs
- ResourcePart.cs
- IPipelineRuntime.cs
- ConfigurationPropertyCollection.cs
- DetailsViewAutoFormat.cs
- XamlStyleSerializer.cs
- ListItemCollection.cs
- WeakReferenceList.cs
- regiisutil.cs
- RSAOAEPKeyExchangeDeformatter.cs
- CodeTypeReferenceSerializer.cs
- WizardSideBarListControlItemEventArgs.cs
- MultipartContentParser.cs
- DeflateStream.cs
- StringTraceRecord.cs
- MethodToken.cs
- ListViewCommandEventArgs.cs
- ListGeneralPage.cs
- GenericsNotImplementedException.cs
- SafeUserTokenHandle.cs
- SelectionPattern.cs
- DefaultValueConverter.cs
- SynchronizedInputAdaptor.cs
- MenuItem.cs
- ConnectorDragDropGlyph.cs
- StatusBar.cs
- XmlSchemaObject.cs
- ReverseInheritProperty.cs
- PerSessionInstanceContextProvider.cs
- ResolvedKeyFrameEntry.cs
- ScrollItemPattern.cs
- CharAnimationBase.cs
- ViewBox.cs
- NavigationPropertyEmitter.cs
- AssemblyGen.cs
- CompilerScopeManager.cs
- ResourceBinder.cs
- ConditionalExpression.cs
- ObjectTokenCategory.cs
- sqlmetadatafactory.cs
- Form.cs
- InternalCache.cs
- ResourceDescriptionAttribute.cs
- BamlBinaryWriter.cs
- RijndaelManaged.cs
- Permission.cs
- Baml6Assembly.cs
- RegexCode.cs
- ResourceManager.cs
- CTreeGenerator.cs
- XsltSettings.cs
- CommandHelper.cs
- IntMinMaxAggregationOperator.cs
- JournalEntryListConverter.cs
- DataContractSet.cs
- PersonalizableAttribute.cs
- XamlRtfConverter.cs
- ComplexPropertyEntry.cs
- TextCompositionManager.cs
- SafeNativeMethods.cs
- WpfSharedXamlSchemaContext.cs
- DataViewManagerListItemTypeDescriptor.cs
- DrawingCollection.cs
- Cloud.cs
- TakeQueryOptionExpression.cs
- IdentityHolder.cs
- ExecutionEngineException.cs
- IgnoreFlushAndCloseStream.cs
- QuadraticBezierSegment.cs
- ApplicationSettingsBase.cs
- ColorContext.cs
- TagPrefixInfo.cs
- TreeIterators.cs
- XmlLanguage.cs
- BindingManagerDataErrorEventArgs.cs
- GridLengthConverter.cs