Comments fix.
This commit is contained in:
parent
2c66e413bf
commit
af572f785b
@ -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 {string} hex
|
||||||
* @param {Object} [options]
|
* @param {Object} [options]
|
||||||
|
|||||||
@ -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.
|
* 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
|
* `charCodeAt(i) & 0xff`). This preserves the operation's byte-string
|
||||||
* coming out of upstream byte-producing ops, while preserving the
|
* semantics for inputs coming out of upstream byte-producing ops, including
|
||||||
* (questionable) UTF-16-truncating behaviour for free-text inputs.
|
* the questionable UTF-16 truncation for free-text inputs.
|
||||||
*
|
*
|
||||||
* @param {string} str
|
* @param {string} str
|
||||||
* @returns {Uint8Array}
|
* @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
|
* 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
|
* 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
|
* (i.e. r/s may have a leading "00" pair) because the raw-signature fixtures
|
||||||
* compatibility behaviour.
|
* assert the INTEGER byte strings, not canonicalized scalar values.
|
||||||
*
|
*
|
||||||
* @param {string} asn1Hex
|
* @param {string} asn1Hex
|
||||||
* @returns {{r: string, s: string}}
|
* @returns {{r: string, s: string}}
|
||||||
|
|||||||
@ -369,9 +369,9 @@ function parsePkcs8(bytes) {
|
|||||||
return rsaPrivateFromBytes(parseRsaPrivateKey(inner));
|
return rsaPrivateFromBytes(parseRsaPrivateKey(inner));
|
||||||
}
|
}
|
||||||
if (alg === ID_DSA) {
|
if (alg === ID_DSA) {
|
||||||
// DSA PKCS#8 carries only x (with p/q/g in the algorithm
|
// DSA PKCS#8 carries only the private x value, with p/q/g in the
|
||||||
// parameters). Without y, deriving the public key is unsupported;
|
// algorithm parameters. It does not carry the public y value needed
|
||||||
// mark the info accordingly and let derivePublicKeyInfo throw.
|
// here, so mark the info accordingly and let derivePublicKeyInfo throw.
|
||||||
return { kty: "DSA", isPrivate: true, y: null };
|
return { kty: "DSA", isPrivate: true, y: null };
|
||||||
}
|
}
|
||||||
// EC and everything else delegate to the existing EC loader by
|
// EC and everything else delegate to the existing EC loader by
|
||||||
|
|||||||
@ -58,8 +58,8 @@ function getCurve(name) {
|
|||||||
Point,
|
Point,
|
||||||
n: params.n,
|
n: params.n,
|
||||||
coordCharLen: params.coordCharLen,
|
coordCharLen: params.coordCharLen,
|
||||||
// Uniform-ish random scalar in [1, n-1], matching the previous bias
|
// Uniform-ish random scalar in [1, n-1]. The modulo reduction keeps
|
||||||
// profile for compatibility with existing SM2 behaviour.
|
// the existing scalar-generation distribution for SM2 ciphertexts.
|
||||||
randomScalar: () => bytesToNumberBE(dh.utils.randomSecretKey()) % (params.n - 1n) + 1n,
|
randomScalar: () => bytesToNumberBE(dh.utils.randomSecretKey()) % (params.n - 1n) + 1n,
|
||||||
};
|
};
|
||||||
curveCache[name] = cached;
|
curveCache[name] = cached;
|
||||||
|
|||||||
@ -165,8 +165,8 @@ ${extensionsText}`;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format the algorithm label for the Public Key block. Mirrors the legacy
|
* Format the algorithm label for the Public Key block. The golden fixtures
|
||||||
* labels: "EC", "DSA", "RSA".
|
* use short labels for the classic key families: "EC", "DSA", "RSA".
|
||||||
*
|
*
|
||||||
* @param {object} spki
|
* @param {object} spki
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* ASN.1 / OID / PEM tests.
|
* 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
|
* - Hex to Object Identifier
|
||||||
* - Object Identifier to Hex
|
* - Object Identifier to Hex
|
||||||
* - Hex to PEM
|
* - Hex to PEM
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user