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
- ConfigsHelper.cs
- ILGenerator.cs
- SortKey.cs
- DetailsViewCommandEventArgs.cs
- WindowsListViewGroup.cs
- PixelFormats.cs
- Stack.cs
- HitTestWithGeometryDrawingContextWalker.cs
- CodeArrayIndexerExpression.cs
- TextEditorCharacters.cs
- KnownTypesHelper.cs
- ScrollItemProviderWrapper.cs
- ObjectDataSourceMethodEditor.cs
- Style.cs
- ProbeMatches11.cs
- CallbackValidator.cs
- SymmetricKeyWrap.cs
- FileDialogCustomPlacesCollection.cs
- SqlParameterCollection.cs
- DoubleLink.cs
- JsonWriterDelegator.cs
- ImageField.cs
- TextInfo.cs
- PointHitTestResult.cs
- ValidationRule.cs
- PackageProperties.cs
- StylusPlugInCollection.cs
- TaskExceptionHolder.cs
- ISFTagAndGuidCache.cs
- OdbcDataAdapter.cs
- GeneralTransform3DGroup.cs
- CatalogPart.cs
- GPStream.cs
- HtmlControlPersistable.cs
- EnumConverter.cs
- X500Name.cs
- InfoCardConstants.cs
- CheckoutException.cs
- AttributeProviderAttribute.cs
- SymbolTable.cs
- TraceLog.cs
- TouchesCapturedWithinProperty.cs
- HMACSHA256.cs
- WebControlsSection.cs
- DefaultPrintController.cs
- SchemaTableOptionalColumn.cs
- FormViewCommandEventArgs.cs
- AbandonedMutexException.cs
- QilVisitor.cs
- SQLGuidStorage.cs
- FileClassifier.cs
- FrugalList.cs
- TranslateTransform3D.cs
- RelationshipSet.cs
- VoiceInfo.cs
- Misc.cs
- ConfigXmlDocument.cs
- RequestStatusBarUpdateEventArgs.cs
- PkcsUtils.cs
- XamlNamespaceHelper.cs
- CopyOnWriteList.cs
- PhysicalOps.cs
- SecurityIdentifierConverter.cs
- SessionStateItemCollection.cs
- TextCompositionManager.cs
- ColumnResizeAdorner.cs
- HttpSessionStateBase.cs
- DbDataSourceEnumerator.cs
- XPathAxisIterator.cs
- dataprotectionpermission.cs
- ToolboxComponentsCreatingEventArgs.cs
- RenderData.cs
- ADConnectionHelper.cs
- ShaperBuffers.cs
- ArrangedElementCollection.cs
- DispatchChannelSink.cs
- ActivityXamlServices.cs
- Compiler.cs
- SQLInt64.cs
- WmlTextViewAdapter.cs
- TransformPatternIdentifiers.cs
- HtmlTableRowCollection.cs
- SqlRecordBuffer.cs
- RuntimeResourceSet.cs
- NTAccount.cs
- TypeHelper.cs
- MemberProjectedSlot.cs
- StrongName.cs
- MLangCodePageEncoding.cs
- SafeNativeMethodsCLR.cs
- QuaternionRotation3D.cs
- PersonalizationStateQuery.cs
- WebPartConnectionsEventArgs.cs
- Light.cs
- XmlEntity.cs
- AsymmetricSignatureDeformatter.cs
- SymbolEqualComparer.cs
- CodeVariableReferenceExpression.cs
- TextTreeRootNode.cs
- AssemblyAttributes.cs