I have the ObjC method below and I'd like to call do port it to managed code but have no idea where to start. Can somebody please assist?
- (NSData *)deriveKey
{
NSData *passphrase = [self.passwordField.stringValue dataUsingEncoding:NSUTF8StringEncoding];
NSData *salt = [self.saltField.stringValue dataUsingEncoding:NSUTF8StringEncoding];
NSMutableData *key = [NSMutableData dataWithLength:kCCKeySizeAES256];
CCKeyDerivationPBKDF(kCCPBKDF2,
[passphrase bytes],
[passphrase length],
[salt bytes],
[salt length],
kCCPRFHmacAlgSHA256,
PBKDFNumberOfRounds,
[key mutableBytes],
[key length]);
return key;
}
In .NET PKCS#5v2 (which defines PBKDF2) support is available using
Rfc2898DeriveBytes. However it does not let you select the hash algorithm.