168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
size_t i;
uint8_t *clientKey, *serverKey, *clientSignature;
intmax_t iterCount;
OFHash *hash;
OFDataArray *ret, *authMessage, *tmpArray, *salt, *saltedPassword;
OFString *tmpString, *sNonce;
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
hash = [[[hashType alloc] init] autorelease];
ret = [OFDataArray dataArrayWithItemSize: 1];
authMessage = [OFDataArray dataArrayWithItemSize: 1];
OFString *chal = [OFString stringWithCString: [challenge cArray]
length: [challenge count] *
|
>
>
>
|
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
size_t i;
uint8_t *clientKey, *serverKey, *clientSignature;
intmax_t iterCount;
OFHash *hash;
OFDataArray *ret, *authMessage, *tmpArray, *salt, *saltedPassword;
OFString *tmpString, *sNonce;
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
enum {
GOT_SNONCE, GOT_SALT, GOT_ITERCOUNT
} got = 0;
hash = [[[hashType alloc] init] autorelease];
ret = [OFDataArray dataArrayWithItemSize: 1];
authMessage = [OFDataArray dataArrayWithItemSize: 1];
OFString *chal = [OFString stringWithCString: [challenge cArray]
length: [challenge count] *
|
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
if (![entry hasPrefix: cNonce])
@throw [XMPPAuthFailedException
newWithClass: isa
connection: nil
reason: @"Received wrong nonce"];
sNonce = entry;
} else if ([comp hasPrefix: @"s="])
salt = [OFDataArray
dataArrayWithBase64EncodedString: entry];
else if ([comp hasPrefix: @"i="])
iterCount = [entry decimalValue];
}
// Add c=<base64(GS2Header+channelBindingData)>
// XXX: No channel binding for now
tmpArray = [OFDataArray dataArrayWithItemSize: 1];
[tmpArray addNItems: [GS2Header cStringLength]
fromCArray: [GS2Header cString]];
tmpString = [tmpArray stringByBase64Encoding];
[ret addNItems: 2
|
>
|
>
|
>
|
|
>
>
>
>
|
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
if (![entry hasPrefix: cNonce])
@throw [XMPPAuthFailedException
newWithClass: isa
connection: nil
reason: @"Received wrong nonce"];
sNonce = entry;
got |= GOT_SNONCE;
} else if ([comp hasPrefix: @"s="]) {
salt = [OFDataArray
dataArrayWithBase64EncodedString: entry];
got |= GOT_SALT;
} else if ([comp hasPrefix: @"i="]) {
iterCount = [entry decimalValue];
got |= GOT_ITERCOUNT;
}
}
if (got != (GOT_SNONCE | GOT_SALT | GOT_ITERCOUNT))
@throw [OFInvalidServerReplyException newWithClass: isa];
// Add c=<base64(GS2Header+channelBindingData)>
// XXX: No channel binding for now
tmpArray = [OFDataArray dataArrayWithItemSize: 1];
[tmpArray addNItems: [GS2Header cStringLength]
fromCArray: [GS2Header cString]];
tmpString = [tmpArray stringByBase64Encoding];
[ret addNItems: 2
|