diff options
Diffstat (limited to 'src/DotNetOpenAuth.OpenId')
3 files changed, 19 insertions, 3 deletions
diff --git a/src/DotNetOpenAuth.OpenId/DotNetOpenAuth.OpenId.csproj b/src/DotNetOpenAuth.OpenId/DotNetOpenAuth.OpenId.csproj index a215cb9..6f032c6 100644 --- a/src/DotNetOpenAuth.OpenId/DotNetOpenAuth.OpenId.csproj +++ b/src/DotNetOpenAuth.OpenId/DotNetOpenAuth.OpenId.csproj @@ -119,11 +119,11 @@ <Compile Include="OpenId\ProviderEndpointDescription.cs" /> <Compile Include="OpenId\Realm.cs" /> <Compile Include="OpenId\RelyingPartyDescription.cs" /> - <Compile Include="OpenId\DiffieHellmanUtilities.cs" /> + <Compile Include="OpenId\DiffieHellmanUtilities.cs" Condition=" '$(ExcludeDiffieHellman)' != 'true' " /> <Compile Include="OpenId\HmacShaAssociation.cs" /> <Compile Include="OpenId\Messages\AssociateUnencryptedRequest.cs" /> <Compile Include="OpenId\Messages\AssociateDiffieHellmanRequest.cs" /> - <Compile Include="OpenId\Messages\AssociateDiffieHellmanResponse.cs" /> + <Compile Include="OpenId\Messages\AssociateDiffieHellmanResponse.cs" Condition=" '$(ExcludeDiffieHellman)' != 'true' " /> <Compile Include="OpenId\Messages\AssociateRequest.cs" /> <Compile Include="OpenId\Messages\AssociateSuccessfulResponse.cs" /> <Compile Include="OpenId\Messages\AssociateUnencryptedResponse.cs" /> @@ -176,7 +176,7 @@ <Project>{60426312-6AE5-4835-8667-37EDEA670222}</Project> <Name>DotNetOpenAuth.Messaging</Name> </ProjectReference> - <ProjectReference Include="..\Org.Mentalis.Security.Cryptography\Org.Mentalis.Security.Cryptography.csproj"> + <ProjectReference Include="..\Org.Mentalis.Security.Cryptography\Org.Mentalis.Security.Cryptography.csproj" Condition=" '$(ExcludeDiffieHellman)' != 'true' " > <Project>{26DC877F-5987-48DD-9DDB-E62F2DE0E150}</Project> <Name>Org.Mentalis.Security.Cryptography</Name> </ProjectReference> diff --git a/src/DotNetOpenAuth.OpenId/OpenId/HmacShaAssociation.cs b/src/DotNetOpenAuth.OpenId/OpenId/HmacShaAssociation.cs index d723756..6a681a0 100644 --- a/src/DotNetOpenAuth.OpenId/OpenId/HmacShaAssociation.cs +++ b/src/DotNetOpenAuth.OpenId/OpenId/HmacShaAssociation.cs @@ -161,7 +161,11 @@ namespace DotNetOpenAuth.OpenId { hashSizeInBits < securityRequirements.MinimumHashBitLength) { continue; } +#if !ExcludeDiffieHellman sessionType = DiffieHellmanUtilities.GetNameForSize(protocol, hashSizeInBits); +#else + sessionType = requireMatchingDHSessionType ? null : protocol.Args.SessionType.NoEncryption; +#endif if (requireMatchingDHSessionType && sessionType == null) { continue; } @@ -195,10 +199,14 @@ namespace DotNetOpenAuth.OpenId { return true; } +#if !ExcludeDiffieHellman // When there _is_ a DH session, it must match in hash length with the association type. int associationSecretLengthInBytes = GetSecretLength(protocol, associationType); int sessionHashLengthInBytes = DiffieHellmanUtilities.Lookup(protocol, sessionType).HashSize / 8; return associationSecretLengthInBytes == sessionHashLengthInBytes; +#else + return false; +#endif } /// <summary> diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Messages/AssociateDiffieHellmanRequest.cs b/src/DotNetOpenAuth.OpenId/OpenId/Messages/AssociateDiffieHellmanRequest.cs index 5accf26..b4f809f 100644 --- a/src/DotNetOpenAuth.OpenId/OpenId/Messages/AssociateDiffieHellmanRequest.cs +++ b/src/DotNetOpenAuth.OpenId/OpenId/Messages/AssociateDiffieHellmanRequest.cs @@ -12,7 +12,9 @@ namespace DotNetOpenAuth.OpenId.Messages { using System.Text; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.Messaging.Reflection; +#if !ExcludeDiffieHellman using Org.Mentalis.Security.Cryptography; +#endif /// <summary> /// An OpenID direct request from Relying Party to Provider to initiate an association that uses Diffie-Hellman encryption. @@ -76,6 +78,7 @@ namespace DotNetOpenAuth.OpenId.Messages { [MessagePart("openid.dh_consumer_public", IsRequired = true, AllowEmpty = false)] internal byte[] DiffieHellmanConsumerPublic { get; set; } +#if !ExcludeDiffieHellman /// <summary> /// Gets the Diffie-Hellman algorithm. /// </summary> @@ -83,11 +86,13 @@ namespace DotNetOpenAuth.OpenId.Messages { /// This property is initialized with a call to <see cref="InitializeRequest"/>. /// </remarks> internal DiffieHellman Algorithm { get; private set; } +#endif /// <summary> /// Called by the Relying Party to initialize the Diffie-Hellman algorithm and consumer public key properties. /// </summary> internal void InitializeRequest() { +#if !ExcludeDiffieHellman if (this.DiffieHellmanModulus == null || this.DiffieHellmanGen == null) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, OpenIdStrings.DiffieHellmanRequiredPropertiesNotSet, string.Join(", ", new string[] { "DiffieHellmanModulus", "DiffieHellmanGen" }))); } @@ -95,6 +100,9 @@ namespace DotNetOpenAuth.OpenId.Messages { this.Algorithm = new DiffieHellmanManaged(this.DiffieHellmanModulus ?? DefaultMod, this.DiffieHellmanGen ?? DefaultGen, DefaultX); byte[] consumerPublicKeyExchange = this.Algorithm.CreateKeyExchange(); this.DiffieHellmanConsumerPublic = DiffieHellmanUtilities.EnsurePositive(consumerPublicKeyExchange); +#else + throw new NotSupportedException(); +#endif } } } |