diff -r 8982b8fada63 -r dee779b84a95 MYCryptor.m --- a/MYCryptor.m Tue Apr 07 10:56:58 2009 -0700 +++ b/MYCryptor.m Thu Apr 09 22:47:11 2009 -0700 @@ -57,11 +57,14 @@ fromPassphrase: (NSString*)passphrase salt: (id)salt { + // This follows algorithm PBKDF1 from PKCS#5 v2.0, with Hash=SHA-256 and c=13. Assert(passphrase); Assert(salt); passphrase = $sprintf(@"MYCrypto|%@|%@", passphrase, salt); size_t lengthInBytes = (lengthInBits + 7)/8; MYDigest *digest = [[passphrase dataUsingEncoding: NSUTF8StringEncoding] my_SHA256Digest]; + for (int i=0; i<12; i++) + digest = digest.asData.my_SHA256Digest; if (lengthInBytes <= digest.length) return [digest.asData subdataWithRange: NSMakeRange(0,lengthInBytes)]; else @@ -126,7 +129,7 @@ - (BOOL) _outputBytes: (const void*)bytes length: (size_t)length { if (_outputStream) { - NSInteger written = [_outputStream write: bytes maxLength: length]; + size_t written = [_outputStream write: bytes maxLength: length]; if (written < 0) { self.error = _outputStream.streamError; if (_error)