ObjXMPP  Check-in [6b83d2b4d4]

Overview
Comment:Rename XMPPAuthenticator functions
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 6b83d2b4d49876ecbf3b22e1bcb03e9be68f5ca7ba102efabf635954ab966ad3
User & Date: florob@babelmonkeys.de on 2011-02-24 21:44:51
Other Links: manifest | tags
Context
2011-02-25
22:52
A little cleanup work. Still needs a configure script. check-in: c8b860a877 user: js tags: trunk
2011-02-24
21:44
Rename XMPPAuthenticator functions check-in: 6b83d2b4d4 user: florob@babelmonkeys.de tags: trunk
18:51
Escape SCRAM usernames (authzid and authcid) check-in: a59df3b671 user: florob@babelmonkeys.de tags: trunk
Changes

Modified src/XMPPAuthenticator.h from [dd2be7ab8f] to [d4a2643832].

61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
- initWithAuthzid: (OFString*)authzid
	  authcid: (OFString*)authcid
	 password: (OFString*)password;

/**
 * \return A OFDataAray containing the initial authentication message
 */
- (OFDataArray*)getClientFirstMessage;

/**
 * \param challenge The challenge to generate a response for
 * \return The response to the given challenge
 */
- (OFDataArray*)getResponseWithChallenge: (OFDataArray*)challenge;

/**
 * Checks whether the servers final message was valid
 *
 * \param  message The servers final message
 */
- (void)parseServerFinalMessage: (OFDataArray*)message;
@end







|





|








61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
- initWithAuthzid: (OFString*)authzid
	  authcid: (OFString*)authcid
	 password: (OFString*)password;

/**
 * \return A OFDataAray containing the initial authentication message
 */
- (OFDataArray*)clientFirstMessage;

/**
 * \param challenge The challenge to generate a response for
 * \return The response to the given challenge
 */
- (OFDataArray*)calculateResponseWithChallenge: (OFDataArray*)challenge;

/**
 * Checks whether the servers final message was valid
 *
 * \param  message The servers final message
 */
- (void)parseServerFinalMessage: (OFDataArray*)message;
@end

Modified src/XMPPAuthenticator.m from [ce929b9acc] to [6b8d4dd60e].

53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
	[authzid release];
	[authcid release];
	[password release];

	[super dealloc];
}

- (OFDataArray*)getClientFirstMessage
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- (OFDataArray*)getResponseWithChallenge: (OFDataArray*)challenge
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- (void)parseServerFinalMessage: (OFDataArray*)message
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}
@end







|





|











53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
	[authzid release];
	[authcid release];
	[password release];

	[super dealloc];
}

- (OFDataArray*)clientFirstMessage
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- (OFDataArray*)calculateResponseWithChallenge: (OFDataArray*)challenge
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- (void)parseServerFinalMessage: (OFDataArray*)message
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}
@end

Modified src/XMPPConnection.m from [b8bdaffc4b] to [134b7975a7].

231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
	OFXMLElement *authTag;

	authTag = [OFXMLElement elementWithName: @"auth"
				      namespace: NS_SASL];
	[authTag addAttributeWithName: @"mechanism"
			  stringValue: name];
	[authTag addChild: [OFXMLElement elementWithCharacters:
	    [[authModule getClientFirstMessage] stringByBase64Encoding]]];

	[self sendStanza: authTag];
}

- (void)_sendResourceBind
{
	XMPPIQ *iq = [XMPPIQ IQWithType: @"set"







|







231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
	OFXMLElement *authTag;

	authTag = [OFXMLElement elementWithName: @"auth"
				      namespace: NS_SASL];
	[authTag addAttributeWithName: @"mechanism"
			  stringValue: name];
	[authTag addChild: [OFXMLElement elementWithCharacters:
	    [[authModule clientFirstMessage] stringByBase64Encoding]]];

	[self sendStanza: authTag];
}

- (void)_sendResourceBind
{
	XMPPIQ *iq = [XMPPIQ IQWithType: @"set"
310
311
312
313
314
315
316

317
318
319
320
321
322
323
324
	if ([elem.namespace isEqual: NS_SASL]) {
		if ([elem.name isEqual: @"challenge"]) {
			OFXMLElement *responseTag;
			OFDataArray *challenge =
			    [OFDataArray dataArrayWithBase64EncodedString:
				[elem.children.firstObject stringValue]];
			OFDataArray *response =

			    [authModule getResponseWithChallenge: challenge];

			responseTag = [OFXMLElement elementWithName: @"response"
							  namespace: NS_SASL];
			[responseTag
			    addChild: [OFXMLElement elementWithCharacters:
				[response stringByBase64Encoding]]];








>
|







310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
	if ([elem.namespace isEqual: NS_SASL]) {
		if ([elem.name isEqual: @"challenge"]) {
			OFXMLElement *responseTag;
			OFDataArray *challenge =
			    [OFDataArray dataArrayWithBase64EncodedString:
				[elem.children.firstObject stringValue]];
			OFDataArray *response =
			    [authModule
			        calculateResponseWithChallenge: challenge];

			responseTag = [OFXMLElement elementWithName: @"response"
							  namespace: NS_SASL];
			[responseTag
			    addChild: [OFXMLElement elementWithCharacters:
				[response stringByBase64Encoding]]];

Modified src/XMPPPLAINAuth.m from [14bbbb67be] to [c67e112e64].

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
	      password: (OFString*)password
{
	return [[[self alloc] initWithAuthzid: authzid
				     authcid: authcid
				    password: password] autorelease];
}

- (OFDataArray*)getClientFirstMessage
{
	OFDataArray *message = [OFDataArray dataArrayWithItemSize: 1];
	/* authzid */
	if (authzid)
		[message addItem: authzid];
	/* separator */
	[message addItem: ""];
	/* authcid */
	[message addNItems: [authcid cStringLength]
		fromCArray: [authcid cString]];
	/* separator */
	[message addItem: ""];
	/* passwd */
	[message addNItems: [password cStringLength]
		fromCArray: [password cString]];

	return message;
}

- (OFDataArray*)getResponseWithChallenge: (OFDataArray*)challenge
{
	@throw [XMPPAuthFailedException
	    newWithClass: isa
	      connection: nil
		  reason: @"Received a challenge during PLAIN auth"];
}

- (void)parseServerFinalMessage: (OFDataArray*)message
{
	return;
}
@end







|



















|












36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
	      password: (OFString*)password
{
	return [[[self alloc] initWithAuthzid: authzid
				     authcid: authcid
				    password: password] autorelease];
}

- (OFDataArray*)clientFirstMessage
{
	OFDataArray *message = [OFDataArray dataArrayWithItemSize: 1];
	/* authzid */
	if (authzid)
		[message addItem: authzid];
	/* separator */
	[message addItem: ""];
	/* authcid */
	[message addNItems: [authcid cStringLength]
		fromCArray: [authcid cString]];
	/* separator */
	[message addItem: ""];
	/* passwd */
	[message addNItems: [password cStringLength]
		fromCArray: [password cString]];

	return message;
}

- (OFDataArray*)calculateResponseWithChallenge: (OFDataArray*)challenge
{
	@throw [XMPPAuthFailedException
	    newWithClass: isa
	      connection: nil
		  reason: @"Received a challenge during PLAIN auth"];
}

- (void)parseServerFinalMessage: (OFDataArray*)message
{
	return;
}
@end

Modified src/XMPPSCRAMAuth.m from [709f3138f4] to [8be49d66e3].

253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
		return [ret autorelease];
	} @finally {
		[pool release];
		[self freeMemory: result];
	}
}

- (OFDataArray*)getClientFirstMessage
{
	OFDataArray *ret = [OFDataArray dataArrayWithItemSize: 1];
	[GS2Header release];
	if (authzid)
		GS2Header = [[OFString alloc]
		    initWithFormat: @"n,a=%@,", authzid];
	else







|







253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
		return [ret autorelease];
	} @finally {
		[pool release];
		[self freeMemory: result];
	}
}

- (OFDataArray*)clientFirstMessage
{
	OFDataArray *ret = [OFDataArray dataArrayWithItemSize: 1];
	[GS2Header release];
	if (authzid)
		GS2Header = [[OFString alloc]
		    initWithFormat: @"n,a=%@,", authzid];
	else
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292

	[ret addNItems: [clientFirstMessageBare cStringLength]
	    fromCArray: [clientFirstMessageBare cString]];

	return ret;
}

- (OFDataArray*)getResponseWithChallenge: (OFDataArray*)challenge
{
	size_t i;
	uint8_t *clientKey, *serverKey, *clientSignature;
	intmax_t iterCount;
	OFHash *hash;
	OFDataArray *ret, *authMessage, *tmpArray, *salt, *saltedPassword;
	OFString *tmpString, *sNonce;







|







278
279
280
281
282
283
284
285
286
287
288
289
290
291
292

	[ret addNItems: [clientFirstMessageBare cStringLength]
	    fromCArray: [clientFirstMessageBare cString]];

	return ret;
}

- (OFDataArray*)calculateResponseWithChallenge: (OFDataArray*)challenge
{
	size_t i;
	uint8_t *clientKey, *serverKey, *clientSignature;
	intmax_t iterCount;
	OFHash *hash;
	OFDataArray *ret, *authMessage, *tmpArray, *salt, *saltedPassword;
	OFString *tmpString, *sNonce;