Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
openssl
提交
ff3fa48f
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,发现更多精彩内容 >>
提交
ff3fa48f
编写于
12月 09, 2001
作者:
B
Ben Laurie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve back compatibility.
上级
87166e1f
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
52 addition
and
17 deletion
+52
-17
apps/speed.c
apps/speed.c
+3
-3
crypto/evp/p5_crpt2.c
crypto/evp/p5_crpt2.c
+1
-1
crypto/hmac/hmac.c
crypto/hmac/hmac.c
+10
-2
crypto/hmac/hmac.h
crypto/hmac/hmac.h
+5
-1
crypto/pkcs12/p12_mutl.c
crypto/pkcs12/p12_mutl.c
+1
-1
doc/crypto/hmac.pod
doc/crypto/hmac.pod
+27
-4
ssl/t1_enc.c
ssl/t1_enc.c
+5
-5
未找到文件。
apps/speed.c
浏览文件 @
ff3fa48f
...
...
@@ -1065,8 +1065,8 @@ int MAIN(int argc, char **argv)
HMAC_CTX
hctx
;
HMAC_CTX_init
(
&
hctx
);
HMAC_Init
(
&
hctx
,(
unsigned
char
*
)
"This is a key..."
,
16
,
EVP_md5
());
HMAC_Init
_ex
(
&
hctx
,(
unsigned
char
*
)
"This is a key..."
,
16
,
EVP_md5
());
for
(
j
=
0
;
j
<
SIZE_NUM
;
j
++
)
{
...
...
@@ -1074,7 +1074,7 @@ int MAIN(int argc, char **argv)
Time_F
(
START
);
for
(
count
=
0
,
run
=
1
;
COND
(
c
[
D_HMAC
][
j
]);
count
++
)
{
HMAC_Init
(
&
hctx
,
NULL
,
0
,
NULL
);
HMAC_Init
_ex
(
&
hctx
,
NULL
,
0
,
NULL
);
HMAC_Update
(
&
hctx
,
buf
,
lengths
[
j
]);
HMAC_Final
(
&
hctx
,
&
(
hmac
[
0
]),
NULL
);
}
...
...
crypto/evp/p5_crpt2.c
浏览文件 @
ff3fa48f
...
...
@@ -100,7 +100,7 @@ int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
itmp
[
1
]
=
(
unsigned
char
)((
i
>>
16
)
&
0xff
);
itmp
[
2
]
=
(
unsigned
char
)((
i
>>
8
)
&
0xff
);
itmp
[
3
]
=
(
unsigned
char
)(
i
&
0xff
);
HMAC_Init
(
&
hctx
,
pass
,
passlen
,
EVP_sha1
());
HMAC_Init
_ex
(
&
hctx
,
pass
,
passlen
,
EVP_sha1
());
HMAC_Update
(
&
hctx
,
salt
,
saltlen
);
HMAC_Update
(
&
hctx
,
itmp
,
4
);
HMAC_Final
(
&
hctx
,
digtmp
,
NULL
);
...
...
crypto/hmac/hmac.c
浏览文件 @
ff3fa48f
...
...
@@ -60,8 +60,8 @@
#include <string.h>
#include <openssl/hmac.h>
void
HMAC_Init
(
HMAC_CTX
*
ctx
,
const
void
*
key
,
int
len
,
const
EVP_MD
*
md
)
void
HMAC_Init
_ex
(
HMAC_CTX
*
ctx
,
const
void
*
key
,
int
len
,
const
EVP_MD
*
md
)
{
int
i
,
j
,
reset
=
0
;
unsigned
char
pad
[
HMAC_MAX_MD_CBLOCK
];
...
...
@@ -110,6 +110,14 @@ void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
EVP_MD_CTX_copy_ex
(
&
ctx
->
md_ctx
,
&
ctx
->
i_ctx
);
}
void
HMAC_Init
(
HMAC_CTX
*
ctx
,
const
void
*
key
,
int
len
,
const
EVP_MD
*
md
)
{
if
(
key
&&
md
)
HMAC_CTX_init
(
ctx
);
HMAC_Init_ex
(
ctx
,
key
,
len
,
md
);
}
void
HMAC_Update
(
HMAC_CTX
*
ctx
,
const
unsigned
char
*
data
,
int
len
)
{
EVP_DigestUpdate
(
&
ctx
->
md_ctx
,
data
,
len
);
...
...
crypto/hmac/hmac.h
浏览文件 @
ff3fa48f
...
...
@@ -86,8 +86,12 @@ typedef struct hmac_ctx_st
void
HMAC_CTX_init
(
HMAC_CTX
*
ctx
);
void
HMAC_CTX_cleanup
(
HMAC_CTX
*
ctx
);
#define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx)
/* deprecated */
void
HMAC_Init
(
HMAC_CTX
*
ctx
,
const
void
*
key
,
int
len
,
const
EVP_MD
*
md
);
const
EVP_MD
*
md
);
/* deprecated */
void
HMAC_Init_ex
(
HMAC_CTX
*
ctx
,
const
void
*
key
,
int
len
,
const
EVP_MD
*
md
);
void
HMAC_Update
(
HMAC_CTX
*
ctx
,
const
unsigned
char
*
data
,
int
len
);
void
HMAC_Final
(
HMAC_CTX
*
ctx
,
unsigned
char
*
md
,
unsigned
int
*
len
);
unsigned
char
*
HMAC
(
const
EVP_MD
*
evp_md
,
const
void
*
key
,
int
key_len
,
...
...
crypto/pkcs12/p12_mutl.c
浏览文件 @
ff3fa48f
...
...
@@ -87,7 +87,7 @@ int PKCS12_gen_mac (PKCS12 *p12, const char *pass, int passlen,
return
0
;
}
HMAC_CTX_init
(
&
hmac
);
HMAC_Init
(
&
hmac
,
key
,
PKCS12_MAC_KEY_LENGTH
,
md_type
);
HMAC_Init
_ex
(
&
hmac
,
key
,
PKCS12_MAC_KEY_LENGTH
,
md_type
);
HMAC_Update
(
&
hmac
,
p12
->
authsafes
->
d
.
data
->
data
,
p12
->
authsafes
->
d
.
data
->
length
);
HMAC_Final
(
&
hmac
,
mac
,
maclen
);
...
...
doc/crypto/hmac.pod
浏览文件 @
ff3fa48f
...
...
@@ -13,11 +13,16 @@ authentication code
int key_len, const unsigned char *d, int n,
unsigned char *md, unsigned int *md_len);
void HMAC_CTX_init(HMAC_CTX *ctx);
void HMAC_Init(HMAC_CTX *ctx, const void *key, int key_len,
const EVP_MD *md);
void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int key_len,
const EVP_MD *md);
void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len);
void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);
void HMAC_CTX_cleanup(HMAC_CTX *ctx);
void HMAC_cleanup(HMAC_CTX *ctx);
=head1 DESCRIPTION
...
...
@@ -39,13 +44,31 @@ B<evp_md> can be EVP_sha1(), EVP_ripemd160() etc.
B<key> and B<evp_md> may be B<NULL> if a key and hash function have
been set in a previous call to HMAC_Init() for that B<HMAC_CTX>.
HMAC_cleanup() erases the key and other data from the B<HMAC_CTX>.
HMAC_CTX_init() initialises a B<HMAC_CTX> before first use. It must be
called.
HMAC_CTX_cleanup() erases the key and other data from the B<HMAC_CTX>
and releases any associated resources. It must be called when an
B<HMAC_CTX> is no longer required.
HMAC_cleanup() is an alias for HMAC_CTX_cleanup() included for back
compatibility with 0.9.6b, it is deprecated.
The following functions may be used if the message is not completely
stored in memory:
HMAC_Init() initializes a B<HMAC_CTX> structure to use the hash
function B<evp_md> and the key B<key> which is B<key_len> bytes long.
function B<evp_md> and the key B<key> which is B<key_len> bytes
long. It is deprecated and only included for backward compatibility
with OpenSSL 0.9.6b.
HMAC_Init_ex() initializes or reuses a B<HMAC_CTX> structure to use
the function B<evp_md> and key B<key>. Either can be NULL, in which
case the existing one will be reused. HMAC_CTX_init() must have been
called before the first use of an B<HMAC_CTX> in this
function. B<N.B. HMAC_Init() had this undocumented behaviour in
previous versions of OpenSSL - failure to switch to HMAC_Init_ex() in
programs that expect it will cause them to stop working>.
HMAC_Update() can be called repeatedly with chunks of the message to
be authenticated (B<len> bytes at B<data>).
...
...
@@ -57,8 +80,8 @@ must have space for the hash function output.
HMAC() returns a pointer to the message authentication code.
HMAC_
Init(), HMAC_Update(), HMAC_Final() and HMAC_cleanup() do not
return values.
HMAC_
CTX_init(), HMAC_Init_ex(), HMAC_Update(), HMAC_Final() and
HMAC_CTX_cleanup() do not
return values.
=head1 CONFORMING TO
...
...
ssl/t1_enc.c
浏览文件 @
ff3fa48f
...
...
@@ -78,16 +78,16 @@ static void tls1_P_hash(const EVP_MD *md, const unsigned char *sec,
HMAC_CTX_init
(
&
ctx
);
HMAC_CTX_init
(
&
ctx_tmp
);
HMAC_Init
(
&
ctx
,
sec
,
sec_len
,
md
);
HMAC_Init
(
&
ctx_tmp
,
sec
,
sec_len
,
md
);
HMAC_Init
_ex
(
&
ctx
,
sec
,
sec_len
,
md
);
HMAC_Init
_ex
(
&
ctx_tmp
,
sec
,
sec_len
,
md
);
HMAC_Update
(
&
ctx
,
seed
,
seed_len
);
HMAC_Final
(
&
ctx
,
A1
,
&
A1_len
);
n
=
0
;
for
(;;)
{
HMAC_Init
(
&
ctx
,
NULL
,
0
,
NULL
);
/* re-init */
HMAC_Init
(
&
ctx_tmp
,
NULL
,
0
,
NULL
);
/* re-init */
HMAC_Init
_ex
(
&
ctx
,
NULL
,
0
,
NULL
);
/* re-init */
HMAC_Init
_ex
(
&
ctx_tmp
,
NULL
,
0
,
NULL
);
/* re-init */
HMAC_Update
(
&
ctx
,
A1
,
A1_len
);
HMAC_Update
(
&
ctx_tmp
,
A1
,
A1_len
);
HMAC_Update
(
&
ctx
,
seed
,
seed_len
);
...
...
@@ -652,7 +652,7 @@ int tls1_mac(SSL *ssl, unsigned char *md, int send)
/* I should fix this up TLS TLS TLS TLS TLS XXXXXXXX */
HMAC_CTX_init
(
&
hmac
);
HMAC_Init
(
&
hmac
,
mac_sec
,
EVP_MD_size
(
hash
),
hash
);
HMAC_Init
_ex
(
&
hmac
,
mac_sec
,
EVP_MD_size
(
hash
),
hash
);
HMAC_Update
(
&
hmac
,
seq
,
8
);
HMAC_Update
(
&
hmac
,
buf
,
5
);
HMAC_Update
(
&
hmac
,
rec
->
input
,
rec
->
length
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录