Note that there are some explanatory texts on larger screens.

plurals
  1. POCCKeyDerivationPBKDF on iOS5
    primarykey
    data
    text
    <p>I'm trying to write a password encryption function into my app, following <a href="http://blog.securemacprogramming.com/2012/07/password-checking-with-commoncrypto/" rel="nofollow">this article</a>.</p> <p>I wrote a function that runs the <code>CCCalibratePBKDF</code> function and outputs the number of rounds. </p> <pre><code>const uint32_t oneSecond = 1000; uint rounds = CCCalibratePBKDF(kCCPBKDF2, predictedPasswordLength, predictedSaltLength, kCCPRFHmacAlgSHA256, kCCKeySizeAES128, oneSecond); </code></pre> <p>This works perfectly, but when I try to implement the next part it all goes wrong.</p> <p>I can start writing the <code>CCKeyDerivationPBKDF</code> function call and it auto-completes the function and all the parameters. As I go through filling it in all the parameters are also auto-completed.</p> <pre><code>- (NSData *)authenticationDataForPassword: (NSString *)password salt: (NSData *)salt rounds: (uint) rounds { const NSString *plainData = @"Fuzzy Aliens"; uint8_t key[kCCKeySizeAES128] = {0}; int keyDerivationResult = CCKeyDerivationPBKDF(kCCPBKDF2, [password UTF8String], [password lengthOfBytesUsingEncoding: NSUTF8StringEncoding], [salt bytes], [salt length], kCCPRFHmacAlgSHA256, rounds, key, kCCKeySizeAES128); if (keyDerivationResult == kCCParamError) { //you shouldn't get here with the parameters as above return nil; } uint8_t hmac[CC_SHA256_DIGEST_LENGTH] = {0}; CCHmac(kCCHmacAlgSHA256, key, kCCKeySizeAES128, [plainData UTF8String], [plainData lengthOfBytesUsingEncoding: NSUTF8StringEncoding], hmac); NSData *hmacData = [NSData dataWithBytes: hmac length: CC_SHA256_DIGEST_LENGTH]; return hmacData; } </code></pre> <p>But as soon as I hit ; it marks an error saying "No matching function for call to 'CCKeyDerivationPBKDF'" and it won't build or anything.</p> <p>I've imported CommonCrypto/CommonKeyDerivation.h and CommonCrypto/CommonCryptor.h as both of these were necessary for the enum names.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload