Skip to content

Commit

Permalink
5.0.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
kjur committed Oct 18, 2015
1 parent 20dc9ee commit 703251f
Show file tree
Hide file tree
Showing 12 changed files with 1,167 additions and 769 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

ChangeLog for jsrsasign

* Changes between 5.0.0 to 5.0.1 (2015-Oct-17)
- keyutil 1.0.10 to 1.0.11
- add support for bare RSA NED hexadecimal key in KEYUTIL.getKey

* Changes between 4.9.2 to 5.0.0 (2015-Oct-14)
- *NOTICE* release 4.10.0 declined since API semver violation
- some JWS HS* and Crypto Mac signature issue was fixed.
Expand Down
2 changes: 1 addition & 1 deletion api/files.html
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ <h2><a href="symbols/src/keyutil-1.0.js.html">keyutil-1.0.js</a></h2>


<dt class="heading">Version:</dt>
<dd>keyutil 1.0.11 (2015-Oct-14)</dd>
<dd>keyutil 1.0.12 (2015-Oct-14)</dd>



Expand Down
26 changes: 24 additions & 2 deletions api/symbols/KEYUTIL.html
Original file line number Diff line number Diff line change
Expand Up @@ -915,12 +915,12 @@ <h1 class="classTitle">



<pre class="code">// 1. loading private key
<pre class="code">// 1. loading PEM private key
var key = KEYUTIL.getKey(pemPKCS1PrivateKey);
var key = KEYUTIL.getKey(pemPKCS5EncryptedPrivateKey, "passcode");
var key = KEYUTIL.getKey(pemPKC85PlainPrivateKey);
var key = KEYUTIL.getKey(pemPKC85EncryptedPrivateKey, "passcode");
// 2. loading public key
// 2. loading PEM public key
var key = KEYUTIL.getKey(pemPKCS8PublicKey);
var key = KEYUTIL.getKey(pemX509Certificate);
// 3. exporting private key
Expand Down Expand Up @@ -1353,12 +1353,34 @@ <h1 class="classTitle">
<li>JWT plain RSA private key without P/Q/DP/DQ/COEFF (since jsrsasign 5.0.0)</li>
</ul>
NOTE: <a href="https://tools.ietf.org/html/rfc7517">RFC 7517 JSON Web Key(JWK)</a> support for RSA/ECC private/public key from jsrsasign 4.8.1.

<h5>EXAMPLE</h5>


</div>



<pre class="code">// 1. loading private key from PEM string
keyObj = KEYUTIL.getKey("-----BEGIN RSA PRIVATE KEY...");
keyObj = KEYUTIL.getKey("-----BEGIN RSA PRIVATE KEY..., "passcode");
keyObj = KEYUTIL.getKey("-----BEGIN PRIVATE KEY...");
keyObj = KEYUTIL.getKey("-----BEGIN PRIVATE KEY...", "passcode");
// 2. loading public key from PEM string
keyObj = KEYUTIL.getKey("-----BEGIN PUBLIC KEY...");
keyObj = KEYUTIL.getKey("-----BEGIN X509 CERTIFICATE...");
// 3. loading hexadecimal PKCS#5/PKCS#8 key
keyObj = KEYUTIL.getKey("308205c1...", null, "pkcs8pub");
keyObj = KEYUTIL.getKey("3082048b...", null, "pkcs5prv");
// 4. loading JSON Web Key(JWK)
keyObj = KEYUTIL.getKey({kty: "RSA", n: "0vx7...", e: "AQAB"});
keyObj = KEYUTIL.getKey({kty: "EC", crv: "P-256",
x: "MKBC...", y: "4Etl6...", d: "870Mb..."});
// 5. bare hexadecimal key
keyObj = KEYUTIL.getKey({n: "75ab..", e: "010001"});</pre>




<dl class="detailList">
<dt class="heading">Parameters:</dt>
Expand Down
1,480 changes: 764 additions & 716 deletions api/symbols/src/keyutil-1.0.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kjur/jsrsasign",
"version": "5.0.0",
"version": "5.0.1",
"main": "jsrsasign-latest-all-min.js",
"description": "The 'jsrsasign' (RSA-Sign JavaScript Library) is an opensource free cryptography library supporting RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate, CRL CMS SignedData, TimeStamp, CAdES, JWS and JWT in pure JavaScript.",
"license": "MIT",
Expand Down
286 changes: 286 additions & 0 deletions jsrsasign-5.0.1-all-min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions jsrsasign-latest-all-min.js

Large diffs are not rendered by default.

108 changes: 78 additions & 30 deletions keyutil-1.0.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! keyutil-1.0.11.js (c) 2013-2015 Kenji Urushima | kjur.github.com/jsrsasign/license
/*! keyutil-1.0.12.js (c) 2013-2015 Kenji Urushima | kjur.github.com/jsrsasign/license
*/
/*
* keyutil.js - key utility for PKCS#1/5/8 PEM, RSA/DSA/ECDSA key object
Expand All @@ -15,7 +15,7 @@
* @fileOverview
* @name keyutil-1.0.js
* @author Kenji Urushima [email protected]
* @version keyutil 1.0.11 (2015-Oct-14)
* @version keyutil 1.0.12 (2015-Oct-14)
* @since jsrsasign 4.1.4
* @license <a href="http://kjur.github.io/jsrsasign/license/">MIT License</a>
*/
Expand Down Expand Up @@ -62,12 +62,12 @@
* </dl>
*
* @example
* // 1. loading private key
* // 1. loading PEM private key
* var key = KEYUTIL.getKey(pemPKCS1PrivateKey);
* var key = KEYUTIL.getKey(pemPKCS5EncryptedPrivateKey, "passcode");
* var key = KEYUTIL.getKey(pemPKC85PlainPrivateKey);
* var key = KEYUTIL.getKey(pemPKC85EncryptedPrivateKey, "passcode");
* // 2. loading public key
* // 2. loading PEM public key
* var key = KEYUTIL.getKey(pemPKCS8PublicKey);
* var key = KEYUTIL.getKey(pemX509Certificate);
* // 3. exporting private key
Expand Down Expand Up @@ -1249,6 +1249,26 @@ var KEYUTIL = function() {
* <li>JWT plain RSA private key without P/Q/DP/DQ/COEFF (since jsrsasign 5.0.0)</li>
* </ul>
* NOTE: <a href="https://tools.ietf.org/html/rfc7517">RFC 7517 JSON Web Key(JWK)</a> support for RSA/ECC private/public key from jsrsasign 4.8.1.
*
* <h5>EXAMPLE</h5>
* @example
* // 1. loading private key from PEM string
* keyObj = KEYUTIL.getKey("-----BEGIN RSA PRIVATE KEY...");
* keyObj = KEYUTIL.getKey("-----BEGIN RSA PRIVATE KEY..., "passcode");
* keyObj = KEYUTIL.getKey("-----BEGIN PRIVATE KEY...");
* keyObj = KEYUTIL.getKey("-----BEGIN PRIVATE KEY...", "passcode");
* // 2. loading public key from PEM string
* keyObj = KEYUTIL.getKey("-----BEGIN PUBLIC KEY...");
* keyObj = KEYUTIL.getKey("-----BEGIN X509 CERTIFICATE...");
* // 3. loading hexadecimal PKCS#5/PKCS#8 key
* keyObj = KEYUTIL.getKey("308205c1...", null, "pkcs8pub");
* keyObj = KEYUTIL.getKey("3082048b...", null, "pkcs5prv");
* // 4. loading JSON Web Key(JWK)
* keyObj = KEYUTIL.getKey({kty: "RSA", n: "0vx7...", e: "AQAB"});
* keyObj = KEYUTIL.getKey({kty: "EC", crv: "P-256",
* x: "MKBC...", y: "4Etl6...", d: "870Mb..."});
* // 5. bare hexadecimal key
* keyObj = KEYUTIL.getKey({n: "75ab..", e: "010001"});
*/
KEYUTIL.getKey = function(param, passcode, hextype) {
// 1. by key RSAKey/KJUR.crypto.ECDSA/KJUR.crypto.DSA object
Expand All @@ -1260,12 +1280,32 @@ KEYUTIL.getKey = function(param, passcode, hextype) {
return param;

// 2. by parameters of key
// 2.1. ECC private key
if (param.d !== undefined && param.curve !== undefined) {

// 2.1. bare ECC
// 2.1.1. bare ECC public key by hex values
if (param.curve !== undefined &&
param.xy !== undefined && param.d === undefined) {
return new KJUR.crypto.ECDSA({pub: param.xy, curve: param.curve});
}

// 2.1.2. bare ECC private key by hex values
if (param.curve !== undefined && param.d !== undefined) {
return new KJUR.crypto.ECDSA({prv: param.d, curve: param.curve});
}
// 2.2. bare RSA private key
if (param.n !== undefined &&

// 2.2. bare RSA
// 2.2.1. bare RSA public key by hex values
if (param.kty === undefined &&
param.n !== undefined && param.e !== undefined &&
param.d === undefined) {
var key = new RSAKey();
key.setPublic(param.n, param.e);
return key;
}

// 2.2.2. bare RSA private key with P/Q/DP/DQ/COEFF by hex values
if (param.kty === undefined &&
param.n !== undefined &&
param.e !== undefined &&
param.d !== undefined &&
param.p !== undefined &&
Expand All @@ -1279,33 +1319,40 @@ KEYUTIL.getKey = function(param, passcode, hextype) {
param.dp, param.dq, param.co);
return key;
}
// 2.3. DSA private key
if (param.p !== undefined && param.q !== undefined && param.g !== undefined &&
param.y !== undefined && param.x !== undefined) {
var key = new KJUR.crypto.DSA();
key.setPrivate(param.p, param.q, param.g, param.y, param.x);
return key;
}

// 2.4. ECC public key
if (param.xy !== undefined && param.d === undefined && param.curve !== undefined) {
return new KJUR.crypto.ECDSA({pub: param.xy, curve: param.curve});
}
// 2.5. bare RSA public key
if (param.kty === undefined && param.n !== undefined && param.e) {
// 2.2.3. bare RSA public key without P/Q/DP/DQ/COEFF by hex values
if (param.kty === undefined &&
param.n !== undefined &&
param.e !== undefined &&
param.d !== undefined &&
param.p === undefined) {
var key = new RSAKey();
key.setPublic(param.n, param.e);
key.setPrivate(param.n, param.e, param.d);
return key;
}
// 2.6. DSA public key
if (param.p !== undefined && param.q !== undefined && param.g !== undefined &&

// 2.3. bare DSA
// 2.3.1. bare DSA public key by hex values
if (param.p !== undefined && param.q !== undefined &&
param.g !== undefined &&
param.y !== undefined && param.x === undefined) {
var key = new KJUR.crypto.DSA();
key.setPublic(param.p, param.q, param.g, param.y);
return key;
}

// 2.7. JWK RSA public key
// 2.3.2. bare DSA private key by hex values
if (param.p !== undefined && param.q !== undefined &&
param.g !== undefined &&
param.y !== undefined && param.x !== undefined) {
var key = new KJUR.crypto.DSA();
key.setPrivate(param.p, param.q, param.g, param.y, param.x);
return key;
}

// 3. JWK
// 3.1. JWK RSA
// 3.1.1. JWK RSA public key by b64u values
if (param.kty === "RSA" &&
param.n !== undefined &&
param.e !== undefined &&
Expand All @@ -1315,7 +1362,7 @@ KEYUTIL.getKey = function(param, passcode, hextype) {
return key;
}

// 2.8.1. JWK RSA private key with p/q/dp/dq/coeff
// 3.1.2. JWK RSA private key with p/q/dp/dq/coeff by b64u values
if (param.kty === "RSA" &&
param.n !== undefined &&
param.e !== undefined &&
Expand All @@ -1337,7 +1384,7 @@ KEYUTIL.getKey = function(param, passcode, hextype) {
return key;
}

// 2.8.2. JWK RSA private key without p/q/dp/dq/coeff
// 3.1.3. JWK RSA private key without p/q/dp/dq/coeff by b64u
// since jsrsasign 5.0.0 keyutil 1.0.11
if (param.kty === "RSA" &&
param.n !== undefined &&
Expand All @@ -1350,7 +1397,8 @@ KEYUTIL.getKey = function(param, passcode, hextype) {
return key;
}

// 2.9. JWK ECC public key
// 3.2. JWK ECC
// 3.2.1. JWK ECC public key by b64u values
if (param.kty === "EC" &&
param.crv !== undefined &&
param.x !== undefined &&
Expand All @@ -1365,7 +1413,7 @@ KEYUTIL.getKey = function(param, passcode, hextype) {
return ec;
}

// 2.10. JWK ECC private key
// 3.2.2. JWK ECC private key by b64u values
if (param.kty === "EC" &&
param.crv !== undefined &&
param.x !== undefined &&
Expand All @@ -1378,7 +1426,7 @@ KEYUTIL.getKey = function(param, passcode, hextype) {
return ec;
}

// 3. by PEM certificate (-----BEGIN ... CERTIFITE----)
// 4. by PEM certificate (-----BEGIN ... CERTIFITE----)
if (param.indexOf("-END CERTIFICATE-", 0) != -1 ||
param.indexOf("-END X509 CERTIFICATE-", 0) != -1 ||
param.indexOf("-END TRUSTED CERTIFICATE-", 0) != -1) {
Expand Down
4 changes: 2 additions & 2 deletions keyutil-1.0.min.js

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions npm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ and this 'jsrsasign' module.
- provides RSAPSS signing
- also provides support for JSON Web Signatures (JWS) and JSON Web Token (JWT)

CONCLUDED THIRD-PARTY LIBRARIES
-------------------------------

- [CryptoJS](https://code.google.com/p/crypto-js/): for symmetric cipher, hash, mac, PBKDF (BSD License)
- [BitCoinJS](http://bitcoinjs.org/): for ECDSA (MIT License)
- [OpenPGP.js](http://openpgpjs.org/): for DSA (LGPL License)
- [Tom Wu's jsbn](http://www-cs-students.stanford.edu/~tjw/jsbn/): for BigInteger, RSA encryption and EC (BSD License)
- [Yahoo YUI](http://yuilibrary.com/): for class inheritance (BSD License)
- [json-sans-eval](https://code.google.com/p/json-sans-eval/): secure JSON parser (Apache License)

AVAILABLE CLASSES AND METHODS
-----------------------------

Expand Down
Loading

0 comments on commit 703251f

Please sign in to comment.