Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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); } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SelectionEditor.cs
- PositiveTimeSpanValidatorAttribute.cs
- TemplateEditingFrame.cs
- XmlAttributeAttribute.cs
- CompositionAdorner.cs
- LocationReferenceValue.cs
- RoleGroupCollectionEditor.cs
- BaseCollection.cs
- SelectionProviderWrapper.cs
- XmlSchemaAnyAttribute.cs
- Durable.cs
- OleServicesContext.cs
- IntegerValidator.cs
- StatusBarPanel.cs
- RoutedEvent.cs
- ProfileServiceManager.cs
- Freezable.cs
- ReadWriteControlDesigner.cs
- TabletDevice.cs
- RegisteredDisposeScript.cs
- XmlSchemaSimpleTypeList.cs
- PackageRelationship.cs
- EnterpriseServicesHelper.cs
- Propagator.Evaluator.cs
- LinkDescriptor.cs
- MetabaseSettings.cs
- MatrixConverter.cs
- path.cs
- LinqDataSourceHelper.cs
- ProjectionCamera.cs
- SpellerHighlightLayer.cs
- MemberHolder.cs
- Stopwatch.cs
- Debug.cs
- GridSplitterAutomationPeer.cs
- StylusPointProperties.cs
- IERequestCache.cs
- Bezier.cs
- DataGridItemEventArgs.cs
- WebSysDisplayNameAttribute.cs
- TableCell.cs
- X509PeerCertificateAuthenticationElement.cs
- ScriptResourceAttribute.cs
- UnsafeNativeMethods.cs
- DataGridViewRowCancelEventArgs.cs
- TraceLog.cs
- SafeTimerHandle.cs
- ApplicationFileCodeDomTreeGenerator.cs
- SuppressMessageAttribute.cs
- DesignerVerb.cs
- DateTimeParse.cs
- SecurityCriticalDataForSet.cs
- OpenTypeLayout.cs
- ControlIdConverter.cs
- ResourceReferenceExpression.cs
- GeometryCombineModeValidation.cs
- XmlMemberMapping.cs
- RelatedEnd.cs
- TextRange.cs
- StylusOverProperty.cs
- TextPattern.cs
- SQLInt16Storage.cs
- EntityFunctions.cs
- BuildProvider.cs
- DataGridViewCheckBoxColumn.cs
- Documentation.cs
- ExpanderAutomationPeer.cs
- JsonStringDataContract.cs
- RadioButtonPopupAdapter.cs
- XmlSchemaGroupRef.cs
- CheckBoxPopupAdapter.cs
- __Error.cs
- RequestQueue.cs
- XmlBinaryWriterSession.cs
- Dispatcher.cs
- CompositeControl.cs
- LayoutEditorPart.cs
- WebPartConnectionsConnectVerb.cs
- Comparer.cs
- WebPartDisplayModeCollection.cs
- ManagementEventWatcher.cs
- VisualStateGroup.cs
- OutputCacheProfile.cs
- ElapsedEventArgs.cs
- FlowLayoutPanel.cs
- DetailsViewUpdatedEventArgs.cs
- TextControl.cs
- Rules.cs
- AsymmetricSignatureDeformatter.cs
- SynchronizedInputProviderWrapper.cs
- CompositeControl.cs
- DelegateHelpers.cs
- FixedDocumentPaginator.cs
- DotExpr.cs
- PointCollectionValueSerializer.cs
- EnumValidator.cs
- SessionState.cs
- VerticalAlignConverter.cs
- Button.cs
- UnauthorizedWebPart.cs