如何在 iOS 设备上创建 PBKDF2 密钥 [英] How to create PBKDF2 key on iOS device
问题描述
我需要创建一个 PBKDF2 密钥,以便在我的 iPhone Xcode 应用程序中的 AES 加密例程中使用.我已经看到使用 OpenSSL 来执行此操作的参考资料,但没有找到对 OpenSSL 中要调用的模块的具体参考资料.
I need to create a PBKDF2 key to use in my AES encryption routine in my iPhone Xcode application. I have seen references to using OpenSSL to do this, but not found specific references to what module within OpenSSL to call.
我已经扫描了各种 OpenSSL .h 文件,以寻找进行此调用的方法,但到目前为止都没有成功.
I have scanned various OpenSSL .h files searching for a means to make this call, but have so far been unsuccessful.
我将使用的密钥是 5 位数字,Salt 是 12 个字符,迭代次数是 1000,我需要一个 128 位生成的密钥.
The key I will be using is 5-digits, Salt is 12 characters, Iterations is 1000, and I need a 128-bit generated key.
推荐答案
您可以使用openssl/evp.h
中的PKCS5_PBKDF2_HMAC_SHA1()
函数.从声明中可以很容易地判断如何使用该函数:
You can use the PKCS5_PBKDF2_HMAC_SHA1()
function in openssl/evp.h
. Divining how to use the function is pretty easy from the declaration:
int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
const unsigned char *salt, int saltlen, int iter,
int keylen, unsigned char *out);
这篇关于如何在 iOS 设备上创建 PBKDF2 密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!