我在上使用OpenSSL 0.9.8,我想使用一个PBKDF,但是我在OpenSSL的网站上找不到任何关于它的文档/人。
我正在研究QCA,Qt的OpenSSL包装器,当我到达Qt时,PKCS5_PBKDF2_HMAC_SHA1 as PBKDF2,这是我在OpenSSL网站上都找不到的函数。它在OSX上被标记为不推荐,所以我的问题是:在PBKDF2上是否有一个或多个OpenSSL?如果有/正在,有人知道我在哪里可以找到文件吗?
发布于 2014-02-23 08:11:20
在0.9.8中只有PKCS5_PBKDF2_HMAC_SHA1。
示例C代码:
#include <openssl/evp.h>
#include <openssl/sha.h>
void PBKDF2_HMAC_SHA_1nat(const char* pass, const unsigned char* salt, int32_t iterations, uint32_t outputBytes, char* hexResult)
{
unsigned int i;
unsigned char digest[outputBytes];
PKCS5_PBKDF2_HMAC_SHA1(pass, strlen(pass), salt, strlen(salt), iterations, outputBytes, digest);
for (i = 0; i < sizeof(digest); i++)
sprintf(hexResult + (i * 2), "%02x", 255 & digest[i]);
}在1.0.1中还有PKCS5_PBKDF2_HMAC,它允许传入不同的底层哈希函数。
PBKDF2-HMAC-SHA-512示例C代码:
#include <openssl/evp.h>
#include <openssl/sha.h>
void PBKDF2_HMAC_SHA_1(const char* pass, const unsigned char* salt, int32_t iterations, uint32_t outputBytes, char* hexResult)
{
unsigned int i;
unsigned char digest[outputBytes];
PKCS5_PBKDF2_HMAC(pass, strlen(pass), salt, strlen(salt), iterations, EVP_sha512(), outputBytes, digest);
for (i = 0; i < sizeof(digest); i++)
sprintf(hexResult + (i * 2), "%02x", 255 & digest[i]);
}发布于 2013-12-15 16:42:20
只有一个,它在中声明。这个2009年年员额将它命名为尚未记录在案,这似乎仍然是正确的。它在我的Linux系统上确实有一个手册页。
顺便说一句,最近Mac放弃了所有openssl的密码使用(使用CommonCrypto代替)。
https://crypto.stackexchange.com/questions/12337
复制相似问题