EDIT: I'm using Objective-C and V4 of RNCryptor
--
You received this message because you are subscribed to the Google Groups "rncryptor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rncryptor+...@googlegroups.com.
Visit this group at https://groups.google.com/group/rncryptor.
For more options, visit https://groups.google.com/d/optout.
This approach sounds fine (and as you suspect, it's a very common approach in crypto). Just a few thoughts.Rather than generating a password A, generate two keys A1 and A2. Use these to encrypt using the key-based API rather than the password API. The two keys are the encryption key and the hmac key. When you use the password interface, RNCryptor expands the password into those two keys. This is intentionally very time-intensive to strengthen weak passwords that humans generate. There's no reason for that expensive step if you're using random keys.To generate the random keys, just use +randomDataOfLength:. Look in the test cases for several examples. The results should be ideal for your purposes.-Rob
Takes a data, returns a processed data, and invalidates the cryptor.
RNEncryptorV3 *enc = [[RNEncryptorV3 alloc] initWithEncryptionKey:decryptedFEK hmacKey:decryptedHMAC];
tempEnc1 = [enc encryptData:self.rawData1];
tempEnc2 = [enc encryptData:self.rawData2];
tempEnc3 = [enc encryptData:self.rawData3];
tempEnc4 = [enc encryptData:self.rawData4];
On Monday, 18 April 2016 04:22:02 UTC+2, Rob Napier wrote:
This approach sounds fine (and as you suspect, it's a very common approach in crypto). Just a few thoughts.Rather than generating a password A, generate two keys A1 and A2. Use these to encrypt using the key-based API rather than the password API. The two keys are the encryption key and the hmac key. When you use the password interface, RNCryptor expands the password into those two keys. This is intentionally very time-intensive to strengthen weak passwords that humans generate. There's no reason for that expensive step if you're using random keys.To generate the random keys, just use +randomDataOfLength:. Look in the test cases for several examples. The results should be ideal for your purposes.-Rob
So I've come up with this class and I would like to ask you if you could be so kind and verify the implementation:
I don't understand the use of the TSDebugPassword. This feels very insecure. If you need to store the keys, they should be stored in (iCloud) Keychain. That's the tool designed for this.
eraseKeys is doing nothing at all.
range. I've verified in the debugger that this method does overwrite the actual memory with zeros.[_decryptedFEK appendData:[RNCryptor randomDataOfLength:kCCKeySizeAES256]];
NSRange range = NSMakeRange(0, _decryptedHMAC.length);
[_decryptedHMAC resetBytesInRange:range];
[_decryptedFEK resetBytesInRange:range];
The code I've posted previously contained a copy/paste error in the decryptedFEK method which apparently nobody noticed so far. I've also improved the eraseKeys method to actually overwrite the cached memory using NSMutableData's - (void)resetBytesInRange:(NSRange)range. I've verified in the debugger that this method does overwrite the actual memory with zeros.To avoid badly formatted code again, I've attached the files this time.
--
You received this message because you are subscribed to the Google Groups "rncryptor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rncryptor+...@googlegroups.com.
Visit this group at https://groups.google.com/group/rncryptor.
For more options, visit https://groups.google.com/d/optout.