如何在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个字符,Iterations是1000,而I需要一个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.
推荐答案
您可以使用 PKCS5_PBKDF2_HMAC_SHA1()
function in openssl / evp.h
。从声明中划分如何使用函数很容易:
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屋!