Adjust to ObjFW changes & small fixes
This commit is contained in:
parent
5fa8b0b9b3
commit
cb5f6bfe40
12 changed files with 98 additions and 91 deletions
|
@ -65,11 +65,11 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
password: (nullable OFString *)password OF_DESIGNATED_INITIALIZER;
|
password: (nullable OFString *)password OF_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Returns an OFDataArray containing the initial authentication message.
|
* \brief Returns OFData containing the initial authentication message.
|
||||||
*
|
*
|
||||||
* \return An OFDataAray containing the initial authentication message
|
* \return An OFDataAray containing the initial authentication message
|
||||||
*/
|
*/
|
||||||
- (OFDataArray *)initialMessage;
|
- (nullable OFData *)initialMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Continue authentication with the specified data.
|
* \brief Continue authentication with the specified data.
|
||||||
|
@ -77,7 +77,7 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* \param data The continuation data send by the server
|
* \param data The continuation data send by the server
|
||||||
* \return The appropriate response if the data was a challenge, nil otherwise
|
* \return The appropriate response if the data was a challenge, nil otherwise
|
||||||
*/
|
*/
|
||||||
- (nullable OFDataArray *)continueWithData: (OFDataArray *)data;
|
- (nullable OFData *)continueWithData: (OFData *)data;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -65,12 +65,12 @@
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OFDataArray *)initialMessage
|
- (OFData *)initialMessage
|
||||||
{
|
{
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OFDataArray *)continueWithData: (OFDataArray *)challenge
|
- (OFData *)continueWithData: (OFData *)challenge
|
||||||
{
|
{
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
|
@ -895,10 +895,9 @@ OF_ASSUME_NONNULL_END
|
||||||
{
|
{
|
||||||
if ([[element name] isEqual: @"challenge"]) {
|
if ([[element name] isEqual: @"challenge"]) {
|
||||||
OFXMLElement *responseTag;
|
OFXMLElement *responseTag;
|
||||||
OFDataArray *challenge = [OFDataArray
|
OFData *challenge =
|
||||||
dataArrayWithBase64EncodedString: [element stringValue]];
|
[OFData dataWithBase64EncodedString: [element stringValue]];
|
||||||
OFDataArray *response = [_authModule
|
OFData *response = [_authModule continueWithData: challenge];
|
||||||
continueWithData: challenge];
|
|
||||||
|
|
||||||
responseTag = [OFXMLElement elementWithName: @"response"
|
responseTag = [OFXMLElement elementWithName: @"response"
|
||||||
namespace: XMPP_NS_SASL];
|
namespace: XMPP_NS_SASL];
|
||||||
|
@ -915,8 +914,8 @@ OF_ASSUME_NONNULL_END
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([[element name] isEqual: @"success"]) {
|
if ([[element name] isEqual: @"success"]) {
|
||||||
[_authModule continueWithData: [OFDataArray
|
[_authModule continueWithData: [OFData
|
||||||
dataArrayWithBase64EncodedString: [element stringValue]]];
|
dataWithBase64EncodedString: [element stringValue]]];
|
||||||
|
|
||||||
[_delegates broadcastSelector: @selector(
|
[_delegates broadcastSelector: @selector(
|
||||||
connectionWasAuthenticated:)
|
connectionWasAuthenticated:)
|
||||||
|
@ -1078,7 +1077,7 @@ OF_ASSUME_NONNULL_END
|
||||||
- (void)XMPP_sendAuth: (OFString *)authName
|
- (void)XMPP_sendAuth: (OFString *)authName
|
||||||
{
|
{
|
||||||
OFXMLElement *authTag;
|
OFXMLElement *authTag;
|
||||||
OFDataArray *initialMessage = [_authModule initialMessage];
|
OFData *initialMessage = [_authModule initialMessage];
|
||||||
|
|
||||||
authTag = [OFXMLElement elementWithName: @"auth"
|
authTag = [OFXMLElement elementWithName: @"auth"
|
||||||
namespace: XMPP_NS_SASL];
|
namespace: XMPP_NS_SASL];
|
||||||
|
|
|
@ -98,7 +98,7 @@
|
||||||
OFString *feature;
|
OFString *feature;
|
||||||
OFMutableString *caps = [OFMutableString string];
|
OFMutableString *caps = [OFMutableString string];
|
||||||
OFSHA1Hash *hash = [OFSHA1Hash cryptoHash];
|
OFSHA1Hash *hash = [OFSHA1Hash cryptoHash];
|
||||||
OFDataArray *digest = [OFDataArray dataArray];
|
OFData *digest;
|
||||||
|
|
||||||
enumerator = [_identities objectEnumerator];
|
enumerator = [_identities objectEnumerator];
|
||||||
while ((identity = [enumerator nextObject]) != nil)
|
while ((identity = [enumerator nextObject]) != nil)
|
||||||
|
@ -112,8 +112,8 @@
|
||||||
[hash updateWithBuffer: [caps UTF8String]
|
[hash updateWithBuffer: [caps UTF8String]
|
||||||
length: [caps UTF8StringLength]];
|
length: [caps UTF8StringLength]];
|
||||||
|
|
||||||
[digest addItems: [hash digest]
|
digest = [OFData dataWithItems: [hash digest]
|
||||||
count: [OFSHA1Hash digestSize]];
|
count: [[hash class] digestSize]];
|
||||||
|
|
||||||
return [digest stringByBase64Encoding];
|
return [digest stringByBase64Encoding];
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,13 +40,16 @@
|
||||||
password: nil] autorelease];
|
password: nil] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OFDataArray *)initialMessage
|
- (OFData *)initialMessage
|
||||||
{
|
{
|
||||||
OFDataArray *message = [OFDataArray dataArray];
|
OFMutableData *message = [OFMutableData data];
|
||||||
|
|
||||||
/* authzid */
|
/* authzid */
|
||||||
if (_authzid)
|
if (_authzid != nil)
|
||||||
[message addItem: _authzid];
|
[message addItems: [_authzid UTF8String]
|
||||||
|
count: [_authzid UTF8StringLength]];
|
||||||
|
|
||||||
|
[message makeImmutable];
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#import <ObjFW/OFArray.h>
|
#import <ObjFW/OFArray.h>
|
||||||
#import <ObjFW/OFDictionary.h>
|
#import <ObjFW/OFDictionary.h>
|
||||||
#import <ObjFW/OFNumber.h>
|
#import <ObjFW/OFNumber.h>
|
||||||
#import <ObjFW/OFDataArray.h>
|
#import <ObjFW/OFData.h>
|
||||||
#import <ObjFW/OFAutoreleasePool.h>
|
#import <ObjFW/OFAutoreleasePool.h>
|
||||||
|
|
||||||
#import <ObjFW/OFNotImplementedException.h>
|
#import <ObjFW/OFNotImplementedException.h>
|
||||||
|
@ -52,8 +52,8 @@
|
||||||
|
|
||||||
_file = [file copy];
|
_file = [file copy];
|
||||||
@try {
|
@try {
|
||||||
_data = [[[OFDataArray dataArrayWithContentsOfFile:
|
_data = [[[OFData dataWithContentsOfFile: file]
|
||||||
file] messagePackValue] retain];
|
messagePackValue] retain];
|
||||||
} @catch (id e) {
|
} @catch (id e) {
|
||||||
_data = [[OFMutableDictionary alloc] init];
|
_data = [[OFMutableDictionary alloc] init];
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,14 @@
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_BEGIN
|
OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@class OFDataArray;
|
@class OFMutableData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A class to provide multiple delegates in a single class
|
* \brief A class to provide multiple delegates in a single class
|
||||||
*/
|
*/
|
||||||
@interface XMPPMulticastDelegate: OFObject
|
@interface XMPPMulticastDelegate: OFObject
|
||||||
{
|
{
|
||||||
OFDataArray *_delegates;
|
OFMutableData *_delegates;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#import <ObjFW/ObjFW.h>
|
#import <ObjFW/ObjFW.h>
|
||||||
#import <ObjFW/OFDataArray.h>
|
#import <ObjFW/OFData.h>
|
||||||
|
|
||||||
#import "XMPPMulticastDelegate.h"
|
#import "XMPPMulticastDelegate.h"
|
||||||
|
|
||||||
|
@ -35,7 +35,8 @@
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
@try {
|
@try {
|
||||||
_delegates = [[OFDataArray alloc] initWithItemSize: sizeof(id)];
|
_delegates = [[OFMutableData alloc]
|
||||||
|
initWithItemSize: sizeof(id)];
|
||||||
} @catch (id e) {
|
} @catch (id e) {
|
||||||
[self release];
|
[self release];
|
||||||
@throw e;
|
@throw e;
|
||||||
|
@ -73,7 +74,8 @@
|
||||||
- (bool)broadcastSelector: (SEL)selector
|
- (bool)broadcastSelector: (SEL)selector
|
||||||
withObject: (id)object
|
withObject: (id)object
|
||||||
{
|
{
|
||||||
OFDataArray *currentDelegates = [_delegates copy];
|
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
||||||
|
OFMutableData *currentDelegates = [[_delegates copy] autorelease];
|
||||||
id *items = [currentDelegates items];
|
id *items = [currentDelegates items];
|
||||||
size_t i, count = [currentDelegates count];
|
size_t i, count = [currentDelegates count];
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
|
@ -90,6 +92,8 @@
|
||||||
handled |= imp(responder, selector, object);
|
handled |= imp(responder, selector, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[pool release];
|
||||||
|
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +101,8 @@
|
||||||
withObject: (id)object1
|
withObject: (id)object1
|
||||||
withObject: (id)object2
|
withObject: (id)object2
|
||||||
{
|
{
|
||||||
OFDataArray *currentDelegates = [_delegates copy];
|
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
||||||
|
OFMutableData *currentDelegates = [[_delegates copy] autorelease];
|
||||||
id *items = [currentDelegates items];
|
id *items = [currentDelegates items];
|
||||||
size_t i, count = [currentDelegates count];
|
size_t i, count = [currentDelegates count];
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
|
@ -114,6 +119,8 @@
|
||||||
handled |= imp(responder, selector, object1, object2);
|
handled |= imp(responder, selector, object1, object2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[pool release];
|
||||||
|
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -44,13 +44,14 @@
|
||||||
password: password] autorelease];
|
password: password] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OFDataArray *)initialMessage
|
- (OFData *)initialMessage
|
||||||
{
|
{
|
||||||
OFDataArray *message = [OFDataArray dataArray];
|
OFMutableData *message = [OFMutableData data];
|
||||||
|
|
||||||
/* authzid */
|
/* authzid */
|
||||||
if (_authzid)
|
if (_authzid != nil)
|
||||||
[message addItem: _authzid];
|
[message addItems: [_authzid UTF8String]
|
||||||
|
count: [_authzid UTF8StringLength]];
|
||||||
|
|
||||||
/* separator */
|
/* separator */
|
||||||
[message addItem: ""];
|
[message addItem: ""];
|
||||||
|
@ -66,6 +67,8 @@
|
||||||
[message addItems: [_password UTF8String]
|
[message addItems: [_password UTF8String]
|
||||||
count: [_password UTF8StringLength]];
|
count: [_password UTF8StringLength]];
|
||||||
|
|
||||||
|
[message makeImmutable];
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -35,7 +35,7 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
OFString *_cNonce;
|
OFString *_cNonce;
|
||||||
OFString *_GS2Header;
|
OFString *_GS2Header;
|
||||||
OFString *_clientFirstMessageBare;
|
OFString *_clientFirstMessageBare;
|
||||||
OFDataArray *_serverSignature;
|
OFData *_serverSignature;
|
||||||
XMPPConnection *_connection;
|
XMPPConnection *_connection;
|
||||||
bool _plusAvailable;
|
bool _plusAvailable;
|
||||||
bool _authenticated;
|
bool _authenticated;
|
||||||
|
|
|
@ -41,13 +41,13 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface XMPPSCRAMAuth ()
|
@interface XMPPSCRAMAuth ()
|
||||||
- (OFString *)XMPP_genNonce;
|
- (OFString *)XMPP_genNonce;
|
||||||
- (const uint8_t *)XMPP_HMACWithKey: (OFDataArray *)key
|
- (const uint8_t *)XMPP_HMACWithKey: (OFData *)key
|
||||||
data: (OFDataArray *)data;
|
data: (OFData *)data;
|
||||||
- (OFDataArray *)XMPP_hiWithData: (OFDataArray *)str
|
- (OFData *)XMPP_hiWithData: (OFData *)str
|
||||||
salt: (OFDataArray *)salt
|
salt: (OFData *)salt
|
||||||
iterationCount: (intmax_t)i;
|
iterationCount: (intmax_t)i;
|
||||||
- (OFDataArray *)XMPP_parseServerFirstMessage: (OFDataArray *)data;
|
- (OFData *)XMPP_parseServerFirstMessage: (OFData *)data;
|
||||||
- (OFDataArray *)XMPP_parseServerFinalMessage: (OFDataArray *)data;
|
- (OFData *)XMPP_parseServerFinalMessage: (OFData *)data;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
OF_ASSUME_NONNULL_END
|
||||||
|
@ -158,9 +158,9 @@ OF_ASSUME_NONNULL_END
|
||||||
[old release];
|
[old release];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OFDataArray *)initialMessage
|
- (OFData *)initialMessage
|
||||||
{
|
{
|
||||||
OFDataArray *ret = [OFDataArray dataArray];
|
OFMutableData *ret = [OFMutableData data];
|
||||||
|
|
||||||
/* New authentication attempt, reset status */
|
/* New authentication attempt, reset status */
|
||||||
[_cNonce release];
|
[_cNonce release];
|
||||||
|
@ -171,7 +171,7 @@ OF_ASSUME_NONNULL_END
|
||||||
_serverSignature = nil;
|
_serverSignature = nil;
|
||||||
_authenticated = false;
|
_authenticated = false;
|
||||||
|
|
||||||
if (_authzid)
|
if (_authzid != nil)
|
||||||
_GS2Header = [[OFString alloc]
|
_GS2Header = [[OFString alloc]
|
||||||
initWithFormat: @"%@,a=%@,",
|
initWithFormat: @"%@,a=%@,",
|
||||||
(_plusAvailable ? @"p=tls-unique" : @"y"),
|
(_plusAvailable ? @"p=tls-unique" : @"y"),
|
||||||
|
@ -192,13 +192,15 @@ OF_ASSUME_NONNULL_END
|
||||||
[ret addItems: [_clientFirstMessageBare UTF8String]
|
[ret addItems: [_clientFirstMessageBare UTF8String]
|
||||||
count: [_clientFirstMessageBare UTF8StringLength]];
|
count: [_clientFirstMessageBare UTF8StringLength]];
|
||||||
|
|
||||||
|
[ret makeImmutable];
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OFDataArray *)continueWithData: (OFDataArray *)data
|
- (OFData *)continueWithData: (OFData *)data
|
||||||
{
|
{
|
||||||
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
||||||
OFDataArray *ret;
|
OFData *ret;
|
||||||
|
|
||||||
if (!_serverSignature)
|
if (!_serverSignature)
|
||||||
ret = [self XMPP_parseServerFirstMessage: data];
|
ret = [self XMPP_parseServerFirstMessage: data];
|
||||||
|
@ -211,13 +213,14 @@ OF_ASSUME_NONNULL_END
|
||||||
return [ret autorelease];
|
return [ret autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OFDataArray *)XMPP_parseServerFirstMessage: (OFDataArray *)data
|
- (OFData *)XMPP_parseServerFirstMessage: (OFData *)data
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
const uint8_t *clientKey, *serverKey, *clientSignature;
|
const uint8_t *clientKey, *serverKey, *clientSignature;
|
||||||
intmax_t iterCount = 0;
|
intmax_t iterCount = 0;
|
||||||
id <OFCryptoHash> hash;
|
id <OFCryptoHash> hash;
|
||||||
OFDataArray *ret, *authMessage, *tmpArray, *salt = nil, *saltedPassword;
|
OFMutableData *ret, *authMessage, *tmpArray;
|
||||||
|
OFData *salt = nil, *saltedPassword;
|
||||||
OFString *tmpString, *sNonce = nil;
|
OFString *tmpString, *sNonce = nil;
|
||||||
OFEnumerator *enumerator;
|
OFEnumerator *enumerator;
|
||||||
OFString *comp;
|
OFString *comp;
|
||||||
|
@ -228,8 +231,8 @@ OF_ASSUME_NONNULL_END
|
||||||
} got = 0;
|
} got = 0;
|
||||||
|
|
||||||
hash = [[[_hashType alloc] init] autorelease];
|
hash = [[[_hashType alloc] init] autorelease];
|
||||||
ret = [OFDataArray dataArray];
|
ret = [OFMutableData data];
|
||||||
authMessage = [OFDataArray dataArray];
|
authMessage = [OFMutableData data];
|
||||||
|
|
||||||
OFString *chal = [OFString stringWithUTF8String: [data items]
|
OFString *chal = [OFString stringWithUTF8String: [data items]
|
||||||
length: [data count] *
|
length: [data count] *
|
||||||
|
@ -251,8 +254,7 @@ OF_ASSUME_NONNULL_END
|
||||||
sNonce = entry;
|
sNonce = entry;
|
||||||
got |= GOT_SNONCE;
|
got |= GOT_SNONCE;
|
||||||
} else if ([comp hasPrefix: @"s="]) {
|
} else if ([comp hasPrefix: @"s="]) {
|
||||||
salt = [OFDataArray
|
salt = [OFData dataWithBase64EncodedString: entry];
|
||||||
dataArrayWithBase64EncodedString: entry];
|
|
||||||
got |= GOT_SALT;
|
got |= GOT_SALT;
|
||||||
} else if ([comp hasPrefix: @"i="]) {
|
} else if ([comp hasPrefix: @"i="]) {
|
||||||
iterCount = [entry decimalValue];
|
iterCount = [entry decimalValue];
|
||||||
|
@ -264,12 +266,11 @@ OF_ASSUME_NONNULL_END
|
||||||
@throw [OFInvalidServerReplyException exception];
|
@throw [OFInvalidServerReplyException exception];
|
||||||
|
|
||||||
// Add c=<base64(GS2Header+channelBindingData)>
|
// Add c=<base64(GS2Header+channelBindingData)>
|
||||||
tmpArray = [OFDataArray dataArray];
|
tmpArray = [OFMutableData data];
|
||||||
[tmpArray addItems: [_GS2Header UTF8String]
|
[tmpArray addItems: [_GS2Header UTF8String]
|
||||||
count: [_GS2Header UTF8StringLength]];
|
count: [_GS2Header UTF8StringLength]];
|
||||||
if (_plusAvailable && [_connection encrypted]) {
|
if (_plusAvailable && [_connection encrypted]) {
|
||||||
OFDataArray *channelBinding =
|
OFData *channelBinding = [((SSLSocket *)[_connection socket])
|
||||||
[((SSLSocket *)[_connection socket])
|
|
||||||
channelBindingDataWithType: @"tls-unique"];
|
channelBindingDataWithType: @"tls-unique"];
|
||||||
[tmpArray addItems: [channelBinding items]
|
[tmpArray addItems: [channelBinding items]
|
||||||
count: [channelBinding count]];
|
count: [channelBinding count]];
|
||||||
|
@ -291,10 +292,8 @@ OF_ASSUME_NONNULL_END
|
||||||
* IETF RFC 5802:
|
* IETF RFC 5802:
|
||||||
* SaltedPassword := Hi(Normalize(password), salt, i)
|
* SaltedPassword := Hi(Normalize(password), salt, i)
|
||||||
*/
|
*/
|
||||||
tmpArray = [OFDataArray dataArray];
|
tmpArray = [OFMutableData dataWithItems: [_password UTF8String]
|
||||||
[tmpArray addItems: [_password UTF8String]
|
count: [_password UTF8StringLength]];
|
||||||
count: [_password UTF8StringLength]];
|
|
||||||
|
|
||||||
saltedPassword = [self XMPP_hiWithData: tmpArray
|
saltedPassword = [self XMPP_hiWithData: tmpArray
|
||||||
salt: salt
|
salt: salt
|
||||||
iterationCount: iterCount];
|
iterationCount: iterCount];
|
||||||
|
@ -318,11 +317,9 @@ OF_ASSUME_NONNULL_END
|
||||||
* IETF RFC 5802:
|
* IETF RFC 5802:
|
||||||
* ClientKey := HMAC(SaltedPassword, "Client Key")
|
* ClientKey := HMAC(SaltedPassword, "Client Key")
|
||||||
*/
|
*/
|
||||||
tmpArray = [OFDataArray dataArray];
|
|
||||||
[tmpArray addItems: "Client Key"
|
|
||||||
count: 10];
|
|
||||||
clientKey = [self XMPP_HMACWithKey: saltedPassword
|
clientKey = [self XMPP_HMACWithKey: saltedPassword
|
||||||
data: tmpArray];
|
data: [OFData dataWithItems: @"Client key"
|
||||||
|
count: 10]];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IETF RFC 5802:
|
* IETF RFC 5802:
|
||||||
|
@ -330,9 +327,8 @@ OF_ASSUME_NONNULL_END
|
||||||
*/
|
*/
|
||||||
[hash updateWithBuffer: (void *)clientKey
|
[hash updateWithBuffer: (void *)clientKey
|
||||||
length: [_hashType digestSize]];
|
length: [_hashType digestSize]];
|
||||||
tmpArray = [OFDataArray dataArray];
|
tmpArray = [OFMutableData dataWithItems: [hash digest]
|
||||||
[tmpArray addItems: [hash digest]
|
count: [_hashType digestSize]];
|
||||||
count: [_hashType digestSize]];
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IETF RFC 5802:
|
* IETF RFC 5802:
|
||||||
|
@ -345,9 +341,8 @@ OF_ASSUME_NONNULL_END
|
||||||
* IETF RFC 5802:
|
* IETF RFC 5802:
|
||||||
* ServerKey := HMAC(SaltedPassword, "Server Key")
|
* ServerKey := HMAC(SaltedPassword, "Server Key")
|
||||||
*/
|
*/
|
||||||
tmpArray = [OFDataArray dataArray];
|
tmpArray = [OFMutableData dataWithItems: "Server Key"
|
||||||
[tmpArray addItems: "Server Key"
|
count: 10];
|
||||||
count: 10];
|
|
||||||
serverKey = [self XMPP_HMACWithKey: saltedPassword
|
serverKey = [self XMPP_HMACWithKey: saltedPassword
|
||||||
data: tmpArray];
|
data: tmpArray];
|
||||||
|
|
||||||
|
@ -355,19 +350,20 @@ OF_ASSUME_NONNULL_END
|
||||||
* IETF RFC 5802:
|
* IETF RFC 5802:
|
||||||
* ServerSignature := HMAC(ServerKey, AuthMessage)
|
* ServerSignature := HMAC(ServerKey, AuthMessage)
|
||||||
*/
|
*/
|
||||||
tmpArray = [OFDataArray dataArray];
|
tmpArray = [OFMutableData dataWithItems: serverKey
|
||||||
[tmpArray addItems: serverKey
|
count: [_hashType digestSize]];
|
||||||
count: [_hashType digestSize]];
|
|
||||||
_serverSignature = [[OFDataArray alloc] init];
|
[_serverSignature release];
|
||||||
[_serverSignature addItems: [self XMPP_HMACWithKey: tmpArray
|
_serverSignature = [[OFMutableData alloc]
|
||||||
data: authMessage]
|
initWithItems: [self XMPP_HMACWithKey: tmpArray
|
||||||
count: [_hashType digestSize]];
|
data: authMessage]
|
||||||
|
count: [_hashType digestSize]];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IETF RFC 5802:
|
* IETF RFC 5802:
|
||||||
* ClientProof := ClientKey XOR ClientSignature
|
* ClientProof := ClientKey XOR ClientSignature
|
||||||
*/
|
*/
|
||||||
tmpArray = [OFDataArray dataArray];
|
tmpArray = [OFMutableData data];
|
||||||
for (i = 0; i < [_hashType digestSize]; i++) {
|
for (i = 0; i < [_hashType digestSize]; i++) {
|
||||||
uint8_t c = clientKey[i] ^ clientSignature[i];
|
uint8_t c = clientKey[i] ^ clientSignature[i];
|
||||||
[tmpArray addItem: &c];
|
[tmpArray addItem: &c];
|
||||||
|
@ -384,7 +380,7 @@ OF_ASSUME_NONNULL_END
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OFDataArray *)XMPP_parseServerFinalMessage: (OFDataArray *)data
|
- (OFData *)XMPP_parseServerFinalMessage: (OFData *)data
|
||||||
{
|
{
|
||||||
OFString *mess, *value;
|
OFString *mess, *value;
|
||||||
|
|
||||||
|
@ -396,8 +392,7 @@ OF_ASSUME_NONNULL_END
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
mess = [OFString stringWithUTF8String: [data items]
|
mess = [OFString stringWithUTF8String: [data items]
|
||||||
length: [data count] *
|
length: [data count] * [data itemSize]];
|
||||||
[data itemSize]];
|
|
||||||
value = [mess substringWithRange: of_range(2, [mess length] - 2)];
|
value = [mess substringWithRange: of_range(2, [mess length] - 2)];
|
||||||
|
|
||||||
if ([mess hasPrefix: @"v="]) {
|
if ([mess hasPrefix: @"v="]) {
|
||||||
|
@ -435,11 +430,11 @@ OF_ASSUME_NONNULL_END
|
||||||
length: 64];
|
length: 64];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (const uint8_t *)XMPP_HMACWithKey: (OFDataArray *)key
|
- (const uint8_t *)XMPP_HMACWithKey: (OFData *)key
|
||||||
data: (OFDataArray *)data
|
data: (OFData *)data
|
||||||
{
|
{
|
||||||
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
||||||
OFDataArray *k = [OFDataArray dataArray];
|
OFMutableData *k = [OFMutableData data];
|
||||||
size_t i, kSize, blockSize = [_hashType blockSize];
|
size_t i, kSize, blockSize = [_hashType blockSize];
|
||||||
uint8_t *kI = NULL, *kO = NULL;
|
uint8_t *kI = NULL, *kO = NULL;
|
||||||
id <OFCryptoHash> hashI, hashO;
|
id <OFCryptoHash> hashI, hashO;
|
||||||
|
@ -490,16 +485,16 @@ OF_ASSUME_NONNULL_END
|
||||||
return [[hashO autorelease] digest];
|
return [[hashO autorelease] digest];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OFDataArray *)XMPP_hiWithData: (OFDataArray *)str
|
- (OFData *)XMPP_hiWithData: (OFData *)str
|
||||||
salt: (OFDataArray *)salt
|
salt: (OFData *)salt
|
||||||
iterationCount: (intmax_t)i
|
iterationCount: (intmax_t)i
|
||||||
{
|
{
|
||||||
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
||||||
size_t digestSize = [_hashType digestSize];
|
size_t digestSize = [_hashType digestSize];
|
||||||
uint8_t *result = NULL;
|
uint8_t *result = NULL;
|
||||||
const uint8_t *u, *uOld;
|
const uint8_t *u, *uOld;
|
||||||
intmax_t j, k;
|
intmax_t j, k;
|
||||||
OFDataArray *salty, *tmp, *ret;
|
OFMutableData *salty, *tmp, *ret;
|
||||||
|
|
||||||
result = [self allocMemoryWithSize: digestSize];
|
result = [self allocMemoryWithSize: digestSize];
|
||||||
|
|
||||||
|
@ -517,7 +512,7 @@ OF_ASSUME_NONNULL_END
|
||||||
result[j] ^= uOld[j];
|
result[j] ^= uOld[j];
|
||||||
|
|
||||||
for (j = 0; j < i - 1; j++) {
|
for (j = 0; j < i - 1; j++) {
|
||||||
tmp = [[OFDataArray alloc] init];
|
tmp = [[OFMutableData alloc] init];
|
||||||
[tmp addItems: uOld
|
[tmp addItems: uOld
|
||||||
count: digestSize];
|
count: digestSize];
|
||||||
|
|
||||||
|
@ -533,9 +528,8 @@ OF_ASSUME_NONNULL_END
|
||||||
uOld = u;
|
uOld = u;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = [OFDataArray dataArray];
|
ret = [OFMutableData dataWithItems: result
|
||||||
[ret addItems: result
|
count: digestSize];
|
||||||
count: digestSize];
|
|
||||||
} @finally {
|
} @finally {
|
||||||
[self freeMemory: result];
|
[self freeMemory: result];
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,8 @@
|
||||||
ID: (OFString *)ID
|
ID: (OFString *)ID
|
||||||
{
|
{
|
||||||
self = [super initWithName: name
|
self = [super initWithName: name
|
||||||
namespace: XMPP_NS_CLIENT];
|
namespace: XMPP_NS_CLIENT
|
||||||
|
stringValue: nil];
|
||||||
|
|
||||||
@try {
|
@try {
|
||||||
if (![name isEqual: @"iq"] && ![name isEqual: @"message"] &&
|
if (![name isEqual: @"iq"] && ![name isEqual: @"message"] &&
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue