Comment: | OFSecureData: Add allowsSwappableMemory property
With this property, it's possible to specify whether the memory should |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
e629dc83a9aea147800ee650307233aa |
User & Date: | js on 2019-12-27 00:41:54 |
Other Links: | manifest | tags |
2019-12-27
| ||
21:43 | OFSecureData: Fix #ifdefs check-in: d5c4dedada user: js tags: trunk | |
00:41 | OFSecureData: Add allowsSwappableMemory property check-in: e629dc83a9 user: js tags: trunk | |
2019-12-15
| ||
14:42 | Make +[OFSecureData isSecure] per instance check-in: 60caadeb5d user: js tags: trunk | |
Modified src/OFCryptoHash.h from [b402221532] to [ef88b31b2d].
︙ | |||
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | + + + + + - + - + + + + + + + + + + + | @property (readonly, nonatomic) size_t digestSize; /*! * @brief The block size of the cryptographic hash, in bytes. */ @property (readonly, nonatomic) size_t blockSize; /*! * @brief Whether data may be stored in swappable memory. */ @property (readonly, nonatomic) bool allowsSwappableMemory; /*! * @brief A boolean whether the hash has already been calculated. */ @property (readonly, nonatomic, getter=isCalculated) bool calculated; /*! * @brief A buffer containing the cryptographic hash. * * The size of the buffer depends on the hash used. The buffer is part of the * receiver's memory pool. */ @property (readonly, nonatomic) const unsigned char *digest OF_RETURNS_INNER_POINTER; /*! * @brief Creates a new cryptographic hash. * |
︙ |
Modified src/OFData+CryptoHashing.m from [0fcbff4bbf] to [8d65c7cb3f].
︙ | |||
30 31 32 33 34 35 36 | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | - + + | int _OFData_CryptoHashing_reference; @implementation OFData (CryptoHashing) - (OFString *)of_cryptoHashWithClass: (Class <OFCryptoHash>)class { void *pool = objc_autoreleasePoolPush(); |
︙ |
Modified src/OFGZIPStream.m from [f365c42bc2] to [d38773fa18].
︙ | |||
47 48 49 50 51 52 53 | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | - + | { self = [super init]; @try { if (![mode isEqual: @"r"]) @throw [OFNotImplementedException exceptionWithSelector: _cmd |
︙ |
Modified src/OFHMAC.h from [c85420d05a] to [5ff44e63ad].
︙ | |||
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 | 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 82 83 84 85 86 87 88 89 90 | + + + + + + + - + + + + | * * @brief A class which provides methods to calculate an HMAC. */ OF_SUBCLASSING_RESTRICTED @interface OFHMAC: OFObject { Class <OFCryptoHash> _hashClass; bool _allowsSwappableMemory; id <OFCryptoHash> _Nullable _outerHash, _innerHash; id <OFCryptoHash> _Nullable _outerHashCopy, _innerHashCopy; bool _calculated; } /*! * @brief The class for the cryptographic hash used by the HMAC. */ @property (readonly, nonatomic) Class <OFCryptoHash> hashClass; /*! * @brief Whether data may be stored in swappable memory. */ @property (readonly, nonatomic) bool allowsSwappableMemory; /*! * @brief A buffer containing the HMAC. * * The size of the buffer depends on the hash used. The buffer is part of the * receiver's memory pool. */ @property (readonly, nonatomic) const unsigned char *digest OF_RETURNS_INNER_POINTER; /*! * @brief The size of the digest. */ @property (readonly, nonatomic) size_t digestSize; /*! * @brief Returns a new OFHMAC with the specified hashing algorithm. * * @param hashClass The class of the hashing algorithm * @param allowsSwappableMemory Whether data may be stored in swappable memory * @return A new, autoreleased OFHMAC */ |
︙ |
Modified src/OFHMAC.m from [c9ae48fd28] to [8b2647f9b8].
︙ | |||
21 22 23 24 25 26 27 28 29 30 | 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | + + - + + + + + - - + + + + + + - + + + | #import "OFSecureData.h" #import "OFHashAlreadyCalculatedException.h" #import "OFInvalidArgumentException.h" @implementation OFHMAC @synthesize hashClass = _hashClass; @synthesize allowsSwappableMemory = _allowsSwappableMemory; + (instancetype)HMACWithHashClass: (Class <OFCryptoHash>)class allowsSwappableMemory: (bool)allowsSwappableMemory { |
︙ | |||
93 94 95 96 97 98 99 | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | - - + + + + | memset(innerKeyPadItems + length, 0, blockSize - length); for (size_t i = 0; i < blockSize; i++) { outerKeyPadItems[i] ^= 0x5C; innerKeyPadItems[i] ^= 0x36; } |
︙ |
Modified src/OFMD5Hash.h from [7bc2b1da3f] to [dd0468f75a].
︙ | |||
35 36 37 38 39 40 41 42 43 44 45 46 | 35 36 37 38 39 40 41 42 43 44 45 46 47 | + | uint64_t bits; union of_md5_hash_buffer { uint8_t bytes[64]; uint32_t words[16]; } buffer; size_t bufferLength; } *_iVars; bool _allowsSwappableMemory; bool _calculated; } @end OF_ASSUME_NONNULL_END |
Modified src/OFMD5Hash.m from [fabee7cd05] to [cf3dfa1284].
︙ | |||
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | + - + - + + - + - + + + + + + + + | state[1] += new[1]; state[2] += new[2]; state[3] += new[3]; } @implementation OFMD5Hash @synthesize calculated = _calculated; @synthesize allowsSwappableMemory = _allowsSwappableMemory; + (size_t)digestSize { return DIGEST_SIZE; } + (size_t)blockSize { return BLOCK_SIZE; } |
︙ | |||
182 183 184 185 186 187 188 189 190 191 192 193 194 195 | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | + | - (id)copy { OFMD5Hash *copy = [[OFMD5Hash alloc] of_init]; copy->_iVarsData = [_iVarsData copy]; copy->_iVars = copy->_iVarsData.mutableItems; copy->_allowsSwappableMemory = _allowsSwappableMemory; copy->_calculated = _calculated; return copy; } - (void)of_resetState { |
︙ |
Modified src/OFRIPEMD160Hash.h from [8064412ceb] to [a2ac38baf0].
︙ | |||
35 36 37 38 39 40 41 42 43 44 45 46 | 35 36 37 38 39 40 41 42 43 44 45 46 47 | + | uint64_t bits; union of_ripemd160_hash_buffer { uint8_t bytes[64]; uint32_t words[16]; } buffer; size_t bufferLength; } *_iVars; bool _allowsSwappableMemory; bool _calculated; } @end OF_ASSUME_NONNULL_END |
Modified src/OFRIPEMD160Hash.m from [03939c1eca] to [0b670f115d].
︙ | |||
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | + - + - + + - + - + + + + + + + + | state[3] = state[4] + new[0] + new2[1]; state[4] = state[0] + new[1] + new2[2]; state[0] = new2[3]; } @implementation OFRIPEMD160Hash @synthesize calculated = _calculated; @synthesize allowsSwappableMemory = _allowsSwappableMemory; + (size_t)digestSize { return DIGEST_SIZE; } + (size_t)blockSize { return BLOCK_SIZE; } |
︙ | |||
196 197 198 199 200 201 202 203 204 205 206 207 208 209 | 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | + | - (id)copy { OFRIPEMD160Hash *copy = [[OFRIPEMD160Hash alloc] of_init]; copy->_iVarsData = [_iVarsData copy]; copy->_iVars = copy->_iVarsData.mutableItems; copy->_allowsSwappableMemory = _allowsSwappableMemory; copy->_calculated = _calculated; return copy; } - (void)of_resetState { |
︙ |
Modified src/OFSHA1Hash.h from [f45a134709] to [a51d9c4a1d].
︙ | |||
35 36 37 38 39 40 41 42 43 44 45 46 | 35 36 37 38 39 40 41 42 43 44 45 46 47 | + | uint64_t bits; union of_sha1_hash_buffer { uint8_t bytes[64]; uint32_t words[80]; } buffer; size_t bufferLength; } *_iVars; bool _allowsSwappableMemory; bool _calculated; } @end OF_ASSUME_NONNULL_END |
Modified src/OFSHA1Hash.m from [0aa83b56cc] to [3d6aedc638].
︙ | |||
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | + - + - + + - + - + + + + + + + + | state[2] += new[2]; state[3] += new[3]; state[4] += new[4]; } @implementation OFSHA1Hash @synthesize calculated = _calculated; @synthesize allowsSwappableMemory = _allowsSwappableMemory; + (size_t)digestSize { return DIGEST_SIZE; } + (size_t)blockSize { return BLOCK_SIZE; } |
︙ | |||
156 157 158 159 160 161 162 163 164 165 166 167 168 169 | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | + | - (id)copy { OFSHA1Hash *copy = [[OFSHA1Hash alloc] of_init]; copy->_iVarsData = [_iVarsData copy]; copy->_iVars = copy->_iVarsData.mutableItems; copy->_allowsSwappableMemory = _allowsSwappableMemory; copy->_calculated = _calculated; return copy; } - (void)of_resetState { |
︙ |
Modified src/OFSHA224Or256Hash.h from [e39de03a34] to [b17aa63913].
︙ | |||
37 38 39 40 41 42 43 44 45 46 47 48 49 | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | + | union of_sha224_or_256_hash_buffer { uint8_t bytes[64]; uint32_t words[64]; } buffer; size_t bufferLength; } *_iVars; @private bool _allowsSwappableMemory; bool _calculated; OF_RESERVE_IVARS(4) } @end OF_ASSUME_NONNULL_END |
Modified src/OFSHA224Or256Hash.m from [01743762af] to [dbb6d31956].
︙ | |||
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | + - + - + + - + - + + + + + + + + | state[5] += new[5]; state[6] += new[6]; state[7] += new[7]; } @implementation OFSHA224Or256Hash @synthesize calculated = _calculated; @synthesize allowsSwappableMemory = _allowsSwappableMemory; + (size_t)digestSize { OF_UNRECOGNIZED_SELECTOR } + (size_t)blockSize { return BLOCK_SIZE; } |
︙ | |||
182 183 184 185 186 187 188 189 190 191 192 193 194 195 | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | + | - (id)copy { OFSHA224Or256Hash *copy = [[[self class] alloc] of_init]; copy->_iVarsData = [_iVarsData copy]; copy->_iVars = copy->_iVarsData.mutableItems; copy->_allowsSwappableMemory = _allowsSwappableMemory; copy->_calculated = _calculated; return copy; } - (void)updateWithBuffer: (const void *)buffer_ length: (size_t)length |
︙ |
Modified src/OFSHA384Or512Hash.h from [10ea7023d1] to [e24eeb0338].
︙ | |||
37 38 39 40 41 42 43 44 45 46 47 48 49 | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | + | union of_sha384_or_512_hash_buffer { uint8_t bytes[128]; uint64_t words[80]; } buffer; size_t bufferLength; } *_iVars; @private bool _allowsSwappableMemory; bool _calculated; OF_RESERVE_IVARS(4) } @end OF_ASSUME_NONNULL_END |
Modified src/OFSHA384Or512Hash.m from [b218fc3078] to [aa0c17c5cb].
︙ | |||
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | + - + - + + - + - + + + + + + + + | state[5] += new[5]; state[6] += new[6]; state[7] += new[7]; } @implementation OFSHA384Or512Hash @synthesize calculated = _calculated; @synthesize allowsSwappableMemory = _allowsSwappableMemory; + (size_t)digestSize { OF_UNRECOGNIZED_SELECTOR } + (size_t)blockSize { return BLOCK_SIZE; } |
︙ | |||
193 194 195 196 197 198 199 200 201 202 203 204 205 206 | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | + | - (id)copy { OFSHA384Or512Hash *copy = [[[self class] alloc] of_init]; copy->_iVarsData = [_iVarsData copy]; copy->_iVars = copy->_iVarsData.mutableItems; copy->_allowsSwappableMemory = _allowsSwappableMemory; copy->_calculated = _calculated; return copy; } - (void)updateWithBuffer: (const void *)buffer_ length: (size_t)length |
︙ |
Modified src/OFSecureData.h from [95d6612ecd] to [7ba2cee122].
︙ | |||
30 31 32 33 34 35 36 | 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | - + - + - + - + - - + + - - + + - + - + + + - + + + + - + + + + + + + + + + + + + + - + + - + + + + - + + + + + + + + + + + + + + + + + + + + + + + | * deallocated. Check the @ref swappable property to see whether a * particular OFSecureData was allocated in swappable memory. */ OF_SUBCLASSING_RESTRICTED @interface OFSecureData: OFData { struct page *_page; |
︙ |
Modified src/OFSecureData.m from [0b2ff22574] to [800160da50].
︙ | |||
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | + + - - + - + - + - + - + - - + - + - - + - - + + - - - + - - - + - - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + | #import "OFSecureData.h" #import "OFString.h" #import "OFSystemInfo.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFNotImplementedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #ifdef OF_HAVE_THREADS # import "tlskey.h" #endif #define CHUNK_SIZE 16 #if defined(HAVE_MMAP) && defined(HAVE_MLOCK) && defined(MAP_ANON) struct page { struct page *next, *previous; void *map; |
︙ | |||
259 260 261 262 263 264 265 266 267 | 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | + - + - + + - + - + - + - + - + + + + + + - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | chunkIndex = ((uintptr_t)pointer - (uintptr_t)page->page) / CHUNK_SIZE; of_explicit_memset(pointer, 0, bytes); for (size_t i = 0; i < chunks; i++) of_bitset_clear(page->map, chunkIndex + i); } #endif @implementation OFSecureData |
︙ | |||
342 343 344 345 346 347 348 | 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 | - - + - - - + - + + + + + + + - + - + + - + - + | } + (instancetype)dataWithBase64EncodedString: (OFString *)string { OF_UNRECOGNIZED_SELECTOR } |
︙ | |||
392 393 394 395 396 397 398 | 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | - - + + + + + + + + + + + + - + - - - - + + + + + + - + - - - - + - - - - - - | count * itemSize); if (_items == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: count * itemSize]; } |
︙ | |||
464 465 466 467 468 469 470 | 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 | + + + + - + - - - - - - - + + + + + + + - - + + + + | - (instancetype)initWithSerialization: (OFXMLElement *)element { OF_INVALID_INIT_METHOD } - (void)dealloc { [self zero]; #if defined(HAVE_MMAP) && defined(HAVE_MLOCK) && defined(MAP_ANON) if (!_allowsSwappableMemory) { |
︙ | |||
500 501 502 503 504 505 506 | 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 | - - - + + + + + + + + - - - + + + + + + + + | - (void)zero { of_explicit_memset(_items, 0, _count * _itemSize); } - (id)copy { |
︙ |
Modified src/OFString+CryptoHashing.m from [d7c7a2d4d1] to [2bc09b0ad0].
︙ | |||
29 30 31 32 33 34 35 | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | - + + | int _OFString_CryptoHashing_reference; @implementation OFString (CryptoHashing) - (OFString *)of_cryptoHashWithClass: (Class <OFCryptoHash>)class { void *pool = objc_autoreleasePoolPush(); |
︙ |
Modified src/OFZIPArchive.m from [88d0400634] to [f3370d3321].
︙ | |||
750 751 752 753 754 755 756 | 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 | - + | case OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_DEFLATE64: _decompressedStream = [[OFInflate64Stream alloc] initWithStream: stream]; break; default: @throw [OFNotImplementedException exceptionWithSelector: _cmd |
︙ |
Modified src/exceptions/OFNotImplementedException.h from [260f8e8c55] to [4e93960456].
︙ | |||
25 26 27 28 29 30 31 | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | - + | * * @brief An exception indicating that a method or part of it is not * implemented. */ @interface OFNotImplementedException: OFException { SEL _selector; |
︙ | |||
48 49 50 51 52 53 54 | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | - + - + | * @brief Creates a new, autoreleased not implemented exception. * * @param selector The selector which is not or not fully implemented * @param object The object which does not (fully) implement the selector * @return A new, autoreleased not implemented exception */ + (instancetype)exceptionWithSelector: (SEL)selector |
Modified src/exceptions/OFNotImplementedException.m from [cea8613a88] to [6f2dd90cb4].
︙ | |||
56 57 58 59 60 61 62 | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | + - - - + + + + + + + + + | [_object release]; [super dealloc]; } - (OFString *)description { if (_object != nil) |
Modified src/pbkdf2.h from [81ac4cfe1f] to [5413ab5910].
︙ | |||
46 47 48 49 50 51 52 53 54 55 56 | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | + - + | * @param salt The salt to derive a key with * @param saltLength The length of the salt * @param password The password to derive a key from * @param passwordLength The length of the password * @param key The buffer to write the key to * @param keyLength The desired length for the derived key (key needs to have * enough storage) * @param allowsSwappableMemory Whether data may be stored in swappable memory */ extern void of_pbkdf2(OFHMAC *HMAC, size_t iterations, const unsigned char *salt, size_t saltLength, const char *password, size_t passwordLength, |
Modified src/pbkdf2.m from [8a2fd39e02] to [7efc688caa].
︙ | |||
27 28 29 30 31 32 33 | 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, |
︙ |
Modified src/scrypt.h from [79a5b0015a] to [bc4d227940].
︙ | |||
37 38 39 40 41 42 43 | 37 38 39 40 41 42 43 44 45 46 47 48 49 | - + | extern void of_scrypt_block_mix(uint32_t *output, const uint32_t *input, size_t blockSize); extern void of_scrypt_romix(uint32_t *buffer, size_t blockSize, size_t costFactor, uint32_t *tmp); extern void of_scrypt(size_t blockSize, size_t costFactor, size_t parallelization, const unsigned char *salt, size_t saltLength, const char *password, size_t passwordLength, |
Modified src/scrypt.m from [ec228bf0de] to [1e18b4aacd].
︙ | |||
15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | + | * file. */ #include "config.h" #import "OFHMAC.h" #import "OFSHA256Hash.h" #import "OFSecureData.h" #import "OFInvalidArgumentException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "scrypt.h" #import "pbkdf2.h" |
︙ | |||
137 138 139 140 141 142 143 | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | - + - + + + - + - - + - - - + + + + - + - - - + + - - - + + + - + + + - + + - - + + - - + + + - - - + - - - + - | memcpy(tmp, buffer, 128 * blockSize); } } void of_scrypt(size_t blockSize, size_t costFactor, size_t parallelization, const unsigned char *salt, size_t saltLength, const char *password, size_t passwordLength, |
Modified tests/OFHMACTests.m from [f9913e8e72] to [6c35317f46].
︙ | |||
55 56 57 58 59 60 61 | 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 82 83 84 85 | - + + - + + - + + - + + - + + - + + | void *pool = objc_autoreleasePoolPush(); OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; OFHMAC *HMAC_MD5, *HMAC_SHA1, *HMAC_RMD160; OFHMAC *HMAC_SHA256, *HMAC_SHA384, *HMAC_SHA512; TEST(@"+[HMACWithHashClass:] with MD5", |
︙ |
Modified tests/OFMD5HashTests.m from [f4ae6e53d2] to [84a8c85775].
︙ | |||
30 31 32 33 34 35 36 | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | + - + | - (void)MD5HashTests { void *pool = objc_autoreleasePoolPush(); OFMD5Hash *md5, *copy; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", |
︙ |
Modified tests/OFRIPEMD160HashTests.m from [0fcea6bf49] to [b494544df7].
︙ | |||
31 32 33 34 35 36 37 | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | + - + + | - (void)RIPEMD160HashTests { void *pool = objc_autoreleasePoolPush(); OFRIPEMD160Hash *rmd160, *copy; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", |
︙ |
Modified tests/OFSHA1HashTests.m from [24505cc96a] to [314899ff02].
︙ | |||
31 32 33 34 35 36 37 | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | + - + | - (void)SHA1HashTests { void *pool = objc_autoreleasePoolPush(); OFSHA1Hash *sha1, *copy; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", |
︙ |
Modified tests/OFSHA224HashTests.m from [892f9e3b00] to [1766086b41].
︙ | |||
31 32 33 34 35 36 37 | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | + - + | - (void)SHA224HashTests { void *pool = objc_autoreleasePoolPush(); OFSHA224Hash *sha224, *copy; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", |
︙ |
Modified tests/OFSHA256HashTests.m from [56e7b8b3e2] to [98498cfef0].
︙ | |||
31 32 33 34 35 36 37 | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | + - + | - (void)SHA256HashTests { void *pool = objc_autoreleasePoolPush(); OFSHA256Hash *sha256, *copy; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", |
︙ |
Modified tests/OFSHA384HashTests.m from [2c7782d9c6] to [c095da4e9b].
︙ | |||
32 33 34 35 36 37 38 | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | + - + | - (void)SHA384HashTests { void *pool = objc_autoreleasePoolPush(); OFSHA384Hash *sha384, *copy; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", |
︙ |
Modified tests/OFSHA512HashTests.m from [24ed9c7de8] to [cf1a33c46d].
︙ | |||
33 34 35 36 37 38 39 | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | + - + | - (void)SHA512HashTests { void *pool = objc_autoreleasePoolPush(); OFSHA512Hash *sha512, *copy; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"r"]; TEST(@"+[cryptoHashWithAllowsSwappableMemory:]", |
︙ |
Modified tests/PBKDF2Tests.m from [390e84b82b] to [9121c312db].
︙ | |||
23 24 25 26 27 28 29 | 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 | - + + - + - + - + - + - + - + | static OFString *module = @"PBKDF2"; @implementation TestsAppDelegate (PBKDF2Tests) - (void)PBKDF2Tests { void *pool = objc_autoreleasePoolPush(); |
Modified tests/ScryptTests.m from [f9dfdefc9d] to [970ef4d90d].
︙ | |||
152 153 154 155 156 157 158 | 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | - - + + - + - + - + | TEST(@"ROMix", R(memcpy(ROMixBuffer, ROMixInput, 128)) && R(of_scrypt_romix(ROMixBuffer, 1, 16, ROMixTmp)) && memcmp(ROMixBuffer, ROMixOutput, 128) == 0) TEST(@"scrypt test vector #1", |
Modified utils/ofhash/OFHash.m from [95a4c46a8f] to [cb5b9de46c].
︙ | |||
119 120 121 122 123 124 125 | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | - - - - - - - - - - - - - - - | } [OFApplication terminateWithStatus: 1]; break; } } |
︙ | |||
162 163 164 165 166 167 168 169 170 171 172 173 174 175 | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | + + + + + + + + + + + + + + + + + + + + + | !calculateSHA224 && !calculateSHA256 && !calculateSHA384 && !calculateSHA512) help(); if (optionsParser.remainingArguments.count < 1) help(); if (calculateMD5) MD5Hash = [OFMD5Hash cryptoHashWithAllowsSwappableMemory: true]; if (calculateRIPEMD160) RIPEMD160Hash = [OFRIPEMD160Hash cryptoHashWithAllowsSwappableMemory: true]; if (calculateSHA1) SHA1Hash = [OFSHA1Hash cryptoHashWithAllowsSwappableMemory: true]; if (calculateSHA224) SHA224Hash = [OFSHA224Hash cryptoHashWithAllowsSwappableMemory: true]; if (calculateSHA256) SHA256Hash = [OFSHA256Hash cryptoHashWithAllowsSwappableMemory: true]; if (calculateSHA384) SHA384Hash = [OFSHA384Hash cryptoHashWithAllowsSwappableMemory: true]; if (calculateSHA512) SHA512Hash = [OFSHA512Hash cryptoHashWithAllowsSwappableMemory: true]; for (OFString *path in optionsParser.remainingArguments) { void *pool = objc_autoreleasePoolPush(); OFStream *file; if ([path isEqual: @"-"]) file = of_stdin; else { |
︙ |