Differences From Artifact [8a2fd39e02]:
- File src/pbkdf2.m — part of check-in [bceb7ed4c9] at 2019-03-08 00:35:48 on branch trunk — Use dot syntax (user: js, size: 2932) [annotate] [blame] [check-ins using]
To Artifact [7efc688caa]:
- File
src/pbkdf2.m
— part of check-in
[e629dc83a9]
at
2019-12-27 00:41:54
on branch trunk
— OFSecureData: Add allowsSwappableMemory property
With this property, it's possible to specify whether the memory should
be protected from swapping or not. This makes it easier for e.g. the
crypto hash classes: They can now just always use OFSecureData without
wasting unswappable memory if it's not needed. (user: js, size: 3125) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
27 28 29 30 31 32 33 | #import "OFOutOfRangeException.h" #import "pbkdf2.h" void of_pbkdf2(OFHMAC *HMAC, size_t iterations, const unsigned char *salt, size_t saltLength, const char *password, size_t passwordLength, | | | > > | > > | > | 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 | #import "OFOutOfRangeException.h" #import "pbkdf2.h" void of_pbkdf2(OFHMAC *HMAC, size_t iterations, const unsigned char *salt, size_t saltLength, const char *password, size_t passwordLength, unsigned char *key, size_t keyLength, bool allowsSwappableMemory) { void *pool = objc_autoreleasePoolPush(); size_t blocks, digestSize = HMAC.digestSize; OFSecureData *buffer = [OFSecureData dataWithCount: digestSize allowsSwappableMemory: allowsSwappableMemory]; OFSecureData *digest = [OFSecureData dataWithCount: digestSize allowsSwappableMemory: allowsSwappableMemory]; unsigned char *bufferItems = buffer.mutableItems; unsigned char *digestItems = digest.mutableItems; OFSecureData *extendedSalt; unsigned char *extendedSaltItems; if (HMAC == nil || iterations == 0 || salt == NULL || password == NULL || key == NULL || keyLength == 0) @throw [OFInvalidArgumentException exception]; blocks = keyLength / digestSize; if (keyLength % digestSize != 0) blocks++; if (saltLength > SIZE_MAX - 4 || blocks > UINT32_MAX) @throw [OFOutOfRangeException exception]; extendedSalt = [OFSecureData dataWithCount: saltLength + 4 allowsSwappableMemory: allowsSwappableMemory]; extendedSaltItems = extendedSalt.mutableItems; @try { uint32_t i = OF_BSWAP32_IF_LE(1); [HMAC setKey: password length: passwordLength]; |
︙ | ︙ |