Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
码匠许师傅
rt-thread
提交
d576c936
R
rt-thread
项目概览
码匠许师傅
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
d576c936
编写于
6月 06, 2019
作者:
B
Bernard Xiong
提交者:
GitHub
6月 06, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2751 from enkiller/master
[components][drivers] 硬件大数适应性调整
上级
91c858ea
ab7c1530
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
121 addition
and
181 deletion
+121
-181
components/drivers/Kconfig
components/drivers/Kconfig
+1
-1
components/drivers/hwcrypto/hw_bignum.c
components/drivers/hwcrypto/hw_bignum.c
+73
-111
components/drivers/hwcrypto/hw_bignum.h
components/drivers/hwcrypto/hw_bignum.h
+46
-68
components/drivers/hwcrypto/hw_hash.h
components/drivers/hwcrypto/hw_hash.h
+1
-1
未找到文件。
components/drivers/Kconfig
浏览文件 @
d576c936
...
...
@@ -278,7 +278,7 @@ menu "Using Hardware Crypto drivers"
int "IV max size"
default "16"
config HWCRYPTO_KEYBIT_MAX_SIZE
config
RT_
HWCRYPTO_KEYBIT_MAX_SIZE
int "Key max bit length"
default 256
...
...
components/drivers/hwcrypto/hw_bignum.c
浏览文件 @
d576c936
...
...
@@ -14,7 +14,7 @@
static
struct
rt_hwcrypto_ctx
*
bignum_default
;
rt_inline
rt_err_t
rt_hwcrypto_bignum
_init
(
void
)
rt_inline
rt_err_t
hwcrypto_bignum_dev_is
_init
(
void
)
{
struct
rt_hwcrypto_device
*
dev
;
...
...
@@ -55,20 +55,18 @@ rt_err_t rt_hwcrypto_bignum_default(struct rt_hwcrypto_device *device)
}
/**
* @brief
Allocate memory for bignum
*
* @
return Pointer to allocated
bignum obj
* @brief
Init bignum obj
*
* @
param n
bignum obj
*/
struct
hw_bignum_mpi
*
rt_hwcrypto_bignum_alloc
(
void
)
void
rt_hwcrypto_bignum_init
(
struct
hw_bignum_mpi
*
n
)
{
struct
hw_bignum_mpi
*
n
;
if
(
n
==
RT_NULL
)
return
;
n
=
rt_malloc
(
sizeof
(
struct
hw_bignum_mpi
));
if
(
n
)
{
rt_memset
(
n
,
0
,
sizeof
(
struct
hw_bignum_mpi
));
}
return
n
;
n
->
sign
=
1
;
n
->
total
=
0
;
n
->
p
=
RT_NULL
;
}
/**
...
...
@@ -81,7 +79,9 @@ void rt_hwcrypto_bignum_free(struct hw_bignum_mpi *n)
if
(
n
)
{
rt_free
(
n
->
p
);
rt_free
(
n
);
n
->
sign
=
0
;
n
->
total
=
0
;
n
->
p
=
RT_NULL
;
}
}
...
...
@@ -90,7 +90,7 @@ void rt_hwcrypto_bignum_free(struct hw_bignum_mpi *n)
*
* @param n bignum obj
*
* @return binary buffer
L
ength
* @return binary buffer
l
ength
*/
int
rt_hwcrypto_bignum_get_len
(
const
struct
hw_bignum_mpi
*
n
)
{
...
...
@@ -111,29 +111,34 @@ int rt_hwcrypto_bignum_get_len(const struct hw_bignum_mpi *n)
}
/**
* @brief
Get length of bignum as an unsigned binary buffer
* @brief
Export n into unsigned binary data, big endian
*
* @param n bignum obj
* @param buf Buffer for the binary number
* @param len Length of the buffer
*
* @return
binary buffer L
ength
* @return
export bin l
ength
*/
int
rt_hwcrypto_bignum_
ge
t_bin
(
struct
hw_bignum_mpi
*
n
,
rt_uint8_t
*
buf
,
int
len
)
int
rt_hwcrypto_bignum_
expor
t_bin
(
struct
hw_bignum_mpi
*
n
,
rt_uint8_t
*
buf
,
int
len
)
{
int
cp_len
;
int
cp_len
,
i
,
j
;
if
(
n
==
RT_NULL
||
n
->
p
==
RT_NULL
||
buf
==
RT_NULL
)
if
(
n
==
RT_NULL
||
buf
==
RT_NULL
)
{
return
0
;
}
rt_memset
(
buf
,
0
,
len
);
cp_len
=
n
->
total
>
len
?
len
:
n
->
total
;
rt_memcpy
(
n
->
p
,
buf
,
cp_len
);
for
(
i
=
cp_len
,
j
=
0
;
i
>
0
;
i
--
,
j
++
)
{
buf
[
i
-
1
]
=
n
->
p
[
j
];
}
return
cp_len
;
}
/**
* @brief
Set binary buffer to unsigned bignum
* @brief
Import n from unsigned binary data, big endian
*
* @param n bignum obj
* @param buf Buffer for the binary number
...
...
@@ -141,82 +146,39 @@ int rt_hwcrypto_bignum_get_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int len
*
* @return RT_EOK on success.
*/
rt_err_t
rt_hwcrypto_bignum_
se
t_bin
(
struct
hw_bignum_mpi
*
n
,
rt_uint8_t
*
buf
,
int
len
)
rt_err_t
rt_hwcrypto_bignum_
impor
t_bin
(
struct
hw_bignum_mpi
*
n
,
rt_uint8_t
*
buf
,
int
len
)
{
int
cp_len
,
i
,
j
;
void
*
temp_p
;
if
(
n
==
RT_NULL
)
{
return
-
RT_EINVAL
;
}
if
(
n
->
p
&&
n
->
total
>=
len
)
{
rt_memcpy
(
n
->
p
,
buf
,
len
);
return
RT_EOK
;
}
temp_p
=
rt_malloc
(
len
);
if
(
temp_p
==
RT_NULL
)
if
(
n
==
RT_NULL
||
buf
==
RT_NULL
)
{
return
-
RT_ENOMEM
;
return
0
;
}
if
(
n
->
p
)
if
(
n
->
total
<
len
)
{
temp_p
=
rt_malloc
(
len
);
if
(
temp_p
==
RT_NULL
)
{
return
0
;
}
rt_memset
(
temp_p
,
0
,
len
);
rt_free
(
n
->
p
);
n
->
p
=
temp_p
;
n
->
total
=
0
;
n
->
total
=
len
;
}
rt_memcpy
(
n
->
p
,
buf
,
len
);
n
->
total
=
len
;
return
RT_EOK
;
}
/**
* @brief Unsigned comparison
*
* @param a bignum obj
* @param b bignum obj
*
* @return 0 is equal
*/
int
rt_hwcrypto_bignum_cmp
(
const
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
)
{
int
a_len
,
b_len
;
cp_len
=
n
->
total
>
len
?
len
:
n
->
total
;
if
(
a
==
RT_NULL
||
a
->
p
==
RT_NULL
||
b
==
RT_NULL
||
b
->
p
==
RT_NULL
)
{
return
-
1
;
}
a_len
=
rt_hwcrypto_bignum_get_len
(
a
);
b_len
=
rt_hwcrypto_bignum_get_len
(
b
);
if
(
a_len
!=
b_len
)
for
(
i
=
cp_len
,
j
=
0
;
i
>
0
;
i
--
,
j
++
)
{
return
a_len
-
b_len
;
n
->
p
[
j
]
=
buf
[
i
-
1
]
;
}
return
rt_memcmp
(
a
->
p
,
b
->
p
,
a_len
);
}
/**
* @brief Compare bignum to standard Unsigned integer
*
* @param a bignum obj
* @param b Unsigned integer
*
* @return 0 is equal
*/
int
rt_hwcrypto_bignum_cmp_d
(
const
struct
hw_bignum_mpi
*
a
,
unsigned
long
b
)
{
struct
hw_bignum_mpi
tmp_b
;
b
=
b
<=
0
?
-
b
:
b
;
tmp_b
.
total
=
sizeof
(
unsigned
long
);
tmp_b
.
p
=
&
b
;
return
rt_hwcrypto_bignum_cmp
(
a
,
&
tmp_b
);
return
cp_len
;
}
/**
* @brief
a = b + c
* @brief
x = a + b
*
* @param a bignum obj
* @param b bignum obj
...
...
@@ -224,26 +186,26 @@ int rt_hwcrypto_bignum_cmp_d(const struct hw_bignum_mpi *a, unsigned long b)
*
* @return RT_EOK on success.
*/
rt_err_t
rt_hwcrypto_bignum_add
(
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
,
const
struct
hw_bignum_mpi
*
c
)
rt_err_t
rt_hwcrypto_bignum_add
(
struct
hw_bignum_mpi
*
x
,
const
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
)
{
struct
hwcrypto_bignum
*
bignum_ctx
;
if
(
rt_hwcrypto_bignum
_init
()
!=
RT_EOK
)
if
(
hwcrypto_bignum_dev_is
_init
()
!=
RT_EOK
)
{
return
-
RT_ERROR
;
}
bignum_ctx
=
(
struct
hwcrypto_bignum
*
)
bignum_default
;
if
(
bignum_ctx
->
ops
->
add
)
{
return
bignum_ctx
->
ops
->
add
(
bignum_ctx
,
a
,
b
,
c
);
return
bignum_ctx
->
ops
->
add
(
bignum_ctx
,
x
,
a
,
b
);
}
return
-
RT_ERROR
;
}
/**
* @brief
a = b - c
* @brief
x = a - b
*
* @param a bignum obj
* @param b bignum obj
...
...
@@ -251,26 +213,26 @@ rt_err_t rt_hwcrypto_bignum_add(struct hw_bignum_mpi *a,
*
* @return RT_EOK on success.
*/
rt_err_t
rt_hwcrypto_bignum_sub
(
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
,
const
struct
hw_bignum_mpi
*
c
)
rt_err_t
rt_hwcrypto_bignum_sub
(
struct
hw_bignum_mpi
*
x
,
const
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
)
{
struct
hwcrypto_bignum
*
bignum_ctx
;
if
(
rt_hwcrypto_bignum
_init
()
!=
RT_EOK
)
if
(
hwcrypto_bignum_dev_is
_init
()
!=
RT_EOK
)
{
return
-
RT_ERROR
;
}
bignum_ctx
=
(
struct
hwcrypto_bignum
*
)
bignum_default
;
if
(
bignum_ctx
->
ops
->
sub
)
{
return
bignum_ctx
->
ops
->
sub
(
bignum_ctx
,
a
,
b
,
c
);
return
bignum_ctx
->
ops
->
sub
(
bignum_ctx
,
x
,
a
,
b
);
}
return
-
RT_ERROR
;
}
/**
* @brief
a = b * c
* @brief
x = a * b
*
* @param a bignum obj
* @param b bignum obj
...
...
@@ -278,26 +240,26 @@ rt_err_t rt_hwcrypto_bignum_sub(struct hw_bignum_mpi *a,
*
* @return RT_EOK on success.
*/
rt_err_t
rt_hwcrypto_bignum_mul
(
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
,
const
struct
hw_bignum_mpi
*
c
)
rt_err_t
rt_hwcrypto_bignum_mul
(
struct
hw_bignum_mpi
*
x
,
const
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
)
{
struct
hwcrypto_bignum
*
bignum_ctx
;
if
(
rt_hwcrypto_bignum
_init
()
!=
RT_EOK
)
if
(
hwcrypto_bignum_dev_is
_init
()
!=
RT_EOK
)
{
return
-
RT_ERROR
;
}
bignum_ctx
=
(
struct
hwcrypto_bignum
*
)
bignum_default
;
if
(
bignum_ctx
->
ops
->
mul
)
{
return
bignum_ctx
->
ops
->
mul
(
bignum_ctx
,
a
,
b
,
c
);
return
bignum_ctx
->
ops
->
mul
(
bignum_ctx
,
x
,
a
,
b
);
}
return
-
RT_ERROR
;
}
/**
* @brief
a = b * c (mod d
)
* @brief
x = a * b (mod c
)
*
* @param a bignum obj
* @param b bignum obj
...
...
@@ -305,27 +267,27 @@ rt_err_t rt_hwcrypto_bignum_mul(struct hw_bignum_mpi *a,
*
* @return RT_EOK on success.
*/
rt_err_t
rt_hwcrypto_bignum_mulmod
(
struct
hw_bignum_mpi
*
a
,
rt_err_t
rt_hwcrypto_bignum_mulmod
(
struct
hw_bignum_mpi
*
x
,
const
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
,
const
struct
hw_bignum_mpi
*
c
,
const
struct
hw_bignum_mpi
*
d
)
const
struct
hw_bignum_mpi
*
c
)
{
struct
hwcrypto_bignum
*
bignum_ctx
;
if
(
rt_hwcrypto_bignum
_init
()
!=
RT_EOK
)
if
(
hwcrypto_bignum_dev_is
_init
()
!=
RT_EOK
)
{
return
-
RT_ERROR
;
}
bignum_ctx
=
(
struct
hwcrypto_bignum
*
)
bignum_default
;
if
(
bignum_ctx
->
ops
->
mulmod
)
{
return
bignum_ctx
->
ops
->
mulmod
(
bignum_ctx
,
a
,
b
,
c
,
d
);
return
bignum_ctx
->
ops
->
mulmod
(
bignum_ctx
,
x
,
a
,
b
,
c
);
}
return
-
RT_ERROR
;
}
/**
* @brief
a = b ^ c (mod d
)
* @brief
x = a ^ b (mod c
)
*
* @param a bignum obj
* @param b bignum obj
...
...
@@ -333,21 +295,21 @@ rt_err_t rt_hwcrypto_bignum_mulmod(struct hw_bignum_mpi *a,
*
* @return RT_EOK on success.
*/
rt_err_t
bignum_exptmod
(
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
,
const
struct
hw_bignum_mpi
*
c
,
const
struct
hw_bignum_mpi
*
d
)
rt_err_t
rt_hwcrypto_bignum_exptmod
(
struct
hw_bignum_mpi
*
x
,
const
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
,
const
struct
hw_bignum_mpi
*
c
)
{
struct
hwcrypto_bignum
*
bignum_ctx
;
if
(
rt_hwcrypto_bignum
_init
()
!=
RT_EOK
)
if
(
hwcrypto_bignum_dev_is
_init
()
!=
RT_EOK
)
{
return
-
RT_ERROR
;
}
bignum_ctx
=
(
struct
hwcrypto_bignum
*
)
bignum_default
;
if
(
bignum_ctx
->
ops
->
exptmod
)
{
return
bignum_ctx
->
ops
->
exptmod
(
bignum_ctx
,
a
,
b
,
c
,
d
);
return
bignum_ctx
->
ops
->
exptmod
(
bignum_ctx
,
x
,
a
,
b
,
c
);
}
return
-
RT_ERROR
;
}
components/drivers/hwcrypto/hw_bignum.h
浏览文件 @
d576c936
...
...
@@ -22,34 +22,35 @@ struct hwcrypto_bignum;
/* bignum obj */
struct
hw_bignum_mpi
{
rt_size_t
total
;
/**< Total length of data */
rt_ubase_t
*
p
;
/**< pointer to data */
int
sign
;
/**< integer sign */
rt_size_t
total
;
/**< total of limbs */
rt_uint8_t
*
p
;
/**< pointer to limbs */
};
struct
hwcrypto_bignum_ops
{
rt_err_t
(
*
add
)(
struct
hwcrypto_bignum
*
bignum_ctx
,
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
,
const
struct
hw_bignum_mpi
*
c
);
/**< a = b + c
*/
struct
hw_bignum_mpi
*
x
,
const
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
);
/**< x = a + b
*/
rt_err_t
(
*
sub
)(
struct
hwcrypto_bignum
*
bignum_ctx
,
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
,
const
struct
hw_bignum_mpi
*
c
);
/**< a = b - c
*/
struct
hw_bignum_mpi
*
x
,
const
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
);
/**< x = a - b
*/
rt_err_t
(
*
mul
)(
struct
hwcrypto_bignum
*
bignum_ctx
,
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
,
const
struct
hw_bignum_mpi
*
c
);
/**< a = b * c
*/
struct
hw_bignum_mpi
*
x
,
const
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
);
/**< x = a * b
*/
rt_err_t
(
*
mulmod
)(
struct
hwcrypto_bignum
*
bignum_ctx
,
struct
hw_bignum_mpi
*
a
,
struct
hw_bignum_mpi
*
x
,
const
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
,
const
struct
hw_bignum_mpi
*
c
,
const
struct
hw_bignum_mpi
*
d
);
/**< a = b * c (mod d) */
const
struct
hw_bignum_mpi
*
c
);
/**< x = a * b (mod c) */
rt_err_t
(
*
exptmod
)(
struct
hwcrypto_bignum
*
bignum_ctx
,
struct
hw_bignum_mpi
*
a
,
struct
hw_bignum_mpi
*
x
,
const
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
,
const
struct
hw_bignum_mpi
*
c
,
const
struct
hw_bignum_mpi
*
d
);
/**< a = b ^ c (mod d) */
const
struct
hw_bignum_mpi
*
c
);
/**< x = a ^ b (mod c) */
};
/**
...
...
@@ -69,11 +70,9 @@ struct hwcrypto_bignum
rt_err_t
rt_hwcrypto_bignum_default
(
struct
rt_hwcrypto_device
*
device
);
/**
* @brief Allocate memory for bignum
*
* @return Pointer to allocated bignum obj
* @brief Init bignum obj
*/
struct
hw_bignum_mpi
*
rt_hwcrypto_bignum_alloc
(
void
);
void
rt_hwcrypto_bignum_init
(
struct
hw_bignum_mpi
*
n
);
/**
* @brief free a bignum obj
...
...
@@ -92,18 +91,18 @@ void rt_hwcrypto_bignum_free(struct hw_bignum_mpi *n);
int
rt_hwcrypto_bignum_get_len
(
const
struct
hw_bignum_mpi
*
n
);
/**
* @brief
Get length of bignum as an unsigned binary buffer
* @brief
Export n into unsigned binary data, big endian
*
* @param n bignum obj
* @param buf Buffer for the binary number
* @param len Length of the buffer
*
* @return
binary buffer L
ength
* @return
export bin l
ength
*/
int
rt_hwcrypto_bignum_
ge
t_bin
(
struct
hw_bignum_mpi
*
n
,
rt_uint8_t
*
buf
,
int
len
);
int
rt_hwcrypto_bignum_
expor
t_bin
(
struct
hw_bignum_mpi
*
n
,
rt_uint8_t
*
buf
,
int
len
);
/**
* @brief
Set binary buffer to unsigned bignum
* @brief
Import n from unsigned binary data, big endian
*
* @param n bignum obj
* @param buf Buffer for the binary number
...
...
@@ -111,31 +110,10 @@ int rt_hwcrypto_bignum_get_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int len
*
* @return RT_EOK on success.
*/
rt_err_t
rt_hwcrypto_bignum_
se
t_bin
(
struct
hw_bignum_mpi
*
n
,
rt_uint8_t
*
buf
,
int
len
);
rt_err_t
rt_hwcrypto_bignum_
impor
t_bin
(
struct
hw_bignum_mpi
*
n
,
rt_uint8_t
*
buf
,
int
len
);
/**
* @brief Unsigned comparison
*
* @param a bignum obj
* @param b bignum obj
*
* @return 0 is equal
*/
int
rt_hwcrypto_bignum_cmp
(
const
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
);
/**
* @brief Compare bignum to standard Unsigned integer
*
* @param a bignum obj
* @param b Unsigned integer
*
* @return 0 is equal
*/
int
rt_hwcrypto_bignum_cmp_d
(
const
struct
hw_bignum_mpi
*
a
,
unsigned
long
b
);
/**
* @brief a = b + c
* @brief x = a + b
*
* @param a bignum obj
* @param b bignum obj
...
...
@@ -143,12 +121,12 @@ int rt_hwcrypto_bignum_cmp_d(const struct hw_bignum_mpi *a, unsigned long b);
*
* @return RT_EOK on success.
*/
rt_err_t
rt_hwcrypto_bignum_add
(
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
,
const
struct
hw_bignum_mpi
*
c
);
rt_err_t
rt_hwcrypto_bignum_add
(
struct
hw_bignum_mpi
*
x
,
const
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
);
/**
* @brief
a = b - c
* @brief
x = a - b
*
* @param a bignum obj
* @param b bignum obj
...
...
@@ -156,12 +134,12 @@ rt_err_t rt_hwcrypto_bignum_add(struct hw_bignum_mpi *a,
*
* @return RT_EOK on success.
*/
rt_err_t
rt_hwcrypto_bignum_sub
(
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
,
const
struct
hw_bignum_mpi
*
c
);
rt_err_t
rt_hwcrypto_bignum_sub
(
struct
hw_bignum_mpi
*
x
,
const
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
);
/**
* @brief
a = b * c
* @brief
x = a * b
*
* @param a bignum obj
* @param b bignum obj
...
...
@@ -169,12 +147,12 @@ rt_err_t rt_hwcrypto_bignum_sub(struct hw_bignum_mpi *a,
*
* @return RT_EOK on success.
*/
rt_err_t
rt_hwcrypto_bignum_mul
(
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
,
const
struct
hw_bignum_mpi
*
c
);
rt_err_t
rt_hwcrypto_bignum_mul
(
struct
hw_bignum_mpi
*
x
,
const
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
);
/**
* @brief
a = b * c (mod d
)
* @brief
x = a * b (mod c
)
*
* @param a bignum obj
* @param b bignum obj
...
...
@@ -182,13 +160,13 @@ rt_err_t rt_hwcrypto_bignum_mul(struct hw_bignum_mpi *a,
*
* @return RT_EOK on success.
*/
rt_err_t
rt_hwcrypto_bignum_mulmod
(
struct
hw_bignum_mpi
*
a
,
rt_err_t
rt_hwcrypto_bignum_mulmod
(
struct
hw_bignum_mpi
*
x
,
const
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
,
const
struct
hw_bignum_mpi
*
c
,
const
struct
hw_bignum_mpi
*
d
);
const
struct
hw_bignum_mpi
*
c
);
/**
* @brief
a = b ^ c (mod d
)
* @brief
x = a ^ b (mod c
)
*
* @param a bignum obj
* @param b bignum obj
...
...
@@ -196,10 +174,10 @@ rt_err_t rt_hwcrypto_bignum_mulmod(struct hw_bignum_mpi *a,
*
* @return RT_EOK on success.
*/
rt_err_t
bignum_exptmod
(
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
,
const
struct
hw_bignum_mpi
*
c
,
const
struct
hw_bignum_mpi
*
d
);
rt_err_t
rt_hwcrypto_bignum_exptmod
(
struct
hw_bignum_mpi
*
x
,
const
struct
hw_bignum_mpi
*
a
,
const
struct
hw_bignum_mpi
*
b
,
const
struct
hw_bignum_mpi
*
c
);
#ifdef __cplusplus
}
...
...
components/drivers/hwcrypto/hw_hash.h
浏览文件 @
d576c936
...
...
@@ -101,7 +101,7 @@ void rt_hwcrypto_hash_reset(struct rt_hwcrypto_ctx *ctx);
*
* @return RT_EOK on success.
*/
rt_err_t
rt_hwcrypto_hash_type
(
struct
rt_hwcrypto_ctx
*
ctx
,
hwcrypto_type
type
);
rt_err_t
rt_hwcrypto_hash_
set_
type
(
struct
rt_hwcrypto_ctx
*
ctx
,
hwcrypto_type
type
);
#ifdef __cplusplus
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录