This commit is contained in:
Looly 2019-10-08 16:02:06 +08:00
parent 5d99de9b89
commit 1364656855
2 changed files with 4 additions and 3 deletions

View File

@ -12,6 +12,7 @@
* 【core】 修改错别字pr#568@Github
* 【core】 增加DateUtil.parseCST方法issue#570@Github
* 【core】 增加defaultIfEmpty方法
* 【crypto】 修改bigIntToFixexLengthBytes为bigIntToFixedLengthBytespr#575@Github
### Bug修复
* 【all】 修复阶乘计算错误bugissue#I12XE4@Gitee

View File

@ -189,8 +189,8 @@ public class SmUtil {
*/
public static byte[] rsAsn1ToPlain(byte[] rsDer) {
ASN1Sequence seq = ASN1Sequence.getInstance(rsDer);
byte[] r = bigIntToFixexLengthBytes(ASN1Integer.getInstance(seq.getObjectAt(0)).getValue());
byte[] s = bigIntToFixexLengthBytes(ASN1Integer.getInstance(seq.getObjectAt(1)).getValue());
byte[] r = bigIntToFixedLengthBytes(ASN1Integer.getInstance(seq.getObjectAt(0)).getValue());
byte[] s = bigIntToFixedLengthBytes(ASN1Integer.getInstance(seq.getObjectAt(1)).getValue());
byte[] result = new byte[RS_LEN * 2];
System.arraycopy(r, 0, result, 0, r.length);
System.arraycopy(s, 0, result, RS_LEN, s.length);
@ -251,7 +251,7 @@ public class SmUtil {
* @return 固定长度bytes
* @since 4.5.0
*/
private static byte[] bigIntToFixexLengthBytes(BigInteger rOrS) {
private static byte[] bigIntToFixedLengthBytes(BigInteger rOrS) {
// for sm2p256v1, n is 00fffffffeffffffffffffffffffffffff7203df6b21c6052b53bbf40939d54123,
// r and s are the result of mod n, so they should be less than n and have length<=32
byte[] rs = rOrS.toByteArray();