Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
openssl
提交
f513939e
O
openssl
项目概览
btwise
/
openssl
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
openssl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f513939e
编写于
7月 11, 1999
作者:
D
Dr. Stephen Henson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a debugging option to PKCS#5 v2.0 key generation function.
上级
0ab8beb4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
6 deletion
+35
-6
CHANGES
CHANGES
+5
-0
crypto/evp/p5_crpt2.c
crypto/evp/p5_crpt2.c
+30
-6
未找到文件。
CHANGES
浏览文件 @
f513939e
...
...
@@ -4,6 +4,11 @@
Changes between 0.9.3a and 0.9.4
*) Add a debugging option to PKCS#5 v2 key generation function: when
you #define DEBUG_PKCS5V2 passwords, salts, iteration counts and
derived keys are printed to stderr.
[Steve Henson]
*) Copy the flags in ASN1_STRING_dup().
[Roman E. Pavlov <pre@mo.msk.ru>]
...
...
crypto/evp/p5_crpt2.c
浏览文件 @
f513939e
...
...
@@ -55,7 +55,6 @@
* Hudson (tjh@cryptsoft.com).
*
*/
#if !defined(NO_HMAC) && !defined(NO_SHA)
#include <stdio.h>
#include <stdlib.h>
#include <openssl/x509.h>
...
...
@@ -63,6 +62,13 @@
#include <openssl/hmac.h>
#include "cryptlib.h"
/* set this to print out info about the keygen algorithm */
/* #define DEBUG_PKCS5V2 */
#ifdef DEBUG_PKCS5V2
static
void
h__dump
(
const
unsigned
char
*
p
,
int
len
);
#endif
/* This is an implementation of PKCS#5 v2.0 password based encryption key
* derivation function PBKDF2 using the only currently defined function HMAC
* with SHA1. Verified against test vectors posted by Peter Gutmann
...
...
@@ -74,14 +80,15 @@ int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
int
keylen
,
unsigned
char
*
out
)
{
unsigned
char
digtmp
[
SHA_DIGEST_LENGTH
],
*
p
,
itmp
[
4
];
int
cplen
,
j
,
k
;
int
cplen
,
j
,
k
,
tkeylen
;
unsigned
long
i
=
1
;
HMAC_CTX
hctx
;
p
=
out
;
tkeylen
=
keylen
;
if
(
passlen
==
-
1
)
passlen
=
strlen
(
pass
);
while
(
keylen
)
{
if
(
keylen
>
SHA_DIGEST_LENGTH
)
cplen
=
SHA_DIGEST_LENGTH
;
else
cplen
=
keylen
;
while
(
t
keylen
)
{
if
(
t
keylen
>
SHA_DIGEST_LENGTH
)
cplen
=
SHA_DIGEST_LENGTH
;
else
cplen
=
t
keylen
;
/* We are unlikely to ever use more than 256 blocks (5120 bits!)
* but just in case...
*/
...
...
@@ -99,11 +106,20 @@ int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
digtmp
,
SHA_DIGEST_LENGTH
,
digtmp
,
NULL
);
for
(
k
=
0
;
k
<
cplen
;
k
++
)
p
[
k
]
^=
digtmp
[
k
];
}
keylen
-=
cplen
;
t
keylen
-=
cplen
;
i
++
;
p
+=
cplen
;
}
HMAC_cleanup
(
&
hctx
);
#ifdef DEBUG_PKCS5V2
fprintf
(
stderr
,
"Password:
\n
"
);
h__dump
(
pass
,
passlen
);
fprintf
(
stderr
,
"Salt:
\n
"
);
h__dump
(
salt
,
saltlen
);
fprintf
(
stderr
,
"Iteration count %d
\n
"
,
iter
);
fprintf
(
stderr
,
"Key:
\n
"
);
h__dump
(
out
,
keylen
);
#endif
return
1
;
}
...
...
@@ -219,4 +235,12 @@ int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
PBKDF2PARAM_free
(
kdf
);
return
0
;
}
#ifdef DEBUG_PKCS5V2
static
void
h__dump
(
const
unsigned
char
*
p
,
int
len
)
{
for
(;
len
--
;
p
++
)
fprintf
(
stderr
,
"%02X "
,
*
p
);
fprintf
(
stderr
,
"
\n
"
);
}
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录