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
- ViewCellRelation.cs
- ConfigXmlCDataSection.cs
- WinInet.cs
- CollectionConverter.cs
- SwitchElementsCollection.cs
- TemplateXamlTreeBuilder.cs
- TemplateInstanceAttribute.cs
- _IPv4Address.cs
- ItemCollectionEditor.cs
- LoginUtil.cs
- ExecutionContext.cs
- PersistenceContext.cs
- EdmToObjectNamespaceMap.cs
- DownloadProgressEventArgs.cs
- HScrollProperties.cs
- PanelStyle.cs
- DataBindingHandlerAttribute.cs
- SqlWriter.cs
- LoadWorkflowCommand.cs
- DetailsViewRow.cs
- EventToken.cs
- LinkedResource.cs
- PropertyRef.cs
- nulltextnavigator.cs
- HttpHeaderCollection.cs
- DebugControllerThread.cs
- HttpClientProtocol.cs
- RowTypeElement.cs
- CategoryAttribute.cs
- ZipArchive.cs
- smtppermission.cs
- CodeIdentifier.cs
- ImageClickEventArgs.cs
- DataRowChangeEvent.cs
- QueryOutputWriter.cs
- ServiceModelSecurityTokenRequirement.cs
- ToolboxItem.cs
- MsmqBindingFilter.cs
- RadioButtonRenderer.cs
- CompModSwitches.cs
- CFStream.cs
- Converter.cs
- TypeUtils.cs
- ExpandCollapsePattern.cs
- WebConfigurationHostFileChange.cs
- AttributeTableBuilder.cs
- PropertyNames.cs
- CreateParams.cs
- OperationDescription.cs
- RenderData.cs
- SamlAudienceRestrictionCondition.cs
- CompositeScriptReferenceEventArgs.cs
- SqlConnectionManager.cs
- wgx_exports.cs
- ContextStack.cs
- PersonalizationAdministration.cs
- SerializerDescriptor.cs
- SortAction.cs
- SoapObjectReader.cs
- AnimationStorage.cs
- Component.cs
- PathFigure.cs
- TripleDES.cs
- ContractMapping.cs
- Win32NamedPipes.cs
- MethodAccessException.cs
- BStrWrapper.cs
- QueryContext.cs
- ValidationHelpers.cs
- Zone.cs
- InfoCardCryptoHelper.cs
- ToolStripGrip.cs
- FileDialogCustomPlace.cs
- PasswordTextContainer.cs
- CreateUserWizard.cs
- FixedPageProcessor.cs
- SubstitutionResponseElement.cs
- ExceptionUtil.cs
- JumpList.cs
- SettingsAttributes.cs
- TextRenderer.cs
- SrgsSubset.cs
- CodeAttributeDeclarationCollection.cs
- DataServiceQueryException.cs
- _BaseOverlappedAsyncResult.cs
- OdbcEnvironmentHandle.cs
- SymmetricSecurityProtocol.cs
- ConsoleTraceListener.cs
- ArrayConverter.cs
- Figure.cs
- InputLanguageEventArgs.cs
- RealizationDrawingContextWalker.cs
- XPathSelectionIterator.cs
- RightsManagementLicense.cs
- WSTransactionSection.cs
- TaskHelper.cs
- DynamicValueConverter.cs
- ConsumerConnectionPointCollection.cs
- SystemDropShadowChrome.cs
- SafeProcessHandle.cs