summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOAuth/ChannelElements/HmacSha1SigningBindingElement.cs4
-rw-r--r--src/DotNetOAuth/ChannelElements/RsaSha1SigningBindingElement.cs11
2 files changed, 8 insertions, 7 deletions
diff --git a/src/DotNetOAuth/ChannelElements/HmacSha1SigningBindingElement.cs b/src/DotNetOAuth/ChannelElements/HmacSha1SigningBindingElement.cs
index c0bd030..131ef79 100644
--- a/src/DotNetOAuth/ChannelElements/HmacSha1SigningBindingElement.cs
+++ b/src/DotNetOAuth/ChannelElements/HmacSha1SigningBindingElement.cs
@@ -30,8 +30,8 @@ namespace DotNetOAuth.ChannelElements {
/// </remarks>
protected override string GetSignature(ITamperResistantOAuthMessage message) {
string key = Uri.EscapeDataString(message.ConsumerSecret) + "&" + Uri.EscapeDataString(message.TokenSecret);
- HashAlgorithm hasher = new HMACSHA1(Encoding.UTF8.GetBytes(key));
- byte[] digest = hasher.ComputeHash(Encoding.UTF8.GetBytes(ConstructSignatureBaseString(message)));
+ HashAlgorithm hasher = new HMACSHA1(Encoding.ASCII.GetBytes(key));
+ byte[] digest = hasher.ComputeHash(Encoding.ASCII.GetBytes(ConstructSignatureBaseString(message)));
return Uri.EscapeDataString(Convert.ToBase64String(digest));
}
}
diff --git a/src/DotNetOAuth/ChannelElements/RsaSha1SigningBindingElement.cs b/src/DotNetOAuth/ChannelElements/RsaSha1SigningBindingElement.cs
index 76bcd50..edd5109 100644
--- a/src/DotNetOAuth/ChannelElements/RsaSha1SigningBindingElement.cs
+++ b/src/DotNetOAuth/ChannelElements/RsaSha1SigningBindingElement.cs
@@ -6,11 +6,8 @@
namespace DotNetOAuth.ChannelElements {
using System;
- using System.Collections.Generic;
- using System.Linq;
+ using System.Security.Cryptography;
using System.Text;
- using DotNetOAuth.Messaging;
- using DotNetOAuth.Messaging.Bindings;
/// <summary>
/// A binding element that signs outgoing messages and verifies the signature on incoming messages.
@@ -32,7 +29,11 @@ namespace DotNetOAuth.ChannelElements {
/// This method signs the message per OAuth 1.0 section 9.3.
/// </remarks>
protected override string GetSignature(ITamperResistantOAuthMessage message) {
- throw new NotImplementedException();
+ AsymmetricAlgorithm provider = new RSACryptoServiceProvider();
+ AsymmetricSignatureFormatter hasher = new RSAPKCS1SignatureFormatter(provider);
+ hasher.SetHashAlgorithm("SHA1");
+ byte[] digest = hasher.CreateSignature(Encoding.ASCII.GetBytes(ConstructSignatureBaseString(message)));
+ return Uri.EscapeDataString(Convert.ToBase64String(digest));
}
}
}