<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>.NET Security Blog : Orcas</title><link>http://blogs.msdn.com/shawnfa/archive/tags/Orcas/default.aspx</link><description>Tags: Orcas</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Disabling the FIPS Algorithm Check</title><link>http://blogs.msdn.com/shawnfa/archive/2008/03/14/disabling-the-fips-algorithm-check.aspx</link><pubDate>Fri, 14 Mar 2008 17:00:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8191587</guid><dc:creator>shawnfa</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/8191587.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=8191587</wfw:commentRss><description>&lt;p&gt;&lt;a href="http://blogs.msdn.com/shawnfa/archive/2005/05/16/417975.aspx"&gt;.NET 2.0 introduced a check for FIPS certified algorithms&lt;/a&gt; if your local security policy was configured to require them.&amp;nbsp; This resulted in algorithms which are not FIPS compliant (or implementations which were not FIPS certified) throwing an InvalidOperationException from their constructors.&lt;/p&gt; &lt;p&gt;In some cases this isn't a desirable behavior.&amp;nbsp; For instance, some applications need to use the MD5 hashing algorithm for compatibility with an older communication protocol or file format.&amp;nbsp; Prior to .NET 3.5, the AES algorithm was only available in an implementation which was not FIPS certified, and if you needed to use that algorithm the FIPS check could also block you.&lt;/p&gt; &lt;p&gt;To help these cases, we added a configuration file switch to .NET 2.0 SP 1 (and therefore .NET 3.5) which allows an application to say "I know what I'm doing, please don't enforce FIPS for me".&amp;nbsp; For these applications, they can setup a configuration file similar to:&lt;/p&gt; &lt;p&gt; &lt;div style="border-right: black thin inset; padding-right: 1em; border-top: black thin inset; padding-left: 1em; font-size: 10pt; background: lightgrey; padding-bottom: 1em; margin: 1em 1em 1em 2em; border-left: black thin inset; color: black; padding-top: 1em; border-bottom: black thin inset; font-family: monospace"&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;configuration&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;runtime&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;enforceFIPSPolicy&lt;/span&gt;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;enabled&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;false&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;runtime&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;configuration&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Which will prevent the CLR from throwing InvalidOperationExceptions from the constructor of uncertified algorithms and implementations.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8191587" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Cryptography/default.aspx">Cryptography</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Windows/default.aspx">Windows</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Orcas/default.aspx">Orcas</category></item><item><title>Manifested Controls Redux</title><link>http://blogs.msdn.com/shawnfa/archive/2008/01/24/manifested-controls-redux.aspx</link><pubDate>Thu, 24 Jan 2008 21:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7224860</guid><dc:creator>shawnfa</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/7224860.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=7224860</wfw:commentRss><description>&lt;P&gt;Last year, I made a &lt;A href="http://blogs.msdn.com/shawnfa/archive/2007/03/07/specifying-permissions-for-ie-controls-in-orcas.aspx" mce_href="http://blogs.msdn.com/shawnfa/archive/2007/03/07/specifying-permissions-for-ie-controls-in-orcas.aspx"&gt;series&lt;/A&gt; &lt;A href="http://blogs.msdn.com/shawnfa/archive/2007/03/12/tying-your-ie-hosted-control-to-a-manifest.aspx" mce_href="http://blogs.msdn.com/shawnfa/archive/2007/03/12/tying-your-ie-hosted-control-to-a-manifest.aspx"&gt;of&lt;/A&gt; &lt;A href="http://blogs.msdn.com/shawnfa/archive/2007/03/09/manifests-for-ie-hosted-controls.aspx" mce_href="http://blogs.msdn.com/shawnfa/archive/2007/03/09/manifests-for-ie-hosted-controls.aspx"&gt;posts&lt;/A&gt; about a new feature available in the betas of .NET 3.5 which enabled you to specify declaratively the set of permissions that IE hosted managed controls should run with.&amp;nbsp; Since the betas there have been a couple of tweaks to the manifest control model, so those posts need a refresh.&lt;/P&gt;
&lt;P&gt;Most notably, the Low Safety (Unrestricted) setting for the Permissions for Components with Manifests URL action is not a part of the final shipping Orcas bits.&amp;nbsp; Instead, the two options are:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;EM&gt;High Safety&lt;/EM&gt; - manifested controls can run with the permissions it requests, but only if those permissions are a subset of the permissions it would have been granted by CAS policy or if the manifests are signed by a trusted publisher.&lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;Disabled&lt;/EM&gt; - manifested controls may not run at all.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;If you're using a machine that had one of the .NET 3.5 betas on it, the Low Safety option will still appear in your Internet Explorer dialog box, however the CLR will treat a value of Low Safety as if it were Disabled.&lt;/P&gt;
&lt;P&gt;A lot of times when people look at this feature, they would like a full end-to-end sample of a control in a web page taking advantage of a manifest to elevate its permissions.&amp;nbsp; I've attached a ZIP file containing a sample control to this post.&lt;/P&gt;
&lt;P&gt;In order to use this sample:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create a ManifestControl subdirectory in your wwwroot. 
&lt;LI&gt;Copy ManifestControl.control, ManifestControl.dll, ManifestControl.dll.manifest, and ManifestControl.html to the ManifestControl directory created in step 1. 
&lt;LI&gt;Ensure that your web server is setup to allow downloading of .dll, .control, and .dll.manifest files. 
&lt;LI&gt;Install ManifestControl.cer in your Trusted Publishers certificate store. 
&lt;LI&gt;Install ManifestControl.cer in your Trusted Root Certification Authorities certificate store. (&lt;STRONG&gt;Once you are done with the sample, the test certificate should be removed from both of these certificate stores&lt;/STRONG&gt;) 
&lt;LI&gt;Navigate Internet Explorer to &lt;A href="http://localhost/ManifestControl/ManifestControl.html" mce_href="http://localhost/ManifestControl/ManifestControl.html"&gt;http://localhost/ManifestControl/ManifestControl.html&lt;/A&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7224860" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/shawnfa/attachment/7224860.ashx" length="20562" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/CAS/default.aspx">CAS</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Policy/default.aspx">Policy</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Orcas/default.aspx">Orcas</category></item><item><title>Bypassing the Authenticode Signature Check on Startup</title><link>http://blogs.msdn.com/shawnfa/archive/2007/05/07/bypassing-the-authenticode-signature-check-on-startup.aspx</link><pubDate>Mon, 07 May 2007 21:25:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2466313</guid><dc:creator>shawnfa</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/2466313.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=2466313</wfw:commentRss><description>&lt;p&gt;A while back I&amp;nbsp;wrote about &lt;a href="http://blogs.msdn.com/shawnfa/archive/2005/12/13/502779.aspx"&gt;the performance penalty of loading an assembly with an Authenticode signature&lt;/a&gt;.&amp;nbsp; The CLR will attempt to verify the signature at load time to generate &lt;a href="http://msdn2.microsoft.com/en-us/library/system.security.policy.publisher.aspx"&gt;Publisher evidence&lt;/a&gt; for the assembly.&amp;nbsp; However, by default most applications don't need Publisher evidence.&amp;nbsp; Standard CAS policy does not rely on the PublisherMembershipCondition, so unless your application will run on a machine with custom CAS policy modifications, or is intending on satisfying demands for PublisherIdentityPermission (taking into mind that &lt;a href="http://blogs.msdn.com/shawnfa/archive/2005/05/17/418729.aspx"&gt;FullTrust means FullTrust in v2.0 of the framework&lt;/a&gt;), this is wasted startup cost that could be done without.&lt;/p&gt; &lt;p&gt;Obviously if you know your application doesn't need the Publisher evidence, you won't want to pay the cost of having the signature verified.&amp;nbsp; If you &lt;a href="http://msdn2.microsoft.com/en-us/vstudio/aa700831.aspx"&gt;download the Orcas Beta 1 bits&lt;/a&gt;, you'll be able to take advantage of a feature in the runtime that disables this signature verification.&amp;nbsp; Your application can now opt out of Authenticode signature verification; which will mean that time to load each assembly will improve (therefore leading to an improvement in startup time if your entry point assembly has an Authenticode signature).&amp;nbsp;&amp;nbsp;The tradeoff of course is that&amp;nbsp;assemblies&amp;nbsp;will no longer receive Publisher evidence or PublisherIdentityPermission.&amp;nbsp; Applications which wish to take advantage of this can add the following line to their .exe.config file:&lt;/p&gt; &lt;p&gt; &lt;div style="border-right: black thin inset; padding-right: 1em; border-top: black thin inset; padding-left: 1em; font-size: 10pt; background: lightgrey; padding-bottom: 1em; margin: 1em 1em 1em 2em; border-left: black thin inset; color: black; padding-top: 1em; border-bottom: black thin inset; font-family: monospace"&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;configuration&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;runtime&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;generatePublisherEvidence&lt;/span&gt;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;enabled&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;false&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;runtime&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px"&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;configuration&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Which&amp;nbsp;will prevent the CLR from verifying the Authenticode signatures of any assembly loaded by the application.&amp;nbsp;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2466313" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/CAS/default.aspx">CAS</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Policy/default.aspx">Policy</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Orcas/default.aspx">Orcas</category></item><item><title>Tying your IE Hosted Control to a Manifest</title><link>http://blogs.msdn.com/shawnfa/archive/2007/03/12/tying-your-ie-hosted-control-to-a-manifest.aspx</link><pubDate>Mon, 12 Mar 2007 17:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1846554</guid><dc:creator>shawnfa</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/1846554.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=1846554</wfw:commentRss><description>&lt;P&gt;Last week, I talked about the &lt;A class="" href="http://blogs.msdn.com/shawnfa/archive/2007/03/07/specifying-permissions-for-ie-controls-in-orcas.aspx" mce_href="http://blogs.msdn.com/shawnfa/archive/2007/03/07/specifying-permissions-for-ie-controls-in-orcas.aspx"&gt;Orcas feature which allows you to provide a manifest to elevate your control's permissions declaratively&lt;/A&gt;.&amp;nbsp; We also saw &lt;A href="http://blogs.msdn.com/shawnfa/archive/2007/03/09/manifests-for-ie-hosted-controls.aspx" mce_href="http://blogs.msdn.com/shawnfa/archive/2007/03/09/manifests-for-ie-hosted-controls.aspx"&gt;how to generate manifests&lt;/A&gt; that would state what permissions your control needs (and the rules associated with those manifests).&amp;nbsp; Now it's time to tie it all together and create an HTML page that has a control and its associated manifests.&lt;/P&gt;
&lt;P&gt;Once you've gotten this far, the last step is thankfully pretty painless.&amp;nbsp; A similar syntax to the one used to attach a config file to a control is used to tie a manifest to it.&amp;nbsp; The only change you need to make to your HTML page which already hosts a managed control via the object tag is to add a link in the HTML head section to the manifest:&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: black thin inset; PADDING-RIGHT: 1em; BORDER-TOP: black thin inset; PADDING-LEFT: 1em; FONT-SIZE: 10pt; BACKGROUND: lightgrey; PADDING-BOTTOM: 1em; MARGIN: 1em 1em 1em 2em; BORDER-LEFT: black thin inset; COLOR: black; PADDING-TOP: 1em; BORDER-BOTTOM: black thin inset; FONT-FAMILY: monospace"&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;html&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;head&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;link&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;rel&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;MANIFEST&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;href&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;TemplateControl.control&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;head&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;body&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;object&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;classid&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;TemplateControl.dll#TemplateControlClass&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;body&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;html&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There you have it!&amp;nbsp; The control hosted in TemplateControl.dll will now be associated with the TemplateControl.control deployment manifest, which points ad the TemplateControl.dll.manifest application manifest.&amp;nbsp; TemplateControl.dll.manifest gives the permission set the control should run with.&amp;nbsp; If the signer of TemplateControl.control is a trusted publisher, and manifested controls have not been disabled from this zone then the control will run with the permissions it asked for. 
&lt;P&gt;If this does not work as expected, double check that the manifests are following &lt;A href="http://blogs.msdn.com/shawnfa/archive/2007/03/09/manifests-for-ie-hosted-controls.aspx" mce_href="http://blogs.msdn.com/shawnfa/archive/2007/03/09/manifests-for-ie-hosted-controls.aspx"&gt;all of the rules for manifests&lt;/A&gt;.&amp;nbsp; You can also check to make sure that the "Permissions for Controls with Manifests" IE security setting is not "disable" (which it is for the MyComputer zone), and that the target machine has Orcas on it.&amp;nbsp; Finally, there's always the &lt;A href="http://support.microsoft.com/kb/313892/" mce_href="http://support.microsoft.com/kb/313892/"&gt;IEHost debug log&lt;/A&gt; which should list out any errors encountered parsing the manifests.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1846554" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/CAS/default.aspx">CAS</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Orcas/default.aspx">Orcas</category></item><item><title>Manifests for IE Hosted Controls</title><link>http://blogs.msdn.com/shawnfa/archive/2007/03/09/manifests-for-ie-hosted-controls.aspx</link><pubDate>Fri, 09 Mar 2007 20:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1846339</guid><dc:creator>shawnfa</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/1846339.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=1846339</wfw:commentRss><description>&lt;P&gt;Earlier this week,I talked about the Orcas feature where &lt;A href="http://blogs.msdn.com/shawnfa/archive/2007/03/07/specifying-permissions-for-ie-controls-in-orcas.aspx" mce_href="http://blogs.msdn.com/shawnfa/archive/2007/03/07/specifying-permissions-for-ie-controls-in-orcas.aspx"&gt;controls can declaratively request permissions&lt;/A&gt; in a similar way to ClickOnce applications.&amp;nbsp; In fact, the manifests used for this request are the same manifests used for ClickOnce applications, with a few special requirements added onto them.&amp;nbsp; When you're developing controls, its possible to have manifests which don't meet one of these requirements.&amp;nbsp; In that case, the error in the manifest will be logged to the &lt;A href="http://support.microsoft.com/kb/313892/" mce_href="http://support.microsoft.com/kb/313892/"&gt;IEHost debug log&lt;/A&gt; in order&amp;nbsp;to help you figure out what needs to be changed.&amp;nbsp; Lets dig in deeper to the manifests, since they are really at the heart of this feature.&lt;/P&gt;
&lt;P&gt;Like a ClickOnce application, IE hosted controls will have both a deployment and an application manifest.&amp;nbsp; By convention, the deployment manifest will have a .control extension, while the application manifest will have a .dll.manifest extension.&amp;nbsp; Both manifests are required to have a valid Authenticode and StrongName signature (a self signed certificate will work, however it must be installed in the trusted root store on the client machines so that it "chains" to a valid root).&amp;nbsp; Both manifests must also be located on the same site as the control -- a control on foo.com cannot have manifest on bar.com.&amp;nbsp; Similarly, a deployment manifest on bar.com cannot refer to an application manifest on baz.com.&lt;/P&gt;
&lt;P&gt;Outside of those common requirements, each manifest has its own specific requirements.&amp;nbsp; Let's look at the deployment manifest first.&amp;nbsp; The requirements for the deployment manifest are:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;It must not request to be installed on the local machine.&amp;nbsp; IE hosted controls do not get installed into the ClickOnce application store. 
&lt;LI&gt;It must have a deploymentProvider which exactly matches the URL it was downloaded from. 
&lt;LI&gt;Point at the application manifest, and&amp;nbsp;have the correct hash of the manifest included.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;I've attached TemplateControl.control as a template that control deployment manifests can be based upon.&amp;nbsp; The first two requirements can be seen in the deployment section of the manifest:&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: black thin inset; PADDING-RIGHT: 1em; BORDER-TOP: black thin inset; PADDING-LEFT: 1em; FONT-SIZE: 10pt; BACKGROUND: lightgrey; PADDING-BOTTOM: 1em; MARGIN: 1em 1em 1em 2em; BORDER-LEFT: black thin inset; COLOR: black; PADDING-TOP: 1em; BORDER-BOTTOM: black thin inset; FONT-FAMILY: monospace"&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;deployment&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;install&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;deploymentProvider&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;codebase&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;http://www.contoso.com/TemplateControl/TemplateControl.control&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;deployment&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;And the last one is in the dependency section:&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: black thin inset; PADDING-RIGHT: 1em; BORDER-TOP: black thin inset; PADDING-LEFT: 1em; FONT-SIZE: 10pt; BACKGROUND: lightgrey; PADDING-BOTTOM: 1em; MARGIN: 1em 1em 1em 2em; BORDER-LEFT: black thin inset; COLOR: black; PADDING-TOP: 1em; BORDER-BOTTOM: black thin inset; FONT-FAMILY: monospace"&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;dependency&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;dependentAssembly&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;codebase&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;TemplateControl.dll.manifest&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;size&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;1929&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;dependencyType&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;install&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;assemblyIdentity&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;TemplateControl.dll&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;version&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;1.0.0.0&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;publicKeyToken&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;7bbbb9ce54f53dd4&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;processorArchitecture&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;msil&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;language&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;neutral&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;win32&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;hash&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;dsig:Transforms&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;dsig:Transform&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Algorithm&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;urn:schemas-microsoft-com:HashTransforms.Identity&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;dsig:Transforms&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;dsig:DigestMethod&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Algorithm&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;http://www.w3.org/2000/09/xmldsig#sha1&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;dsig:DigestValue&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;QPq0hc3mZPhWUeRAthX7QefabZk=&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;dsig:DigestValue&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;hash&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;dependentAssembly&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;dependency&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;Onto the application manifest.&amp;nbsp; There are a few more rules around this manifest:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The hash of the application manifest must match the hash specified in the deployment manifest 
&lt;LI&gt;The entry point must match the control being downloaded 
&lt;LI&gt;There must be a &amp;lt;hostInBrowser /&amp;gt; tag 
&lt;LI&gt;A permission set must be supplied 
&lt;LI&gt;The only file allowed to be listed is the control itself, we do not support having additional files in the manifest.&amp;nbsp; You can of course load them when your control is running, but only the control assembly may appear in the manifest 
&lt;LI&gt;The control must have its SHA-1 hash listed, and that hash must match the control&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Again, I've attached TemplateControl.dll.manifest to this post to use as a template for control application manifests.&amp;nbsp; You can see in the entry point section that the entry point is indeed the control (assuming the control is hosted in TemplateControl.dll), and that it should be hosted in the browser:&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: black thin inset; PADDING-RIGHT: 1em; BORDER-TOP: black thin inset; PADDING-LEFT: 1em; FONT-SIZE: 10pt; BACKGROUND: lightgrey; PADDING-BOTTOM: 1em; MARGIN: 1em 1em 1em 2em; BORDER-LEFT: black thin inset; COLOR: black; PADDING-TOP: 1em; BORDER-BOTTOM: black thin inset; FONT-FAMILY: monospace"&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;entryPoint&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;assemblyIdentity&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;TemplateControl&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;version&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;1.0.0.0&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;publicKeyToken&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;7bbbb9ce54f53dd4&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;processorArchitecture&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;msil&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;language&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;neutral&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;commandLine&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;file&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;TemplateControl.dll&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;hostInBrowser&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;urn:schemas-microsoft-com:asm.v3&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;entryPoint&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;The permission set exists in the trustInfo section, as is the case for regular ClickOnce manifests:&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: black thin inset; PADDING-RIGHT: 1em; BORDER-TOP: black thin inset; PADDING-LEFT: 1em; FONT-SIZE: 10pt; BACKGROUND: lightgrey; PADDING-BOTTOM: 1em; MARGIN: 1em 1em 1em 2em; BORDER-LEFT: black thin inset; COLOR: black; PADDING-TOP: 1em; BORDER-BOTTOM: black thin inset; FONT-FAMILY: monospace"&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;trustInfo&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;security&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;applicationRequestMinimum&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;PermissionSet&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;System.Security.NamedPermissionSet&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;version&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;1&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Unrestricted&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Description&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Allows full access to all resources&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;SameSite&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;site&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;FullTrust&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;defaultAssemblyRequest&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;permissionSetReference&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;FullTrust&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;applicationRequestMinimum&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;security&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;trustInfo&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;And the dependency is the control assembly:&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: black thin inset; PADDING-RIGHT: 1em; BORDER-TOP: black thin inset; PADDING-LEFT: 1em; FONT-SIZE: 10pt; BACKGROUND: lightgrey; PADDING-BOTTOM: 1em; MARGIN: 1em 1em 1em 2em; BORDER-LEFT: black thin inset; COLOR: black; PADDING-TOP: 1em; BORDER-BOTTOM: black thin inset; FONT-FAMILY: monospace"&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;dependency&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;dependentAssembly&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;codebase&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;TemplateControl.dll&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;size&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;4608&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;dependencyType&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;install&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;allowDelayedBinding&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;assemblyIdentity&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;TemplateControl&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;version&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;1.0.0.0&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;publicKeyToken&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;7bbbb9ce54f53dd4&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;processorArchitecture&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;msil&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;language&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;neutral&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;hash&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;dsig:Transforms&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;dsig:Transform&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Algorithm&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;urn:schemas-microsoft-com:HashTransforms.Identity&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;dsig:Transforms&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;dsig:DigestMethod&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Algorithm&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;http://www.w3.org/2000/09/xmldsig#sha1&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;dsig:DigestValue&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;yxh1Z4B1Maw8UoXSU+rDwsj+8bA=&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;dsig:DigestValue&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;hash&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;dependentAssembly&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;dependency&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;Unfortunately, the tools story for&amp;nbsp;creating control manifests&amp;nbsp;isn't all together great at this point.&amp;nbsp; The easiest way that you'll be able to generate these manifests is to start with the template manifests, and then use the &lt;A href="http://msdn2.microsoft.com/en-us/library/acz3y3te(VS.80).aspx" mce_href="http://msdn2.microsoft.com/en-us/library/acz3y3te(VS.80).aspx"&gt;Mage tool&lt;/A&gt; that ships in the Framework SDK to update and sign them.&amp;nbsp; Since Mage does not yet know about control manifests, there are a few manual steps involved:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create a directory containing your manifest and control.&amp;nbsp; You may want to edit the manifest at this point, to point it at YourControl.dll rather than TemplateControl.dll.&amp;nbsp; You could also update the other names in the manifest. 
&lt;LI&gt;Update the hash value of your control:&amp;nbsp;Mage -Update YourControl.dll.manifest 
&lt;LI&gt;Mage will give a warning about a .dll not being a valid entry point, and insert dependencies on the operating system and CLR.&amp;nbsp; You'll have to edit the manifest so that the extra dependencies are removed. 
&lt;LI&gt;Sign the manifest: Mage -Sign YourControl.dll.manifest -CertFile &lt;EM&gt;&amp;lt;path to your certificate&amp;gt;&lt;/EM&gt; -Password &lt;EM&gt;&amp;lt;certificate password&amp;gt;&lt;/EM&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;At this point you'll have a valid application manifest for your control.&amp;nbsp; Similar steps are required to setup the deployment manifest:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Rename TemplateControl.control to give it a more appropriate name.&amp;nbsp; You'll also need to change the deploymentProvider to point at the URL where your manifest will be accessed by client machines, and update the reference to TemplateControl.dll.manifest to point at your control's application manifest. 
&lt;LI&gt;Update the hash value of the application manifest: Mage -Update YourControl.control 
&lt;LI&gt;Sign the manifest: Mage -Sign YourControl.control -CertFile &lt;EM&gt;&amp;lt;path to your certificate&amp;gt;&lt;/EM&gt; -Password &lt;EM&gt;&amp;lt;certificate password&amp;gt;&lt;/EM&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Now you have a pair of valid manifests to use with your control.&amp;nbsp; Yes, I know that this isn't exactly ... well ... the easiest procedure in the world.&amp;nbsp; Hopefully by the time we finish the release we will have a better story here, but for now these steps will allow you to play with generating controls for the CTP releases.&lt;/P&gt;
&lt;P&gt;So now we know the overall picture of manifested IE controls in Orcas and have seen what the manifests look like and how to create them, that leaves us with one last step.&amp;nbsp; Next time, we'll take a look at how we hook the whole thing up in an HTML page to get the full story working end-to-end.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;[Update 3/29]&lt;/STRONG&gt; &lt;A class="" href="http://blogs.msdn.com/shawnfa/pages/templatecontrol-control.aspx" mce_href="http://blogs.msdn.com/shawnfa/pages/templatecontrol-control.aspx"&gt;Provided a link to the TemplateControl.control file&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1846339" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/shawnfa/attachment/1846339.ashx" length="1929" type="text/xml" /><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/CAS/default.aspx">CAS</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Orcas/default.aspx">Orcas</category></item><item><title>Specifying Permissions for IE Controls in Orcas</title><link>http://blogs.msdn.com/shawnfa/archive/2007/03/07/specifying-permissions-for-ie-controls-in-orcas.aspx</link><pubDate>Wed, 07 Mar 2007 22:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1830177</guid><dc:creator>shawnfa</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/1830177.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=1830177</wfw:commentRss><description>&lt;P&gt;One of my most read blog posts (and one of the reasons I created this blog in the first place -- to answer what was one of the most asked questions on the old .NET Security newsgroup), is my post about &lt;A href="http://blogs.msdn.com/shawnfa/archive/2003/06/26/57026.aspx" mce_href="http://blogs.msdn.com/shawnfa/archive/2003/06/26/57026.aspx"&gt;granting managed controls hosted in IE extra permissions&lt;/A&gt;.&amp;nbsp; If you need to have a managed control run above its default grant set, the process getting this working in .NET versions through&amp;nbsp;.NET 2.0&amp;nbsp;was relatively painful.&lt;/P&gt;
&lt;P&gt;You needed to create an extra code group that granted your control the permissions required, and then get that policy deployed to all client machines.&amp;nbsp; One of the more common ways of doing this is to use the .NET MMC snap-in to create a policy MSI file.&amp;nbsp; However, those policy files are snapshots of policy and overwrite any other custom policy settings on each client machine.&amp;nbsp; This means if a user has two controls they use that require an MSI prerequisite, they end up fighting for control over policy -- only the last one installed wins.&amp;nbsp; There's also no guarantee that client machines have run my MSI file, so unless the control does runtime permission checking it will sometimes fail on misconfigured machines.&lt;/P&gt;
&lt;P&gt;Versioning provides another challenge here.&amp;nbsp; Since &lt;A href="http://blogs.msdn.com/shawnfa/archive/2006/07/11/661769.aspx" mce_href="http://blogs.msdn.com/shawnfa/archive/2006/07/11/661769.aspx"&gt;every CLR has independent security policy&lt;/A&gt;&amp;nbsp;and IE will always load the latest runtime version when hosting a control, as soon as a new version of the CLR ships all changes in policy will no longer apply to hosted controls, and new MSIs will need to be created.&lt;/P&gt;
&lt;P&gt;On top of all of these challenges, is the problem mentioned in the original blog post -- namely that the AppDomain hosting the control will only have Url and Zone evidence.&amp;nbsp; If your code group uses a stronger membership condition (and it probably should) such as StrongName or Publisher, any demands will fail when they hit the AppDomain boundary because the domain will not match your code group and will have lower trust than your assembly.&amp;nbsp; This required adding an assert at each of the control's entry points, which is not really a great coding practice.&lt;/P&gt;
&lt;P&gt;With all of these problems, it's pretty obvious that we need a better solution for controls which need to run with higher permission than default.&amp;nbsp; A lot of these problems apply to applications as well as controls, and we solved them in .NET 2.0 by having those applications use ClickOnce.&amp;nbsp; Since ClickOnce applications can specify their required permissions in a manifest and allow the user to decide if this is a safe set of permissions to grant, there was no policy modification.&lt;/P&gt;
&lt;P&gt;Orcas introduces a very similar system for IE hosted controls.&amp;nbsp; They can now include a set of manifests, which are very similar to the ClickOnce manifests, that state the required set of permissions for the control to run.&amp;nbsp; Again, this decouples the control from policy which solves the MSI-fight problem as well as the CLR versioning problem.&amp;nbsp; Just like ClickOnce applications, these controls are hosted in &lt;A href="http://blogs.msdn.com/shawnfa/archive/2006/04/19/579066.aspx" mce_href="http://blogs.msdn.com/shawnfa/archive/2006/04/19/579066.aspx"&gt;simple sandbox domains&lt;/A&gt; -- this means that the domain and the control both have the same permission set, removing the need to assert at the entry points.&lt;/P&gt;
&lt;P&gt;One of the first&amp;nbsp;questions that comes to mind when thinking about this feature is if a control is allowed to declaratively state what permissions it wants to run with, what's to prevent malicious controls from elevating to FullTrust and doing whatever it wants to my machine?&amp;nbsp; We've decided not to do any prompting of the user for this feature, instead we use a simple algorithm to determine if the control should be allowed to run with its requested permissions.&amp;nbsp; Specifically, if any of these requirements are met, then we allow the control to run:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The control is requesting a subset of the permissions it would have gotten anyway.&amp;nbsp; So if a control is coming from the Internet zone and it is requesting the Internet permission set, we'll allow it to run.&lt;/LI&gt;
&lt;LI&gt;The control is signed by a trusted publisher.&amp;nbsp; The control's deployment manifest must be signed (more on the requirements for manifests later) by a X.509 certificate.&amp;nbsp; If the signer is in the client's trusted publisher list and the certificate is valid and chains to a trusted root, then we allow the control to run with whatever permissions it requests.&amp;nbsp; This is likely the easiest way for IT organizations to make use of the feature, as trusted publishers can be controlled via group policy.&lt;/LI&gt;
&lt;LI&gt;If the zone the manifest is running from explicitly allows controls loaded from it to elevate their permissions&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;If all three of those checks fail, then the control is not allowed to run.&amp;nbsp; (Note that we don't run the control with the permissions it would be granted from policy if these checks fail -- we assume that the control was authored to run with the specified set of permissions, and should not be run with less than the requested set).&lt;/P&gt;
&lt;P&gt;The third check may need a little more explanation.&amp;nbsp; When you install Orcas, you'll see that a new option has been added to the Internet Explorer Security Settings dialog box called "Permissions for components with manifests":&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/photos/shawnfa/images/1830158/original.aspx" mce_href="http://blogs.msdn.com/photos/shawnfa/images/1830158/original.aspx"&gt;&lt;IMG src="http://blogs.msdn.com/photos/shawnfa/images/1830158/original.aspx" mce_src="http://blogs.msdn.com/photos/shawnfa/images/1830158/original.aspx"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;As you can see, there are three possible values for this setting:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;EM&gt;Disable&lt;/EM&gt; - controls with manifests will not be allowed to run at all.&amp;nbsp; Even if the control is requesting only Execution permission and is signed by a trusted publisher, if the zone it's loaded from is set to disabled the CLR will not allow the control to run.&lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;High Safety&lt;/EM&gt; - controls are not allowed to elevate their permissions via this setting alone.&amp;nbsp; If the control is not requesting elevation or is signed by a trusted publisher than it will be allowed to run, however this setting will cause check #3 above to fail.&lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;Low Safety (Unrestricted)&lt;/EM&gt; - controls are allowed to elevate.&amp;nbsp; Even if the first two elevation checks fail, if the zone is set to low safety, then the control will be allowed to run with whatever permissions it asks for.&amp;nbsp; The reason that "Unrestricted" appears in the setting is that by setting this value, you're effectively giving all controls loaded from this zone the ability to run fully trusted.&amp;nbsp; Obviously that's not something that should be done lightly if at all. &lt;EM&gt;[Updated 1/24/2008 - Low Safety was removed after the Orcas betas.]&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Essentially, if the setting for the deployment manifest's zone is High Safety then elevation check #3 fails, if it is Low Safety then elevation check #3 succeeds.&amp;nbsp; The default values for this setting are:&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=2 width=400 border=1 unselectable="on"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=200&gt;MyComputer&lt;/TD&gt;
&lt;TD class="" vAlign=top width=200&gt;Disable&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=200&gt;Local Intranet&lt;/TD&gt;
&lt;TD class="" vAlign=top width=200&gt;High Safety&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=200&gt;Trusted Sites&lt;/TD&gt;
&lt;TD class="" vAlign=top width=200&gt;High Safety&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=200&gt;Internet&lt;/TD&gt;
&lt;TD class="" vAlign=top width=200&gt;High Safety&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=200&gt;Restricted Sites&lt;/TD&gt;
&lt;TD class="" vAlign=top width=200&gt;Disable&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;So no zone will elevate by default, and manifested controls are disabled entirely on the local machine and restricted sites.&lt;/P&gt;
&lt;P&gt;Next time: More information about the manifests&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1830177" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/ClickOnce/default.aspx">ClickOnce</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/CAS/default.aspx">CAS</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Policy/default.aspx">Policy</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Orcas/default.aspx">Orcas</category></item><item><title>Introduction to the Orcas Add-In Model</title><link>http://blogs.msdn.com/shawnfa/archive/2007/02/20/introduction-to-the-orcas-add-in-model.aspx</link><pubDate>Tue, 20 Feb 2007 21:08:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1728286</guid><dc:creator>shawnfa</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/1728286.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=1728286</wfw:commentRss><description>&lt;p&gt;One of the features the CLR team is adding in Orcas is that we're providing a new model to help enable your application to host Add-Ins.&amp;nbsp; I've got a special interest in this set of features, as I always try to make my hobby applications pluggable for some reason, and I tend to end up writing a ton of infrastructure that, once Orcas ships, I will no longer have to.&amp;nbsp;&amp;nbsp;The&amp;nbsp;Add-In team has&amp;nbsp;done the work to enable discovery, versioning, and most importantly (from my perspective at least :-) ) securely sandboxing those Add-Ins.&lt;/p&gt; &lt;p&gt;Recently, they've done a pretty big brain-dump of how their feature is going to work.&amp;nbsp; Some of the resources available are:&lt;/p&gt; &lt;p&gt;MSDN Magazine Articles:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://msdn.microsoft.com/msdnmag/issues/07/02/CLRInsideOut/default.aspx"&gt;.NET Application Extensibility (part 1)&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://msdn.microsoft.com/msdnmag/issues/07/03/CLRInsideOut/default.aspx"&gt;.NET Application Extensibility (part 2)&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Blogs&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://blogs.msdn.com/clraddins/"&gt;The Add-In Team Blog&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://blogs.msdn.com/zifengh/"&gt;Jason He's Blog&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Jason's blog is interesting because he's decided to go through the steps to upgrade Paint.NET to use the new AddIn model, and discuss his experiences.&amp;nbsp; If you're intereseted in making your apps extensible, it's worth checking out this feature to see if it's made your life any easier.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1728286" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Other/default.aspx">Other</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Orcas/default.aspx">Orcas</category></item><item><title>Elliptic Curve Diffie-Hellman</title><link>http://blogs.msdn.com/shawnfa/archive/2007/01/22/elliptic-curve-diffie-hellman.aspx</link><pubDate>Tue, 23 Jan 2007 00:58:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1509885</guid><dc:creator>shawnfa</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/1509885.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=1509885</wfw:commentRss><description>&lt;p&gt;The second elliptic curve algorithm added to Orcas is elliptic curve Diffie-Hellman, as the ECDiffieHellmanCng class.&lt;/p&gt; &lt;p&gt;This is the first time Diffie-Hellman is available as part of the .NET Framework, so lets take a quick look at what it is and what it does.&amp;nbsp; Diffie-Hellman is one of the oldest asymmetric algorithms, however unlike the other asymmetric algorithms in the framework today, it does not perform encryption or digital signatures.&amp;nbsp; Instead it allows two parties to exchange private key material even if they only can communicate through a completely public channel.&amp;nbsp; (In &lt;em&gt;&lt;a href="http://www.amazon.com/Network-Security-Private-Communication-Public/dp/0130614661"&gt;Network Security: Private Communication in a Public World&lt;/a&gt;&lt;/em&gt;, an amusing example is given where Diffie-Hellman is performed by two parties taking out ads in the local newspaper).&lt;/p&gt; &lt;p&gt;Key exchange is somewhat of a misleading term, since it implies that one party to the communication generates a key and via the communication protocol lets the other party know what that key is.&amp;nbsp; Instead what really happens is that Diffie-Hellman allows both parties to calculate the same secret value, which is referred to as the secret agreement in the managed Diffie-Hellman classes.&amp;nbsp; This secret agreement can then be used for any number of purposes, including being used as a symmetric key.&lt;/p&gt; &lt;p&gt;Instead of exposing the secret agreement directly however, the ECDiffieHellmanCng class does some post-processing on the agreement before letting the value out.&amp;nbsp; We refer to this post processing as the key derivation function; you can select which KDF you want to use and set its parameters via a set of properties on the instance of the Diffie-Hellman object:&lt;/p&gt; &lt;p&gt; &lt;table border="2"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Key Derivation Function&lt;/b&gt;&lt;/td&gt; &lt;td&gt;&lt;b&gt;Properties&lt;/b&gt;&lt;/td&gt; &lt;td&gt;&lt;b&gt;Meaning&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="3"&gt;Hash&lt;/td&gt; &lt;td&gt;HashAlgorithm&lt;/td&gt; &lt;td&gt;Hash algorithm to process the secret agreement with&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SecretPrepend&lt;/td&gt; &lt;td&gt;Optional byte array to prepend to the secret agreement before hashing it&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SecretAppend&lt;/td&gt; &lt;td&gt;Optional byte array to append to the secret agreement before hashing it&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="4"&gt;Hmac&lt;/td&gt; &lt;td&gt;HashAlgortihm&lt;/td&gt; &lt;td&gt;Hash algorithm to process the secret agreement with (using the HMAC version of the algorithm).&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HmacKey&lt;/td&gt; &lt;td&gt;Key used for the HMAC operation&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SecretPrepend&lt;/td&gt; &lt;td&gt;Optional byte array to prepend to the secret agreement before hashing it&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SecretAppend&lt;/td&gt; &lt;td&gt;Optional byte array to append to the secret agreement before hashing it&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt;Tls&lt;/td&gt; &lt;td&gt;Label&lt;/td&gt; &lt;td&gt;&lt;a href="http://www.ietf.org/rfc/rfc2246.txt?number=2246"&gt;TLS PRF Label&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Seed&lt;/td&gt; &lt;td&gt;&lt;a href="http://www.ietf.org/rfc/rfc2246.txt?number=2246"&gt;TLS PRF Seed&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt; &lt;p&gt;The result of passing the secret agreement through the key derivation function is a byte array that may be used as key material for your application.&amp;nbsp; The number of bytes of key material generated is dependent on the key derivation function, for instance SHA-256 will generate 256 bits of key material, while SHA-512 will generate 512 bits of key material.&lt;/p&gt; &lt;p&gt;The basic flow of an elliptic curve Diffie-Hellman key exchange is:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Alice and Bob create a key pair to use&amp;nbsp;for the Diffie-Hellman key exchange operation  &lt;li&gt;Alice and Bob configure the KDF using agreed upon parameters  &lt;li&gt;Alice sends Bob her public key  &lt;li&gt;Bob sends Alice his public key  &lt;li&gt;Using each other's public keys, the secret agreement is generated, and the KDF is applied to the secret agreement generating key material.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;In code, this looks basically as you would expect:&lt;/p&gt; &lt;p&gt; &lt;div style="border-right: black thin inset; padding-right: 1em; border-top: black thin inset; padding-left: 1em; font-size: 10pt; background: lightgrey; padding-bottom: 1em; margin: 1em 1em 1em 2em; border-left: black thin inset; color: black; padding-top: 1em; border-bottom: black thin inset; font-family: consolas"&gt; &lt;p style="margin: 0px"&gt;&lt;span style="color: teal"&gt;ECDiffieHellmanCng&lt;/span&gt; alice = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: teal"&gt;ECDiffieHellmanCng&lt;/span&gt;();&lt;/p&gt; &lt;p style="margin: 0px"&gt;alice.KeyDerivationFunction = &lt;span style="color: teal"&gt;ECDiffieHellmanKeyDerivationFunction&lt;/span&gt;.Hash;&lt;/p&gt; &lt;p style="margin: 0px"&gt;alice.HashAlgorithm = &lt;span style="color: teal"&gt;CngAlgorithm&lt;/span&gt;.Sha256;&lt;/p&gt; &lt;p style="margin: 0px"&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin: 0px"&gt;&lt;span style="color: teal"&gt;ECDiffieHellmanCng&lt;/span&gt; bob = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: teal"&gt;ECDiffieHellmanCng&lt;/span&gt;();&lt;/p&gt; &lt;p style="margin: 0px"&gt;bob.KeyDerivationFunction = &lt;span style="color: teal"&gt;ECDiffieHellmanKeyDerivationFunction&lt;/span&gt;.Hash;&lt;/p&gt; &lt;p style="margin: 0px"&gt;bob.HashAlgorithm = &lt;span style="color: teal"&gt;CngAlgorithm&lt;/span&gt;.Sha256;&lt;/p&gt; &lt;p style="margin: 0px"&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;byte&lt;/span&gt;[]&amp;nbsp;bobKey = bob.DeriveKeyMaterial(alice.PublicKey);&lt;/p&gt; &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;byte&lt;/span&gt;[]&amp;nbsp;aliceKey = alice.DeriveKeyMaterial(bob.PublicKey);&lt;/p&gt;&lt;/div&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;After running this code, aliceKey and&amp;nbsp;bobKey are both 32 bytes long and match each other.&amp;nbsp; Now, Alice could use this as a symmetric key:&lt;/p&gt; &lt;p&gt; &lt;div style="border-right: black thin inset; padding-right: 1em; border-top: black thin inset; padding-left: 1em; font-size: 10pt; background: lightgrey; padding-bottom: 1em; margin: 1em 1em 1em 2em; border-left: black thin inset; color: black; padding-top: 1em; border-bottom: black thin inset; font-family: consolas"&gt; &lt;p style="margin: 0px"&gt;&lt;span style="color: teal"&gt;AesCryptoServiceProvider&lt;/span&gt; aes = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: teal"&gt;AesCryptoServiceProvider&lt;/span&gt;();&lt;/p&gt; &lt;p style="margin: 0px"&gt;aes.Key = aliceKey;&lt;/p&gt;&lt;/div&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;Obviously, this example is simplified as both Alice and Bob are unlikely to be running in the same process.&amp;nbsp; ECDiffieHellmanPublicKey, which is the class returned by the PublicKey property is Serializable, so that it may be sent across any remoting channel.&amp;nbsp; It also can be manually converted to and from a byte array and XML, allowing for manual serialization in advanced use cases.&lt;/p&gt; &lt;p&gt;One thing to note about Diffie-Hellman is that it only guarantees that both parties are generating a secret that nobody else knows about.&amp;nbsp; It does not let either party know the identity of the other.&amp;nbsp; For instance, in the above code, Alice cannot be sure that the other person in the conversation is Bob; there could potentially be a man-in-the-middle attack here.&lt;/p&gt; &lt;p&gt;In order to solve that, Alice or Bob could use a well-known public key that is distributed by PKI (you can pass a CngKey to the DeriveKeyMaterial API in this case).&amp;nbsp; You could also use HMAC as the KDF and a key that you know only Alice and Bob share to solve this problem.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1509885" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Cryptography/default.aspx">Cryptography</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/CNG/default.aspx">CNG</category></item><item><title>Elliptic Curve DSA</title><link>http://blogs.msdn.com/shawnfa/archive/2007/01/18/elliptic-curve-dsa.aspx</link><pubDate>Thu, 18 Jan 2007 23:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1490163</guid><dc:creator>shawnfa</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/1490163.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=1490163</wfw:commentRss><description>&lt;P&gt;&lt;A href="http://blogs.msdn.com/shawnfa/archive/2007/01/17/new-crypto-algorithms-in-orcas.aspx" mce_href="http://blogs.msdn.com/shawnfa/archive/2007/01/17/new-crypto-algorithms-in-orcas.aspx"&gt;Yesterday I gave a quick rundown of all the new cryptographic algorithms available in the Orcas January CTP&lt;/A&gt;.&amp;nbsp; Today, let's dive in a little deeper to the first of the elliptic curve algorithms, ECDSA.&amp;nbsp; (ECDSA, along with the rest of the CNG classes in the .NET Framework, is only available on Windows Vista).&lt;/P&gt;
&lt;P&gt;ECDSA is an implementation of the &lt;A href="http://csrc.nist.gov/cryptval/dss.htm" mce_href="http://csrc.nist.gov/cryptval/dss.htm"&gt;digital signature standard&lt;/A&gt; using elliptic curves, which makes the ECDsaCng class a sort of cousin of the DSACryptoServiceProvider class.&amp;nbsp; Because&amp;nbsp;DSA and ECDSA&amp;nbsp;are cousins rather than just different implementations of the same algorithm, there is a new base class ECDsa that elliptic curve DSA implementations derive from.&amp;nbsp; You also cannot sign some data with DSACryptoServiceProvider and then verify that signature with ECDsaCng.&lt;/P&gt;
&lt;P&gt;Let's take a look at a basic example of using ECDSA:&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: black thin inset; PADDING-RIGHT: 1em; BORDER-TOP: black thin inset; PADDING-LEFT: 1em; FONT-SIZE: 10pt; BACKGROUND: lightgrey; PADDING-BOTTOM: 1em; MARGIN: 1em 1em 1em 2em; BORDER-LEFT: black thin inset; COLOR: black; PADDING-TOP: 1em; BORDER-BOTTOM: black thin inset; FONT-FAMILY: consolas"&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: teal"&gt;ECDsaCng&lt;/SPAN&gt; dsa = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: teal"&gt;ECDsaCng&lt;/SPAN&gt;();&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;dsa.HashAlgorithm = &lt;SPAN style="COLOR: teal"&gt;CngAlgorithm&lt;/SPAN&gt;.Sha256;&lt;/P&gt;
&lt;P style="MARGIN: 0px" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;byte&lt;/SPAN&gt;[] data = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;byte&lt;/SPAN&gt;[] { 21, 5, 8, 12,&amp;nbsp;2007 };&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;byte&lt;/SPAN&gt;[] signature = dsa.SignData(data);&lt;/P&gt;
&lt;P style="MARGIN: 0px" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (dsa.VerifyData(data, signature))&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: teal"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: maroon"&gt;"Verified"&lt;/SPAN&gt;);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: teal"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: maroon"&gt;"Not verified"&lt;/SPAN&gt;);&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;First we create a new ECDsaCng object, which will generate a random key for us to use.&amp;nbsp; Next, we setup the hash algorithm to use on the input data when creating the signature.&amp;nbsp; Finally, we can call SignData to create a signature over a blob of data, and VerifyData to verify that the signature is correct.&lt;/P&gt;
&lt;P&gt;There are also SignHash/VerifyHash APIs available -- SignData will essentially just hash the data with the hash algorithm specified on the ECDsaCng object (defaulting to SHA-256) and then do a SignHash on the resulting hash value.&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: black thin inset; PADDING-RIGHT: 1em; BORDER-TOP: black thin inset; PADDING-LEFT: 1em; BACKGROUND: lightgrey; PADDING-BOTTOM: 1em; MARGIN: 1em 1em 1em 2em; BORDER-LEFT: black thin inset; COLOR: black; PADDING-TOP: 1em; BORDER-BOTTOM: black thin inset"&gt;&lt;A class="" title=PseudoEnums name=PseudoEnums&gt;&lt;/A&gt;&lt;B&gt;Sidebar: CNG Pseudo-Enums&lt;/B&gt; 
&lt;P&gt;I showed the HashAlgorithm property in the example, even though I was setting it back to the default value, because it uses the CngAlgorithm class which is the first of several pseudo-enums that will show up when you play with the CNG classes.&amp;nbsp; &lt;A href="http://msdn2.microsoft.com/en-us/library/bb204774.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/bb204774.aspx"&gt;CNG itself is very configurable&lt;/A&gt;, and it takes most of its configuration options as strings.&amp;nbsp; With our managed APIs, we didn't want to limit the set of parameters you can pass to CNG to the set that we had predefined a mapping from a traditional enum to a CNG string for.&amp;nbsp; We also wanted to preserve type safety (having everything be a string makes it unclear which strings can go where), and provide pre-defined values for the common cases.&lt;/P&gt;
&lt;P&gt;The result is a set of pseudo-enumerations like CngAlgorithm.&amp;nbsp; CngAlgorithm isn't an enum, it's a class.&amp;nbsp; We've provided a set of CngAlgorithms representing the common algorithm names as static properties, which allow you to use it with enum-like syntax.&amp;nbsp; There's also a CngAlgorithm constructor which takes a string, which means that if you need to use a CNG algorithm that isn't in the list you can construct a CngAlgorithm&amp;nbsp;to reference&amp;nbsp;that algorithm.&lt;/P&gt;
&lt;P&gt;Each of the pseudo enums also behave just as you would expect when dealing with them directly.&amp;nbsp; You can compare them with your language of choice's equality comparison operators, get their hash code, and convert them to their underlying strings.&amp;nbsp; In addition to CngAlgorithm other pseudo-enums you'll find are CngAlgorithmGroup, CngKeyFormat, and CngProvider.&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;The default constructor generates a random key for use with the P-521 curve, described in &lt;A href="http://csrc.nist.gov/publications/fips/fips186-2/fips186-2-change1.pdf" mce_href="http://csrc.nist.gov/publications/fips/fips186-2/fips186-2-change1.pdf"&gt;appendix 6 of FIPS 186-2&lt;/A&gt;.&amp;nbsp; There is also a constructor which accepts the curve you wish to work with; currently ECDsaCng supports P-192, P-256 and P-521. Or, if you don't want to generate a random key&amp;nbsp;you can pass in an existing key to the constructor&amp;nbsp;and it will work with that.&lt;/P&gt;
&lt;P&gt;Incidentally, the CngKey class is your one stop shop for anything to do with CNG keys (stored by NCrypt).&amp;nbsp; You can use this class to create a new random key, open or delete an existing key, get the properties of a key, import / export the key, etc.&amp;nbsp; We also expose a SafeNCryptKeyHandle which represents&amp;nbsp;the underlying NCRYPT_KEY_HANDLE, allowing you to easily P/Invoke for any other functionality not exposed in the CngKey class itself.&lt;/P&gt;
&lt;P&gt;In addition to exporting the ECDSA key&amp;nbsp;via the CngKey&amp;nbsp;property of the&amp;nbsp;ECDsaCng object, you can also export the key into XML.&amp;nbsp; However, since there is currently no standard format for elliptic curve XML, you need to specify which format you want the XML to appear in (not specifying a format will cause an exception).&amp;nbsp; Currently, we only support one option which is the format described in &lt;A href="http://www.ietf.org/rfc/rfc4050.txt" mce_href="http://www.ietf.org/rfc/rfc4050.txt"&gt;RFC 4050&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;So that concludes&amp;nbsp;our whirlwind tour of the ECDsaCng class.&amp;nbsp; Next time we'll take a look at the elliptic curve Diffie-Hellman support in Orcas.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1490163" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Cryptography/default.aspx">Cryptography</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/CNG/default.aspx">CNG</category></item><item><title>New Crypto Algorithms in Orcas</title><link>http://blogs.msdn.com/shawnfa/archive/2007/01/17/new-crypto-algorithms-in-orcas.aspx</link><pubDate>Wed, 17 Jan 2007 21:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1484417</guid><dc:creator>shawnfa</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/1484417.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=1484417</wfw:commentRss><description>&lt;P&gt;The &lt;A title="Orcas January CTP" href="http://www.microsoft.com/downloads/details.aspx?familyid=69055927-458B-4129-9047-FCC4FACAE96C&amp;amp;displaylang=en&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?familyid=69055927-458B-4129-9047-FCC4FACAE96C&amp;amp;displaylang=en&amp;amp;displaylang=en"&gt;January CTP of Orcas is now available&lt;/A&gt;, and with it comes a total of&amp;nbsp;12 new cryptography algorithm implementation classes, which include 2.5 new algorithms.&amp;nbsp; (I'll count AES as 0.5 since we did already have Rijndael :-) ).&amp;nbsp; These classes also are the first set of managed wrappers around the &lt;A title="CNG Reference" href="http://msdn2.microsoft.com/en-us/library/aa376210.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/aa376210.aspx"&gt;new CNG APIs in Windows Vista&lt;/A&gt;, which will use the Cng suffix on the implementation classes.&lt;/P&gt;
&lt;P&gt;Dividing the new algorithms up into their types (all in the System.Security.Cryptography namespace in System.Core.dll), this CTP has:&lt;/P&gt;
&lt;H2&gt;Hash Algorithms&lt;/H2&gt;
&lt;P&gt;
&lt;TABLE class="" border=2&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class=""&gt;&lt;STRONG&gt;Algorithm&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class=""&gt;&lt;STRONG&gt;Class&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class=""&gt;&lt;STRONG&gt;OS Required&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;MD5&lt;/TD&gt;
&lt;TD class=""&gt;MD5Cng&lt;/TD&gt;
&lt;TD class=""&gt;Windows Vista&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;SHA-1&lt;/TD&gt;
&lt;TD class=""&gt;SHA1Cng&lt;/TD&gt;
&lt;TD class=""&gt;Windows Vista&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" rowSpan=2&gt;SHA-256&lt;/TD&gt;
&lt;TD class=""&gt;SHA256CryptoServiceProvider&lt;/TD&gt;
&lt;TD class=""&gt;Windows 2003&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;SHA256Cng&lt;/TD&gt;
&lt;TD class=""&gt;Windows Vista&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" rowSpan=2&gt;SHA-384&lt;/TD&gt;
&lt;TD class=""&gt;SHA384CryptoServiceProvider&lt;/TD&gt;
&lt;TD class=""&gt;Windows 2003&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;SHA384Cng&lt;/TD&gt;
&lt;TD class=""&gt;Windows Vista&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" rowSpan=2&gt;SHA-512&lt;/TD&gt;
&lt;TD class=""&gt;SHA512CryptoServiceProvider&lt;/TD&gt;
&lt;TD class=""&gt;Windows 2003&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;SHA512Cng&lt;/TD&gt;
&lt;TD class=""&gt;Windows Vista&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;The hash algorithms work just as you would expect, and should function as simple drop-in replacements for corresponding algorithms that have already shipped in v2.0 of the .NET Framework.&amp;nbsp;&amp;nbsp;The big advantage here is that these hash algorithms are just wrappers around the Windows implementations of the algorithms, and therefore are &lt;A href="http://blogs.msdn.com/shawnfa/archive/2005/05/16/417975.aspx" mce_href="http://blogs.msdn.com/shawnfa/archive/2005/05/16/417975.aspx"&gt;FIPS compliant versions of the SHA-2 algorithms&lt;/A&gt; which had only managed versions in v2.0.&amp;nbsp; For applications targeting Vista which must use CNG, this set of algorithms also provides CNG wrappers for all of our hashing algorithms.&lt;/P&gt;
&lt;H2&gt;Symmetric Algorithms&lt;/H2&gt;
&lt;P&gt;
&lt;TABLE class="" border=2&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class=""&gt;&lt;STRONG&gt;Algorithm&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class=""&gt;&lt;STRONG&gt;Class&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class=""&gt;&lt;STRONG&gt;OS Required&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" rowSpan=2&gt;AES&lt;/TD&gt;
&lt;TD class=""&gt;AesCryptoServiceProvider&lt;/TD&gt;
&lt;TD class=""&gt;Windows XP SP2&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;AesManaged&lt;/TD&gt;
&lt;TD class=""&gt;All Supported Platforms&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;We've provided a new Aes base class for implementations of AES (&lt;A href="http://blogs.msdn.com/shawnfa/archive/2006/10/09/The-Differences-Between-Rijndael-and-AES.aspx" mce_href="http://blogs.msdn.com/shawnfa/archive/2006/10/09/The-Differences-Between-Rijndael-and-AES.aspx"&gt;rather than Rijndael which allows some parameters to be set differently than AES&lt;/A&gt;).&amp;nbsp; Two implementations of this base class are shipping with the Orcas January CTP, once which wraps the CAPI implementation of AES and a managed implementation of the algorithm which should run on any platform the CLR supports.&lt;/P&gt;
&lt;P&gt;AesManaged is actually just a wrapper around RinjdaelManaged with some code added to make sure that you do not setup the algorithm to operate in a non-AES compatible way.&amp;nbsp; For instance, AesManaged does not allow you to change the block size.&amp;nbsp; (It will also disallow the use of CFB and OFB mode because of the way that RijndaelManaged works with those modes).&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;Asymmetric Algorithms&lt;/H2&gt;
&lt;P&gt;
&lt;TABLE class="" border=2&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class=""&gt;&lt;STRONG&gt;Algorithm&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class=""&gt;&lt;STRONG&gt;Class&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class=""&gt;&lt;STRONG&gt;OS Required&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;Elliptic Curve DSA&lt;/TD&gt;
&lt;TD class=""&gt;ECDSACng&lt;/TD&gt;
&lt;TD class=""&gt;Windows Vista&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;Elliptic Curve Diffie-Hellman&lt;/TD&gt;
&lt;TD class=""&gt;ECDiffieHellmanCng&lt;/TD&gt;
&lt;TD class=""&gt;Windows Vista&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;These are the really interesting additions to the cryptography libraries in this CTP, the first appearance of elliptic curve cryptography in the .NET Framework.&amp;nbsp; Since these will take more than just a paragraph to cover, the next couple of blog posts will focus on these classes (as well as the other supporting classes to&amp;nbsp;help work with CNG).&amp;nbsp; Up next, Elliptic Curve DSA.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1484417" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Cryptography/default.aspx">Cryptography</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/CNG/default.aspx">CNG</category></item><item><title>Using Lightweight CodeGen from Partial Trust</title><link>http://blogs.msdn.com/shawnfa/archive/2006/10/05/Using-Lightweight-CodeGen-from-Partial-Trust.aspx</link><pubDate>Thu, 05 Oct 2006 19:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:794142</guid><dc:creator>shawnfa</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/794142.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=794142</wfw:commentRss><description>&lt;P&gt;Last time I talked about &lt;A href="http://blogs.msdn.com/shawnfa/archive/2006/09/29/777047.aspx" mce_href="http://blogs.msdn.com/shawnfa/archive/2006/09/29/777047.aspx"&gt;the new Orcas feature allowing you to use reflection from partial trust&lt;/A&gt;.&amp;nbsp; Specifically we talked about standard reflection and Reflection.Emit, putting off Lightweight CodeGen until today.&lt;/P&gt;
&lt;P&gt;Before we start, if you're new to LCG, you might want to check out &lt;A href="http://blogs.msdn.com/yirutang/archive/2005/05/19/420183.aspx" mce_href="http://blogs.msdn.com/yirutang/archive/2005/05/19/420183.aspx"&gt;Yiru's quick introduction to the feature&lt;/A&gt;.&amp;nbsp; If you're planning on doing much work with DynamicMethods, &lt;A href="http://blogs.msdn.com/haibo_luo" mce_href="http://blogs.msdn.com/haibo_luo"&gt;Haibo's&lt;/A&gt; excellent &lt;A href="http://blogs.msdn.com/haibo_luo/archive/2005/10/25/484861.aspx" mce_href="http://blogs.msdn.com/haibo_luo/archive/2005/10/25/484861.aspx"&gt;VS 2005 DynamicMethod visualizer&lt;/A&gt; is highly recommended.&lt;/P&gt;
&lt;H2&gt;Traditional Dynamic Methods&lt;/H2&gt;
&lt;P&gt;The v2.0 DynamicMethod constructors took as a parameter either a module or type to host the method.&amp;nbsp; In Orcas, these constructors will no longer demand ReflectionPermission/ReflectionEmit to use.&amp;nbsp; If you've selected to host the dynamic method outside of your assembly, then a demand for ReflectionPermission/RestrictedMemberAccess + the grant set of the target assembly will be done.&amp;nbsp; For compatibility with v2.0, if a demand for SecurityPermission/ControlEvidence would have succeeded then this operation is also allowed.&amp;nbsp; Using the skip visibility feature will still require ReflectionPermission/MemberAccess.&lt;/P&gt;
&lt;P&gt;Let's look at a few examples to help clear that up.&amp;nbsp; Lets say a simple sandbox domain is setup with a grant set of Internet + RestrictedMemberAccess.&amp;nbsp; Assemblies A and B containing types TypeA and TypeB are loaded into the domain, along with two host assemblies, HostAssemblyA and HostAssemblyB containing HostTypeA and HostTypeB.&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class=""&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class=""&gt;Emitting type&lt;/TD&gt;
&lt;TD class=""&gt;Host target&lt;/TD&gt;
&lt;TD class=""&gt;Success&lt;/TD&gt;
&lt;TD class=""&gt;Reason&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="BACKGROUND-COLOR: lightgreen"&gt;
&lt;TD class=""&gt;TypeA&lt;/TD&gt;
&lt;TD class=""&gt;TypeA&lt;/TD&gt;
&lt;TD class=""&gt;Yes&lt;/TD&gt;
&lt;TD class=""&gt;You can always emit into your own assembly&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="BACKGROUND-COLOR: lightgreen"&gt;
&lt;TD class=""&gt;TypeA&lt;/TD&gt;
&lt;TD class=""&gt;TypeB&lt;/TD&gt;
&lt;TD class=""&gt;Yes&lt;/TD&gt;
&lt;TD class=""&gt;Everything in the domain has RMA + the grant set of Assembly A (so RMA + Internet)&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="BACKGROUND-COLOR: lightgreen"&gt;
&lt;TD class=""&gt;HostTypeA&lt;/TD&gt;
&lt;TD class=""&gt;TypeB&lt;/TD&gt;
&lt;TD class=""&gt;Yes&lt;/TD&gt;
&lt;TD class=""&gt;Everything in the domain has RMA + the grant set of Assembly B&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="BACKGROUND-COLOR: red"&gt;
&lt;TD class=""&gt;TypeB&lt;/TD&gt;
&lt;TD class=""&gt;HostTypeB&lt;/TD&gt;
&lt;TD class=""&gt;No&lt;/TD&gt;
&lt;TD class=""&gt;In this case, the demand will be for RMA + grant of HostAssembly = FullTrust. This will fail on B's stack frame&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="BACKGROUND-COLOR: orange"&gt;
&lt;TD class=""&gt;HostTypeA&lt;/TD&gt;
&lt;TD class=""&gt;HostTypeB&lt;/TD&gt;
&lt;TD class=""&gt;It depends :-)&lt;/TD&gt;
&lt;TD class=""&gt;This will also trigger a demand for FullTrust, which will be satisfied by HostTypeA but fail when it hits the AppDomain boundary. If HostTypeA asserted for FullTrust before creating the dynamic method this will succeed, otherwise it will fail.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;This all boils down to one rule which is very similar to the&amp;nbsp;rule for partial trust standard reflection, specifically you can emit methods into assemblies within your trust level -- however you can not emit methods into assemblies which have more trust than you.&lt;/P&gt;
&lt;H2&gt;Anonymously Hosted Dynamic Methods&lt;/H2&gt;
&lt;P&gt;Orcas introduces a new set of constructors which do not allow you to specify the location where the DynamicMethod is hosted&amp;nbsp;and are&amp;nbsp;specially tailored to enable partially trusted code to use LCG -- no demands are made when emitting one of these anonymously hosted dynamic methods.&lt;/P&gt;
&lt;P&gt;One of the constructors for anonymously hosted dynamic methods accept a restricted skip visibility flag.&amp;nbsp; If you create your method and do not ask for restricted skip visibility then everything works exactly as you would expect.&amp;nbsp; Namely, your new method can access public members of any type to do its work.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Things are much more interesting when restricted skip visibility is set to true.&amp;nbsp; Generally, restricted skip visibility is the partial trust equivalent of the skip visibility parameter on standard dynamic methods, meaning that the JIT does not do access checks when your method attempts to access various types, fields, methods and properties.&amp;nbsp; This allows dynamically generated code to access private and internal members of types that it would not normally have access to -- which obviously needs to be a protected operation.&lt;/P&gt;
&lt;P&gt;If restricted skip visibility is on, then each time a member is accessed that a normal visibility check would prevent, a demand for ... you guessed it, RestrictedMemberAccess + the permissions of the target is done.&amp;nbsp; This demand is done against the call stack which was in place when the anonymously hosted dynamic method was created -- which may or may not be the same as the call stack when it gets JITed.&lt;/P&gt;
&lt;P&gt;Another few examples of restricted skip visibility are probably in order.&amp;nbsp; We'll use the same set of types and assemblies as the above examples:&lt;/P&gt;
&lt;P&gt;Let's say that TypeA creates an anonymously hosted dynamic methods with restricted skip visibility that accesses a private field of TypeB.&amp;nbsp; This dynamic method is later invoked:&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class=""&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class=""&gt;Construction call stack&lt;/TD&gt;
&lt;TD class=""&gt;&lt;/TD&gt;
&lt;TD class=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/TD&gt;
&lt;TD class=""&gt;JIT call stack&lt;/TD&gt;
&lt;TD class=""&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;HostTypeA.InvokeAddIn&lt;/TD&gt;
&lt;TD class=""&gt;FullTrust&lt;/TD&gt;
&lt;TD class=""&gt;&lt;/TD&gt;
&lt;TD class=""&gt;TypeA.OnAddInInvoked&lt;/TD&gt;
&lt;TD class=""&gt;Internet + RMA&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;TypeA.Initialize&lt;/TD&gt;
&lt;TD class=""&gt;Internet + RMA&lt;/TD&gt;
&lt;TD class=""&gt;&lt;/TD&gt;
&lt;TD class=""&gt;TypeA.RunDynamicMethod&lt;/TD&gt;
&lt;TD class=""&gt;Internet + RMA&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;TypeA.EmitDynamicMethod&lt;/TD&gt;
&lt;TD class=""&gt;Internet + RMA&lt;/TD&gt;
&lt;TD class=""&gt;&lt;/TD&gt;
&lt;TD class=""&gt;(DynamicMethod)&lt;/TD&gt;
&lt;TD class=""&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;When B causes the dynamic method to be JITed, we see an access to a private member of B.&amp;nbsp; Since B has a grant set of Internet + RMA, the resulting demand is also Internet + RMA.&amp;nbsp; This demand is done against the dynamic method construction call stack and succeeds since everybody on the stack has at least Internet + RMA.&lt;/P&gt;
&lt;P&gt;In a similar example, the host assemblies might want to access private members of each other.&amp;nbsp; For instance if HostTypeA emits a dynamic method which accesses an internal type in HostAssemblyB:&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class=""&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class=""&gt;Construction call stack&lt;/TD&gt;
&lt;TD class=""&gt;&lt;/TD&gt;
&lt;TD class=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/TD&gt;
&lt;TD class=""&gt;JIT call stack&lt;/TD&gt;
&lt;TD class=""&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;HostTypeA.Initialize&lt;/TD&gt;
&lt;TD class=""&gt;FullTrust&lt;/TD&gt;
&lt;TD class=""&gt;&lt;/TD&gt;
&lt;TD class=""&gt;TypeA.OnAddInInvoked&lt;/TD&gt;
&lt;TD class=""&gt;Internet + RMA&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;(Assert FullTrust)&lt;/TD&gt;
&lt;TD class=""&gt;&lt;/TD&gt;
&lt;TD class=""&gt;&lt;/TD&gt;
&lt;TD class=""&gt;TypeA.RunDynamicMethod&lt;/TD&gt;
&lt;TD class=""&gt;Internet + RMA&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class=""&gt;HostTypeA.EmitDynamicMethod&lt;/TD&gt;
&lt;TD class=""&gt;FullTrust&lt;/TD&gt;
&lt;TD class=""&gt;&lt;/TD&gt;
&lt;TD class=""&gt;(DynamicMethod)&lt;/TD&gt;
&lt;TD class=""&gt;FullTrust (transparent)&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;This will also succeed.&amp;nbsp; The JIT will do a demand for RMA + the grant set of the internal type in HostAssemblyB, which becomes a demand for FullTrust.&amp;nbsp; Even though the dynamic method is being JITed and invoked on a call stack where nothing is fully trusted, the demand succeeds because it goes against the call stack when the dynamic method was constructed, which was entirely fully trusted.&amp;nbsp; The assert was necessary to prevent the demand from hitting the partially trusted AppDomain boundary.&lt;/P&gt;
&lt;H2&gt;Three Simple Rules for Partial Trust LCG&lt;/H2&gt;
&lt;P&gt;Although the rules for using LCG from partial trust can seem complicated at first, they really boil down to these three main points:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;If RMA is granted, you can emit into any assembly at your trust level or lower&lt;/LI&gt;
&lt;LI&gt;Any partial trust code can emit an anonymously hosted dynamic method&lt;/LI&gt;
&lt;LI&gt;If RMA is granted, your anonymously hosted dynamic method can also use restricted skip visibility to skip JIT time visibility checks against members at your trust level or lower&lt;/LI&gt;&lt;/OL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=794142" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/CAS/default.aspx">CAS</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Orcas/default.aspx">Orcas</category></item><item><title>RestrictedMemberAccess</title><link>http://blogs.msdn.com/shawnfa/archive/2006/09/29/777047.aspx</link><pubDate>Fri, 29 Sep 2006 19:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:777047</guid><dc:creator>shawnfa</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/shawnfa/comments/777047.aspx</comments><wfw:commentRss>http://blogs.msdn.com/shawnfa/commentrss.aspx?PostID=777047</wfw:commentRss><description>&lt;P&gt;The &lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=82243606-d16d-445c-8949-9ee8c10cda2e&amp;amp;DisplayLang=en"&gt;September CTP of Orcas&lt;/A&gt; went live last night, including lots of features that other MSDN blogs are buzzing about such as LINQ to Objects, partial C# 3.0 support, and partial VB 9.0 support. (And prompting me to create the new &lt;A href="http://blogs.msdn.com/shawnfa/archive/category/15141.aspx"&gt;Orcas category&lt;/A&gt; to replace the&amp;nbsp;defunct Whidbey category).&lt;/P&gt;
&lt;P&gt;However, my favorite feature available in the CTP is down at the bottom of the description:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Reflection in Partial Trust, enabling sand box scenarios for all applications that depend on these features&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yep, reflection is now available in partial trust!&lt;/P&gt;
&lt;P&gt;So, what exactly is this feature?&amp;nbsp; It's easier to consider how it affects the three major portions of reflection: &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Reflection.Emit 
&lt;LI&gt;Reflection 
&lt;LI&gt;DynamicMethods&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Reflection.Emit is the easiest of the group.&amp;nbsp; ReflectionPermission/ReflectionEmit is no longer demanded when you try to emit an assembly.&amp;nbsp; If you try to write the assembly to disk obviously you need FileIOPermission (and for obscure reasons ReflectionEmit to write out debug symbols), but a standard in-memory assembly can be emitted by any assembly with any permission set.&amp;nbsp; The newly emitted assembly will run with the same permissions as the assembly which emitted it.&lt;/P&gt;
&lt;P&gt;Standard reflection is also relatively straight forward.&amp;nbsp;&amp;nbsp;There is now&amp;nbsp;a new flag on ReflectionPermission, RestrictedMemberAccess, which should be granted to any assembly which needs to have access to reflection in partial trust.&amp;nbsp; When some partial trust code attempts to use reflection to access a member which it would not be able to access via standard visibility rules, the CLR will now demand the grant set of the target object plus RestrictedMemberAccess.&lt;/P&gt;
&lt;P&gt;For instance, assembly A and B are both part of the same AddIn, and are hosted in&amp;nbsp;a &lt;A href="http://blogs.msdn.com/shawnfa/archive/2006/04/19/579066.aspx"&gt;simple sandbox domain&lt;/A&gt; granting them the Internet permission set and RestrictedMemberAccess.&amp;nbsp; If&amp;nbsp;a method in assembly A tries to use reflection to invoke a private method in assembly&amp;nbsp;B, the CLR will demand:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;Target Permissions union RestrictedMemberAccess =&lt;BR&gt;B's permissions union RestrictedMemberAccess =&lt;BR&gt;Internet + RestrictedMemberAccess&lt;BR&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The call stack at this point might look like this:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;AppDomain Boundary&lt;/TD&gt;
&lt;TD&gt;Internet + RestrictedMemberAccess&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;HostAssembly&lt;/TD&gt;
&lt;TD&gt;AddInManager.LaunchAddIn&lt;/TD&gt;
&lt;TD&gt;FullTrust&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;AddIn.Run&lt;/TD&gt;
&lt;TD&gt;Internet + RestrictedMemberAccess&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;AddIn.InvokePrivateMethodOnB&lt;/TD&gt;
&lt;TD&gt;Internet + RestrictedMemberAccess&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As the demand for Internet + RestrictedMemberAccess proceeds up the call stack, it will succeed at each frame, and therefore A will be allowed to invoke a private method in B.&lt;/P&gt;
&lt;P&gt;Now, suppose A tries to invoke an internal member in an assembly that's part of the host application, say Host.EraseAllUserData().&amp;nbsp; In this case, the CLR will demand:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;Target Permissions union RestrictedMemberAccess =&lt;BR&gt;Host assembly permissions&amp;nbsp;union RestrictedMemberAccess =&lt;BR&gt;FullTrust union RestrictedMemberAccess&amp;nbsp;=&lt;BR&gt;FullTrust&lt;/BLOCKQUOTE&gt;
&lt;P&gt;By looking at the call stack above, we can see that the demand for FullTrust will fail as soon as it hits the first frame, since A is not fully trusted.&lt;/P&gt;
&lt;P&gt;The reverse scenario will succeed ... if the host assembly tries to reflect into A, the demand for Internet + RestrictedMemberAccess will again succeed at all points on the call stack, allowing the host access to both A and B.&amp;nbsp; (Notice though that if a host assembly attempts to reflect on private members of another fully trusted assembly it would have to Assert for FullTrust first, since the resulting demand would fail when it hit the AppDomain boundary).&lt;/P&gt;
&lt;P&gt;What this boils down to is that any assembly granted RestrictedMemberAccess will be able to reflect on any assembly granted either the same set of permissions it has or a subset thereof.&amp;nbsp; For compatibility reasons, reflection demands will also succeed if the call stack was granted MemberAccess.&lt;/P&gt;
&lt;P&gt;Next time, partial trust reflection and dynamic methods&amp;nbsp;... until then, have fun playing around with the CTP over the weekend! :-)&amp;nbsp;[By the way, this is even easier to do now, since the download page has included Virtual PC images with the CTP already installed].&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=777047" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/CAS/default.aspx">CAS</category><category domain="http://blogs.msdn.com/shawnfa/archive/tags/Orcas/default.aspx">Orcas</category></item></channel></rss>