CCKeyDerivationPBKDF on iOS5

I am trying to write a password encryption function in my application by following this article .

I wrote a function that runs the function CCCalibratePBKDFand displays the number of rounds.

const uint32_t oneSecond = 1000;
uint rounds = CCCalibratePBKDF(kCCPBKDF2,
                               predictedPasswordLength,
                               predictedSaltLength,
                               kCCPRFHmacAlgSHA256,
                               kCCKeySizeAES128,
                               oneSecond);

This works fine, but when I try to implement the next part, everything goes wrong.

I can start writing a function call CCKeyDerivationPBKDF, and it automatically terminates the function and all parameters. When I look at it, all options also automatically end.

- (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;
}

But as soon as I hit; he notes the error: "There is no corresponding function to call" CCKeyDerivationPBKDF "", and it will not build or anything else.

CommonCrypto/CommonKeyDerivation.h CommonCrypto/CommonCryptor.h, .

+5
2

, ( ).

ZXing, .m .mm, ++ ZXing.

, , CCKeyDerivationPBKDF.

.m, , .

- - .

+2

-, , ( , @HachiEthan, ). , , , , /usr/include. , Security.framework . .

, , , iOS 5 Security.framework( - , ​​ OS X 10.6 iOS 4). , .

, , RNCryptor.

+2

All Articles