CryptoPassphrase  Diff

Differences From Artifact [8d62d07f4b]:

To Artifact [37a8c168df]:


38
39
40
41
42
43
44
45

46
47
48
49
50
51
52
	_length = 16;

	return self;
}

- (void)derivePassword
{
	OFSHA384Hash *siteHash = [OFSHA384Hash cryptoHash];

	size_t passphraseLength, combinedPassphraseLength;
	char *combinedPassphrase;

	[siteHash updateWithBuffer: _site.UTF8String
			    length: _site.UTF8StringLength];

	if (_output != NULL) {







|
>







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
	_length = 16;

	return self;
}

- (void)derivePassword
{
	OFSHA384Hash *siteHash = [OFSHA384Hash
	    cryptoHashWithAllowsSwappableMemory: true];
	size_t passphraseLength, combinedPassphraseLength;
	char *combinedPassphrase;

	[siteHash updateWithBuffer: _site.UTF8String
			    length: _site.UTF8StringLength];

	if (_output != NULL) {
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

		if (_keyFile != nil)
			memcpy(combinedPassphrase + passphraseLength,
			    _keyFile.items, _keyFile.count);

		of_scrypt(8, 524288, 2, siteHash.digest,
		    [siteHash.class digestSize], combinedPassphrase,
		    combinedPassphraseLength, _output, _length);
	} @finally {
		of_explicit_memset(combinedPassphrase, 0,
		    combinedPassphraseLength);
		free(combinedPassphrase);
	}

	for (size_t i = 0; i < _length; i++)







|







73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

		if (_keyFile != nil)
			memcpy(combinedPassphrase + passphraseLength,
			    _keyFile.items, _keyFile.count);

		of_scrypt(8, 524288, 2, siteHash.digest,
		    [siteHash.class digestSize], combinedPassphrase,
		    combinedPassphraseLength, _output, _length, true);
	} @finally {
		of_explicit_memset(combinedPassphrase, 0,
		    combinedPassphraseLength);
		free(combinedPassphrase);
	}

	for (size_t i = 0; i < _length; i++)