Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- XmlSignificantWhitespace.cs
- XmlName.cs
- Variable.cs
- ColorTransformHelper.cs
- SmiMetaDataProperty.cs
- SimpleTableProvider.cs
- CompoundFileDeflateTransform.cs
- EndpointConfigContainer.cs
- KerberosRequestorSecurityToken.cs
- XmlAtomicValue.cs
- AbstractSvcMapFileLoader.cs
- Schema.cs
- TextTreeInsertUndoUnit.cs
- TextFormatterHost.cs
- EnumType.cs
- CheckPair.cs
- ValidationVisibilityAttribute.cs
- HostProtectionException.cs
- AttachedAnnotation.cs
- CFGGrammar.cs
- Stack.cs
- FocusWithinProperty.cs
- ContentPlaceHolder.cs
- BaseHashHelper.cs
- OdbcConnectionHandle.cs
- TableLayoutStyleCollection.cs
- DoubleAnimationUsingKeyFrames.cs
- DesignerActionVerbItem.cs
- ViewManager.cs
- TextShapeableCharacters.cs
- DPTypeDescriptorContext.cs
- DataTableReaderListener.cs
- EventToken.cs
- SecurityException.cs
- SubclassTypeValidatorAttribute.cs
- ControlParser.cs
- Matrix3D.cs
- _Semaphore.cs
- BitmapEffectCollection.cs
- BitmapEffectDrawingContextWalker.cs
- VectorAnimationBase.cs
- PrintPageEvent.cs
- HtmlInputText.cs
- StreamingContext.cs
- PageAsyncTaskManager.cs
- GridErrorDlg.cs
- UnionExpr.cs
- XmlChildNodes.cs
- SystemDiagnosticsSection.cs
- Suspend.cs
- ReadWriteObjectLock.cs
- DesignObjectWrapper.cs
- PathSegment.cs
- WebPartUserCapability.cs
- _ListenerRequestStream.cs
- DefaultBinder.cs
- PointCollection.cs
- Pens.cs
- ButtonFieldBase.cs
- coordinatorscratchpad.cs
- AsymmetricSignatureDeformatter.cs
- CommentGlyph.cs
- XmlWriterDelegator.cs
- MappedMetaModel.cs
- XNodeNavigator.cs
- TreeNodeMouseHoverEvent.cs
- StorageRoot.cs
- GridItemCollection.cs
- InheritedPropertyDescriptor.cs
- sitestring.cs
- Freezable.cs
- DelegateBodyWriter.cs
- ViewService.cs
- SaveRecipientRequest.cs
- SerializationFieldInfo.cs
- httpapplicationstate.cs
- DeadCharTextComposition.cs
- DispatcherObject.cs
- EraserBehavior.cs
- SqlCommandSet.cs
- WinInet.cs
- Timer.cs
- ExpressionBinding.cs
- InvalidAsynchronousStateException.cs
- SessionStateSection.cs
- WebColorConverter.cs
- newinstructionaction.cs
- RbTree.cs
- TextDecorationCollection.cs
- GPPOINT.cs
- DataGridViewCellStyleContentChangedEventArgs.cs
- Operator.cs
- NullableConverter.cs
- ReadOnlyCollection.cs
- CacheOutputQuery.cs
- XmlNotation.cs
- HwndAppCommandInputProvider.cs
- HandleCollector.cs
- ValidationUtility.cs
- SqlCacheDependencyDatabaseCollection.cs