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
- CodeArrayCreateExpression.cs
- TreeViewCancelEvent.cs
- smtpconnection.cs
- StickyNoteAnnotations.cs
- PropertyGroupDescription.cs
- ErrorItem.cs
- XmlAnyAttributeAttribute.cs
- TypeContext.cs
- StrokeNodeData.cs
- TextBox.cs
- DataErrorValidationRule.cs
- TableSectionStyle.cs
- NativeActivityMetadata.cs
- MobileComponentEditorPage.cs
- PropertyMapper.cs
- CompressedStack.cs
- VBCodeProvider.cs
- ToolboxItemImageConverter.cs
- ConfigurationElementProperty.cs
- MessageQueueInstaller.cs
- LocalServiceSecuritySettingsElement.cs
- Image.cs
- StreamGeometryContext.cs
- TogglePattern.cs
- NetPeerTcpBindingElement.cs
- Frame.cs
- WebPartConnectionsCancelEventArgs.cs
- EventData.cs
- CompiledRegexRunnerFactory.cs
- EmptyEnumerator.cs
- MultiSelector.cs
- GridLengthConverter.cs
- _AutoWebProxyScriptWrapper.cs
- StyleSheetDesigner.cs
- Label.cs
- BaseTemplateCodeDomTreeGenerator.cs
- objectresult_tresulttype.cs
- FileLogRecordEnumerator.cs
- SignedPkcs7.cs
- WindowsIdentity.cs
- XmlSchemaNotation.cs
- PathGeometry.cs
- WSFederationHttpSecurityMode.cs
- HealthMonitoringSection.cs
- HttpHeaderCollection.cs
- SmtpNegotiateAuthenticationModule.cs
- ComponentChangedEvent.cs
- UIElementIsland.cs
- PropertyChangedEventArgs.cs
- AlternateView.cs
- SaveWorkflowAsyncResult.cs
- RijndaelManaged.cs
- NodeFunctions.cs
- UpdatePanelTriggerCollection.cs
- DbConnectionStringCommon.cs
- BooleanKeyFrameCollection.cs
- ResourceLoader.cs
- SubtreeProcessor.cs
- Expression.cs
- DataGridViewBindingCompleteEventArgs.cs
- LogicalTreeHelper.cs
- WebConvert.cs
- AsyncOperationManager.cs
- SymmetricSecurityProtocol.cs
- StackOverflowException.cs
- StylusPlugInCollection.cs
- XmlSerializableReader.cs
- StructuredTypeEmitter.cs
- PropertyGridCommands.cs
- Stacktrace.cs
- DocumentGridPage.cs
- DecimalConstantAttribute.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- SerializerWriterEventHandlers.cs
- PriorityBindingExpression.cs
- DomainLiteralReader.cs
- CatalogPartChrome.cs
- RedirectionProxy.cs
- NetCodeGroup.cs
- ColumnHeader.cs
- GridEntry.cs
- TextEffectCollection.cs
- TextRangeEditLists.cs
- DocumentManager.cs
- CodeDesigner.cs
- XpsDigitalSignature.cs
- UnknownWrapper.cs
- PageParser.cs
- EventDescriptor.cs
- TransactionManagerProxy.cs
- CellParaClient.cs
- LinqDataSourceDisposeEventArgs.cs
- VariantWrapper.cs
- DSASignatureDeformatter.cs
- DataList.cs
- GlobalEventManager.cs
- ReferentialConstraint.cs
- CanonicalizationDriver.cs
- AnnotationDocumentPaginator.cs
- SqlDataSourceCache.cs