chore: build

This commit is contained in:
2026-05-01 22:28:13 +02:00
parent ece977f268
commit 99ce3e4bb3
532 changed files with 5244 additions and 13124 deletions
+19
View File
@@ -380,6 +380,10 @@ function crypto_sign_open(m, sm, n, pk) {
return -1;
}
if(!_isCanonicalSignatureScalar(sm, 32)) {
return -1;
}
for(i = 0; i < n; ++i) {
m[i] = sm[i];
}
@@ -409,6 +413,21 @@ function crypto_sign_open(m, sm, n, pk) {
return mlen;
}
function _isCanonicalSignatureScalar(bytes, offset) {
var i;
// Compare little-endian scalar S against group order L and require S < L.
for(i = 31; i >= 0; --i) {
if(bytes[offset + i] < L[i]) {
return true;
}
if(bytes[offset + i] > L[i]) {
return false;
}
}
// S == L is non-canonical.
return false;
}
function modL(r, x) {
var carry, i, j, k;
for(i = 63; i >= 32; --i) {
+465 -435
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -123,6 +123,7 @@ _IN('2.5.4.13', 'description');
_IN('2.5.4.15', 'businessCategory');
_IN('2.5.4.17', 'postalCode');
_IN('2.5.4.42', 'givenName');
_IN('2.5.4.65', 'pseudonym');
_IN('1.3.6.1.4.1.311.60.2.1.2', 'jurisdictionOfIncorporationStateOrProvinceName');
_IN('1.3.6.1.4.1.311.60.2.1.3', 'jurisdictionOfIncorporationCountryName');
+26 -7
View File
@@ -1133,6 +1133,9 @@ pki.setRsaPublicKey = pki.rsa.setPublicKey = function(n, e) {
* _parseAllDigestBytes testing flag to control parsing of all
* digest bytes. Unsupported and not for general usage.
* (default: true)
* _skipPaddingChecks testing flag to skip some padding checks to
* test other checks. Unsupported and not for general usage.
* (default: false)
*
* @return true if the signature was verified, false if not.
*/
@@ -1144,27 +1147,32 @@ pki.setRsaPublicKey = pki.rsa.setPublicKey = function(n, e) {
}
if(options === undefined) {
options = {
_parseAllDigestBytes: true
_parseAllDigestBytes: true,
_skipPaddingChecks: false
};
}
if(!('_parseAllDigestBytes' in options)) {
options._parseAllDigestBytes = true;
}
if(!('_skipPaddingChecks' in options)) {
options._skipPaddingChecks = false;
}
if(scheme === 'RSASSA-PKCS1-V1_5') {
scheme = {
verify: function(digest, d) {
// remove padding
d = _decodePkcs1_v1_5(d, key, true);
d = _decodePkcs1_v1_5(d, key, true, undefined, options);
// d is ASN.1 BER-encoded DigestInfo
var obj = asn1.fromDer(d, {
parseAllBytes: options._parseAllDigestBytes
});
// validate DigestInfo
// validate DigestInfo structure and element count
var capture = {};
var errors = [];
if(!asn1.validate(obj, digestInfoValidator, capture, errors)) {
if(!asn1.validate(obj, digestInfoValidator, capture, errors) ||
obj.value.length !== 2) {
var error = new Error(
'ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 ' +
'DigestInfo value.');
@@ -1208,7 +1216,7 @@ pki.setRsaPublicKey = pki.rsa.setPublicKey = function(n, e) {
scheme = {
verify: function(digest, d) {
// remove padding
d = _decodePkcs1_v1_5(d, key, true);
d = _decodePkcs1_v1_5(d, key, true, undefined, options);
return digest === d;
}
};
@@ -1626,10 +1634,11 @@ function _encodePkcs1_v1_5(m, key, bt) {
* @param key the RSA key to use.
* @param pub true if the key is a public key, false if it is private.
* @param ml the message length, if specified.
* @param options testing options.
*
* @return the decoded bytes.
*/
function _decodePkcs1_v1_5(em, key, pub, ml) {
function _decodePkcs1_v1_5(em, key, pub, ml, options) {
// get the length of the modulus in bytes
var k = Math.ceil(key.n.bitLength() / 8);
@@ -1649,7 +1658,7 @@ function _decodePkcs1_v1_5(em, key, pub, ml) {
var bt = eb.getByte();
if(first !== 0x00 ||
(pub && bt !== 0x00 && bt !== 0x01) ||
(!pub && bt != 0x02) ||
(!pub && bt !== 0x02) ||
(pub && bt === 0x00 && typeof(ml) === 'undefined')) {
throw new Error('Encryption block is invalid.');
}
@@ -1673,6 +1682,11 @@ function _decodePkcs1_v1_5(em, key, pub, ml) {
}
++padNum;
}
// RFC 2313 8.1 note 6
if(padNum < 8 && !(options ? options._skipPaddingChecks : false)) {
throw new Error('Encryption block is invalid.');
}
} else if(bt === 0x02) {
// look for 0x00 byte
padNum = 0;
@@ -1683,6 +1697,11 @@ function _decodePkcs1_v1_5(em, key, pub, ml) {
}
++padNum;
}
// RFC 2313 8.1 note 6
if(padNum < 8 && !(options ? options._skipPaddingChecks : false)) {
throw new Error('Encryption block is invalid.');
}
}
// zero must be 0x00 and padNum must be (k - 3 - message length)
+9
View File
@@ -3167,6 +3167,15 @@ pki.verifyCertificateChain = function(caStore, chain, options) {
};
}
}
// check for absent basicConstraints on non-leaf certificates
if(error === null && bcExt === null) {
error = {
message:
'Certificate is missing basicConstraints extension and cannot ' +
'be used as a CA.',
error: pki.certificateError.bad_certificate
};
}
// basic constraints cA flag must be set
if(error === null && bcExt !== null && !bcExt.cA) {
// bad certificate