From 7a57185524e90251ba41215a57777707c93d1795 Mon Sep 17 00:00:00 2001 From: Brian Turek Date: Thu, 25 Jun 2015 17:27:19 -0400 Subject: [PATCH] Pushing compiled files for v1.6.1 --- CHANGELOG | 5 +++++ bower.json | 2 +- package.json | 2 +- src/sha.js | 50 +++++++++++++++++++++++++------------------------- src/sha1.js | 22 +++++++++++----------- src/sha256.js | 28 ++++++++++++++-------------- src/sha512.js | 32 ++++++++++++++++---------------- 7 files changed, 73 insertions(+), 68 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index bf6fba7..b2691ec 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,11 @@ ------------------------- jsSHA - ChangeLog ------------------------- +1.6.1 (2015-06-25) +========================= +- Fixed issue with SHA-512 family of hashes failing is raw input was a + particular size + 1.6.0 (2015-03-08) ========================= This marks the last v1.X new feature release. The API is changing diff --git a/bower.json b/bower.json index 7d132ea..4b97c6b 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name" : "jsSHA", - "version" : "1.6.0", + "version" : "1.6.1", "description" : "jsSHA is a JavaScript implementation of the entire family of SHA hashes as defined in FIPS 180-2 (SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512) as well as HMAC", "main" : "src/sha.js", "repository" : { diff --git a/package.json b/package.json index 3826997..f8f6263 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jssha", - "version": "1.6.0", + "version": "1.6.1", "description": "jsSHA is a JavaScript implementation of the entire family of SHA hashes as defined in FIPS 180-2 (SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512) as well as HMAC", "main": "src/sha.js", "repository": { diff --git a/src/sha.js b/src/sha.js index 55f13fc..aaf4458 100644 --- a/src/sha.js +++ b/src/sha.js @@ -9,28 +9,28 @@ Several functions taken from Paul Johnston */ -'use strict';(function(U){function z(a,b,c){var e=0,f=[0],k="",h=null,k=c||"UTF8";if("UTF8"!==k&&"UTF16BE"!==k&&"UTF16LE"!==k)throw"encoding must be UTF8, UTF16BE, or UTF16LE";if("HEX"===b){if(0!==a.length%2)throw"srcString of HEX type must be in byte increments";h=D(a);e=h.binLen;f=h.value}else if("TEXT"===b||"ASCII"===b)h=L(a,k),e=h.binLen,f=h.value;else if("B64"===b)h=M(a),e=h.binLen,f=h.value;else if("BYTES"===b)h=N(a),e=h.binLen,f=h.value;else throw"inputFormat must be HEX, TEXT, ASCII, B64, or BYTES"; -this.getHash=function(a,b,c,k){var h=null,d=f.slice(),n=e,m;3===arguments.length?"number"!==typeof c&&(k=c,c=1):2===arguments.length&&(c=1);if(c!==parseInt(c,10)||1>c)throw"numRounds must a integer >= 1";switch(b){case "HEX":h=O;break;case "B64":h=P;break;case "BYTES":h=Q;break;default:throw"format must be HEX, B64, or BYTES";}if("SHA-1"===a)for(m=0;mm/8){for(;d.length<=b;)d.push(0);d[b]&=4294967040}for(n=0;n<=b;n+=1)r[n]=d[n]^ -909522486,u[n]=d[n]^1549556828;c="SHA-1"===c?A(u.concat(A(r.concat(f),a+e)),a+t):w(u.concat(w(r.concat(f),a+e,c)),a+t,c);return h(c,R(q))}}function q(a,b){this.a=a;this.b=b}function L(a,b){var c=[],e,f=[],k=0,h,p,q;if("UTF8"===b)for(h=0;he?f.push(e):2048>e?(f.push(192|e>>>6),f.push(128|e&63)):55296>e||57344<=e?f.push(224|e>>>12,128|e>>>6&63,128|e&63):(h+=1,e=65536+((e&1023)<<10|a.charCodeAt(h)&1023),f.push(240|e>>>18,128|e>>>12&63,128|e>>>6&63,128|e&63)), -p=0;p>>2;c.length<=q;)c.push(0);c[q]|=f[p]<<24-k%4*8;k+=1}else if("UTF16BE"===b||"UTF16LE"===b)for(h=0;h>8);for(q=k>>>2;c.length<=q;)c.push(0);c[q]|=e<<16-k%4*8;k+=2}return{value:c,binLen:8*k}}function D(a){var b=[],c=a.length,e,f,k;if(0!==c%2)throw"String of HEX type must be in byte increments";for(e=0;e>>3;b.length<=k;)b.push(0);b[e>>>3]|=f<<24-e%8*4}return{value:b,binLen:4*c}}function N(a){var b=[],c,e,f;for(e=0;e>>2,b.length<=f&&b.push(0),b[f]|=c<<24-e%4*8;return{value:b,binLen:8*a.length}}function M(a){var b=[],c=0,e,f,k,h,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw"Invalid character in base-64 string";f=a.indexOf("=");a=a.replace(/\=/g,"");if(-1!==f&&fc)throw"numRounds must a integer >= 1";switch(b){case "HEX":h=P;break;case "B64":h=Q;break;case "BYTES":h=R;break;default:throw"format must be HEX, B64, or BYTES";}if("SHA-1"===a)for(m=0;mm/8){for(;d.length<=b;)d.push(0);d[b]&=4294967040}for(n=0;n<=b;n+=1)r[n]=d[n]^ +909522486,v[n]=d[n]^1549556828;c="SHA-1"===c?B(v.concat(B(r.concat(f),a+e)),a+u):x(v.concat(x(r.concat(f),a+e,c)),a+u,c);return h(c,S(q))}}function q(a,b){this.a=a;this.b=b}function M(a,b){var c=[],e,f=[],k=0,h,p,q;if("UTF8"===b)for(h=0;he?f.push(e):2048>e?(f.push(192|e>>>6),f.push(128|e&63)):55296>e||57344<=e?f.push(224|e>>>12,128|e>>>6&63,128|e&63):(h+=1,e=65536+((e&1023)<<10|a.charCodeAt(h)&1023),f.push(240|e>>>18,128|e>>>12&63,128|e>>>6&63,128|e&63)), +p=0;p>>2;c.length<=q;)c.push(0);c[q]|=f[p]<<24-k%4*8;k+=1}else if("UTF16BE"===b||"UTF16LE"===b)for(h=0;h>8);for(q=k>>>2;c.length<=q;)c.push(0);c[q]|=e<<16-k%4*8;k+=2}return{value:c,binLen:8*k}}function E(a){var b=[],c=a.length,e,f,k;if(0!==c%2)throw"String of HEX type must be in byte increments";for(e=0;e>>3;b.length<=k;)b.push(0);b[e>>>3]|=f<<24-e%8*4}return{value:b,binLen:4*c}}function O(a){var b=[],c,e,f;for(e=0;e>>2,b.length<=f&&b.push(0),b[f]|=c<<24-e%4*8;return{value:b,binLen:8*a.length}}function N(a){var b=[],c=0,e,f,k,h,p;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw"Invalid character in base-64 string";f=a.indexOf("=");a=a.replace(/\=/g,"");if(-1!==f&&fe)throw"numRounds must a integer >= 1";switch(b){case "HEX":f=z;break;case "B64":f=A;break;case "BYTES":f=B;break;default:throw"format must be HEX, B64, or BYTES";}if("SHA-1"===c)for(p=0;pp/8){for(;h.length<=b;)h.push(0);h[b]&=4294967040}for(m=0;m<=b;m+=1)n[m]=h[m]^909522486,u[m]=h[m]^1549556828;if("SHA-1"===f)f=t(u.concat(t(n.concat(d),c+a)),c+s);else throw"Unexpected error in HMAC implementation";return g(f,C(r))}}function w(c,b){var g=[],a,d=[],e=0,f,k,q;if("UTF8"===b)for(f=0;fa?d.push(a):2048>a?(d.push(192|a>>>6),d.push(128| -a&63)):55296>a||57344<=a?d.push(224|a>>>12,128|a>>>6&63,128|a&63):(f+=1,a=65536+((a&1023)<<10|c.charCodeAt(f)&1023),d.push(240|a>>>18,128|a>>>12&63,128|a>>>6&63,128|a&63)),k=0;k>>2;g.length<=q;)g.push(0);g[q]|=d[k]<<24-e%4*8;e+=1}else if("UTF16BE"===b||"UTF16LE"===b)for(f=0;f>8);for(q=e>>>2;g.length<=q;)g.push(0);g[q]|=a<<16-e%4*8;e+=2}return{value:g,binLen:8*e}}function v(c){var b=[],g=c.length,a,d,e;if(0!== -g%2)throw"String of HEX type must be in byte increments";for(a=0;a>>3;b.length<=e;)b.push(0);b[a>>>3]|=d<<24-a%8*4}return{value:b,binLen:4*g}}function y(c){var b=[],g,a,d;for(a=0;a>>2,b.length<=d&&b.push(0),b[d]|=g<<24-a%4*8;return{value:b,binLen:8*c.length}}function x(c){var b=[],g=0,a,d,e,f,k;if(-1===c.search(/^[a-zA-Z0-9=+\/]+$/))throw"Invalid character in base-64 string"; -d=c.indexOf("=");c=c.replace(/\=/g,"");if(-1!==d&&de)throw"numRounds must a integer >= 1";switch(b){case "HEX":g=A;break;case "B64":g=B;break;case "BYTES":g=C;break;default:throw"format must be HEX, B64, or BYTES";}if("SHA-1"===c)for(p=0;pp/8){for(;h.length<=b;)h.push(0);h[b]&=4294967040}for(m=0;m<=b;m+=1)n[m]=h[m]^909522486,v[m]=h[m]^1549556828;if("SHA-1"===f)f=u(v.concat(u(n.concat(d),c+a)),c+t);else throw"Unexpected error in HMAC implementation";return g(f,D(r))}}function x(c,b){var f=[],a,d=[],e=0,g,k,q;if("UTF8"===b)for(g=0;ga?d.push(a):2048>a?(d.push(192|a>>>6),d.push(128| +a&63)):55296>a||57344<=a?d.push(224|a>>>12,128|a>>>6&63,128|a&63):(g+=1,a=65536+((a&1023)<<10|c.charCodeAt(g)&1023),d.push(240|a>>>18,128|a>>>12&63,128|a>>>6&63,128|a&63)),k=0;k>>2;f.length<=q;)f.push(0);f[q]|=d[k]<<24-e%4*8;e+=1}else if("UTF16BE"===b||"UTF16LE"===b)for(g=0;g>8);for(q=e>>>2;f.length<=q;)f.push(0);f[q]|=a<<16-e%4*8;e+=2}return{value:f,binLen:8*e}}function w(c){var b=[],f=c.length,a,d,e;if(0!== +f%2)throw"String of HEX type must be in byte increments";for(a=0;a>>3;b.length<=e;)b.push(0);b[a>>>3]|=d<<24-a%8*4}return{value:b,binLen:4*f}}function z(c){var b=[],f,a,d;for(a=0;a>>2,b.length<=d&&b.push(0),b[d]|=f<<24-a%4*8;return{value:b,binLen:8*c.length}}function y(c){var b=[],f=0,a,d,e,g,k;if(-1===c.search(/^[a-zA-Z0-9=+\/]+$/))throw"Invalid character in base-64 string"; +d=c.indexOf("=");c=c.replace(/\=/g,"");if(-1!==d&&dd)throw"numRounds must a integer >= 1";switch(b){case "HEX":g=A;break;case "B64":g=B;break;case "BYTES":g=C;break;default:throw"format must be HEX, B64, or BYTES";}if("SHA-224"===a)for(l=0;ll/8){for(;e.length<=b;)e.push(0);e[b]&=4294967040}for(k=0;k<=b;k+=1)p[k]=e[k]^909522486,E[k]=e[k]^1549556828;d=t(E.concat(t(p.concat(f),a+c,d)),a+n,d);return g(d,D(s))}}function x(a,b){var d=[],c,f=[],h=0,g,m,q;if("UTF8"===b)for(g=0;gc?f.push(c):2048>c?(f.push(192|c>>>6),f.push(128|c&63)):55296>c||57344<=c?f.push(224|c>>>12,128|c>>>6&63,128|c&63):(g+=1,c=65536+((c& -1023)<<10|a.charCodeAt(g)&1023),f.push(240|c>>>18,128|c>>>12&63,128|c>>>6&63,128|c&63)),m=0;m>>2;d.length<=q;)d.push(0);d[q]|=f[m]<<24-h%4*8;h+=1}else if("UTF16BE"===b||"UTF16LE"===b)for(g=0;g>8);for(q=h>>>2;d.length<=q;)d.push(0);d[q]|=c<<16-h%4*8;h+=2}return{value:d,binLen:8*h}}function w(a){var b=[],d=a.length,c,f,h;if(0!==d%2)throw"String of HEX type must be in byte increments";for(c=0;c>>3;b.length<=h;)b.push(0);b[c>>>3]|=f<<24-c%8*4}return{value:b,binLen:4*d}}function z(a){var b=[],d,c,f;for(c=0;c>>2,b.length<=f&&b.push(0),b[f]|=d<<24-c%4*8;return{value:b,binLen:8*a.length}}function y(a){var b=[],d=0,c,f,h,g,m;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw"Invalid character in base-64 string";f=a.indexOf("=");a=a.replace(/\=/g,"");if(-1!==f&&fd)throw"numRounds must a integer >= 1";switch(b){case "HEX":g=B;break;case "B64":g=C;break;case "BYTES":g=D;break;default:throw"format must be HEX, B64, or BYTES";}if("SHA-224"===a)for(l=0;ll/8){for(;e.length<=b;)e.push(0);e[b]&=4294967040}for(k=0;k<=b;k+=1)p[k]=e[k]^909522486,F[k]=e[k]^1549556828;d=u(F.concat(u(p.concat(f),a+c,d)),a+n,d);return g(d,E(t))}}function y(a,b){var d=[],c,f=[],h=0,g,m,q;if("UTF8"===b)for(g=0;gc?f.push(c):2048>c?(f.push(192|c>>>6),f.push(128|c&63)):55296>c||57344<=c?f.push(224|c>>>12,128|c>>>6&63,128|c&63):(g+=1,c=65536+((c& +1023)<<10|a.charCodeAt(g)&1023),f.push(240|c>>>18,128|c>>>12&63,128|c>>>6&63,128|c&63)),m=0;m>>2;d.length<=q;)d.push(0);d[q]|=f[m]<<24-h%4*8;h+=1}else if("UTF16BE"===b||"UTF16LE"===b)for(g=0;g>8);for(q=h>>>2;d.length<=q;)d.push(0);d[q]|=c<<16-h%4*8;h+=2}return{value:d,binLen:8*h}}function x(a){var b=[],d=a.length,c,f,h;if(0!==d%2)throw"String of HEX type must be in byte increments";for(c=0;c>>3;b.length<=h;)b.push(0);b[c>>>3]|=f<<24-c%8*4}return{value:b,binLen:4*d}}function A(a){var b=[],d,c,f;for(c=0;c>>2,b.length<=f&&b.push(0),b[f]|=d<<24-c%4*8;return{value:b,binLen:8*a.length}}function z(a){var b=[],d=0,c,f,h,g,m;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw"Invalid character in base-64 string";f=a.indexOf("=");a=a.replace(/\=/g,"");if(-1!==f&&fc)throw"numRounds must a integer >= 1";switch(b){case "HEX":h=D;break;case "B64":h=E;break;case "BYTES":h=F;break;default:throw"format must be HEX, B64, or BYTES";}if("SHA-384"===a)for(p=0;pp/8){for(;d.length<=b;)d.push(0);d[b]&=4294967040}for(n=0;n<=b;n+=1)q[n]=d[n]^909522486,H[n]=d[n]^1549556828;c=u(H.concat(u(q.concat(g),a+f,c)),a+r,c);return h(c,G(m))}}function m(a,b){this.a=a;this.b=b}function z(a,b){var c=[],f,g=[],l=0,h,s,m;if("UTF8"===b)for(h=0;hf?g.push(f):2048>f?(g.push(192|f>>> -6),g.push(128|f&63)):55296>f||57344<=f?g.push(224|f>>>12,128|f>>>6&63,128|f&63):(h+=1,f=65536+((f&1023)<<10|a.charCodeAt(h)&1023),g.push(240|f>>>18,128|f>>>12&63,128|f>>>6&63,128|f&63)),s=0;s>>2;c.length<=m;)c.push(0);c[m]|=g[s]<<24-l%4*8;l+=1}else if("UTF16BE"===b||"UTF16LE"===b)for(h=0;h>8);for(m=l>>>2;c.length<=m;)c.push(0);c[m]|=f<<16-l%4*8;l+=2}return{value:c,binLen:8*l}}function y(a){var b=[],c=a.length, -f,g,l;if(0!==c%2)throw"String of HEX type must be in byte increments";for(f=0;f>>3;b.length<=l;)b.push(0);b[f>>>3]|=g<<24-f%8*4}return{value:b,binLen:4*c}}function B(a){var b=[],c,f,g;for(f=0;f>>2,b.length<=g&&b.push(0),b[g]|=c<<24-f%4*8;return{value:b,binLen:8*a.length}}function A(a){var b=[],c=0,f,g,l,h,m;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw"Invalid character in base-64 string"; -g=a.indexOf("=");a=a.replace(/\=/g,"");if(-1!==g&&gc)throw"numRounds must a integer >= 1";switch(b){case "HEX":h=E;break;case "B64":h=F;break;case "BYTES":h=G;break;default:throw"format must be HEX, B64, or BYTES";}if("SHA-384"===a)for(p=0;pp/8){for(;d.length<=b;)d.push(0);d[b]&=4294967040}for(n=0;n<=b;n+=1)q[n]=d[n]^909522486,I[n]=d[n]^1549556828;c=v(I.concat(v(q.concat(g),a+f,c)),a+r,c);return h(c,H(m))}}function m(a,b){this.a=a;this.b=b}function A(a,b){var c=[],f,g=[],l=0,h,t,m;if("UTF8"===b)for(h=0;hf?g.push(f):2048>f?(g.push(192|f>>> +6),g.push(128|f&63)):55296>f||57344<=f?g.push(224|f>>>12,128|f>>>6&63,128|f&63):(h+=1,f=65536+((f&1023)<<10|a.charCodeAt(h)&1023),g.push(240|f>>>18,128|f>>>12&63,128|f>>>6&63,128|f&63)),t=0;t>>2;c.length<=m;)c.push(0);c[m]|=g[t]<<24-l%4*8;l+=1}else if("UTF16BE"===b||"UTF16LE"===b)for(h=0;h>8);for(m=l>>>2;c.length<=m;)c.push(0);c[m]|=f<<16-l%4*8;l+=2}return{value:c,binLen:8*l}}function z(a){var b=[],c=a.length, +f,g,l;if(0!==c%2)throw"String of HEX type must be in byte increments";for(f=0;f>>3;b.length<=l;)b.push(0);b[f>>>3]|=g<<24-f%8*4}return{value:b,binLen:4*c}}function C(a){var b=[],c,f,g;for(f=0;f>>2,b.length<=g&&b.push(0),b[g]|=c<<24-f%4*8;return{value:b,binLen:8*a.length}}function B(a){var b=[],c=0,f,g,l,h,m;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw"Invalid character in base-64 string"; +g=a.indexOf("=");a=a.replace(/\=/g,"");if(-1!==g&&g