diff --git a/src/XMPPConnection.m b/src/XMPPConnection.m index 4cc2fda..a3b3628 100644 --- a/src/XMPPConnection.m +++ b/src/XMPPConnection.m @@ -59,7 +59,7 @@ @end @implementation XMPPConnection -@synthesize username, password, server, resource, JID, port, useTLS, delegate; +@synthesize JID, port, useTLS, delegate; - init { @@ -110,6 +110,11 @@ [old release]; } +- (OFString*)username +{ + return [[username copy] autorelease]; +} + - (void)setResource: (OFString*)resource_ { OFString *old = resource; @@ -133,6 +138,11 @@ [old release]; } +- (OFString*)resource +{ + return [[resource copy] autorelease]; +} + - (void)setServer: (OFString*)server_ { OFString *old = server; @@ -156,6 +166,11 @@ [old release]; } +- (OFString*)server +{ + return [[server copy] autorelease]; +} + - (void)setPassword: (OFString*)password_ { OFString *old = password; @@ -178,6 +193,11 @@ [old release]; } +- (OFString*)password +{ + return [[password copy] autorelease]; +} + - (void)connect { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; diff --git a/src/XMPPSCRAMAuth.m b/src/XMPPSCRAMAuth.m index fbc9f1e..a29b95d 100644 --- a/src/XMPPSCRAMAuth.m +++ b/src/XMPPSCRAMAuth.m @@ -172,6 +172,9 @@ extern uint32_t arc4random_uniform(uint32_t); 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]; @@ -193,13 +196,20 @@ extern uint32_t arc4random_uniform(uint32_t); reason: @"Received wrong nonce"]; sNonce = entry; - } else if ([comp hasPrefix: @"s="]) + got |= GOT_SNONCE; + } else if ([comp hasPrefix: @"s="]) { salt = [OFDataArray dataArrayWithBase64EncodedString: entry]; - else if ([comp hasPrefix: @"i="]) + 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= // XXX: No channel binding for now tmpArray = [OFDataArray dataArrayWithItemSize: 1];