Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / infocard / Service / managed / Microsoft / InfoCards / DecryptRequest.cs / 1 / DecryptRequest.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace Microsoft.InfoCards { using System; using System.IO; using IDT = Microsoft.InfoCards.Diagnostics.InfoCardTrace; using System.Security.Principal; using System.Diagnostics; // // Summary: // Manages an decryption request from the client against a specified cryptosession. // class DecryptRequest : ClientRequest { // // The cryptosession id we are attaching to. // int m_cryptoSession; // // Whether the data is padded using OAEP. // bool m_useOAEP; // // The encrypted data we wish to decrypt. // byte[] m_encrypted; // // The data after decryption. // byte[] m_decrypted; // // Sumamry: // Construct a DecyrptRequest object // // Arguments: // callingProcess - The process in which the caller originated. // callingIdentity - The WindowsIdentity of the caller // rpcHandle - The handle of the native RPC request // inArgs - The stream to read input data from // outArgs - The stream to write output data to // public DecryptRequest( Process callingProcess, WindowsIdentity callingIdentity, IntPtr rpcHandle, Stream inArgs, Stream outArgs ) : base( callingProcess, callingIdentity, rpcHandle, inArgs, outArgs ) { IDT.TraceDebug( "Intiating a Decrypt request" ); m_cryptoSession = 0; m_useOAEP = false; m_encrypted = null; m_decrypted = null; } protected override void OnMarshalInArgs() { IDT.DebugAssert( null != InArgs, "null inargs" ); BinaryReader reader = new InfoCardBinaryReader( InArgs ); // // Reader should have data in the order: // crytposession ( int32 ) // isOAEP ( int32 ) // encrypted len ( int32 ) // encrypted bytes // m_cryptoSession = reader.ReadInt32(); m_useOAEP = reader.ReadBoolean(); int count = reader.ReadInt32(); m_encrypted = reader.ReadBytes( count ); IDT.ThrowInvalidArgumentConditional( 0 == m_cryptoSession, "cryptoSession" ); IDT.ThrowInvalidArgumentConditional( null == m_encrypted || 0 == m_encrypted.Length, "encrypted" ); } // // Summary: // Attach to the appropriate cryptosession and decrypt the data. // protected override void OnProcess() { IDT.DebugAssert( 0 != m_cryptoSession, "null crypto session" ); IDT.DebugAssert( null != m_encrypted && 0 != m_encrypted.Length, "null encrypted data" ); AsymmetricCryptoSession session = (AsymmetricCryptoSession) CryptoSession.Find( m_cryptoSession, CallerPid, RequestorIdentity.User ); m_decrypted = session.Decrypt( m_useOAEP, m_encrypted ); IDT.DebugAssert( null != m_decrypted && 0 != m_decrypted.Length, "null decrypted data" ); } // // Summary: // Return our decrypted data back to the caller, and wipe our cleartext buffer. // protected override void OnMarshalOutArgs() { IDT.DebugAssert( null != OutArgs, "Null out args" ); IDT.DebugAssert( null != m_decrypted, "null decrypted buffer" ); try { BinaryWriter writer = new BinaryWriter( OutArgs ); Utility.SerializeBytes( writer, m_decrypted ); } finally { Array.Clear( m_decrypted, 0, m_decrypted.Length ); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataObject.cs
- BooleanStorage.cs
- QueryComponents.cs
- HostingEnvironment.cs
- MatrixConverter.cs
- IPAddressCollection.cs
- ListViewTableRow.cs
- ItemContainerProviderWrapper.cs
- ping.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- SystemKeyConverter.cs
- ApplicationGesture.cs
- EncryptedData.cs
- SecurityPolicySection.cs
- WinEventHandler.cs
- NavigationPropertyEmitter.cs
- OrderedDictionaryStateHelper.cs
- TextEmbeddedObject.cs
- EffectiveValueEntry.cs
- CheckBoxRenderer.cs
- FlatButtonAppearance.cs
- WeakEventManager.cs
- FileChangesMonitor.cs
- Funcletizer.cs
- ComponentEditorPage.cs
- MediaScriptCommandRoutedEventArgs.cs
- GridViewRowPresenter.cs
- TextureBrush.cs
- IncrementalReadDecoders.cs
- SchemaMerger.cs
- XmlElementCollection.cs
- TagPrefixCollection.cs
- MatrixCamera.cs
- PeerNameRegistration.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- SoapIgnoreAttribute.cs
- WindowsComboBox.cs
- DataGridRowDetailsEventArgs.cs
- FileDocument.cs
- AttributeQuery.cs
- SafeFreeMibTable.cs
- DataGridItemEventArgs.cs
- DataServiceQuery.cs
- SafeCloseHandleCritical.cs
- PeerMaintainer.cs
- ExtensionSimplifierMarkupObject.cs
- SortKey.cs
- HtmlInputHidden.cs
- SqlWebEventProvider.cs
- ResourceReferenceExpression.cs
- OneToOneMappingSerializer.cs
- HttpCookiesSection.cs
- LoginName.cs
- Matrix3DValueSerializer.cs
- ProcessModule.cs
- SchemaDeclBase.cs
- WindowsTreeView.cs
- SamlAssertion.cs
- ReliableSessionBindingElement.cs
- AnnotationResourceChangedEventArgs.cs
- HotSpot.cs
- DesigntimeLicenseContextSerializer.cs
- SequenceDesigner.xaml.cs
- GeometryGroup.cs
- OleDbReferenceCollection.cs
- MessageDecoder.cs
- ButtonPopupAdapter.cs
- SettingsBindableAttribute.cs
- DecoderNLS.cs
- BufferedGraphicsContext.cs
- ReadOnlyDictionary.cs
- Dispatcher.cs
- ColumnBinding.cs
- CalendarDataBindingHandler.cs
- XmlSchemaSequence.cs
- XmlSignificantWhitespace.cs
- DocumentApplicationJournalEntry.cs
- ColumnResizeUndoUnit.cs
- TypeHelper.cs
- Collection.cs
- PipelineModuleStepContainer.cs
- LineInfo.cs
- DataTableCollection.cs
- ToolboxDataAttribute.cs
- RelationshipEndMember.cs
- Column.cs
- SplayTreeNode.cs
- JsonMessageEncoderFactory.cs
- DataTablePropertyDescriptor.cs
- EntityClientCacheKey.cs
- listviewsubitemcollectioneditor.cs
- Trigger.cs
- CacheModeValueSerializer.cs
- PropertyInfoSet.cs
- PreservationFileWriter.cs
- ImmutableCollection.cs
- SQLBoolean.cs
- TextEditorSelection.cs
- CreatingCookieEventArgs.cs
- CreateDataSourceDialog.cs