blob: cb44c7cd55f20f7b6540d84329934f799bc1051a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
//-----------------------------------------------------------------------
// <copyright file="AssociateDiffieHellmanRelyingPartyResponse.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OpenId.Messages {
using System;
using System.Diagnostics.Contracts;
using System.Security.Cryptography;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.Messaging.Reflection;
using Org.Mentalis.Security.Cryptography;
/// <summary>
/// The successful Diffie-Hellman association response message.
/// </summary>
/// <remarks>
/// Association response messages are described in OpenID 2.0 section 8.2. This type covers section 8.2.3.
/// </remarks>
internal class AssociateDiffieHellmanRelyingPartyResponse : AssociateDiffieHellmanResponse {
/// <summary>
/// Initializes a new instance of the <see cref="AssociateDiffieHellmanRelyingPartyResponse"/> class.
/// </summary>
/// <param name="responseVersion">The OpenID version of the response message.</param>
/// <param name="originatingRequest">The originating request.</param>
internal AssociateDiffieHellmanRelyingPartyResponse(Version responseVersion, AssociateDiffieHellmanRequest originatingRequest)
: base(responseVersion, originatingRequest) {
}
/// <summary>
/// Creates the association at relying party side after the association response has been received.
/// </summary>
/// <param name="request">The original association request that was already sent and responded to.</param>
/// <returns>The newly created association.</returns>
/// <remarks>
/// The resulting association is <i>not</i> added to the association store and must be done by the caller.
/// </remarks>
protected Association CreateAssociationAtRelyingParty(AssociateRequest request) {
var diffieHellmanRequest = request as AssociateDiffieHellmanRequest;
ErrorUtilities.VerifyArgument(diffieHellmanRequest != null, OpenIdStrings.DiffieHellmanAssociationRequired);
HashAlgorithm hasher = DiffieHellmanUtilities.Lookup(Protocol, this.SessionType);
byte[] associationSecret = DiffieHellmanUtilities.SHAHashXorSecret(hasher, diffieHellmanRequest.Algorithm, this.DiffieHellmanServerPublic, this.EncodedMacKey);
Association association = HmacShaAssociation.Create(Protocol, this.AssociationType, this.AssociationHandle, associationSecret, TimeSpan.FromSeconds(this.ExpiresIn));
return association;
}
}
}
|