Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
openssl
提交
82b22305
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,发现更多精彩内容 >>
提交
82b22305
编写于
8月 18, 2001
作者:
B
Ben Laurie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add RC4 support to OpenBSD.
上级
a8a00498
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
60 addition
and
28 deletion
+60
-28
crypto/engine/hw_openbsd_dev_crypto.c
crypto/engine/hw_openbsd_dev_crypto.c
+1
-0
crypto/evp/evp.h
crypto/evp/evp.h
+1
-0
crypto/evp/evp_enc.c
crypto/evp/evp_enc.c
+6
-0
crypto/evp/openbsd_hw.c
crypto/evp/openbsd_hw.c
+52
-28
未找到文件。
crypto/engine/hw_openbsd_dev_crypto.c
浏览文件 @
82b22305
...
...
@@ -60,6 +60,7 @@
static
void
load_ciphers
(
ENGINE
*
e
)
{
ENGINE_add_cipher
(
e
,
EVP_dev_crypto_des_ede3_cbc
());
ENGINE_add_cipher
(
e
,
EVP_dev_crypto_rc4
());
}
ENGINE
*
ENGINE_openbsd_dev_crypto
(
void
)
...
...
crypto/evp/evp.h
浏览文件 @
82b22305
...
...
@@ -558,6 +558,7 @@ const EVP_CIPHER *EVP_des_ede3_cbc(void);
const
EVP_CIPHER
*
EVP_desx_cbc
(
void
);
# ifdef OPENSSL_OPENBSD_DEV_CRYPTO
const
EVP_CIPHER
*
EVP_dev_crypto_des_ede3_cbc
(
void
);
const
EVP_CIPHER
*
EVP_dev_crypto_rc4
(
void
);
# endif
#endif
#ifndef OPENSSL_NO_RC4
...
...
crypto/evp/evp_enc.c
浏览文件 @
82b22305
...
...
@@ -222,6 +222,7 @@ int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
b
=
ctx
->
cipher
->
block_size
;
if
(
b
==
1
)
{
EVP_CIPHER_CTX_cleanup
(
ctx
);
*
outl
=
0
;
return
1
;
}
...
...
@@ -303,6 +304,7 @@ int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
b
=
ctx
->
cipher
->
block_size
;
if
(
ctx
->
flags
&
EVP_CIPH_NO_PADDING
)
{
EVP_CIPHER_CTX_cleanup
(
ctx
);
if
(
ctx
->
buf_len
)
{
EVPerr
(
EVP_F_EVP_DECRYPTFINAL
,
EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH
);
...
...
@@ -315,12 +317,14 @@ int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
{
if
(
ctx
->
buf_len
||
!
ctx
->
final_used
)
{
EVP_CIPHER_CTX_cleanup
(
ctx
);
EVPerr
(
EVP_F_EVP_DECRYPTFINAL
,
EVP_R_WRONG_FINAL_BLOCK_LENGTH
);
return
(
0
);
}
n
=
ctx
->
final
[
b
-
1
];
if
(
n
>
b
)
{
EVP_CIPHER_CTX_cleanup
(
ctx
);
EVPerr
(
EVP_F_EVP_DECRYPTFINAL
,
EVP_R_BAD_DECRYPT
);
return
(
0
);
}
...
...
@@ -328,6 +332,7 @@ int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
{
if
(
ctx
->
final
[
--
b
]
!=
n
)
{
EVP_CIPHER_CTX_cleanup
(
ctx
);
EVPerr
(
EVP_F_EVP_DECRYPTFINAL
,
EVP_R_BAD_DECRYPT
);
return
(
0
);
}
...
...
@@ -339,6 +344,7 @@ int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
}
else
*
outl
=
0
;
EVP_CIPHER_CTX_cleanup
(
ctx
);
return
(
1
);
}
...
...
crypto/evp/openbsd_hw.c
浏览文件 @
82b22305
...
...
@@ -62,6 +62,7 @@
/* longest key supported in hardware */
#define MAX_HW_KEY 24
#define MAX_HW_IV 8
static
int
fd
;
static
int
dev_failed
;
...
...
@@ -107,6 +108,7 @@ static int dev_crypto_init(EVP_CIPHER_CTX *ctx)
static
int
dev_crypto_cleanup
(
EVP_CIPHER_CTX
*
ctx
)
{
printf
(
"Cleanup %d
\n
"
,
data
(
ctx
)
->
ses
);
if
(
ioctl
(
fd
,
CIOCFSESSION
,
&
data
(
ctx
)
->
ses
)
==
-
1
)
err
(
"CIOCFSESSION failed"
);
...
...
@@ -116,40 +118,34 @@ static int dev_crypto_cleanup(EVP_CIPHER_CTX *ctx)
}
/* FIXME: there should be some non-fatal way to report we fell back to s/w? */
static
int
dev_crypto_des_ede3_init_key
(
EVP_CIPHER_CTX
*
ctx
,
const
unsigned
char
*
key
,
const
unsigned
char
*
iv
,
int
enc
)
static
int
dev_crypto_init_key
(
EVP_CIPHER_CTX
*
ctx
,
int
cipher
,
const
unsigned
char
*
key
,
int
klen
)
{
if
(
!
dev_crypto_init
(
ctx
))
{
/* fall back to using software... */
ctx
->
cipher
=
EVP_des_ede3_cbc
();
return
ctx
->
cipher
->
init
(
ctx
,
key
,
iv
,
enc
);
}
memcpy
(
data
(
ctx
)
->
key
,
key
,
24
);
return
0
;
assert
(
ctx
->
cipher
->
iv_len
<=
MAX_HW_IV
);
memcpy
(
data
(
ctx
)
->
key
,
key
,
klen
);
data
(
ctx
)
->
cipher
=
CRYPTO_3DES_CBC
;
data
(
ctx
)
->
cipher
=
cipher
;
data
(
ctx
)
->
mac
=
0
;
data
(
ctx
)
->
keylen
=
24
;
data
(
ctx
)
->
keylen
=
klen
;
if
(
ioctl
(
fd
,
CIOCGSESSION
,
data
(
ctx
))
==
-
1
)
{
err
(
"CIOCGSESSION failed"
);
/* fall back to using software... */
dev_crypto_cleanup
(
ctx
);
ctx
->
cipher
=
EVP_des_ede3_cbc
();
return
ctx
->
cipher
->
init
(
ctx
,
key
,
iv
,
enc
);
return
0
;
}
printf
(
"Init %d
\n
"
,
data
(
ctx
)
->
ses
);
return
1
;
}
static
int
dev_crypto_des_ede3_cbc_cipher
(
EVP_CIPHER_CTX
*
ctx
,
unsigned
char
*
out
,
const
unsigned
char
*
in
,
unsigned
int
inl
)
static
int
dev_crypto_cipher
(
EVP_CIPHER_CTX
*
ctx
,
unsigned
char
*
out
,
const
unsigned
char
*
in
,
unsigned
int
inl
)
{
struct
crypt_op
cryp
;
unsigned
char
lb
[
8
];
unsigned
char
lb
[
MAX_HW_IV
];
assert
(
data
(
ctx
));
assert
(
!
dev_failed
);
...
...
@@ -158,18 +154,16 @@ static int dev_crypto_des_ede3_cbc_cipher(EVP_CIPHER_CTX *ctx,
cryp
.
ses
=
data
(
ctx
)
->
ses
;
cryp
.
op
=
ctx
->
encrypt
?
COP_ENCRYPT
:
COP_DECRYPT
;
cryp
.
flags
=
0
;
#if 0
cryp.len=((inl+7)/8)*8;
#endif
cryp
.
len
=
inl
;
assert
((
inl
&
7
)
==
0
);
assert
((
inl
&
ctx
->
cipher
->
block_size
)
==
0
);
cryp
.
src
=
(
caddr_t
)
in
;
cryp
.
dst
=
(
caddr_t
)
out
;
cryp
.
mac
=
0
;
cryp
.
iv
=
(
caddr_t
)
ctx
->
iv
;
if
(
ctx
->
cipher
->
iv_len
)
cryp
.
iv
=
(
caddr_t
)
ctx
->
iv
;
if
(
!
ctx
->
encrypt
)
memcpy
(
lb
,
&
in
[
cryp
.
len
-
8
],
8
);
memcpy
(
lb
,
&
in
[
cryp
.
len
-
ctx
->
cipher
->
iv_len
],
ctx
->
cipher
->
iv_len
);
if
(
ioctl
(
fd
,
CIOCCRYPT
,
&
cryp
)
==
-
1
)
{
...
...
@@ -179,19 +173,49 @@ static int dev_crypto_des_ede3_cbc_cipher(EVP_CIPHER_CTX *ctx,
}
if
(
ctx
->
encrypt
)
memcpy
(
ctx
->
iv
,
&
out
[
cryp
.
len
-
8
],
8
);
memcpy
(
ctx
->
iv
,
&
out
[
cryp
.
len
-
ctx
->
cipher
->
iv_len
],
ctx
->
cipher
->
iv_len
);
else
memcpy
(
ctx
->
iv
,
lb
,
8
);
memcpy
(
ctx
->
iv
,
lb
,
ctx
->
cipher
->
iv_len
);
return
1
;
}
static
int
dev_crypto_des_ede3_init_key
(
EVP_CIPHER_CTX
*
ctx
,
const
unsigned
char
*
key
,
const
unsigned
char
*
iv
,
int
enc
)
{
return
dev_crypto_init_key
(
ctx
,
CRYPTO_3DES_CBC
,
key
,
24
);
}
#define dev_crypto_des_ede3_cbc_cipher dev_crypto_cipher
BLOCK_CIPHER_def_cbc
(
dev_crypto_des_ede3
,
session_op
,
NID_des_ede3
,
8
,
24
,
8
,
0
,
dev_crypto_des_ede3_init_key
,
dev_crypto_cleanup
,
EVP_CIPHER_set_asn1_iv
,
EVP_CIPHER_get_asn1_iv
,
NULL
)
static
int
dev_crypto_rc4_init_key
(
EVP_CIPHER_CTX
*
ctx
,
const
unsigned
char
*
key
,
const
unsigned
char
*
iv
,
int
enc
)
{
return
dev_crypto_init_key
(
ctx
,
CRYPTO_ARC4
,
key
,
16
);
}
static
const
EVP_CIPHER
r4_cipher
=
{
NID_rc4
,
1
,
16
,
0
,
/* FIXME: key should be up to 256 bytes */
EVP_CIPH_VARIABLE_LENGTH
,
dev_crypto_rc4_init_key
,
dev_crypto_cipher
,
dev_crypto_cleanup
,
sizeof
(
session_op
),
NULL
,
NULL
,
NULL
};
const
EVP_CIPHER
*
EVP_dev_crypto_rc4
(
void
)
{
return
&
r4_cipher
;
}
#else
static
void
*
dummy
=&
dummy
;
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录