CryptoPassphrase  Diff

Differences From Artifact [c255ef24dd]:

To Artifact [c0c1315d5a]:


51
52
53
54
55
56
57
58


59
60
61
62
63
64
65
51
52
53
54
55
56
57

58
59
60
61
62
63
64
65
66







-
+
+







- (size_t)length
{
	return _length;
}

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

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

	if (_output != NULL) {
85
86
87
88
89
90
91
92

93
94
95
96
97
98
99
86
87
88
89
90
91
92

93
94
95
96
97
98
99
100







-
+








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

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

	/*