diff --git a/src/core/lib/Asn1.mjs b/src/core/lib/Asn1.mjs index 06780342..d64bac7d 100644 --- a/src/core/lib/Asn1.mjs +++ b/src/core/lib/Asn1.mjs @@ -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] diff --git a/src/core/lib/Ecdsa.mjs b/src/core/lib/Ecdsa.mjs index 0b1b5921..f78025bc 100644 --- a/src/core/lib/Ecdsa.mjs +++ b/src/core/lib/Ecdsa.mjs @@ -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}} diff --git a/src/core/lib/KeyConvert.mjs b/src/core/lib/KeyConvert.mjs index 29637907..0b3e5a83 100644 --- a/src/core/lib/KeyConvert.mjs +++ b/src/core/lib/KeyConvert.mjs @@ -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 diff --git a/src/core/lib/SM2.mjs b/src/core/lib/SM2.mjs index a2f219bb..eb5ac8d7 100644 --- a/src/core/lib/SM2.mjs +++ b/src/core/lib/SM2.mjs @@ -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; diff --git a/src/core/operations/ParseX509Certificate.mjs b/src/core/operations/ParseX509Certificate.mjs index 9fede294..d83b8cc7 100644 --- a/src/core/operations/ParseX509Certificate.mjs +++ b/src/core/operations/ParseX509Certificate.mjs @@ -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} diff --git a/tests/operations/tests/ASN1.mjs b/tests/operations/tests/ASN1.mjs index baadd851..af18f2a2 100644 --- a/tests/operations/tests/ASN1.mjs +++ b/tests/operations/tests/ASN1.mjs @@ -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