Overview
Comment: | Optimize HMAC implementation |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
bfe06785665f41ee2c56f5e7201f09c1 |
User & Date: | florob@babelmonkeys.de on 2011-09-09 01:42:33 |
Other Links: | manifest | tags |
Context
2011-09-09
| ||
14:42 | Prevent a possible leak. check-in: 547b55739a user: js tags: trunk | |
01:42 | Optimize HMAC implementation check-in: bfe0678566 user: florob@babelmonkeys.de tags: trunk | |
2011-08-04
| ||
16:59 | Adjust to recent ObjFW changes. check-in: 8242aaa109 user: js tags: trunk | |
Changes
Modified src/XMPPSCRAMAuth.m from [3fc8922722] to [3d74f25717].
︙ | ︙ | |||
372 373 374 375 376 377 378 | - (uint8_t*)XMPP_HMACWithKey: (OFDataArray*)key data: (OFDataArray*)data { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFDataArray *k = [OFDataArray dataArrayWithItemSize: 1]; size_t i, kSize, blockSize = [hashType blockSize]; | | | | | | | < < | < < > > > > | | | > | | | | < | | < < | < > | < < < < < < > | | 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 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 430 431 432 | - (uint8_t*)XMPP_HMACWithKey: (OFDataArray*)key data: (OFDataArray*)data { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFDataArray *k = [OFDataArray dataArrayWithItemSize: 1]; size_t i, kSize, blockSize = [hashType blockSize]; uint8_t *kI = NULL, *kO = NULL; OFHash *hashI, *hashO; if ([key itemSize] * [key count] > blockSize) { hashI = [[[hashType alloc] init] autorelease]; [hashI updateWithBuffer: [key cArray] length: [key itemSize] * [key count]]; [k addNItems: [hashType digestSize] fromCArray: [hashI digest]]; } else [k addNItems: [key itemSize] * [key count] fromCArray: [key cArray]]; @try { kI = [self allocMemoryWithSize: blockSize]; kO = [self allocMemoryWithSize: blockSize]; kSize = [k count]; memcpy(kI, [k cArray], kSize); memset(kI + kSize, 0, blockSize - kSize); memcpy(kO, kI, blockSize); for (i = 0; i < blockSize; i++) { kI[i] ^= HMAC_IPAD; kO[i] ^= HMAC_OPAD; } hashI = [[[hashType alloc] init] autorelease]; [hashI updateWithBuffer: (char*)kI length: blockSize]; [hashI updateWithBuffer: [data cArray] length: [data itemSize] * [data count]]; hashO = [[hashType alloc] init]; [hashO updateWithBuffer: (char*)kO length: blockSize]; [hashO updateWithBuffer: (char*)[hashI digest] length: [hashType digestSize]]; } @finally { [self freeMemory: kI]; [self freeMemory: kO]; } [pool release]; [hashO autorelease]; return [hashO digest]; } - (OFDataArray*)XMPP_hiWithData: (OFDataArray *)str salt: (OFDataArray *)salt_ iterationCount: (intmax_t)i { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; |
︙ | ︙ |