|
1 /* |
|
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Name : CSIPSecChallengeMD5.h |
|
16 * Part of : SIPSec/DigestPlugin |
|
17 * Version : SIP/6.0 |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 /** |
|
25 @internalComponent |
|
26 */ |
|
27 |
|
28 #ifndef __CSIPSEC_CHALLENGEMD5_H__ |
|
29 #define __CSIPSEC_CHALLENGEMD5_H__ |
|
30 |
|
31 // INCLUDES |
|
32 #include "CSIPSecChallenge.h" |
|
33 #include "MSIPSecAlgorithm.h" |
|
34 |
|
35 // CONSTANTS |
|
36 |
|
37 // CLASS DECLARATION |
|
38 |
|
39 /** |
|
40 * @brief Class representing MD5 challenge received in 401/407 response |
|
41 * |
|
42 * @class CSIPSecChallengeMD5 CSIPSecChallengeMD5.h "CSIPSecChallengeMD5.h" |
|
43 * |
|
44 * This class provides to means to process MD5 challenge, which includes |
|
45 * calculating digest response based on challenge values and data in outgoing |
|
46 * SIP request. |
|
47 * Class also provides function to calculate secret data, which is hashed value |
|
48 * of concatenation of username, realm and password. |
|
49 */ |
|
50 class CSIPSecChallengeMD5 : public CSIPSecChallenge, |
|
51 public MSIPSecAlgorithm |
|
52 { |
|
53 public: // Constructors and destructor |
|
54 |
|
55 /** |
|
56 * Constructs the object, and pushes it to cleanupstack. |
|
57 * @param aType the type of challenge |
|
58 * @param aAuthenticateHeader SIP authenticate header |
|
59 * @param aQop qop of the challenge |
|
60 * @return Return the CSIPSecChallengeMD5 object |
|
61 */ |
|
62 static CSIPSecChallengeMD5* |
|
63 NewLC( CSIPSecDigest::TChallengeType aType, |
|
64 CSIPAuthenticateHeaderBase& aAuthenticateHeader, |
|
65 CSIPSecRequestData::TQop aQop ); |
|
66 |
|
67 /** |
|
68 * Destructor |
|
69 */ |
|
70 ~CSIPSecChallengeMD5(); |
|
71 |
|
72 public: // From CSIPSecChallenge |
|
73 |
|
74 inline MSIPSecAlgorithm& Algorithm() |
|
75 { |
|
76 return *this; |
|
77 } |
|
78 |
|
79 void VerifyTypeL( CSIPSecUserRecord::TType aType ) const; |
|
80 |
|
81 CSIPSecUserRecord* CreateUserRecordL( const TDesC8& aRealm, |
|
82 const MSIPSecUser& aUser, |
|
83 TRegistrationId aRegistrationId, |
|
84 TTransactionId aTransactionId, |
|
85 TUint aResponseCode ) const; |
|
86 |
|
87 public: // From MSIPSecAlgorithm |
|
88 |
|
89 RStringF AlgorithmName() const; |
|
90 |
|
91 TBool ProcessResponseL( TSIPSecDigestCtxSetup& aContext, |
|
92 TBool& aAskCredentials ) const; |
|
93 |
|
94 void ProcessRequestL( TSIPSecDigestCtxProcess& aContext ) const; |
|
95 |
|
96 void GenerateCNonceL( TSIPSecDigestCtxSetup& aContext ) const; |
|
97 |
|
98 public: // New functions |
|
99 |
|
100 /** |
|
101 * The name of the supported algorithm |
|
102 * @return The name of the supported algorithm |
|
103 */ |
|
104 static RStringF SupportedAlgorithm(); |
|
105 |
|
106 protected: // New functions, for internal use |
|
107 |
|
108 /* |
|
109 * Constructor |
|
110 * @param aType the type of challenge |
|
111 * @param aQop qop of the challenge |
|
112 */ |
|
113 CSIPSecChallengeMD5( CSIPSecDigest::TChallengeType aType, |
|
114 CSIPSecRequestData::TQop aQop ); |
|
115 |
|
116 /** |
|
117 * Calculates and returns "request-digest". |
|
118 * @param aContext Digest context |
|
119 * @return "request-digest" |
|
120 */ |
|
121 HBufC8* RequestDigestL( TSIPSecDigestCtxProcess& aContext ) const; |
|
122 |
|
123 /** |
|
124 * Calculates secret data (A1). |
|
125 * @param aContext Digest context |
|
126 */ |
|
127 void CalculateSecretDataA1L( TSIPSecDigestCtxSetup& aContext ) const; |
|
128 |
|
129 /** |
|
130 * Calculates request data (A2). |
|
131 * @param aContext Digest context |
|
132 */ |
|
133 HBufC8* CalculateA2L( TSIPSecDigestCtxProcess& aContext ) const; |
|
134 |
|
135 /* |
|
136 * Converts the MD5 hash descriptor into an ASCII representation of the |
|
137 * hexadecimal values. |
|
138 * @param aDigest Message digest |
|
139 * @param aData Data to hash |
|
140 * @return Buffer of characters representing the hexadecimal values |
|
141 * ('0'..'9','a'..'f'). Ownership is transferred. |
|
142 */ |
|
143 HBufC8* HashL( CMD5& aDigest, TPtrC8 aData ) const; |
|
144 }; |
|
145 |
|
146 #endif //end of __CSIPSEC_CHALLENGEMD5_H__ |
|
147 |
|
148 // End of File |