Comments fix.

This commit is contained in:
Leon Zandman 2026-05-17 19:36:32 +02:00
parent 2c66e413bf
commit af572f785b
6 changed files with 14 additions and 14 deletions

View File

@ -144,7 +144,7 @@ export function derToPem(hex, label) {
}
/**
* Walk an asn1js parse tree and produce an indented dump.
* Walk an asn1js parse tree and produce CyberChef's indented ASN.1 dump.
*
* @param {string} hex
* @param {Object} [options]

View File

@ -72,9 +72,9 @@ export function digestBytes(algo, bytes) {
/**
* Convert a JS string to bytes by Latin-1 truncation of each code unit (i.e.
* `charCodeAt(i) & 0xff`). This keeps signatures interoperable for inputs
* coming out of upstream byte-producing ops, while preserving the
* (questionable) UTF-16-truncating behaviour for free-text inputs.
* `charCodeAt(i) & 0xff`). This preserves the operation's byte-string
* semantics for inputs coming out of upstream byte-producing ops, including
* the questionable UTF-16 truncation for free-text inputs.
*
* @param {string} str
* @returns {Uint8Array}
@ -181,8 +181,8 @@ export function isAsn1Hex(hex) {
/**
* Parse an ASN.1 DER-encoded ECDSA signature and return the raw r/s INTEGER
* bytes as hex. Preserves the DER 2's-complement leading 0x00 when present
* (i.e. r/s may have a leading "00" pair). Existing tests assume this
* compatibility behaviour.
* (i.e. r/s may have a leading "00" pair) because the raw-signature fixtures
* assert the INTEGER byte strings, not canonicalized scalar values.
*
* @param {string} asn1Hex
* @returns {{r: string, s: string}}

View File

@ -369,9 +369,9 @@ function parsePkcs8(bytes) {
return rsaPrivateFromBytes(parseRsaPrivateKey(inner));
}
if (alg === ID_DSA) {
// DSA PKCS#8 carries only x (with p/q/g in the algorithm
// parameters). Without y, deriving the public key is unsupported;
// mark the info accordingly and let derivePublicKeyInfo throw.
// DSA PKCS#8 carries only the private x value, with p/q/g in the
// algorithm parameters. It does not carry the public y value needed
// here, so mark the info accordingly and let derivePublicKeyInfo throw.
return { kty: "DSA", isPrivate: true, y: null };
}
// EC and everything else delegate to the existing EC loader by

View File

@ -58,8 +58,8 @@ function getCurve(name) {
Point,
n: params.n,
coordCharLen: params.coordCharLen,
// Uniform-ish random scalar in [1, n-1], matching the previous bias
// profile for compatibility with existing SM2 behaviour.
// Uniform-ish random scalar in [1, n-1]. The modulo reduction keeps
// the existing scalar-generation distribution for SM2 ciphertexts.
randomScalar: () => bytesToNumberBE(dh.utils.randomSecretKey()) % (params.n - 1n) + 1n,
};
curveCache[name] = cached;

View File

@ -165,8 +165,8 @@ ${extensionsText}`;
}
/**
* Format the algorithm label for the Public Key block. Mirrors the legacy
* labels: "EC", "DSA", "RSA".
* Format the algorithm label for the Public Key block. The golden fixtures
* use short labels for the classic key families: "EC", "DSA", "RSA".
*
* @param {object} spki
* @returns {string}

View File

@ -1,7 +1,7 @@
/**
* ASN.1 / OID / PEM tests.
*
* Covers the four operations migrated to the in-house Asn1.mjs helper:
* Covers the four operations backed by the in-house Asn1.mjs helper:
* - Hex to Object Identifier
* - Object Identifier to Hex
* - Hex to PEM