Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
c971db9a
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c971db9a
编写于
8月 29, 2018
作者:
A
apetcher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8201317: X25519/X448 code improvements
Summary: Minor code/comment improvements Reviewed-by: xuelei
上级
940609d3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
58 addition
and
7 deletion
+58
-7
src/share/classes/sun/security/util/math/intpoly/IntegerPolynomial.java
...ses/sun/security/util/math/intpoly/IntegerPolynomial.java
+58
-7
未找到文件。
src/share/classes/sun/security/util/math/intpoly/IntegerPolynomial.java
浏览文件 @
c971db9a
...
...
@@ -70,13 +70,28 @@ public abstract class IntegerPolynomial implements IntegerFieldModuloP {
protected
final
int
bitsPerLimb
;
private
final
long
[]
posModLimbs
;
// must work when a==r
/**
* Multiply an IntegerPolynomial representation (a) with a long (b) and
* store the result in an IntegerPolynomial representation (r). Requires
* that a.length == r.length == numLimbs. It is allowed for a and r to be
* the same array.
*/
protected
abstract
void
multByInt
(
long
[]
a
,
long
b
,
long
[]
r
);
// must work when a==r
/**
* Multiply two IntegerPolynomial representations (a and b) and store the
* result in an IntegerPolynomial representation (r). Requires that
* a.length == b.length == r.length == numLimbs. It is allowed for a and r
* to be the same array.
*/
protected
abstract
void
mult
(
long
[]
a
,
long
[]
b
,
long
[]
r
);
// must work when a==r
/**
* Multiply an IntegerPolynomial representation (a) with itself and store
* the result in an IntegerPolynomialRepresentation (r). Requires that
* a.length == r.length == numLimbs. It is allowed for a and r
* to be the same array.
*/
protected
abstract
void
square
(
long
[]
a
,
long
[]
r
);
IntegerPolynomial
(
int
bitsPerLimb
,
...
...
@@ -240,7 +255,9 @@ public abstract class IntegerPolynomial implements IntegerFieldModuloP {
carry
(
limbs
,
0
,
limbs
.
length
-
1
);
}
// carry out of the specified position and return the carry value
/**
* Carry out of the specified position and return the carry value.
*/
protected
long
carryOut
(
long
[]
limbs
,
int
index
)
{
long
carry
=
carryValue
(
limbs
[
index
]);
limbs
[
index
]
-=
(
carry
<<
bitsPerLimb
);
...
...
@@ -261,9 +278,20 @@ public abstract class IntegerPolynomial implements IntegerFieldModuloP {
}
}
/**
* Carry out of the last limb and reduce back in. This method will be
* called as part of the "finalReduce" operation that puts the
* representation into a fully-reduced form. It is representation-
* specific, because representations have different amounts of empty
* space in the high-order limb. Requires that limbs.length=numLimbs.
*/
protected
abstract
void
finalCarryReduceLast
(
long
[]
limbs
);
// Convert reduced limbs into a number between 0 and MODULUS-1
/**
* Convert reduced limbs into a number between 0 and MODULUS-1.
* Requires that limbs.length == numLimbs. This method only works if the
* modulus has at most three terms.
*/
protected
void
finalReduce
(
long
[]
limbs
)
{
// This method works by doing several full carry/reduce operations.
...
...
@@ -313,8 +341,10 @@ public abstract class IntegerPolynomial implements IntegerFieldModuloP {
}
// v must be final reduced. I.e. all limbs in [0, bitsPerLimb)
// and value in [0, modulus)
/**
* Decode the value in v and store it in dst. Requires that v is final
* reduced. I.e. all limbs in [0, 2^bitsPerLimb) and value in [0, modulus).
*/
protected
void
decode
(
long
[]
v
,
byte
[]
dst
,
int
offset
,
int
length
)
{
int
nextLimbIndex
=
0
;
...
...
@@ -344,12 +374,25 @@ public abstract class IntegerPolynomial implements IntegerFieldModuloP {
}
}
/**
* Add two IntegerPolynomial representations (a and b) and store the result
* in an IntegerPolynomialRepresentation (dst). Requires that
* a.length == b.length == dst.length. It is allowed for a and
* dst to be the same array.
*/
protected
void
addLimbs
(
long
[]
a
,
long
[]
b
,
long
[]
dst
)
{
for
(
int
i
=
0
;
i
<
dst
.
length
;
i
++)
{
dst
[
i
]
=
a
[
i
]
+
b
[
i
];
}
}
/**
* Branch-free conditional swap of a and b. Requires that swap is 0 or 1,
* and that a.length == b.length. If swap==0, then the values of a and b
* will be unchanged. If swap==1, then the values of a and b will be
* swapped. The behavior is undefined if swap has any value other than
* 0 or 1.
*/
protected
static
void
conditionalSwap
(
int
swap
,
long
[]
a
,
long
[]
b
)
{
int
maskValue
=
0
-
swap
;
for
(
int
i
=
0
;
i
<
a
.
length
;
i
++)
{
...
...
@@ -359,6 +402,9 @@ public abstract class IntegerPolynomial implements IntegerFieldModuloP {
}
}
/**
* Stores the reduced, little-endian value of limbs in result.
*/
protected
void
limbsToByteArray
(
long
[]
limbs
,
byte
[]
result
)
{
long
[]
reducedLimbs
=
limbs
.
clone
();
...
...
@@ -367,6 +413,11 @@ public abstract class IntegerPolynomial implements IntegerFieldModuloP {
decode
(
reducedLimbs
,
result
,
0
,
result
.
length
);
}
/**
* Add the reduced number corresponding to limbs and other, and store
* the low-order bytes of the sum in result. Requires that
* limbs.length==other.length. The result array may have any length.
*/
protected
void
addLimbsModPowerTwo
(
long
[]
limbs
,
long
[]
other
,
byte
[]
result
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录