Overview
Comment: | Add support for using a keyfile |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
f13f84c5b98e57ca35007dd7ec4c22cf |
User & Date: | js on 2017-11-26 15:01:01 |
Other Links: | manifest | tags |
Context
2017-11-26
| ||
19:19 | iOS: A few code modernizations check-in: 6205c4feae user: js tags: trunk | |
15:01 | Add support for using a keyfile check-in: f13f84c5b9 user: js tags: trunk | |
2017-10-21
| ||
20:07 | iOS: Allow all orientations check-in: 1a36714841 user: js tags: trunk | |
Changes
Modified LegacyPasswordGenerator.h from [2ef1978fd7] to [8bad498857].
︙ | |||
22 23 24 25 26 27 28 29 30 31 32 | 22 23 24 25 26 27 28 29 30 31 32 33 | + | #import "PasswordGenerator.h" @interface LegacyPasswordGenerator: OFObject <PasswordGenerator> { size_t _length; OFString *_site; OFData *_keyfile; const char *_passphrase; unsigned char *_output; } @end |
Modified LegacyPasswordGenerator.m from [9b014f5aed] to [bea47eab32].
︙ | |||
19 20 21 22 23 24 25 | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | - + + | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #import "LegacyPasswordGenerator.h" @implementation LegacyPasswordGenerator |
︙ | |||
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | 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 | + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + | { return _length; } - (void)derivePassword { OFSHA256Hash *siteHash = [OFSHA256Hash cryptoHash]; size_t passphraseLength, combinedPassphraseLength; char *combinedPassphrase; [siteHash updateWithBuffer: [_site UTF8String] length: [_site UTF8StringLength]]; if (_output != NULL) { of_explicit_memset(_output, 0, _length); [self freeMemory: _output]; } _output = [self allocMemoryWithSize: _length + 1]; passphraseLength = combinedPassphraseLength = strlen(_passphrase); if (_keyfile != nil) { if (SIZE_MAX - combinedPassphraseLength < [_keyfile count]) @throw [OFOutOfRangeException exception]; combinedPassphraseLength += [_keyfile count]; } if ((combinedPassphrase = malloc(combinedPassphraseLength)) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: combinedPassphraseLength]; @try { memcpy(combinedPassphrase, _passphrase, passphraseLength); if (_keyfile != nil) memcpy(combinedPassphrase + passphraseLength, [_keyfile items], [_keyfile count]); |
︙ |
Modified NewPasswordGenerator.h from [fd9b5734ae] to [47a42d209c].
︙ | |||
22 23 24 25 26 27 28 29 30 31 32 | 22 23 24 25 26 27 28 29 30 31 32 33 | + | #import "PasswordGenerator.h" @interface NewPasswordGenerator: OFObject <PasswordGenerator> { size_t _length; OFString *_site; OFData *_keyfile; const char *_passphrase; unsigned char *_output; } @end |
Modified NewPasswordGenerator.m from [6858c9a024] to [ecdd3d4c11].
︙ | |||
19 20 21 22 23 24 25 | 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 82 83 84 85 86 87 88 89 90 91 92 93 | - - + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #import "NewPasswordGenerator.h" @implementation NewPasswordGenerator |
Modified PasswordGenerator.h from [a21fea91c9] to [20269debc0].
︙ | |||
19 20 21 22 23 24 25 | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | - - - - + + + + + | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #import <ObjFW/ObjFW.h> @protocol PasswordGenerator |
Modified ScryptPWGen.m from [c48c7fa7a2] to [9af2fb9acc].
︙ | |||
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 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 | + - + + - + - + + + | [OFApplication programName]]; if (verbose) [output writeString: @"\n" @"Options:\n" @" -h --help Show this help\n" @" -k --keyfile Use the specified key file\n" @" -l --length Length for the derived password\n" @" -L --legacy Use the legacy algorithm " @"(compatible with scrypt-genpass)\n" @" -r --repeat Repeat input\n"]; } @implementation ScryptPWGen - (void)applicationDidFinishLaunching { |
︙ | |||
108 109 110 111 112 113 114 | 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 | - + - + - + - + + + + + - + - | } id <PasswordGenerator> generator = (_legacy ? [LegacyPasswordGenerator generator] : [NewPasswordGenerator generator]); generator.site = [[optionsParser remainingArguments] firstObject]; |
︙ | |||
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 | 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 | + + + + | } @finally { of_explicit_memset(passphraseCopy, 0, strlen(passphraseCopy)); free(passphraseCopy); } } generator.keyfile = keyfile; generator.passphrase = passphrase; [generator derivePassword]; @try { [of_stdout writeBuffer: generator.output length: generator.length]; [of_stdout writeBuffer: "\n" length: 1]; } @finally { of_explicit_memset(generator.output, 0, generator.length); } } @finally { of_explicit_memset(passphrase, 0, strlen(passphrase)); if (keyfile != nil) of_explicit_memset([keyfile items], 0, [keyfile count]); } [OFApplication terminate]; } @end |