summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OpenId/OpenId/HmacShaAssociation.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2012-03-11 16:48:34 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2012-03-11 16:48:34 -0700
commit34da8f975a0515d72fda97979d0602d3c004173f (patch)
treee9738b1b79bca6d347127ab456ce0c3a295a74d2 /src/DotNetOpenAuth.OpenId/OpenId/HmacShaAssociation.cs
parent92ee03ce2e9528212ea363a0574240e6fc17bb47 (diff)
downloadDotNetOpenAuth-34da8f975a0515d72fda97979d0602d3c004173f.zip
DotNetOpenAuth-34da8f975a0515d72fda97979d0602d3c004173f.tar.gz
DotNetOpenAuth-34da8f975a0515d72fda97979d0602d3c004173f.tar.bz2
Changed the compile-time switch for DH support into a runtime check for the supporting assembling.
Fixes #87
Diffstat (limited to 'src/DotNetOpenAuth.OpenId/OpenId/HmacShaAssociation.cs')
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/HmacShaAssociation.cs28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/HmacShaAssociation.cs b/src/DotNetOpenAuth.OpenId/OpenId/HmacShaAssociation.cs
index 4a13ac6..5e3553d 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/HmacShaAssociation.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/HmacShaAssociation.cs
@@ -140,11 +140,13 @@ namespace DotNetOpenAuth.OpenId {
hashSizeInBits < securityRequirements.MinimumHashBitLength) {
continue;
}
-#if !ExcludeDiffieHellman
- sessionType = DiffieHellmanUtilities.GetNameForSize(protocol, hashSizeInBits);
-#else
- sessionType = requireMatchingDHSessionType ? null : protocol.Args.SessionType.NoEncryption;
-#endif
+
+ if (OpenIdUtilities.IsDiffieHellmanPresent) {
+ sessionType = DiffieHellmanUtilities.GetNameForSize(protocol, hashSizeInBits);
+ } else {
+ sessionType = requireMatchingDHSessionType ? null : protocol.Args.SessionType.NoEncryption;
+ }
+
if (requireMatchingDHSessionType && sessionType == null) {
continue;
}
@@ -178,14 +180,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
+ if (OpenIdUtilities.IsDiffieHellmanPresent) {
+ // 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;
+ }
}
/// <summary>