Code:
/ DotNET / DotNET / 8.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
- EditBehavior.cs
- InternalCache.cs
- CodeAttributeArgumentCollection.cs
- WhitespaceRule.cs
- RequestQueue.cs
- SocketElement.cs
- WmiPutTraceRecord.cs
- ObjectTypeMapping.cs
- HighContrastHelper.cs
- HwndSourceParameters.cs
- NegationPusher.cs
- Localizer.cs
- DataMisalignedException.cs
- XmlEncoding.cs
- _SafeNetHandles.cs
- TypeUnloadedException.cs
- ToolStripDesignerAvailabilityAttribute.cs
- BaseCollection.cs
- SafeHandles.cs
- ConcurrencyMode.cs
- SignatureSummaryDialog.cs
- GradientBrush.cs
- XPathSingletonIterator.cs
- SqlTriggerAttribute.cs
- SpotLight.cs
- ObfuscateAssemblyAttribute.cs
- MultiBinding.cs
- XmlElement.cs
- FontConverter.cs
- CharKeyFrameCollection.cs
- Permission.cs
- CustomAssemblyResolver.cs
- SystemResourceHost.cs
- RenderData.cs
- Parameter.cs
- RegistrySecurity.cs
- Grant.cs
- Row.cs
- ParenthesizePropertyNameAttribute.cs
- StringValidator.cs
- IpcClientManager.cs
- BinaryUtilClasses.cs
- BorderGapMaskConverter.cs
- ReferentialConstraint.cs
- SignatureDescription.cs
- PasswordPropertyTextAttribute.cs
- ConstructorNeedsTagAttribute.cs
- DataGridItemAttachedStorage.cs
- ButtonBase.cs
- CombinedGeometry.cs
- Material.cs
- ReferenceEqualityComparer.cs
- ImagingCache.cs
- HttpProxyCredentialType.cs
- TableRowCollection.cs
- HttpModuleActionCollection.cs
- MatrixAnimationUsingKeyFrames.cs
- SapiRecognizer.cs
- UnicodeEncoding.cs
- HostedController.cs
- TaiwanLunisolarCalendar.cs
- ViewManagerAttribute.cs
- EditorAttribute.cs
- WebUtil.cs
- NativeMethods.cs
- HttpDictionary.cs
- JsonReader.cs
- CustomLineCap.cs
- TheQuery.cs
- ImageBrush.cs
- DropShadowBitmapEffect.cs
- codemethodreferenceexpression.cs
- ProviderConnectionPoint.cs
- ReservationCollection.cs
- CodeGenerator.cs
- EventToken.cs
- HttpCacheParams.cs
- SoapTypeAttribute.cs
- DesignerActionGlyph.cs
- WebRequestModuleElementCollection.cs
- PrinterSettings.cs
- Point3DCollectionValueSerializer.cs
- WindowsGrip.cs
- DocumentGridPage.cs
- UnknownBitmapEncoder.cs
- OraclePermission.cs
- AssemblyResourceLoader.cs
- HwndSourceParameters.cs
- QilTypeChecker.cs
- VarRefManager.cs
- TdsParserSessionPool.cs
- OperationInvokerTrace.cs
- CodeRemoveEventStatement.cs
- ProfileModule.cs
- DataBindingExpressionBuilder.cs
- NamedPipeWorkerProcess.cs
- ExecutionEngineException.cs
- HandleCollector.cs
- RelationshipType.cs
- ErrorActivity.cs