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
- WmpBitmapEncoder.cs
- ClientTargetCollection.cs
- CompositionTarget.cs
- ClrPerspective.cs
- VirtualizedItemPattern.cs
- BitmapSourceSafeMILHandle.cs
- Cursors.cs
- WebPartConnectionsCancelEventArgs.cs
- TypedRowGenerator.cs
- UriTemplateClientFormatter.cs
- CallSite.cs
- Debug.cs
- EntityDataSourceWrapperCollection.cs
- hresults.cs
- DynamicPropertyHolder.cs
- RtfNavigator.cs
- COM2EnumConverter.cs
- UpDownEvent.cs
- PerspectiveCamera.cs
- OleDbSchemaGuid.cs
- ColorContext.cs
- PipeSecurity.cs
- StatusBar.cs
- FieldReference.cs
- bindurihelper.cs
- StyleXamlParser.cs
- TableDetailsRow.cs
- OracleBFile.cs
- WCFModelStrings.Designer.cs
- AxHost.cs
- WmpBitmapDecoder.cs
- DataGridHeaderBorder.cs
- CommandHelpers.cs
- datacache.cs
- graph.cs
- WinFormsSecurity.cs
- HtmlInputPassword.cs
- Pen.cs
- DefaultParameterValueAttribute.cs
- WhileDesigner.cs
- ArrayTypeMismatchException.cs
- Literal.cs
- WarningException.cs
- SqlCacheDependencyDatabaseCollection.cs
- TypeSemantics.cs
- InvalidFilterCriteriaException.cs
- PtsHelper.cs
- DesignParameter.cs
- ExpressionBuilderContext.cs
- RuntimeHelpers.cs
- SafeFileMapViewHandle.cs
- HandleRef.cs
- WorkflowOperationAsyncResult.cs
- SqlDataSourceSelectingEventArgs.cs
- CryptoApi.cs
- ObjectViewListener.cs
- XmlSecureResolver.cs
- ToolboxComponentsCreatedEventArgs.cs
- PropertiesTab.cs
- StringConverter.cs
- IncrementalCompileAnalyzer.cs
- Properties.cs
- CultureSpecificStringDictionary.cs
- WebContext.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- UpdateCompiler.cs
- Mapping.cs
- CannotUnloadAppDomainException.cs
- EnlistmentState.cs
- NetworkStream.cs
- InputScope.cs
- VariableQuery.cs
- SqlProcedureAttribute.cs
- SchemaImporter.cs
- AnnouncementInnerClientCD1.cs
- MimeImporter.cs
- SqlPersonalizationProvider.cs
- Debugger.cs
- ImageFormat.cs
- ErrorWrapper.cs
- TextTreeInsertElementUndoUnit.cs
- Maps.cs
- XPathNodeInfoAtom.cs
- PathTooLongException.cs
- InkSerializer.cs
- CryptoConfig.cs
- ObjectDataSourceFilteringEventArgs.cs
- ArrayItemValue.cs
- StateBag.cs
- DrawingContextDrawingContextWalker.cs
- GridViewRowCollection.cs
- Function.cs
- HitTestParameters.cs
- Error.cs
- SQLMembershipProvider.cs
- HostedBindingBehavior.cs
- Certificate.cs
- UnionExpr.cs
- TagMapCollection.cs
- IdnMapping.cs