Differences From Artifact [1155a2350b]:
- File NewPasswordGenerator.m — part of check-in [a703cf8d62] at 2021-03-14 00:17:32 on branch trunk — Update copyright (user: js, size: 3249) [annotate] [blame] [check-ins using]
To Artifact [85e48149ff]:
- File
NewPasswordGenerator.m
— part of check-in
[007bd9985e]
at
2021-03-21 11:03:01
on branch trunk
— Allow swappable memory
Most OSes and/or ulimits do not allow allocating such large amounts of
unswappable memory. (user: js, size: 3246) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
51 52 53 54 55 56 57 | [siteHash updateWithBuffer: _site.UTF8String length: _site.UTF8StringLength]; [_output release]; _output = nil; _output = [[OFSecureData alloc] initWithCount: _length + 1 | | | | | 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 | [siteHash updateWithBuffer: _site.UTF8String length: _site.UTF8StringLength]; [_output release]; _output = nil; _output = [[OFSecureData alloc] initWithCount: _length + 1 allowsSwappableMemory: true]; passphraseLength = combinedPassphraseLength = _passphrase.count - 1; if (_keyFile != nil) { if (SIZE_MAX - combinedPassphraseLength < _keyFile.count) @throw [OFOutOfRangeException exception]; combinedPassphraseLength += _keyFile.count; } combinedPassphrase = [OFSecureData dataWithCount: combinedPassphraseLength allowsSwappableMemory: true]; combinedPassphraseItems = combinedPassphrase.mutableItems; memcpy(combinedPassphraseItems, _passphrase.items, passphraseLength); if (_keyFile != nil) memcpy(combinedPassphraseItems + passphraseLength, _keyFile.items, _keyFile.count); outputItems = _output.mutableItems; of_scrypt((of_scrypt_parameters_t){ .blockSize = 8, .costFactor = 524288, .parallelization = 2, .salt = siteHash.digest, .saltLength = [siteHash.class digestSize], .password = combinedPassphraseItems, .passwordLength = combinedPassphraseLength, .key = outputItems, .keyLength = _length, .allowsSwappableMemory = true }); for (size_t i = 0; i < _length; i++) outputItems[i] = "123456789" "abcdefghijkmnopqrstuvwxyz" "ABCDEFGHJKLMNPQRSTUVWXYZ" "#$%-=?"[outputItems[i] & 0x3F]; } @end |