Skip to content

Commit 5f60f1b

Browse files
committed
Fix AONT fallback logic
1 parent 6d169a6 commit 5f60f1b

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/javascript/EncryptHelper.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,10 @@ export function mgf1_sha256(seed, maskLen) {
447447
export function EnAONT(plain) {
448448
const len = plain.length;
449449
if (len < 2) {
450-
throw new Error(
450+
/*throw new Error(
451451
"Insufficient payload length. Payload too short for AONT Feistel split."
452-
);
452+
);*/
453+
return plain; //如果密文太短(长度只有一字节),无法执行,就自动跳过执行。
453454
}
454455

455456
// 动态计算切分点。即使长度为奇数也能完美处理
@@ -493,9 +494,10 @@ export function EnAONT(plain) {
493494
export function DeAONT(cipher) {
494495
const len = cipher.length;
495496
if (len < 2) {
496-
throw new Error(
497+
/*throw new Error(
497498
"Insufficient payload length. Payload too short for AONT Feistel split."
498-
);
499+
);*/
500+
return cipher; //如果密文太短(长度只有一字节),无法执行,就自动跳过执行。
499501
}
500502

501503
// 按照正向相同的切分点切分

0 commit comments

Comments
 (0)