//----------------------------------------------------------------------- // // Copyright (c) Andrew Arnott. All rights reserved. // //----------------------------------------------------------------------- #if CLR4 namespace DotNetOpenAuth.OAuth { using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Tasks; using DotNetOpenAuth.Messaging; /// /// A delegating HTTP handler that signs outgoing HTTP requests /// with an RSA-SHA1 signature. /// public class OAuth1RsaSha1HttpMessageHandler : OAuth1HttpMessageHandlerBase { /// /// Gets or sets the certificate used to sign outgoing messages. Used only by Consumers. /// public X509Certificate2 SigningCertificate { get; set; } /// /// Gets the signature method to include in the oauth_signature_method parameter. /// /// /// The signature method. /// protected override string SignatureMethod { get { return "RSA-SHA1"; } } /// /// Calculates the signature for the specified buffer. /// /// The payload to calculate the signature for. /// /// The signature. /// protected override byte[] Sign(byte[] signedPayload) { ErrorUtilities.VerifyOperation(this.SigningCertificate != null, Strings.RequiredPropertyNotYetPreset); var provider = (RSACryptoServiceProvider)this.SigningCertificate.PrivateKey; byte[] binarySignature = provider.SignData(signedPayload, "SHA1"); return binarySignature; } } } #endif