Skip to content

Commit

Permalink
v10.19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Raka-loah committed Jul 4, 2024
1 parent 3cad072 commit 7e1407d
Show file tree
Hide file tree
Showing 10 changed files with 242 additions and 243 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"babel-plugin-dynamic-import-node": "^2.3.3",
"babel-plugin-transform-builtin-extend": "1.1.2",
"base64-loader": "^1.0.0",
"chromedriver": "^125.0.3",
"chromedriver": "^126.0.4",
"cli-progress": "^3.12.0",
"colors": "^1.4.0",
"copy-webpack-plugin": "^12.0.2",
Expand Down
2 changes: 1 addition & 1 deletion src/core/Recipe.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Recipe {
disabled: c.disabled || c.op === "Comment",
});
} catch (error) {
console.log(`[WARNING] ${c.op} Not found: ${error}`);
log.warn(`[WARNING] ${c.op} Not found: ${error}`);
}

});
Expand Down
1 change: 0 additions & 1 deletion src/core/lib/IP.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export function ipv6CidrRange(cidr, includeNetworkInfo) {
output += "掩码: " + ipv6ToStr(mask) + "\n";
output += "范围: " + ipv6ToStr(ip1) + " - " + ipv6ToStr(ip2) + "\n";
// output += "范围中地址数: " + (parseInt(total.join(""), 2) + 1) + "\n\n";
/* global BigInt */
output += "范围中地址数: " + (BigInt("0b" + total.join("")) + BigInt(1)) + "\n\n";
}

Expand Down
82 changes: 41 additions & 41 deletions src/core/operations/ParseCSR.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ class ParseCSR extends Operation {
// Parse the CSR into JSON parameters
const csrParam = new r.KJUR.asn1.csr.CSRUtil.getParam(input);

return `Subject\n${formatDnObj(csrParam.subject, 2)}
Public Key${formatSubjectPublicKey(csrParam.sbjpubkey)}
Signature${formatSignature(csrParam.sigalg, csrParam.sighex)}
Requested Extensions${formatRequestedExtensions(csrParam)}`;
return `主体\n${formatDnObj(csrParam.subject, 2)}
公钥${formatSubjectPublicKey(csrParam.sbjpubkey)}
签名${formatSignature(csrParam.sigalg, csrParam.sighex)}
请求的扩展程序${formatRequestedExtensions(csrParam)}`;
}
}

Expand All @@ -73,18 +73,18 @@ Requested Extensions${formatRequestedExtensions(csrParam)}`;
function formatSignature(sigAlg, sigHex) {
let out = `\n`;

out += ` Algorithm: ${sigAlg}\n`;
out += ` 算法: ${sigAlg}\n`;

if (new RegExp("withdsa", "i").test(sigAlg)) {
const d = new r.KJUR.crypto.DSA();
const sigParam = d.parseASN1Signature(sigHex);
out += ` Signature:
out += ` 签名:
R: ${formatHexOntoMultiLine(absBigIntToHex(sigParam[0]))}
S: ${formatHexOntoMultiLine(absBigIntToHex(sigParam[1]))}\n`;
} else if (new RegExp("withrsa", "i").test(sigAlg)) {
out += ` Signature: ${formatHexOntoMultiLine(sigHex)}\n`;
out += ` 签名: ${formatHexOntoMultiLine(sigHex)}\n`;
} else {
out += ` Signature: ${formatHexOntoMultiLine(ensureHexIsPositiveInTwosComplement(sigHex))}\n`;
out += ` 签名: ${formatHexOntoMultiLine(ensureHexIsPositiveInTwosComplement(sigHex))}\n`;
}

return chop(out);
Expand All @@ -100,25 +100,25 @@ function formatSubjectPublicKey(publicKeyPEM) {

const publicKey = r.KEYUTIL.getKey(publicKeyPEM);
if (publicKey instanceof r.RSAKey) {
out += ` Algorithm: RSA
Length: ${publicKey.n.bitLength()} bits
Modulus: ${formatHexOntoMultiLine(absBigIntToHex(publicKey.n))}
Exponent: ${publicKey.e} (0x${Utils.hex(publicKey.e)})\n`;
out += ` 算法: RSA
长度: ${publicKey.n.bitLength()} bits
模数: ${formatHexOntoMultiLine(absBigIntToHex(publicKey.n))}
指数: ${publicKey.e} (0x${Utils.hex(publicKey.e)})\n`;
} else if (publicKey instanceof r.KJUR.crypto.ECDSA) {
out += ` Algorithm: ECDSA
Length: ${publicKey.ecparams.keylen} bits
out += ` 算法: ECDSA
长度: ${publicKey.ecparams.keylen} bits
Pub: ${formatHexOntoMultiLine(publicKey.pubKeyHex)}
ASN1 OID: ${r.KJUR.crypto.ECDSA.getName(publicKey.getShortNISTPCurveName())}
NIST CURVE: ${publicKey.getShortNISTPCurveName()}\n`;
} else if (publicKey instanceof r.KJUR.crypto.DSA) {
out += ` Algorithm: DSA
Length: ${publicKey.p.toString(16).length * 4} bits
out += ` 算法: DSA
长度: ${publicKey.p.toString(16).length * 4} bits
Pub: ${formatHexOntoMultiLine(absBigIntToHex(publicKey.y))}
P: ${formatHexOntoMultiLine(absBigIntToHex(publicKey.p))}
Q: ${formatHexOntoMultiLine(absBigIntToHex(publicKey.q))}
G: ${formatHexOntoMultiLine(absBigIntToHex(publicKey.g))}\n`;
} else {
out += `unsupported public key algorithm\n`;
out += `不支持的公钥算法\n`;
}

return chop(out);
Expand All @@ -138,22 +138,22 @@ function formatRequestedExtensions(csrParam) {
switch (extension.extname) {
case "basicConstraints" :
parts = describeBasicConstraints(extension);
formattedExtensions[0] = ` Basic Constraints:${formatExtensionCriticalTag(extension)}\n${indent(4, parts)}`;
formattedExtensions[0] = ` 证书基本约束:${formatExtensionCriticalTag(extension)}\n${indent(4, parts)}`;
break;
case "keyUsage" :
parts = describeKeyUsage(extension);
formattedExtensions[1] = ` Key Usage:${formatExtensionCriticalTag(extension)}\n${indent(4, parts)}`;
formattedExtensions[1] = ` 证书密钥用法:${formatExtensionCriticalTag(extension)}\n${indent(4, parts)}`;
break;
case "extKeyUsage" :
parts = describeExtendedKeyUsage(extension);
formattedExtensions[2] = ` Extended Key Usage:${formatExtensionCriticalTag(extension)}\n${indent(4, parts)}`;
formattedExtensions[2] = ` 扩展密钥用法:${formatExtensionCriticalTag(extension)}\n${indent(4, parts)}`;
break;
case "subjectAltName" :
parts = describeSubjectAlternativeName(extension);
formattedExtensions[3] = ` Subject Alternative Name:${formatExtensionCriticalTag(extension)}\n${indent(4, parts)}`;
formattedExtensions[3] = ` 主体备用名称:${formatExtensionCriticalTag(extension)}\n${indent(4, parts)}`;
break;
default :
parts = ["(unsuported extension)"];
parts = ["(不支持的扩展程序)"];
formattedExtensions.push(` ${extension.extname}:${formatExtensionCriticalTag(extension)}\n${indent(4, parts)}`);
}
}
Expand All @@ -176,7 +176,7 @@ function formatRequestedExtensions(csrParam) {
* @returns String describing whether the extension is critical or not
*/
function formatExtensionCriticalTag(extension) {
return Object.hasOwn(extension, "critical") && extension.critical ? " critical" : "";
return Object.hasOwn(extension, "critical") && extension.critical ? " 关键" : "";
}

/**
Expand Down Expand Up @@ -245,8 +245,8 @@ function formatMultiLine(longStr) {
function describeBasicConstraints(extension) {
const constraints = [];

constraints.push(`CA = ${Object.hasOwn(extension, "cA") && extension.cA ? "true" : "false"}`);
if (Object.hasOwn(extension, "pathLen")) constraints.push(`PathLenConstraint = ${extension.pathLen}`);
constraints.push(`CA = ${Object.hasOwn(extension, "cA") && extension.cA ? "" : ""}`);
if (Object.hasOwn(extension, "pathLen")) constraints.push(`中级CA证书数目上限 = ${extension.pathLen}`);

return constraints;
}
Expand All @@ -261,23 +261,23 @@ function describeKeyUsage(extension) {
const usage = [];

const kuIdentifierToName = {
digitalSignature: "Digital Signature",
nonRepudiation: "Non-repudiation",
keyEncipherment: "Key encipherment",
dataEncipherment: "Data encipherment",
keyAgreement: "Key agreement",
keyCertSign: "Key certificate signing",
cRLSign: "CRL signing",
encipherOnly: "Encipher Only",
decipherOnly: "Decipher Only",
digitalSignature: "签名",
nonRepudiation: "非否认",
keyEncipherment: "密钥加密",
dataEncipherment: "数据加密",
keyAgreement: "密钥协商",
keyCertSign: "证书签名",
cRLSign: "CRL签名",
encipherOnly: "仅加密",
decipherOnly: "仅解密",
};

if (Object.hasOwn(extension, "names")) {
extension.names.forEach((ku) => {
if (Object.hasOwn(kuIdentifierToName, ku)) {
usage.push(kuIdentifierToName[ku]);
} else {
usage.push(`unknown key usage (${ku})`);
usage.push(`未知的密钥用法 (${ku})`);
}
});
}
Expand All @@ -297,11 +297,11 @@ function describeExtendedKeyUsage(extension) {
const usage = [];

const ekuIdentifierToName = {
"serverAuth": "TLS Web Server Authentication",
"clientAuth": "TLS Web Client Authentication",
"codeSigning": "Code signing",
"emailProtection": "E-mail Protection (S/MIME)",
"timeStamping": "Trusted Timestamping",
"serverAuth": "TLS WWW 服务器身份验证",
"clientAuth": "TLS WWW 客户端身份验证",
"codeSigning": "代码签名",
"emailProtection": "电子邮件保护 (S/MIME)",
"timeStamping": "可信任时间戳",
"1.3.6.1.4.1.311.2.1.21": "Microsoft Individual Code Signing", // msCodeInd
"1.3.6.1.4.1.311.2.1.22": "Microsoft Commercial Code Signing", // msCodeCom
"1.3.6.1.4.1.311.10.3.1": "Microsoft Trust List Signing", // msCTLSign
Expand Down Expand Up @@ -359,7 +359,7 @@ function describeSubjectAlternativeName(extension) {
names.push(`Other: ${altName[key].oid}::${altName[key].value.utf8str.str}`);
break;
default:
names.push(`(unable to format SAN '${key}':${altName[key]})\n`);
names.push(`(无法格式化SAN '${key}':${altName[key]})\n`);
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/web/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -519,14 +519,14 @@ <h5 class="modal-title">设置</h5>
<div class="checkbox option-item">
<label for="syncTabs">
<input type="checkbox" option="syncTabs" id="syncTabs">
Keep the current tab in sync between the input and output
同步选中对应的输入和输出标签页
</label>
</div>

<div class="checkbox option-item">
<label for="showCatCount">
<input type="checkbox" option="showCatCount" id="showCatCount">
Show the number of operations in each category
显示每个分类的操作数目
</label>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion tests/browser/01_io.js
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ module.exports = {

/* Complex deep link populates the input correctly (encoding, eol, input) */
browser
.urlHash("recipe=To_Base64('A-Za-z0-9%2B/%3D')&input=VGhlIHNoaXBzIGh1bmcgaW4gdGhlIHNreSBpbiBtdWNoIHRoZSBzYW1lIHdheSB0aGF0IGJyaWNrcyBkb24ndC4M&ienc=21866&oenc=1201&ieol=FF&oeol=PS")
.urlHash("recipe=Base64编码('A-Za-z0-9%2B/%3D')&input=VGhlIHNoaXBzIGh1bmcgaW4gdGhlIHNreSBpbiBtdWNoIHRoZSBzYW1lIHdheSB0aGF0IGJyaWNrcyBkb24ndC4M&ienc=21866&oenc=1201&ieol=FF&oeol=PS")
.waitForElementVisible("#rec-list li.operation");

// browser.expect.element(`#input-text .cm-content`).to.have.property("textContent").match(/^.{65}$/);
Expand Down
2 changes: 1 addition & 1 deletion tests/browser/02_ops.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ module.exports = {
// testOp(browser, "OR", "test input", "test_output");
// testOp(browser, "Object Identifier to Hex", "test input", "test_output");
testOpHtml(browser, "偏移检测", "test input\n\nbest input", ".hl5", "est input");
testOpFile(browser, "Optical Character Recognition", "files/testocr.png", false, /This is a lot of 12 point text to test the/, [], 10000);
testOpFile(browser, "光学字符识别", "files/testocr.png", false, /This is a lot of 12 point text to test the/, [], 10000);
// testOp(browser, "PEM to Hex", "test input", "test_output");
// testOp(browser, "PGP Decrypt", "test input", "test_output");
// testOp(browser, "PGP Decrypt and Verify", "test input", "test_output");
Expand Down
2 changes: 1 addition & 1 deletion tests/browser/browserUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function bake(browser) {
browser
// Ensure we're not currently busy
.waitForElementNotVisible("#output-loader", 5000)
.expect.element("#bake span").text.to.equal("BAKE!");
.expect.element("#bake span").text.to.equal("开整!");

browser
.click("#bake")
Expand Down
Loading

0 comments on commit 7e1407d

Please sign in to comment.