My favorites | Sign in
Logo
                
New issue | Search
for
| Advanced search | Search tips
Issue 14: Work in partial trust scenarios
  Back to list
Status:  Fixed
Owner:  andrewarnott
Closed:  Jun 2008
Type-Enhancement
Priority-Medium
Release-2.1


Sign in to add a comment
 
Reported by andrewarnott, Apr 05, 2007
The unsafe code in the Diffie Hellman implementation ported from mono 
requires full trust to run.  This prevents hosting web sites that accept 
OpenID in some shared hosting environments that require partial trust.

Can we alter the Diffie Hellman implementation to use all safe code?
Comment 1 by andrewarnott, Apr 05, 2007
One way to solve this is to use the Diffie Hellman algorithm that will be included 
in .NET 3.5.  See this MSDN Magazine article: 
http://msdn.microsoft.com/msdnmag/issues/07/04/CLRInsideOut/default.aspx
Comment 2 by andrewarnott, Jan 19, 2008
(No comment was entered for this change.)
Owner: andrewarnott
Comment 3 by andrewarnott, Jan 23, 2008
(No comment was entered for this change.)
Labels: Release-0.2
Comment 4 by andrewarnott, Jan 25, 2008
I learned today that the BigInteger class added in .NET 3.5 is internal only.  So we
can't use it.  But as stated earlier, the Diffie Hellman algorithm as a whole is
available in .NET 3.5 and can perhaps be used to entirely replace the algorithm
that's included in dotnetopenid currently.
Comment 5 by andrewarnott, Jan 30, 2008
(No comment was entered for this change.)
Labels: -Release-0.2 Milestone-Release0.2
Comment 6 by andrewarnott, Feb 04, 2008
Rats.  .NET 3.5 only includes the Elliptic-curve diffie-hellman algorithm, not the
standard DH algorithm.  So it looks like we have only a few options left for making
this library usable in partial trust environments:
* Have an option to compile with only safe code, which would remove DH algorithm and
switch consumer to "dumb" mode in the spec.  Pros: partial trust works.  Cons: dumb
mode is slower.
* Find an alternative DH algorithm that doesn't use a BigInteger class that has
unsafe code in it. Pros: partial trust works. Cons: possible licensing trouble.
* Leave it as is and require full trust to run.  Pros: it's done.  Cons: no shared
hosting environments will host the library.
Comment 7 by andrewarnott, Feb 04, 2008
Verifiable C# implementations of Diffie-Hellman appear to be hard to come by.  But
perhaps the one we have can be altered to work with another implementation of
BigInteger, since that is the class that actually has the unsafe code.  Here are some
alternative open-source implementations of BigInteger:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vjref98/html/java.math.BigInteger.asp
(BCL: java.math.BigInteger)
http://www.codeproject.com/KB/cs/biginteger.aspx
http://www.codeplex.com/biginteger
Summary: Work in partial trust scenarios
Comment 8 by andrewarnott, Feb 09, 2008
Tonight I tried my hand at rewriting the unsafe code in the BigInteger class to use
safe code.  I seem to have succeeded.  The two unit tests (small number, yes) for
this area still pass, and I was able to successfully use the ConsumerPortal sample to
login with my OpenID to both the ServerPortal sample and a live production OpenID
site.  It's looking very promising.

After more code review of my own and cleaning up my work I plan to check into the
trunk.  After which I'd be very grateful to have you guys try it out on as many
OpenID sites as you can (meaning use the ConsumerPortal with your OpenIDs from
various providers) to see if anything broke. 

Let me know what your thoughts are on this.  At the moment, I have the library
compiling without the /unsafe switch and it seems to be working, so I'm pretty
excited.  This fix could probably be merged to the 0.1 branch as well if we wanted to.
Status: Started
Comment 9 by andrewarnott, Feb 10, 2008
Fixed in trunk r118-r120.
Status: Fixed
Comment 10 by andrewarnott, Mar 06, 2008
Fixed in 0.1 branch in r190 (and a few subsequent revisions with bug fixes).
Comment 11 by andrewarnott, Jun 07, 2008
I learned that at least on GoDaddy, strong-named assemblies somehow inherit full
trust, or something akin to that.  When DotNetOpenId is strong-named, either #define
PARTIAL_TRUST must be set or AllowPartiallyTrustedCallers must be.  When it is not
strong-named neither of these is required.

Comment 12 by andrewarnott, Jun 07, 2008
From: http://support.microsoft.com/kb/839300

...use the AllowPartiallyTrustedCallers attribute of the assembly so that an assembly
that has a strong name can be accessed from a Web page...
An assembly that has a strong name can only be called by a fully trusted caller
unless the assembly uses the AllowPartiallyTrustedCallers attribute. 
Comment 13 by andrewarnott, Jun 07, 2008
The fix will be to use the AllowPartiallyTrustedCallers attribute whenever the
assembly is strong-name signed.  This is only a security concern if we use
PermissionSet.Assert, which we currently do not.  This API has security concerns
anyway, so we're not increasing our attack area by using this attribute currently.
Status: Started
Labels: -Milestone-Release0.2 Release-2.1
Comment 14 by andrewarnott, Jun 07, 2008
(No comment was entered for this change.)
Status: Fixed
Sign in to add a comment

Hosted by Google Code