Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
f62df694
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
1 年多 前同步成功
通知
10
Star
18
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Openssl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f62df694
编写于
4月 10, 2010
作者:
A
Andy Polyakov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ctr129.c: fix typo, simplify ctr128_inc and fix "n=0" bug.
上级
42feba47
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
13 addition
and
15 deletion
+13
-15
crypto/modes/ctr128.c
crypto/modes/ctr128.c
+13
-15
未找到文件。
crypto/modes/ctr128.c
浏览文件 @
f62df694
...
@@ -61,14 +61,11 @@
...
@@ -61,14 +61,11 @@
typedef
unsigned
int
u32
;
typedef
unsigned
int
u32
;
typedef
unsigned
char
u8
;
typedef
unsigned
char
u8
;
# define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3]))
# define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); }
#define STRICT_ALIGNMENT
#define STRICT_ALIGNMENT
#if defined(__i386)
|| defined(__i386__)
|| \
#if defined(__i386)
|| defined(__i386__)
|| \
defined(__x86_64)
|| defined(__x86_64__)
|| \
defined(__x86_64)
|| defined(__x86_64__)
|| \
defined(_M_IX86)
|| defined(_M_AMD64)
|| defined(_M_X64) || \
defined(_M_IX86)
|| defined(_M_AMD64)
|| defined(_M_X64) || \
defined(__s390__)
|| defined(__s390x__)
defined(__s390__)
|| defined(__s390x__)
# undef STRICT_ALIGNMENT
# undef STRICT_ALIGNMENT
#endif
#endif
...
@@ -77,18 +74,19 @@ typedef unsigned char u8;
...
@@ -77,18 +74,19 @@ typedef unsigned char u8;
/* increment counter (128-bit int) by 1 */
/* increment counter (128-bit int) by 1 */
static
void
ctr128_inc
(
unsigned
char
*
counter
)
{
static
void
ctr128_inc
(
unsigned
char
*
counter
)
{
u32
c
,
n
=
16
;
u32
n
=
16
;
u8
c
;
do
{
do
{
n
-=
4
;
--
n
;
c
=
GETU32
(
counter
+
n
)
;
c
=
counter
[
n
]
;
++
c
;
c
&=
0xFFFFFFFF
;
++
c
;
PUTU32
(
counter
+
n
,
c
)
;
counter
[
n
]
=
c
;
if
(
c
)
return
;
if
(
c
)
return
;
}
while
(
n
);
}
while
(
n
);
}
}
#if !defined(OPENSSL_SMALL_FOO
R
PRINT)
#if !defined(OPENSSL_SMALL_FOO
T
PRINT)
static
void
ctr128_inc_aligned
(
unsigned
char
*
counter
)
{
static
void
ctr128_inc_aligned
(
unsigned
char
*
counter
)
{
size_t
*
data
,
c
,
n
;
size_t
*
data
,
c
,
n
;
const
union
{
long
one
;
char
little
;
}
is_endian
=
{
1
};
const
union
{
long
one
;
char
little
;
}
is_endian
=
{
1
};
...
@@ -151,14 +149,14 @@ void CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out,
...
@@ -151,14 +149,14 @@ void CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out,
while
(
len
>=
16
)
{
while
(
len
>=
16
)
{
(
*
block
)(
ivec
,
ecount_buf
,
key
);
(
*
block
)(
ivec
,
ecount_buf
,
key
);
ctr128_inc_aligned
(
ivec
);
ctr128_inc_aligned
(
ivec
);
for
(
n
=
0
;
n
<
16
;
n
+=
sizeof
(
size_t
))
for
(;
n
<
16
;
n
+=
sizeof
(
size_t
))
*
(
size_t
*
)(
out
+
n
)
=
*
(
size_t
*
)(
out
+
n
)
=
*
(
size_t
*
)(
in
+
n
)
^
*
(
size_t
*
)(
ecount_buf
+
n
);
*
(
size_t
*
)(
in
+
n
)
^
*
(
size_t
*
)(
ecount_buf
+
n
);
len
-=
16
;
len
-=
16
;
out
+=
16
;
out
+=
16
;
in
+=
16
;
in
+=
16
;
n
=
0
;
}
}
n
=
0
;
if
(
len
)
{
if
(
len
)
{
(
*
block
)(
ivec
,
ecount_buf
,
key
);
(
*
block
)(
ivec
,
ecount_buf
,
key
);
ctr128_inc_aligned
(
ivec
);
ctr128_inc_aligned
(
ivec
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录