diff --git a/ChangeLog.txt b/ChangeLog.txt index e303550e..16a479bd 100755 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,7 +1,19 @@ ChangeLog for jsrsasign -* Changes from 10.4.1 to next release +Add EC support for secp521r1 secp224r1 secp192r1 +* Changes from 10.4.1 to 10.5.0 + - Add EC support for secp521r1 secp224r1 secp192r1 (#521 #519) + Thank you indeed for @cplussharp 's great work. + - EC key length bugs for newly supported curves are fixed. + - src/ecdsa-modified: key length fixes + - src/ecparam.js: add keycharlen property + - src/asn1x509.js: add secp521r1 OID + - test/qunit-do-ecdsamod.html: all test code passed + - test/qunit-do-ecdsamod-unsupport.html: all test code passed + - test/qunit-do-ecdsamod-s.html: all test code passed + - test/qunit-do-ecdsamod-nisttv.html: added for NIST EC keygen test + - sample/sample-ecdsa.html: add P-521 - sample/sample-rsasign.html - fix to trim non hexadecimal strings (#517) diff --git a/api/files.html b/api/files.html index 09edad4b..3726dfd5 100644 --- a/api/files.html +++ b/api/files.html @@ -656,7 +656,7 @@
var ec = new KJUR.crypto.ECDSA({'curve': 'secp256r1', 'prv': prvHex}); +var pubhex = ec.generatePublicKeyHex(); // hexadecimal string of EC public key +var pub ec.getPublicKeyXYHex() → { x: '01bacf...', y: 'c3bc22...' }+ + + + + + + + +
1 /* asn1x509-2.1.8.js (c) 2013-2021 Kenji Urushima | kjur.github.io/jsrsasign/license +1 /* asn1x509-2.1.10.js (c) 2013-2021 Kenji Urushima | kjur.github.io/jsrsasign/license 2 */ 3 /* 4 * asn1x509.js - ASN.1 DER encoder classes for X.509 certificate @@ -23,7 +23,7 @@ 16 * @fileOverview 17 * @name asn1x509-1.0.js 18 * @author Kenji Urushima kenji.urushima@gmail.com - 19 * @version jsrsasign 10.1.10 asn1x509 2.1.8 (2021-Feb-14) + 19 * @version jsrsasign 10.5.0 asn1x509 2.1.10 (2021-Nov-21) 20 * @since jsrsasign 2.1 21 * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a> 22 */ @@ -4169,256 +4169,257 @@ 4162 'secp256r1': '1.2.840.10045.3.1.7', 4163 'secp256k1': '1.3.132.0.10', 4164 'secp384r1': '1.3.132.0.34', -4165 -4166 'pkcs5PBES2': '1.2.840.113549.1.5.13', -4167 'pkcs5PBKDF2': '1.2.840.113549.1.5.12', -4168 -4169 'des-EDE3-CBC': '1.2.840.113549.3.7', -4170 -4171 'data': '1.2.840.113549.1.7.1', // CMS data -4172 'signed-data': '1.2.840.113549.1.7.2', // CMS signed-data -4173 'enveloped-data': '1.2.840.113549.1.7.3', // CMS enveloped-data -4174 'digested-data': '1.2.840.113549.1.7.5', // CMS digested-data -4175 'encrypted-data': '1.2.840.113549.1.7.6', // CMS encrypted-data -4176 'authenticated-data': '1.2.840.113549.1.9.16.1.2', // CMS authenticated-data -4177 'tstinfo': '1.2.840.113549.1.9.16.1.4', // RFC3161 TSTInfo -4178 'signingCertificate': '1.2.840.113549.1.9.16.2.12',// SMIME -4179 'timeStampToken': '1.2.840.113549.1.9.16.2.14',// sigTS -4180 'signaturePolicyIdentifier': '1.2.840.113549.1.9.16.2.15',// cades -4181 'etsArchiveTimeStamp': '1.2.840.113549.1.9.16.2.27',// SMIME -4182 'signingCertificateV2': '1.2.840.113549.1.9.16.2.47',// SMIME -4183 'etsArchiveTimeStampV2':'1.2.840.113549.1.9.16.2.48',// SMIME -4184 'extensionRequest': '1.2.840.113549.1.9.14',// CSR extensionRequest -4185 'contentType': '1.2.840.113549.1.9.3',//PKCS#9 -4186 'messageDigest': '1.2.840.113549.1.9.4',//PKCS#9 -4187 'signingTime': '1.2.840.113549.1.9.5',//PKCS#9 -4188 'counterSignature': '1.2.840.113549.1.9.6',//PKCS#9 -4189 'archiveTimeStampV3': '0.4.0.1733.2.4',//ETSI EN29319122/TS101733 -4190 'pdfRevocationInfoArchival':'1.2.840.113583.1.1.8', //Adobe -4191 'adobeTimeStamp': '1.2.840.113583.1.1.9.1' // Adobe -4192 }; -4193 -4194 this.objCache = {}; -4195 -4196 /** -4197 * get DERObjectIdentifier by registered OID name -4198 * @name name2obj -4199 * @memberOf KJUR.asn1.x509.OID -4200 * @function -4201 * @param {String} name OID -4202 * @description -4203 * @example -4204 * var asn1ObjOID = OID.name2obj('SHA1withRSA'); -4205 */ -4206 this.name2obj = function(name) { -4207 if (typeof this.objCache[name] != "undefined") -4208 return this.objCache[name]; -4209 if (typeof this.name2oidList[name] == "undefined") -4210 throw "Name of ObjectIdentifier not defined: " + name; -4211 var oid = this.name2oidList[name]; -4212 var obj = new KJUR.asn1.DERObjectIdentifier({'oid': oid}); -4213 this.objCache[name] = obj; -4214 return obj; -4215 }; -4216 -4217 /** -4218 * get DERObjectIdentifier by registered attribute type name such like 'C' or 'CN'<br/> -4219 * @name atype2obj -4220 * @memberOf KJUR.asn1.x509.OID -4221 * @function -4222 * @param {String} atype short attribute type name such like 'C', 'CN' or OID -4223 * @return {@link KJUR.asn1.DERObjectIdentifier} instance -4224 * @description -4225 * @example -4226 * KJUR.asn1.x509.OID.atype2obj('CN') → DERObjectIdentifier of 2.5.4.3 -4227 * KJUR.asn1.x509.OID.atype2obj('OU') → DERObjectIdentifier of 2.5.4.11 -4228 * KJUR.asn1.x509.OID.atype2obj('streetAddress') → DERObjectIdentifier of 2.5.4.9 -4229 * KJUR.asn1.x509.OID.atype2obj('2.5.4.9') → DERObjectIdentifier of 2.5.4.9 -4230 */ -4231 this.atype2obj = function(atype) { -4232 if (this.objCache[atype] !== undefined) -4233 return this.objCache[atype]; -4234 -4235 var oid; -4236 -4237 if (atype.match(/^\d+\.\d+\.[0-9.]+$/)) { -4238 oid = atype; -4239 } else if (this.atype2oidList[atype] !== undefined) { -4240 oid = this.atype2oidList[atype]; -4241 } else if (this.name2oidList[atype] !== undefined) { -4242 oid = this.name2oidList[atype]; -4243 } else { -4244 throw "AttributeType name undefined: " + atype; -4245 } -4246 var obj = new KJUR.asn1.DERObjectIdentifier({'oid': oid}); -4247 this.objCache[atype] = obj; -4248 return obj; -4249 }; -4250 }; -4251 -4252 /** -4253 * convert OID to name<br/> -4254 * @name oid2name -4255 * @memberOf KJUR.asn1.x509.OID -4256 * @function -4257 * @param {String} oid dot noted Object Identifer string (ex. 1.2.3.4) -4258 * @return {String} OID name if registered otherwise empty string -4259 * @since asn1x509 1.0.9 -4260 * @description -4261 * This static method converts OID string to its name. -4262 * If OID is undefined then it returns empty string (i.e. ''). -4263 * @example -4264 * KJUR.asn1.x509.OID.oid2name("1.3.6.1.5.5.7.1.1") → 'authorityInfoAccess' -4265 */ -4266 KJUR.asn1.x509.OID.oid2name = function(oid) { -4267 var list = KJUR.asn1.x509.OID.name2oidList; -4268 for (var name in list) { -4269 if (list[name] == oid) return name; -4270 } -4271 return ''; -4272 }; -4273 -4274 /** -4275 * convert OID to AttributeType name<br/> -4276 * @name oid2atype -4277 * @memberOf KJUR.asn1.x509.OID -4278 * @function -4279 * @param {String} oid dot noted Object Identifer string (ex. 1.2.3.4) -4280 * @return {String} OID AttributeType name if registered otherwise oid -4281 * @since jsrsasign 6.2.2 asn1x509 1.0.18 -4282 * @description -4283 * This static method converts OID string to its AttributeType name. -4284 * If OID is not defined in OID.atype2oidList associative array then it returns OID -4285 * specified as argument. -4286 * @example -4287 * KJUR.asn1.x509.OID.oid2atype("2.5.4.3") → CN -4288 * KJUR.asn1.x509.OID.oid2atype("1.3.6.1.4.1.311.60.2.1.3") → jurisdictionOfIncorporationC -4289 * KJUR.asn1.x509.OID.oid2atype("0.1.2.3.4") → 0.1.2.3.4 // unregistered OID -4290 */ -4291 KJUR.asn1.x509.OID.oid2atype = function(oid) { -4292 var list = KJUR.asn1.x509.OID.atype2oidList; -4293 for (var atype in list) { -4294 if (list[atype] == oid) return atype; -4295 } -4296 return oid; -4297 }; -4298 -4299 /** -4300 * convert OID name to OID value<br/> -4301 * @name name2oid -4302 * @memberOf KJUR.asn1.x509.OID -4303 * @function -4304 * @param {String} name OID name or OID (ex. "sha1" or "1.2.3.4") -4305 * @return {String} dot noted Object Identifer string (ex. 1.2.3.4) -4306 * @since asn1x509 1.0.11 -4307 * @description -4308 * This static method converts from OID name to OID string. -4309 * If OID is undefined then it returns empty string (i.e. ''). -4310 * @example -4311 * KJUR.asn1.x509.OID.name2oid("authorityInfoAccess") → "1.3.6.1.5.5.7.1.1" -4312 * KJUR.asn1.x509.OID.name2oid("1.2.3.4") → "1.2.3.4" -4313 * KJUR.asn1.x509.OID.name2oid("UNKNOWN NAME") → "" -4314 */ -4315 KJUR.asn1.x509.OID.name2oid = function(name) { -4316 if (name.match(/^[0-9.]+$/)) return name; -4317 var list = KJUR.asn1.x509.OID.name2oidList; -4318 if (list[name] === undefined) return ''; -4319 return list[name]; -4320 }; -4321 -4322 /** -4323 * X.509 certificate and CRL utilities class<br/> -4324 * @name KJUR.asn1.x509.X509Util -4325 * @class X.509 certificate and CRL utilities class -4326 */ -4327 KJUR.asn1.x509.X509Util = {}; -4328 -4329 /** -4330 * issue a certificate in PEM format (DEPRECATED) -4331 * @name newCertPEM -4332 * @memberOf KJUR.asn1.x509.X509Util -4333 * @function -4334 * @param {Array} param JSON object of parameter to issue a certificate -4335 * @since asn1x509 1.0.6 -4336 * @deprecated since jsrsasign 9.0.0 asn1x509 2.0.0. please move to {@link KJUR.asn1.x509.Certificate} constructor -4337 * @description -4338 * This method can issue a certificate by a simple -4339 * JSON object. -4340 * Signature value will be provided by signing with -4341 * private key using 'cakey' parameter or -4342 * hexadecimal signature value by 'sighex' parameter. -4343 * <br/> -4344 * NOTE: Algorithm parameter of AlgorithmIdentifier will -4345 * be set automatically by default. -4346 * (see {@link KJUR.asn1.x509.AlgorithmIdentifier}) -4347 * from jsrsasign 7.1.1 asn1x509 1.0.20. -4348 * <br/> -4349 * NOTE2: -4350 * RSA-PSS algorithm has been supported from jsrsasign 8.0.21. -4351 * As for RSA-PSS signature algorithm names and signing parameters -4352 * such as MGF function and salt length, please see -4353 * {@link KJUR.asn1.x509.AlgorithmIdentifier} class. -4354 * -4355 * @example -4356 * var certPEM = KJUR.asn1.x509.X509Util.newCertPEM({ -4357 * serial: {int: 4}, -4358 * sigalg: {name: 'SHA1withECDSA'}, -4359 * issuer: {str: '/C=US/O=a'}, -4360 * notbefore: {'str': '130504235959Z'}, -4361 * notafter: {'str': '140504235959Z'}, -4362 * subject: {str: '/C=US/O=b'}, -4363 * sbjpubkey: pubKeyObj, -4364 * ext: [ -4365 * {basicConstraints: {cA: true, critical: true}}, -4366 * {keyUsage: {bin: '11'}}, -4367 * ], -4368 * cakey: prvKeyObj -4369 * }); -4370 * // -- or -- -4371 * var certPEM = KJUR.asn1.x509.X509Util.newCertPEM({ -4372 * serial: {int: 4}, -4373 * sigalg: {name: 'SHA1withECDSA'}, -4374 * issuer: {str: '/C=US/O=a'}, -4375 * notbefore: {'str': '130504235959Z'}, -4376 * notafter: {'str': '140504235959Z'}, -4377 * subject: {str: '/C=US/O=b'}, -4378 * sbjpubkey: pubKeyPEM, -4379 * ext: [ -4380 * {basicConstraints: {cA: true, critical: true}}, -4381 * {keyUsage: {bin: '11'}}, -4382 * ], -4383 * cakey: [prvkey, pass]} -4384 * ); -4385 * // -- or -- -4386 * var certPEM = KJUR.asn1.x509.X509Util.newCertPEM({ -4387 * serial: {int: 1}, -4388 * sigalg: {name: 'SHA1withRSA'}, -4389 * issuer: {str: '/C=US/O=T1'}, -4390 * notbefore: {'str': '130504235959Z'}, -4391 * notafter: {'str': '140504235959Z'}, -4392 * subject: {str: '/C=US/O=T1'}, -4393 * sbjpubkey: pubKeyObj, -4394 * sighex: '0102030405..' -4395 * }); -4396 * // for the issuer and subject field, another -4397 * // representation is also available -4398 * var certPEM = KJUR.asn1.x509.X509Util.newCertPEM({ -4399 * serial: {int: 1}, -4400 * sigalg: {name: 'SHA256withRSA'}, -4401 * issuer: {C: "US", O: "T1"}, -4402 * notbefore: {'str': '130504235959Z'}, -4403 * notafter: {'str': '140504235959Z'}, -4404 * subject: {C: "US", O: "T1", CN: "http://example.com/"}, -4405 * sbjpubkey: pubKeyObj, -4406 * sighex: '0102030405..' -4407 * }); -4408 */ -4409 KJUR.asn1.x509.X509Util.newCertPEM = function(param) { -4410 var _KJUR_asn1_x509 = KJUR.asn1.x509, -4411 _TBSCertificate = _KJUR_asn1_x509.TBSCertificate, -4412 _Certificate = _KJUR_asn1_x509.Certificate; -4413 var cert = new _Certificate(param); -4414 return cert.getPEM(); -4415 }; -4416 -4417