ObjXMPP  Check-in [2adf07b564]

Overview
Comment:Use OpenSSL to generate the nonce.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2adf07b56434aebde7a504507b18b4b348a0e951ff76e8b785321d3135f87c30
User & Date: js on 2011-03-30 18:12:47
Other Links: manifest | tags
Context
2011-03-30
18:35
Set the default namespace and prefixes when creating a new XMPPStanza. check-in: efd0127bff user: js tags: trunk
18:12
Use OpenSSL to generate the nonce. check-in: 2adf07b564 user: js tags: trunk
17:44
Fail if objfw-config is missing. check-in: 3441762189 user: js tags: trunk
Changes

Modified ObjXMPP.xcodeproj/project.pbxproj from [4b39058b85] to [0f33696464].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// !$*UTF8*$!
{
	archiveVersion = 1;
	classes = {
	};
	objectVersion = 46;
	objects = {

/* Begin PBXBuildFile section */
		4B1295EF1337BD5F00154B25 /* test.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B1295EE1337BD5F00154B25 /* test.m */; };
		4B1295F11337C37E00154B25 /* ObjXMPP.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC559911337A65400E345C7 /* ObjXMPP.framework */; };
		4B1295F21337C3CF00154B25 /* ObjFW.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC559D61337ABD300E345C7 /* ObjFW.framework */; };
		4BC559D71337ABD300E345C7 /* ObjFW.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC559D61337ABD300E345C7 /* ObjFW.framework */; };
		4BC559EB1337AC0900E345C7 /* arc4random_uniform.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC559D91337AC0900E345C7 /* arc4random_uniform.m */; };
		4BC559EC1337AC0900E345C7 /* XMPPAuthenticator.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC559DA1337AC0900E345C7 /* XMPPAuthenticator.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BC559ED1337AC0900E345C7 /* XMPPAuthenticator.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC559DB1337AC0900E345C7 /* XMPPAuthenticator.m */; };
		4BC559EE1337AC0900E345C7 /* XMPPConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC559DC1337AC0900E345C7 /* XMPPConnection.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BC559EF1337AC0900E345C7 /* XMPPConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC559DD1337AC0900E345C7 /* XMPPConnection.m */; };
		4BC559F01337AC0900E345C7 /* XMPPExceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC559DE1337AC0900E345C7 /* XMPPExceptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BC559F11337AC0900E345C7 /* XMPPExceptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC559DF1337AC0900E345C7 /* XMPPExceptions.m */; };
		4BC559F21337AC0900E345C7 /* XMPPIQ.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC559E01337AC0900E345C7 /* XMPPIQ.h */; settings = {ATTRIBUTES = (Public, ); }; };













<







1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
// !$*UTF8*$!
{
	archiveVersion = 1;
	classes = {
	};
	objectVersion = 46;
	objects = {

/* Begin PBXBuildFile section */
		4B1295EF1337BD5F00154B25 /* test.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B1295EE1337BD5F00154B25 /* test.m */; };
		4B1295F11337C37E00154B25 /* ObjXMPP.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC559911337A65400E345C7 /* ObjXMPP.framework */; };
		4B1295F21337C3CF00154B25 /* ObjFW.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC559D61337ABD300E345C7 /* ObjFW.framework */; };
		4BC559D71337ABD300E345C7 /* ObjFW.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC559D61337ABD300E345C7 /* ObjFW.framework */; };

		4BC559EC1337AC0900E345C7 /* XMPPAuthenticator.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC559DA1337AC0900E345C7 /* XMPPAuthenticator.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BC559ED1337AC0900E345C7 /* XMPPAuthenticator.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC559DB1337AC0900E345C7 /* XMPPAuthenticator.m */; };
		4BC559EE1337AC0900E345C7 /* XMPPConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC559DC1337AC0900E345C7 /* XMPPConnection.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BC559EF1337AC0900E345C7 /* XMPPConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC559DD1337AC0900E345C7 /* XMPPConnection.m */; };
		4BC559F01337AC0900E345C7 /* XMPPExceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC559DE1337AC0900E345C7 /* XMPPExceptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BC559F11337AC0900E345C7 /* XMPPExceptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC559DF1337AC0900E345C7 /* XMPPExceptions.m */; };
		4BC559F21337AC0900E345C7 /* XMPPIQ.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC559E01337AC0900E345C7 /* XMPPIQ.h */; settings = {ATTRIBUTES = (Public, ); }; };
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
		4B1295E01337BD2D00154B25 /* ObjXMPPTests */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ObjXMPPTests; sourceTree = BUILT_PRODUCTS_DIR; };
		4B1295EE1337BD5F00154B25 /* test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = test.m; path = tests/test.m; sourceTree = SOURCE_ROOT; };
		4BC559911337A65400E345C7 /* ObjXMPP.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ObjXMPP.framework; sourceTree = BUILT_PRODUCTS_DIR; };
		4BC559D61337ABD300E345C7 /* ObjFW.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ObjFW.framework; path = ../../../../Library/Frameworks/ObjFW.framework; sourceTree = "<group>"; };
		4BC559D91337AC0900E345C7 /* arc4random_uniform.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = arc4random_uniform.m; path = src/arc4random_uniform.m; sourceTree = SOURCE_ROOT; };
		4BC559DA1337AC0900E345C7 /* XMPPAuthenticator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMPPAuthenticator.h; path = src/XMPPAuthenticator.h; sourceTree = SOURCE_ROOT; };
		4BC559DB1337AC0900E345C7 /* XMPPAuthenticator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XMPPAuthenticator.m; path = src/XMPPAuthenticator.m; sourceTree = SOURCE_ROOT; };
		4BC559DC1337AC0900E345C7 /* XMPPConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMPPConnection.h; path = src/XMPPConnection.h; sourceTree = SOURCE_ROOT; };
		4BC559DD1337AC0900E345C7 /* XMPPConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XMPPConnection.m; path = src/XMPPConnection.m; sourceTree = SOURCE_ROOT; };
		4BC559DE1337AC0900E345C7 /* XMPPExceptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMPPExceptions.h; path = src/XMPPExceptions.h; sourceTree = SOURCE_ROOT; };
		4BC559DF1337AC0900E345C7 /* XMPPExceptions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XMPPExceptions.m; path = src/XMPPExceptions.m; sourceTree = SOURCE_ROOT; };
		4BC559E01337AC0900E345C7 /* XMPPIQ.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMPPIQ.h; path = src/XMPPIQ.h; sourceTree = SOURCE_ROOT; };







<







51
52
53
54
55
56
57

58
59
60
61
62
63
64
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
		4B1295E01337BD2D00154B25 /* ObjXMPPTests */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ObjXMPPTests; sourceTree = BUILT_PRODUCTS_DIR; };
		4B1295EE1337BD5F00154B25 /* test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = test.m; path = tests/test.m; sourceTree = SOURCE_ROOT; };
		4BC559911337A65400E345C7 /* ObjXMPP.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ObjXMPP.framework; sourceTree = BUILT_PRODUCTS_DIR; };
		4BC559D61337ABD300E345C7 /* ObjFW.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ObjFW.framework; path = ../../../../Library/Frameworks/ObjFW.framework; sourceTree = "<group>"; };

		4BC559DA1337AC0900E345C7 /* XMPPAuthenticator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMPPAuthenticator.h; path = src/XMPPAuthenticator.h; sourceTree = SOURCE_ROOT; };
		4BC559DB1337AC0900E345C7 /* XMPPAuthenticator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XMPPAuthenticator.m; path = src/XMPPAuthenticator.m; sourceTree = SOURCE_ROOT; };
		4BC559DC1337AC0900E345C7 /* XMPPConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMPPConnection.h; path = src/XMPPConnection.h; sourceTree = SOURCE_ROOT; };
		4BC559DD1337AC0900E345C7 /* XMPPConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XMPPConnection.m; path = src/XMPPConnection.m; sourceTree = SOURCE_ROOT; };
		4BC559DE1337AC0900E345C7 /* XMPPExceptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMPPExceptions.h; path = src/XMPPExceptions.h; sourceTree = SOURCE_ROOT; };
		4BC559DF1337AC0900E345C7 /* XMPPExceptions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XMPPExceptions.m; path = src/XMPPExceptions.m; sourceTree = SOURCE_ROOT; };
		4BC559E01337AC0900E345C7 /* XMPPIQ.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMPPIQ.h; path = src/XMPPIQ.h; sourceTree = SOURCE_ROOT; };
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
				4BDEF8061340B240000156D1 /* XMPPRoster.m */,
				4BD9BF57134003F700DAB43A /* XMPPRosterItem.h */,
				4BD9BF58134003F700DAB43A /* XMPPRosterItem.m */,
				4BC559EA1337AC0900E345C7 /* XMPPSCRAMAuth.h */,
				4BC559FD1337AC1800E345C7 /* XMPPSCRAMAuth.m */,
				4BC559FE1337AC1800E345C7 /* XMPPStanza.h */,
				4BC559FF1337AC1800E345C7 /* XMPPStanza.m */,
				4BC559D91337AC0900E345C7 /* arc4random_uniform.m */,
			);
			path = ObjXMPP;
			sourceTree = "<group>";
		};
		4BC5599B1337A65400E345C7 /* Supporting Files */ = {
			isa = PBXGroup;
			children = (







<







165
166
167
168
169
170
171

172
173
174
175
176
177
178
				4BDEF8061340B240000156D1 /* XMPPRoster.m */,
				4BD9BF57134003F700DAB43A /* XMPPRosterItem.h */,
				4BD9BF58134003F700DAB43A /* XMPPRosterItem.m */,
				4BC559EA1337AC0900E345C7 /* XMPPSCRAMAuth.h */,
				4BC559FD1337AC1800E345C7 /* XMPPSCRAMAuth.m */,
				4BC559FE1337AC1800E345C7 /* XMPPStanza.h */,
				4BC559FF1337AC1800E345C7 /* XMPPStanza.m */,

			);
			path = ObjXMPP;
			sourceTree = "<group>";
		};
		4BC5599B1337A65400E345C7 /* Supporting Files */ = {
			isa = PBXGroup;
			children = (
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
			);
			runOnlyForDeploymentPostprocessing = 0;
		};
		4BC5598C1337A65400E345C7 /* Sources */ = {
			isa = PBXSourcesBuildPhase;
			buildActionMask = 2147483647;
			files = (
				4BC559EB1337AC0900E345C7 /* arc4random_uniform.m in Sources */,
				4BC559ED1337AC0900E345C7 /* XMPPAuthenticator.m in Sources */,
				4BC559EF1337AC0900E345C7 /* XMPPConnection.m in Sources */,
				4BC559F11337AC0900E345C7 /* XMPPExceptions.m in Sources */,
				4BC559F31337AC0900E345C7 /* XMPPIQ.m in Sources */,
				4BC559F51337AC0900E345C7 /* XMPPJID.m in Sources */,
				4BC559F71337AC0900E345C7 /* XMPPMessage.m in Sources */,
				4BC559F91337AC0900E345C7 /* XMPPPLAINAuth.m in Sources */,







<







283
284
285
286
287
288
289

290
291
292
293
294
295
296
			);
			runOnlyForDeploymentPostprocessing = 0;
		};
		4BC5598C1337A65400E345C7 /* Sources */ = {
			isa = PBXSourcesBuildPhase;
			buildActionMask = 2147483647;
			files = (

				4BC559ED1337AC0900E345C7 /* XMPPAuthenticator.m in Sources */,
				4BC559EF1337AC0900E345C7 /* XMPPConnection.m in Sources */,
				4BC559F11337AC0900E345C7 /* XMPPExceptions.m in Sources */,
				4BC559F31337AC0900E345C7 /* XMPPIQ.m in Sources */,
				4BC559F51337AC0900E345C7 /* XMPPJID.m in Sources */,
				4BC559F71337AC0900E345C7 /* XMPPMessage.m in Sources */,
				4BC559F91337AC0900E345C7 /* XMPPPLAINAuth.m in Sources */,
392
393
394
395
396
397
398





399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416





417
418
419
420
421
422
423
				DYLIB_CURRENT_VERSION = 0;
				FRAMEWORK_VERSION = A;
				GCC_DYNAMIC_NO_PIC = NO;
				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
				GCC_PRECOMPILE_PREFIX_HEADER = YES;
				GCC_VERSION = 4.2;
				INFOPLIST_FILE = Info.plist;





				PRODUCT_NAME = "$(TARGET_NAME)";
				WRAPPER_EXTENSION = framework;
			};
			name = Debug;
		};
		4BC559BA1337A65500E345C7 /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ALWAYS_SEARCH_USER_PATHS = NO;
				COPY_PHASE_STRIP = YES;
				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
				DYLIB_COMPATIBILITY_VERSION = 0;
				DYLIB_CURRENT_VERSION = 0;
				FRAMEWORK_VERSION = A;
				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
				GCC_PRECOMPILE_PREFIX_HEADER = YES;
				GCC_VERSION = 4.2;
				INFOPLIST_FILE = Info.plist;





				PRODUCT_NAME = "$(TARGET_NAME)";
				WRAPPER_EXTENSION = framework;
			};
			name = Release;
		};
/* End XCBuildConfiguration section */








>
>
>
>
>


















>
>
>
>
>







388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
				DYLIB_CURRENT_VERSION = 0;
				FRAMEWORK_VERSION = A;
				GCC_DYNAMIC_NO_PIC = NO;
				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
				GCC_PRECOMPILE_PREFIX_HEADER = YES;
				GCC_VERSION = 4.2;
				INFOPLIST_FILE = Info.plist;
				OTHER_LDFLAGS = (
					"-lcrypto",
					"-L/opt/local/lib",
					"-lidn",
				);
				PRODUCT_NAME = "$(TARGET_NAME)";
				WRAPPER_EXTENSION = framework;
			};
			name = Debug;
		};
		4BC559BA1337A65500E345C7 /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ALWAYS_SEARCH_USER_PATHS = NO;
				COPY_PHASE_STRIP = YES;
				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
				DYLIB_COMPATIBILITY_VERSION = 0;
				DYLIB_CURRENT_VERSION = 0;
				FRAMEWORK_VERSION = A;
				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
				GCC_PRECOMPILE_PREFIX_HEADER = YES;
				GCC_VERSION = 4.2;
				INFOPLIST_FILE = Info.plist;
				OTHER_LDFLAGS = (
					"-lcrypto",
					"-L/opt/local/lib",
					"-lidn",
				);
				PRODUCT_NAME = "$(TARGET_NAME)";
				WRAPPER_EXTENSION = framework;
			};
			name = Release;
		};
/* End XCBuildConfiguration section */

Modified configure.ac from [62a72c8e7a] to [cc022bbe90].

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
AS_IF([test x"$enable_static" = x"yes" -o x"$enable_shared" = x"no"], [
	AC_PATH_TOOL(AR, ar)
	AC_PROG_RANLIB
	AC_SUBST(OBJXMPP_STATIC_LIB, "libobjxmpp.a")
])

AC_CHECK_LIB(objopenssl, main, [
	LIBS="$LIBS -lobjopenssl"
], [
	AC_MSG_ERROR(You need ObjOpenSSL installed!)
])

PKG_CHECK_MODULES(libidn, [libidn >= 0.25], [
	CPPFLAGS="$CPPFLAGS $libidn_CFLAGS"
	LIBS="$LIBS $libidn_LIBS"







|







30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
AS_IF([test x"$enable_static" = x"yes" -o x"$enable_shared" = x"no"], [
	AC_PATH_TOOL(AR, ar)
	AC_PROG_RANLIB
	AC_SUBST(OBJXMPP_STATIC_LIB, "libobjxmpp.a")
])

AC_CHECK_LIB(objopenssl, main, [
	LIBS="$LIBS -lobjopenssl -lcrypto"
], [
	AC_MSG_ERROR(You need ObjOpenSSL installed!)
])

PKG_CHECK_MODULES(libidn, [libidn >= 0.25], [
	CPPFLAGS="$CPPFLAGS $libidn_CFLAGS"
	LIBS="$LIBS $libidn_LIBS"

Modified src/Makefile from [d823067367] to [b181cca38a].

14
15
16
17
18
19
20
21
22
23
24
25
26
27
       XMPPPLAINAuth.m		\
       XMPPPresence.m		\
       XMPPRoster.m		\
       XMPPRosterItem.m		\
       XMPPSCRAMAuth.m		\
       XMPPStanza.m

INCLUDES := ${SRCS:.m=.h}

SRCS += arc4random_uniform.m

include ../buildsys.mk

LD = ${OBJC}







|
<
<




14
15
16
17
18
19
20
21


22
23
24
25
       XMPPPLAINAuth.m		\
       XMPPPresence.m		\
       XMPPRoster.m		\
       XMPPRosterItem.m		\
       XMPPSCRAMAuth.m		\
       XMPPStanza.m

INCLUDES = ${SRCS:.m=.h}



include ../buildsys.mk

LD = ${OBJC}

Modified src/XMPPSCRAMAuth.m from [7e9107b0df] to [582a13eb09].

19
20
21
22
23
24
25




26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#include <string.h>





#import "XMPPSCRAMAuth.h"
#import "XMPPExceptions.h"

#define HMAC_IPAD 0x36
#define HMAC_OPAD 0x5c

#ifndef HAVE_ARC4RANDOM_UNIFORM
extern uint32_t arc4random_uniform(uint32_t);
#endif

@implementation XMPPSCRAMAuth
+ SCRAMAuthWithAuthcid: (OFString*)authcid
	      password: (OFString*)password
		  hash: (Class)hash;
{
	return [[[self alloc] initWithAuthcid: authcid
				     password: password







>
>
>
>






<
<
<
<







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35




36
37
38
39
40
41
42
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#include <string.h>

#include <assert.h>

#include <openssl/rand.h>

#import "XMPPSCRAMAuth.h"
#import "XMPPExceptions.h"

#define HMAC_IPAD 0x36
#define HMAC_OPAD 0x5c





@implementation XMPPSCRAMAuth
+ SCRAMAuthWithAuthcid: (OFString*)authcid
	      password: (OFString*)password
		  hash: (Class)hash;
{
	return [[[self alloc] initWithAuthcid: authcid
				     password: password
344
345
346
347
348
349
350
351

352

353
354

355


356

357
358
359

360
361
362
363
364
365
366
						      reason: value];

	[pool release];
}

- (OFString*)XMPP_genNonce
{
	OFMutableString *nonce = [OFMutableString string];

	uint32_t res, i;


	for (i = 0; i < 64; i++) {

		while ((res = arc4random_uniform('~' - '!' + 1) + '!') == ',');


		[nonce appendFormat: @"%c", res];

	}

	return nonce;

}

- (uint8_t*)XMPP_HMACWithKey: (OFDataArray*)key
			data: (OFDataArray*)data
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFDataArray *k = [OFDataArray dataArrayWithItemSize: 1];







|
>
|
>


>
|
>
>
|
>


|
>







344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
						      reason: value];

	[pool release];
}

- (OFString*)XMPP_genNonce
{
	uint8_t buf[64];
	size_t i;

	assert(RAND_pseudo_bytes(buf, 64) >= 0);

	for (i = 0; i < 64; i++) {
		uint8_t tmp = (buf[i] % ('~' - '!')) + '!';

		while (tmp == ',')
			tmp = ((buf[i] >> 1) % ('~' - '!')) + '!';

		buf[i] = tmp;
	}

	return [OFString stringWithCString: (char*)buf
				    length: 64];
}

- (uint8_t*)XMPP_HMACWithKey: (OFDataArray*)key
			data: (OFDataArray*)data
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFDataArray *k = [OFDataArray dataArrayWithItemSize: 1];

Deleted src/arc4random_uniform.m version [6ccb87c794].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
76
77
78
79
80
81
/*
 * Copyright (c) 1996, David Mazieres <dm@uun.org>
 * Copyright (c) 2008, Damien Miller <djm@openbsd.org>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/*
 * Arc4 random number generator for OpenBSD.
 *
 * This code is derived from section 17.1 of Applied Cryptography,
 * second edition, which describes a stream cipher allegedly
 * compatible with RSA Labs "RC4" cipher (the actual description of
 * which is a trade secret).  The same algorithm is used as a stream
 * cipher called "arcfour" in Tatu Ylonen's ssh package.
 *
 * RC4 is a registered trademark of RSA Laboratories.
 */

#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
    defined(__APPLE__)
# include <stdlib.h>
#else
# include <bsd/stdlib.h>
#endif
#include <stdint.h>

/*
 * Calculate a uniformly distributed random number less than upper_bound
 * avoiding "modulo bias".
 *
 * Uniformity is achieved by generating new random numbers until the one
 * returned is outside the range [0, 2**32 % upper_bound).  This
 * guarantees the selected random number will be inside
 * [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound)
 * after reduction modulo upper_bound.
 */
uint32_t
arc4random_uniform(uint32_t upper_bound)
{
	uint32_t r, min;

	if (upper_bound < 2)
		return 0;

#if (ULONG_MAX > 0xffffffffUL)
	min = 0x100000000UL % upper_bound;
#else
	/* Calculate (2**32 % upper_bound) avoiding 64-bit math */
	if (upper_bound > 0x80000000)
		min = 1 + ~upper_bound;		/* 2**32 - upper_bound */
	else {
		/* (2**32 - (x * 2)) % x == 2**32 % x when x <= 2**31 */
		min = ((0xffffffff - (upper_bound * 2)) + 1) % upper_bound;
	}
#endif

	/*
	 * This could theoretically loop forever but each retry has
	 * p > 0.5 (worst case, usually far better) of selecting a
	 * number inside the range we need, so it should rarely need
	 * to re-roll.
	 */
	for (;;) {
		r = arc4random();
		if (r >= min)
			break;
	}

	return r % upper_bound;
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<