Adjust to ObjFW changes
FossilOrigin-Name: aec6746a96f92e9bed68663cf775bf229bcdb3930f4a689b3b8b68c27fe29868
This commit is contained in:
parent
6df046ff50
commit
3bb17150aa
3 changed files with 19 additions and 22 deletions
|
@ -50,7 +50,7 @@ showHelp(OFStream *output, bool verbose)
|
||||||
- (void)applicationDidFinishLaunching
|
- (void)applicationDidFinishLaunching
|
||||||
{
|
{
|
||||||
OFString *keyFilePath, *lengthString;
|
OFString *keyFilePath, *lengthString;
|
||||||
const of_options_parser_option_t options[] = {
|
const OFOptionsParserOption options[] = {
|
||||||
{ 'h', @"help", 0, NULL, NULL },
|
{ 'h', @"help", 0, NULL, NULL },
|
||||||
{ 'k', @"keyfile", 1, NULL, &keyFilePath },
|
{ 'k', @"keyfile", 1, NULL, &keyFilePath },
|
||||||
{ 'l', @"length", 1, NULL, &lengthString },
|
{ 'l', @"length", 1, NULL, &lengthString },
|
||||||
|
@ -60,7 +60,7 @@ showHelp(OFStream *output, bool verbose)
|
||||||
};
|
};
|
||||||
OFOptionsParser *optionsParser =
|
OFOptionsParser *optionsParser =
|
||||||
[OFOptionsParser parserWithOptions: options];
|
[OFOptionsParser parserWithOptions: options];
|
||||||
of_unichar_t option;
|
OFUnichar option;
|
||||||
OFMutableData *keyFile = nil;
|
OFMutableData *keyFile = nil;
|
||||||
OFString *prompt;
|
OFString *prompt;
|
||||||
const char *promptCString;
|
const char *promptCString;
|
||||||
|
@ -71,19 +71,19 @@ showHelp(OFStream *output, bool verbose)
|
||||||
while ((option = [optionsParser nextOption]) != '\0') {
|
while ((option = [optionsParser nextOption]) != '\0') {
|
||||||
switch (option) {
|
switch (option) {
|
||||||
case 'h':
|
case 'h':
|
||||||
showHelp(of_stdout, true);
|
showHelp(OFStdOut, true);
|
||||||
|
|
||||||
[OFApplication terminate];
|
[OFApplication terminate];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ':':
|
case ':':
|
||||||
if (optionsParser.lastLongOption != nil)
|
if (optionsParser.lastLongOption != nil)
|
||||||
[of_stderr writeFormat:
|
[OFStdErr writeFormat:
|
||||||
@"%@: Argument for option --%@ missing\n",
|
@"%@: Argument for option --%@ missing\n",
|
||||||
[OFApplication programName],
|
[OFApplication programName],
|
||||||
optionsParser.lastLongOption];
|
optionsParser.lastLongOption];
|
||||||
else
|
else
|
||||||
[of_stderr writeFormat:
|
[OFStdErr writeFormat:
|
||||||
@"%@: Argument for option -%C missing\n",
|
@"%@: Argument for option -%C missing\n",
|
||||||
[OFApplication programName],
|
[OFApplication programName],
|
||||||
optionsParser.lastOption];
|
optionsParser.lastOption];
|
||||||
|
@ -92,12 +92,12 @@ showHelp(OFStream *output, bool verbose)
|
||||||
break;
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
if (optionsParser.lastLongOption != nil)
|
if (optionsParser.lastLongOption != nil)
|
||||||
[of_stderr writeFormat:
|
[OFStdErr writeFormat:
|
||||||
@"%@: Unknown option: --%@\n",
|
@"%@: Unknown option: --%@\n",
|
||||||
[OFApplication programName],
|
[OFApplication programName],
|
||||||
optionsParser.lastLongOption];
|
optionsParser.lastLongOption];
|
||||||
else
|
else
|
||||||
[of_stderr writeFormat:
|
[OFStdErr writeFormat:
|
||||||
@"%@: Unknown option: -%C\n",
|
@"%@: Unknown option: -%C\n",
|
||||||
[OFApplication programName],
|
[OFApplication programName],
|
||||||
optionsParser.lastOption];
|
optionsParser.lastOption];
|
||||||
|
@ -108,7 +108,7 @@ showHelp(OFStream *output, bool verbose)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optionsParser.remainingArguments.count != 1) {
|
if (optionsParser.remainingArguments.count != 1) {
|
||||||
showHelp(of_stderr, false);
|
showHelp(OFStdErr, false);
|
||||||
|
|
||||||
[OFApplication terminateWithStatus: 1];
|
[OFApplication terminateWithStatus: 1];
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ showHelp(OFStream *output, bool verbose)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invalid) {
|
if (invalid) {
|
||||||
[of_stderr writeFormat:
|
[OFStdErr writeFormat:
|
||||||
@"%@: Invalid length: %@\n",
|
@"%@: Invalid length: %@\n",
|
||||||
[OFApplication programName], lengthString];
|
[OFApplication programName], lengthString];
|
||||||
|
|
||||||
|
@ -159,11 +159,11 @@ showHelp(OFStream *output, bool verbose)
|
||||||
memcpy(passphrase.mutableItems, passphraseCString,
|
memcpy(passphrase.mutableItems, passphraseCString,
|
||||||
passphraseLength + 1);
|
passphraseLength + 1);
|
||||||
} @finally {
|
} @finally {
|
||||||
of_explicit_memset(passphraseCString, '\0', passphraseLength);
|
OFZeroMemory(passphraseCString, passphraseLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_repeat) {
|
if (_repeat) {
|
||||||
of_string_encoding_t encoding = [OFLocale encoding];
|
OFStringEncoding encoding = [OFLocale encoding];
|
||||||
|
|
||||||
prompt = [OFString stringWithFormat:
|
prompt = [OFString stringWithFormat:
|
||||||
@"Repeat passphrase for site \"%@\": ", generator.site];
|
@"Repeat passphrase for site \"%@\": ", generator.site];
|
||||||
|
@ -171,22 +171,19 @@ showHelp(OFStream *output, bool verbose)
|
||||||
getpass([prompt cStringWithEncoding: encoding]);
|
getpass([prompt cStringWithEncoding: encoding]);
|
||||||
|
|
||||||
if (strcmp(passphraseCString, passphrase.items) != 0) {
|
if (strcmp(passphraseCString, passphrase.items) != 0) {
|
||||||
[of_stderr writeString: @"Passphrases do not match!\n"];
|
[OFStdErr writeString: @"Passphrases do not match!\n"];
|
||||||
[OFApplication terminateWithStatus: 1];
|
[OFApplication terminateWithStatus: 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
of_explicit_memset(passphraseCString, '\0',
|
OFZeroMemory(passphraseCString, strlen(passphraseCString));
|
||||||
strlen(passphraseCString));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
generator.keyFile = keyFile;
|
generator.keyFile = keyFile;
|
||||||
generator.passphrase = passphrase;
|
generator.passphrase = passphrase;
|
||||||
|
|
||||||
[generator derivePassword];
|
[generator derivePassword];
|
||||||
[of_stdout writeBuffer: generator.output.items
|
[OFStdOut writeBuffer: generator.output.items length: generator.length];
|
||||||
length: generator.length];
|
[OFStdOut writeBuffer: "\n" length: 1];
|
||||||
[of_stdout writeBuffer: "\n"
|
|
||||||
length: 1];
|
|
||||||
|
|
||||||
[OFApplication terminate];
|
[OFApplication terminate];
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
- (void)derivePassword
|
- (void)derivePassword
|
||||||
{
|
{
|
||||||
OFSHA256Hash *siteHash = [OFSHA256Hash
|
OFSHA256Hash *siteHash = [OFSHA256Hash
|
||||||
cryptoHashWithAllowsSwappableMemory: true];
|
hashWithAllowsSwappableMemory: true];
|
||||||
size_t passphraseLength, combinedPassphraseLength;
|
size_t passphraseLength, combinedPassphraseLength;
|
||||||
OFSecureData *combinedPassphrase;
|
OFSecureData *combinedPassphrase;
|
||||||
char *combinedPassphraseItems;
|
char *combinedPassphraseItems;
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
_keyFile.items, _keyFile.count);
|
_keyFile.items, _keyFile.count);
|
||||||
|
|
||||||
outputItems = _output.mutableItems;
|
outputItems = _output.mutableItems;
|
||||||
of_scrypt((of_scrypt_parameters_t){
|
OFScrypt((OFScryptParameters){
|
||||||
.blockSize = 8,
|
.blockSize = 8,
|
||||||
.costFactor = 524288,
|
.costFactor = 524288,
|
||||||
.parallelization = 2,
|
.parallelization = 2,
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
- (void)derivePassword
|
- (void)derivePassword
|
||||||
{
|
{
|
||||||
OFSHA384Hash *siteHash = [OFSHA384Hash
|
OFSHA384Hash *siteHash = [OFSHA384Hash
|
||||||
cryptoHashWithAllowsSwappableMemory: true];
|
hashWithAllowsSwappableMemory: true];
|
||||||
size_t passphraseLength, combinedPassphraseLength;
|
size_t passphraseLength, combinedPassphraseLength;
|
||||||
OFSecureData *combinedPassphrase;
|
OFSecureData *combinedPassphrase;
|
||||||
char *combinedPassphraseItems;
|
char *combinedPassphraseItems;
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
_keyFile.items, _keyFile.count);
|
_keyFile.items, _keyFile.count);
|
||||||
|
|
||||||
outputItems = _output.mutableItems;
|
outputItems = _output.mutableItems;
|
||||||
of_scrypt((of_scrypt_parameters_t){
|
OFScrypt((OFScryptParameters){
|
||||||
.blockSize = 8,
|
.blockSize = 8,
|
||||||
.costFactor = 524288,
|
.costFactor = 524288,
|
||||||
.parallelization = 2,
|
.parallelization = 2,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue