82 CleanupStack::PopAndDestroy(method); |
82 CleanupStack::PopAndDestroy(method); |
83 |
83 |
84 return pNormalizedString; |
84 return pNormalizedString; |
85 } |
85 } |
86 |
86 |
87 HBufC8* CWSOviUtils::DigestAuthStringL(const TDesC8& aNonce, const TDesC8& aTimestamp, const TDesC8& aUser, const TDesC8& aPassword) |
87 HBufC8* CWSOviUtils::GenerateValidatorL(const TDesC8& aUser, const TDesC8& aPassword) |
88 { |
88 { |
89 _LIT8(KFormatUser, "/accounts/%S/"); |
89 _LIT8(KFormatUser, "/accounts/%S/"); |
90 HBufC8* validatorString = HBufC8::NewLC(KFormatUser().Length()+aUser.Length()); |
90 HBufC8* validatorString = HBufC8::NewLC(KFormatUser().Length()+aUser.Length()); |
91 TPtr8 validatorPtr = validatorString->Des(); |
91 TPtr8 validatorPtr = validatorString->Des(); |
92 validatorPtr.Format(KFormatUser,&aUser); |
92 validatorPtr.Format(KFormatUser,&aUser); |
93 CSHA1* sha1 = CSHA1::NewL(); |
93 CSHA1* sha1 = CSHA1::NewL(); |
94 sha1->Update(*validatorString); |
94 sha1->Update(*validatorString); |
95 TPtrC8 validator = sha1->Final(aPassword); |
95 TPtrC8 validator = sha1->Final(aPassword); |
96 CleanupStack::PopAndDestroy(validatorString); |
96 CleanupStack::PopAndDestroy(validatorString); |
97 CleanupStack::PushL(sha1); |
97 CleanupStack::PushL(sha1); |
98 HBufC8* base64validator = SenCryptoUtils::EncodeBase64L(validator); |
98 HBufC8* base64validator = SenCryptoUtils::EncodeBase64L(validator); |
99 sha1->Reset(); |
|
100 sha1->Update(aNonce); |
|
101 sha1->Update(aTimestamp); |
|
102 TPtrC8 digest = sha1->Final(*base64validator); |
|
103 delete base64validator; |
|
104 HBufC8* digestBase64 = SenCryptoUtils::EncodeBase64L(digest); |
|
105 CleanupStack::PopAndDestroy(sha1); |
99 CleanupStack::PopAndDestroy(sha1); |
106 return digestBase64; |
100 return base64validator; |
|
101 } |
|
102 |
|
103 HBufC8* CWSOviUtils::DigestAuthStringL(const TDesC8& aNonce, const TDesC8& aTimestamp, const TDesC8& aUser, const TDesC8& aPassword, const TDesC8& aValidator ) |
|
104 { |
|
105 if ( aValidator == KNullDesC8 ) |
|
106 { |
|
107 CSHA1* sha1 = CSHA1::NewL(); |
|
108 CleanupStack::PushL(sha1); |
|
109 HBufC8* base64validator = GenerateValidatorL(aUser, aPassword); |
|
110 //sha1->Reset(); |
|
111 sha1->Update(aNonce); |
|
112 sha1->Update(aTimestamp); |
|
113 TPtrC8 digest = sha1->Final(*base64validator); |
|
114 delete base64validator; |
|
115 HBufC8* digestBase64 = SenCryptoUtils::EncodeBase64L(digest); |
|
116 CleanupStack::PopAndDestroy(sha1); |
|
117 return digestBase64; |
|
118 } |
|
119 else |
|
120 { |
|
121 CSHA1* sha1 = CSHA1::NewL(); |
|
122 CleanupStack::PushL(sha1); |
|
123 sha1->Update(aNonce); |
|
124 sha1->Update(aTimestamp); |
|
125 TPtrC8 digest = sha1->Final(aValidator); |
|
126 HBufC8* digestBase64 = SenCryptoUtils::EncodeBase64L(digest); |
|
127 CleanupStack::PopAndDestroy(sha1); |
|
128 return digestBase64; |
|
129 } |
107 } |
130 } |
108 |
131 |
109 |
132 |
110 TInt CWSOviUtils::CountCharsToEncode(const TDesC8& aString) |
133 TInt CWSOviUtils::CountCharsToEncode(const TDesC8& aString) |
111 { |
134 { |