Permalink
Browse files

3.1.3 release

  • Loading branch information...
1 parent a2a20cc commit 43b3298227a4f2bdf7ad8bc4c093cebc9b595319 @kjur committed May 28, 2013
Showing with 651 additions and 499 deletions.
  1. +5 −0 ChangeLog.txt
  2. +1 −1 api/files.html
  3. +35 −20 api/symbols/KJUR.crypto.MessageDigest.html
  4. +503 −463 api/symbols/src/crypto-1.0.js.html
  5. +53 −13 crypto-1.0.js
  6. +2 −2 crypto-1.0.min.js
  7. +52 −0 test/qunit-do-crypto-sjcl.html
View
@@ -1,6 +1,11 @@
ChangeLog for jsrsasign
+* Changes between 3.1.2 and 3.1.3 (2013-May-28)
+ - crypto-1.0.js update 1.0.3 to 1.0.4
+ - support "sjcl" (i.e. Stanford JavaScript Crypto Library)
+ provider with sha256 in MessageDigest class
+
* Changes between 3.1.1 and 3.1.2 (2013-May-27)
- pkcs5pkey-1.0.js update 1.0.2 to 1.0.3
- following method added to support loading encrypted PKCS#8 priavte key
View
@@ -368,7 +368,7 @@ <h1 class="classTitle">File Index</h1>
<dt class="heading">Version:</dt>
- <dd>1.0.2 (2013-Mar-12)</dd>
+ <dd>1.0.4 (2013-Mar-28)</dd>
@@ -340,8 +340,17 @@ <h1 class="classTitle">
</div>
<div class="description">MessageDigest class which is very similar to java.security.MessageDigest class
<br/>
-Currently this supports md5, sha1, sha224, sha256, sha384,
-sha512 and ripemd160 for algorithm and 'cryptojs' for provider.</div>
+Currently this supports following algorithm and providers combination:
+<ul>
+<li>md5 - cryptojs</li>
+<li>sha1 - cryptojs</li>
+<li>sha224 - cryptojs</li>
+<li>sha256 - cryptojs</li>
+<li>sha384 - cryptojs</li>
+<li>sha512 - cryptojs</li>
+<li>ripemd160 - cryptojs</li>
+<li>sha256 - sjcl (NEW from crypto.js 1.0.4)</li>
+</ul></div>
</td>
</tr>
</tbody>
@@ -448,21 +457,36 @@ <h1 class="classTitle">
<div class="description">
MessageDigest class which is very similar to java.security.MessageDigest class
<br/>
-Currently this supports md5, sha1, sha224, sha256, sha384,
-sha512 and ripemd160 for algorithm and 'cryptojs' for provider.
+Currently this supports following algorithm and providers combination:
+<ul>
+<li>md5 - cryptojs</li>
+<li>sha1 - cryptojs</li>
+<li>sha224 - cryptojs</li>
+<li>sha256 - cryptojs</li>
+<li>sha384 - cryptojs</li>
+<li>sha512 - cryptojs</li>
+<li>ripemd160 - cryptojs</li>
+<li>sha256 - sjcl (NEW from crypto.js 1.0.4)</li>
+</ul>
</div>
- <pre class="code">var md = new KJUR.crypto.MessageDigest({"alg": "sha1", "prov": "cryptojs"});
-// append data
-md.updateHex('1f2d3e')
+ <pre class="code">// CryptoJS provider sample
+&lt;script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/core.js"&gt;&lt;/script&gt;
+&lt;script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/sha1.js"&gt;&lt;/script&gt;
+&lt;script src="crypto-1.0.js"&gt;&lt;/script&gt;
+var md = new KJUR.crypto.MessageDigest({alg: "sha1", prov: "cryptojs"});
+md.updateString('aaa')
+var mdHex = md.digest()
+
+// SJCL(Stanford JavaScript Crypto Library) provider sample
+&lt;script src="http://bitwiseshiftleft.github.io/sjcl/sjcl.js"&gt;&lt;/script&gt;
+&lt;script src="crypto-1.0.js"&gt;&lt;/script&gt;
+var md = new KJUR.crypto.MessageDigest({alg: "sha256", prov: "sjcl"}); // sjcl supports sha256 only
md.updateString('aaa')
-// get message digest
-md.digest()
-md.digestHex('5f6de0')
-md.digestString('aaa')</pre>
+var mdHex = md.digest()</pre>
@@ -485,15 +509,6 @@ <h1 class="classTitle">
- <dl class="detailList">
- <dt class="heading">See:</dt>
-
- <dd>http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/core-min.js</dd>
-
- <dd>http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha1.js</dd>
-
- </dl>
-
</div>

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,4 +1,4 @@
-/*! crypto-1.0.3.js (c) 2013 Kenji Urushima | kjur.github.com/jsrsasign/license
+/*! crypto-1.0.4.js (c) 2013 Kenji Urushima | kjur.github.com/jsrsasign/license
*/
/*
* crypto.js - Cryptographic Algorithm Provider class
@@ -16,7 +16,7 @@
* @fileOverview
* @name crypto-1.0.js
* @author Kenji Urushima kenji.urushima@gmail.com
- * @version 1.0.2 (2013-Mar-12)
+ * @version 1.0.4 (2013-Mar-28)
* @since 2.2
* @license <a href="http://kjur.github.io/jsrsasign/license/">MIT License</a>
*/
@@ -183,19 +183,32 @@ KJUR.crypto.Util = new function() {
* @param {Array} params parameters for constructor
* @description
* <br/>
- * Currently this supports md5, sha1, sha224, sha256, sha384,
- * sha512 and ripemd160 for algorithm and 'cryptojs' for provider.
+ * Currently this supports following algorithm and providers combination:
+ * <ul>
+ * <li>md5 - cryptojs</li>
+ * <li>sha1 - cryptojs</li>
+ * <li>sha224 - cryptojs</li>
+ * <li>sha256 - cryptojs</li>
+ * <li>sha384 - cryptojs</li>
+ * <li>sha512 - cryptojs</li>
+ * <li>ripemd160 - cryptojs</li>
+ * <li>sha256 - sjcl (NEW from crypto.js 1.0.4)</li>
+ * </ul>
* @example
- * var md = new KJUR.crypto.MessageDigest({"alg": "sha1", "prov": "cryptojs"});
- * // append data
- * md.updateHex('1f2d3e')
+ * // CryptoJS provider sample
+ * &lt;script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/core.js"&gt;&lt;/script&gt;
+ * &lt;script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/sha1.js"&gt;&lt;/script&gt;
+ * &lt;script src="crypto-1.0.js"&gt;&lt;/script&gt;
+ * var md = new KJUR.crypto.MessageDigest({alg: "sha1", prov: "cryptojs"});
+ * md.updateString('aaa')
+ * var mdHex = md.digest()
+ *
+ * // SJCL(Stanford JavaScript Crypto Library) provider sample
+ * &lt;script src="http://bitwiseshiftleft.github.io/sjcl/sjcl.js"&gt;&lt;/script&gt;
+ * &lt;script src="crypto-1.0.js"&gt;&lt;/script&gt;
+ * var md = new KJUR.crypto.MessageDigest({alg: "sha256", prov: "sjcl"}); // sjcl supports sha256 only
* md.updateString('aaa')
- * // get message digest
- * md.digest()
- * md.digestHex('5f6de0')
- * md.digestString('aaa')
- * @see http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/core-min.js
- * @see http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha1.js
+ * var mdHex = md.digest()
*/
KJUR.crypto.MessageDigest = function(params) {
var md = null;
@@ -253,6 +266,33 @@ KJUR.crypto.MessageDigest = function(params) {
return this.digest();
};
}
+ if (':sha256:'.indexOf(alg) != -1 &&
+ prov == 'sjcl') {
+ try {
+ this.md = new sjcl.hash.sha256();
+ } catch (ex) {
+ throw "setAlgAndProvider hash alg set fail alg=" + alg + "/" + ex;
+ }
+ this.updateString = function(str) {
+ this.md.update(str);
+ };
+ this.updateHex = function(hex) {
+ var baHex = sjcl.codec.hex.toBits(hex);
+ this.md.update(baHex);
+ };
+ this.digest = function() {
+ var hash = this.md.finalize();
+ return sjcl.codec.hex.fromBits(hash);
+ };
+ this.digestString = function(str) {
+ this.updateString(str);
+ return this.digest();
+ };
+ this.digestHex = function(hex) {
+ this.updateHex(hex);
+ return this.digest();
+ };
+ }
};
/**
Oops, something went wrong.

0 comments on commit 43b3298

Please sign in to comment.