prototype functional
This commit is contained in:
commit
013377b414
12 files changed
+2030
No files matched your search
@@ -0,0 +1,42 @@
|
||||
-------------------------
|
||||
jsSHA - ChangeLog
|
||||
-------------------------
|
||||
|
||||
1.3 (2010-09-01)
|
||||
=========================
|
||||
- Changed method of declaring objects/classes
|
||||
- Moved non-instance specific variables and methods to class scope
|
||||
- Removed logically correct but unneeded conditionals
|
||||
|
||||
1.2 (2009-07-22)
|
||||
=========================
|
||||
- Added the HMAC algorithm for all supported hashes (using both ASCII and hex
|
||||
keys)
|
||||
- As a result of adding HMAC, added support for hash input text to be hex
|
||||
(ASCII representation of hex)
|
||||
- Added multiple variants of safeAdd functions, resulting in a significant
|
||||
performance gain
|
||||
- Removed wrapper.js file
|
||||
- Used a different JavaScript compressor resulting in smaller file sizes
|
||||
|
||||
1.11 (2008-12-07)
|
||||
=========================
|
||||
- Fixed a base-64 encoding issue resulting from a missing capital 'X'
|
||||
|
||||
1.1 (2008-09-25)
|
||||
=========================
|
||||
- Fixed an issue with incorrect hashes being generated when jsSHA ojbects were
|
||||
used to generate multiple hashes
|
||||
|
||||
1.0 (2008-09-25)
|
||||
=========================
|
||||
- Made all functions/variables follow an object-orientated methodology
|
||||
- Removed support for string hash output as the hash is rarely ASCII friendly
|
||||
- Changed the interface to calculate hashes (see README)
|
||||
- Made sha.js validate against JSLint (http://www.jslint.com/) using
|
||||
"Recommended" settings
|
||||
|
||||
0.1 (2008-02-21)
|
||||
=========================
|
||||
- Initial public release
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
Copyright (c) 2008-2010, Brian Turek
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* The names of the contributors may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
ANDANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIEDWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING,BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OFLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCEOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISEDOF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
jsSHA - A JavaScript implementation of the complete Secure Hash Standard family
|
||||
(SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512) as well as HMAC by
|
||||
Brian Turek
|
||||
|
||||
About
|
||||
-------------------------
|
||||
jsSHA is a javaScript implementation of the complete Secure Hash Algorithm
|
||||
family as defined by FIPS PUB 180-2
|
||||
(http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf).
|
||||
It also includes the HMAC algorithm with SHA support as defined by FIPS PUB 198a
|
||||
(http://csrc.nist.gov/publications/fips/fips198/fips-198a.pdf)
|
||||
|
||||
With the slow phasing out of MD5 as the standard hash to use in web
|
||||
applications, a client-side implementation of the complete Secure Hash Standard
|
||||
family was needed. Due to SHA-384 and SHA-512's use of 64-bit values throughout
|
||||
the algorithm, JavaScript can not easily natively support the calculation of
|
||||
these hashes. As a result, a bit of hacking had to be done to make sure the
|
||||
values behaved themselves. SHA-224 was added to the Secure Hash Standard family
|
||||
on 25 February 2004 so it was also included in this package.
|
||||
|
||||
|
||||
Files
|
||||
-------------------------
|
||||
src/sha.js
|
||||
The complete SHA implementation
|
||||
|
||||
src/sha1.js
|
||||
A smaller/web friendly implementation of only SHA-1.
|
||||
|
||||
src/sha256.js
|
||||
A smaller/web friendly implementation of only SHA-224 and SHA-256.
|
||||
|
||||
src/sha512.js
|
||||
A smaller/web friendly implementation of only SHA-384 and SHA-512.
|
||||
|
||||
test/test.html
|
||||
A test page that calculates various hashes and has their correct values.
|
||||
|
||||
test/HMACGen.py
|
||||
A Python 3.X script that generates the correct HMAC hashes as the specification
|
||||
did not provide hashes for algorithms other than SHA-1
|
||||
|
||||
|
||||
Usage
|
||||
-------------------------
|
||||
Include the desired JavaScript file (sha.js, sha1.js, sha256.js, or sha512.js)
|
||||
in your header (sha.js used below):
|
||||
<script type="text/javascript" src="/path/to/sha.js"></script>
|
||||
|
||||
Instantiate a new jsSHA object with your string to be hashed as the only
|
||||
parameter. Then, call getHash with the desired hash variant (SHA-1, SHA-224,
|
||||
SHA-256, SHA-384, or SHA-512) and output type (HEX or B64). In the example
|
||||
below, "This is a Test" and "SHA-512" were used as the string to be hashed and
|
||||
variant respectively. Also, the HMAC using ASCII key "SecretKey" and hashing
|
||||
algorithm SHA-512 was calculated.
|
||||
|
||||
var shaObj = new jsSHA("This is a Test", "ASCII");
|
||||
var hash = shaObj.getHash("SHA-512", "HEX");
|
||||
var hmac = shaObj.getHMAC("SecretKey", "ASCII", "SHA-512", "HEX");
|
||||
|
||||
NOTE: If you are using sha1.js, omit the SHA variant parameter as there is only
|
||||
one option.
|
||||
|
||||
Contact Info
|
||||
-------------------------
|
||||
The project's website is located at http://jssha.sourceforge.net/
|
||||
|
||||
+1165
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,12 @@
|
||||
/* A JavaScript implementation of the SHA family of hashes, as defined in FIPS
|
||||
* PUB 180-2 as well as the corresponding HMAC implementation as defined in
|
||||
* FIPS PUB 198a
|
||||
*
|
||||
* Version 1.3 Copyright Brian Turek 2008-2010
|
||||
* Distributed under the BSD License
|
||||
* See http://jssha.sourceforge.net/ for more information
|
||||
*
|
||||
* Several functions taken from Paul Johnson
|
||||
*/
|
||||
(function(){var charSize=8,b64pad="",hexCase=0,str2binb=function(a){var b=[],mask=(1<<charSize)-1,length=a.length*charSize,i;for(i=0;i<length;i+=charSize){b[i>>5]|=(a.charCodeAt(i/charSize)&mask)<<(32-charSize-(i%32))}return b},hex2binb=function(a){var b=[],length=a.length,i,num;for(i=0;i<length;i+=2){num=parseInt(a.substr(i,2),16);if(!isNaN(num)){b[i>>3]|=num<<(24-(4*(i%8)))}else{return"INVALID HEX STRING"}}return b},binb2hex=function(a){var b=(hexCase)?"0123456789ABCDEF":"0123456789abcdef",str="",length=a.length*4,i,srcByte;for(i=0;i<length;i+=1){srcByte=a[i>>2]>>((3-(i%4))*8);str+=b.charAt((srcByte>>4)&0xF)+b.charAt(srcByte&0xF)}return str},binb2b64=function(a){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"+"0123456789+/",str="",length=a.length*4,i,j,triplet;for(i=0;i<length;i+=3){triplet=(((a[i>>2]>>8*(3-i%4))&0xFF)<<16)|(((a[i+1>>2]>>8*(3-(i+1)%4))&0xFF)<<8)|((a[i+2>>2]>>8*(3-(i+2)%4))&0xFF);for(j=0;j<4;j+=1){if(i*8+j*6<=a.length*32){str+=b.charAt((triplet>>6*(3-j))&0x3F)}else{str+=b64pad}}}return str},rotl=function(x,n){return(x<<n)|(x>>>(32-n))},parity=function(x,y,z){return x^y^z},ch=function(x,y,z){return(x&y)^(~x&z)},maj=function(x,y,z){return(x&y)^(x&z)^(y&z)},safeAdd_2=function(x,y){var a=(x&0xFFFF)+(y&0xFFFF),msw=(x>>>16)+(y>>>16)+(a>>>16);return((msw&0xFFFF)<<16)|(a&0xFFFF)},safeAdd_5=function(a,b,c,d,e){var f=(a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF)+(e&0xFFFF),msw=(a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(e>>>16)+(f>>>16);return((msw&0xFFFF)<<16)|(f&0xFFFF)},coreSHA1=function(f,g){var W=[],a,b,c,d,e,T,i,t,appendedMessageLength,H=[0x67452301,0xefcdab89,0x98badcfe,0x10325476,0xc3d2e1f0],K=[0x5a827999,0x5a827999,0x5a827999,0x5a827999,0x5a827999,0x5a827999,0x5a827999,0x5a827999,0x5a827999,0x5a827999,0x5a827999,0x5a827999,0x5a827999,0x5a827999,0x5a827999,0x5a827999,0x5a827999,0x5a827999,0x5a827999,0x5a827999,0x6ed9eba1,0x6ed9eba1,0x6ed9eba1,0x6ed9eba1,0x6ed9eba1,0x6ed9eba1,0x6ed9eba1,0x6ed9eba1,0x6ed9eba1,0x6ed9eba1,0x6ed9eba1,0x6ed9eba1,0x6ed9eba1,0x6ed9eba1,0x6ed9eba1,0x6ed9eba1,0x6ed9eba1,0x6ed9eba1,0x6ed9eba1,0x6ed9eba1,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6];f[g>>5]|=0x80<<(24-(g%32));f[(((g+65)>>9)<<4)+15]=g;appendedMessageLength=f.length;for(i=0;i<appendedMessageLength;i+=16){a=H[0];b=H[1];c=H[2];d=H[3];e=H[4];for(t=0;t<80;t+=1){if(t<16){W[t]=f[t+i]}else{W[t]=rotl(W[t-3]^W[t-8]^W[t-14]^W[t-16],1)}if(t<20){T=safeAdd_5(rotl(a,5),ch(b,c,d),e,K[t],W[t])}else if(t<40){T=safeAdd_5(rotl(a,5),parity(b,c,d),e,K[t],W[t])}else if(t<60){T=safeAdd_5(rotl(a,5),maj(b,c,d),e,K[t],W[t])}else{T=safeAdd_5(rotl(a,5),parity(b,c,d),e,K[t],W[t])}e=d;d=c;c=rotl(b,30);b=a;a=T}H[0]=safeAdd_2(a,H[0]);H[1]=safeAdd_2(b,H[1]);H[2]=safeAdd_2(c,H[2]);H[3]=safeAdd_2(d,H[3]);H[4]=safeAdd_2(e,H[4])}return H},jsSHA=function(a,b){this.sha1=null;this.strBinLen=null;this.strToHash=null;if("HEX"===b){if(0!==(a.length%2)){return"TEXT MUST BE IN BYTE INCREMENTS"}this.strBinLen=a.length*4;this.strToHash=hex2binb(a)}else if(("ASCII"===b)||('undefined'===typeof(b))){this.strBinLen=a.length*charSize;this.strToHash=str2binb(a)}else{return"UNKNOWN TEXT INPUT TYPE"}};jsSHA.prototype={getHash:function(a){var b=null,message=this.strToHash.slice();switch(a){case"HEX":b=binb2hex;break;case"B64":b=binb2b64;break;default:return"FORMAT NOT RECOGNIZED"}if(null===this.sha1){this.sha1=coreSHA1(message,this.strBinLen)}return b(this.sha1)},getHMAC:function(a,b,c){var d,keyToUse,i,retVal,keyBinLen,keyWithIPad=[],keyWithOPad=[];switch(c){case"HEX":d=binb2hex;break;case"B64":d=binb2b64;break;default:return"FORMAT NOT RECOGNIZED"}if("HEX"===b){if(0!==(a.length%2)){return"KEY MUST BE IN BYTE INCREMENTS"}keyToUse=hex2binb(a);keyBinLen=a.length*4}else if("ASCII"===b){keyToUse=str2binb(a);keyBinLen=a.length*charSize}else{return"UNKNOWN KEY INPUT TYPE"}if(64<(keyBinLen/8)){keyToUse=coreSHA1(keyToUse,keyBinLen);keyToUse[15]&=0xFFFFFF00}else if(64>(keyBinLen/8)){keyToUse[15]&=0xFFFFFF00}for(i=0;i<=15;i+=1){keyWithIPad[i]=keyToUse[i]^0x36363636;keyWithOPad[i]=keyToUse[i]^0x5C5C5C5C}retVal=coreSHA1(keyWithIPad.concat(this.strToHash),512+this.strBinLen);retVal=coreSHA1(keyWithOPad.concat(retVal),672);return(d(retVal))}};window.jsSHA=jsSHA}());
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/* A JavaScript implementation of the SHA family of hashes, as defined in FIPS
|
||||
* PUB 180-2 as well as the corresponding HMAC implementation as defined in
|
||||
* FIPS PUB 198a
|
||||
*
|
||||
* Version 1.3 Copyright Brian Turek 2008-2010
|
||||
* Distributed under the BSD License
|
||||
* See http://jssha.sourceforge.net/ for more information
|
||||
*
|
||||
* Several functions taken from Paul Johnson
|
||||
*/
|
||||
(function(){var charSize=8,b64pad="",hexCase=0,str2binb=function(a){var b=[],mask=(1<<charSize)-1,length=a.length*charSize,i;for(i=0;i<length;i+=charSize){b[i>>5]|=(a.charCodeAt(i/charSize)&mask)<<(32-charSize-(i%32))}return b},hex2binb=function(a){var b=[],length=a.length,i,num;for(i=0;i<length;i+=2){num=parseInt(a.substr(i,2),16);if(!isNaN(num)){b[i>>3]|=num<<(24-(4*(i%8)))}else{return"INVALID HEX STRING"}}return b},binb2hex=function(a){var b=(hexCase)?"0123456789ABCDEF":"0123456789abcdef",str="",length=a.length*4,i,srcByte;for(i=0;i<length;i+=1){srcByte=a[i>>2]>>((3-(i%4))*8);str+=b.charAt((srcByte>>4)&0xF)+b.charAt(srcByte&0xF)}return str},binb2b64=function(a){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"+"0123456789+/",str="",length=a.length*4,i,j,triplet;for(i=0;i<length;i+=3){triplet=(((a[i>>2]>>8*(3-i%4))&0xFF)<<16)|(((a[i+1>>2]>>8*(3-(i+1)%4))&0xFF)<<8)|((a[i+2>>2]>>8*(3-(i+2)%4))&0xFF);for(j=0;j<4;j+=1){if(i*8+j*6<=a.length*32){str+=b.charAt((triplet>>6*(3-j))&0x3F)}else{str+=b64pad}}}return str},rotr=function(x,n){return(x>>>n)|(x<<(32-n))},shr=function(x,n){return x>>>n},ch=function(x,y,z){return(x&y)^(~x&z)},maj=function(x,y,z){return(x&y)^(x&z)^(y&z)},sigma0=function(x){return rotr(x,2)^rotr(x,13)^rotr(x,22)},sigma1=function(x){return rotr(x,6)^rotr(x,11)^rotr(x,25)},gamma0=function(x){return rotr(x,7)^rotr(x,18)^shr(x,3)},gamma1=function(x){return rotr(x,17)^rotr(x,19)^shr(x,10)},safeAdd_2=function(x,y){var a=(x&0xFFFF)+(y&0xFFFF),msw=(x>>>16)+(y>>>16)+(a>>>16);return((msw&0xFFFF)<<16)|(a&0xFFFF)},safeAdd_4=function(a,b,c,d){var e=(a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF),msw=(a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(e>>>16);return((msw&0xFFFF)<<16)|(e&0xFFFF)},safeAdd_5=function(a,b,c,d,e){var f=(a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF)+(e&0xFFFF),msw=(a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(e>>>16)+(f>>>16);return((msw&0xFFFF)<<16)|(f&0xFFFF)},coreSHA2=function(j,k,l){var a,b,c,d,e,f,g,h,T1,T2,H,lengthPosition,i,t,K,W=[],appendedMessageLength;if(l==="SHA-224"||l==="SHA-256"){lengthPosition=(((k+65)>>9)<<4)+15;K=[0x428A2F98,0x71374491,0xB5C0FBCF,0xE9B5DBA5,0x3956C25B,0x59F111F1,0x923F82A4,0xAB1C5ED5,0xD807AA98,0x12835B01,0x243185BE,0x550C7DC3,0x72BE5D74,0x80DEB1FE,0x9BDC06A7,0xC19BF174,0xE49B69C1,0xEFBE4786,0x0FC19DC6,0x240CA1CC,0x2DE92C6F,0x4A7484AA,0x5CB0A9DC,0x76F988DA,0x983E5152,0xA831C66D,0xB00327C8,0xBF597FC7,0xC6E00BF3,0xD5A79147,0x06CA6351,0x14292967,0x27B70A85,0x2E1B2138,0x4D2C6DFC,0x53380D13,0x650A7354,0x766A0ABB,0x81C2C92E,0x92722C85,0xA2BFE8A1,0xA81A664B,0xC24B8B70,0xC76C51A3,0xD192E819,0xD6990624,0xF40E3585,0x106AA070,0x19A4C116,0x1E376C08,0x2748774C,0x34B0BCB5,0x391C0CB3,0x4ED8AA4A,0x5B9CCA4F,0x682E6FF3,0x748F82EE,0x78A5636F,0x84C87814,0x8CC70208,0x90BEFFFA,0xA4506CEB,0xBEF9A3F7,0xC67178F2];if(l==="SHA-224"){H=[0xc1059ed8,0x367cd507,0x3070dd17,0xf70e5939,0xffc00b31,0x68581511,0x64f98fa7,0xbefa4fa4]}else{H=[0x6A09E667,0xBB67AE85,0x3C6EF372,0xA54FF53A,0x510E527F,0x9B05688C,0x1F83D9AB,0x5BE0CD19]}}j[k>>5]|=0x80<<(24-k%32);j[lengthPosition]=k;appendedMessageLength=j.length;for(i=0;i<appendedMessageLength;i+=16){a=H[0];b=H[1];c=H[2];d=H[3];e=H[4];f=H[5];g=H[6];h=H[7];for(t=0;t<64;t+=1){if(t<16){W[t]=j[t+i]}else{W[t]=safeAdd_4(gamma1(W[t-2]),W[t-7],gamma0(W[t-15]),W[t-16])}T1=safeAdd_5(h,sigma1(e),ch(e,f,g),K[t],W[t]);T2=safeAdd_2(sigma0(a),maj(a,b,c));h=g;g=f;f=e;e=safeAdd_2(d,T1);d=c;c=b;b=a;a=safeAdd_2(T1,T2)}H[0]=safeAdd_2(a,H[0]);H[1]=safeAdd_2(b,H[1]);H[2]=safeAdd_2(c,H[2]);H[3]=safeAdd_2(d,H[3]);H[4]=safeAdd_2(e,H[4]);H[5]=safeAdd_2(f,H[5]);H[6]=safeAdd_2(g,H[6]);H[7]=safeAdd_2(h,H[7])}switch(l){case"SHA-224":return[H[0],H[1],H[2],H[3],H[4],H[5],H[6]];case"SHA-256":return H;default:return[]}},jsSHA=function(a,b){this.sha224=null;this.sha256=null;this.strBinLen=null;this.strToHash=null;if("HEX"===b){if(0!==(a.length%2)){return"TEXT MUST BE IN BYTE INCREMENTS"}this.strBinLen=a.length*4;this.strToHash=hex2binb(a)}else if(("ASCII"===b)||('undefined'===typeof(b))){this.strBinLen=a.length*charSize;this.strToHash=str2binb(a)}else{return"UNKNOWN TEXT INPUT TYPE"}};jsSHA.prototype={getHash:function(a,b){var c=null,message=this.strToHash.slice();switch(b){case"HEX":c=binb2hex;break;case"B64":c=binb2b64;break;default:return"FORMAT NOT RECOGNIZED"}switch(a){case"SHA-224":if(null===this.sha224){this.sha224=coreSHA2(message,this.strBinLen,a)}return c(this.sha224);case"SHA-256":if(null===this.sha256){this.sha256=coreSHA2(message,this.strBinLen,a)}return c(this.sha256);default:return"HASH NOT RECOGNIZED"}},getHMAC:function(a,b,c,d){var e,keyToUse,i,retVal,keyBinLen,hashBitSize,keyWithIPad=[],keyWithOPad=[];switch(d){case"HEX":e=binb2hex;break;case"B64":e=binb2b64;break;default:return"FORMAT NOT RECOGNIZED"}switch(c){case"SHA-224":hashBitSize=224;break;case"SHA-256":hashBitSize=256;break;default:return"HASH NOT RECOGNIZED"}if("HEX"===b){if(0!==(a.length%2)){return"KEY MUST BE IN BYTE INCREMENTS"}keyToUse=hex2binb(a);keyBinLen=a.length*4}else if("ASCII"===b){keyToUse=str2binb(a);keyBLine truncated
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/* A JavaScript implementation of the SHA family of hashes, as defined in FIPS
|
||||
* PUB 180-2 as well as the corresponding HMAC implementation as defined in
|
||||
* FIPS PUB 198a
|
||||
*
|
||||
* Version 1.3 Copyright Brian Turek 2008-2010
|
||||
* Distributed under the BSD License
|
||||
* See http://jssha.sourceforge.net/ for more information
|
||||
*
|
||||
* Several functions taken from Paul Johnson
|
||||
*/
|
||||
(function(){var charSize=8,b64pad="",hexCase=0,Int_64=function(a,b){this.highOrder=a;this.lowOrder=b},str2binb=function(a){var b=[],mask=(1<<charSize)-1,length=a.length*charSize,i;for(i=0;i<length;i+=charSize){b[i>>5]|=(a.charCodeAt(i/charSize)&mask)<<(32-charSize-(i%32))}return b},hex2binb=function(a){var b=[],length=a.length,i,num;for(i=0;i<length;i+=2){num=parseInt(a.substr(i,2),16);if(!isNaN(num)){b[i>>3]|=num<<(24-(4*(i%8)))}else{return"INVALID HEX STRING"}}return b},binb2hex=function(a){var b=(hexCase)?"0123456789ABCDEF":"0123456789abcdef",str="",length=a.length*4,i,srcByte;for(i=0;i<length;i+=1){srcByte=a[i>>2]>>((3-(i%4))*8);str+=b.charAt((srcByte>>4)&0xF)+b.charAt(srcByte&0xF)}return str},binb2b64=function(a){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"+"0123456789+/",str="",length=a.length*4,i,j,triplet;for(i=0;i<length;i+=3){triplet=(((a[i>>2]>>8*(3-i%4))&0xFF)<<16)|(((a[i+1>>2]>>8*(3-(i+1)%4))&0xFF)<<8)|((a[i+2>>2]>>8*(3-(i+2)%4))&0xFF);for(j=0;j<4;j+=1){if(i*8+j*6<=a.length*32){str+=b.charAt((triplet>>6*(3-j))&0x3F)}else{str+=b64pad}}}return str},rotr=function(x,n){if(n<=32){return new Int_64((x.highOrder>>>n)|(x.lowOrder<<(32-n)),(x.lowOrder>>>n)|(x.highOrder<<(32-n)))}else{return new Int_64((x.lowOrder>>>n)|(x.highOrder<<(32-n)),(x.highOrder>>>n)|(x.lowOrder<<(32-n)))}},shr=function(x,n){if(n<=32){return new Int_64(x.highOrder>>>n,x.lowOrder>>>n|(x.highOrder<<(32-n)))}else{return new Int_64(0,x.highOrder<<(32-n))}},ch=function(x,y,z){return new Int_64((x.highOrder&y.highOrder)^(~x.highOrder&z.highOrder),(x.lowOrder&y.lowOrder)^(~x.lowOrder&z.lowOrder))},maj=function(x,y,z){return new Int_64((x.highOrder&y.highOrder)^(x.highOrder&z.highOrder)^(y.highOrder&z.highOrder),(x.lowOrder&y.lowOrder)^(x.lowOrder&z.lowOrder)^(y.lowOrder&z.lowOrder))},sigma0=function(x){var a=rotr(x,28),rotr34=rotr(x,34),rotr39=rotr(x,39);return new Int_64(a.highOrder^rotr34.highOrder^rotr39.highOrder,a.lowOrder^rotr34.lowOrder^rotr39.lowOrder)},sigma1=function(x){var a=rotr(x,14),rotr18=rotr(x,18),rotr41=rotr(x,41);return new Int_64(a.highOrder^rotr18.highOrder^rotr41.highOrder,a.lowOrder^rotr18.lowOrder^rotr41.lowOrder)},gamma0=function(x){var a=rotr(x,1),rotr8=rotr(x,8),shr7=shr(x,7);return new Int_64(a.highOrder^rotr8.highOrder^shr7.highOrder,a.lowOrder^rotr8.lowOrder^shr7.lowOrder)},gamma1=function(x){var a=rotr(x,19),rotr61=rotr(x,61),shr6=shr(x,6);return new Int_64(a.highOrder^rotr61.highOrder^shr6.highOrder,a.lowOrder^rotr61.lowOrder^shr6.lowOrder)},safeAdd_2=function(x,y){var a,msw,lowOrder,highOrder;a=(x.lowOrder&0xFFFF)+(y.lowOrder&0xFFFF);msw=(x.lowOrder>>>16)+(y.lowOrder>>>16)+(a>>>16);lowOrder=((msw&0xFFFF)<<16)|(a&0xFFFF);a=(x.highOrder&0xFFFF)+(y.highOrder&0xFFFF)+(msw>>>16);msw=(x.highOrder>>>16)+(y.highOrder>>>16)+(a>>>16);highOrder=((msw&0xFFFF)<<16)|(a&0xFFFF);return new Int_64(highOrder,lowOrder)},safeAdd_4=function(a,b,c,d){var e,msw,lowOrder,highOrder;e=(a.lowOrder&0xFFFF)+(b.lowOrder&0xFFFF)+(c.lowOrder&0xFFFF)+(d.lowOrder&0xFFFF);msw=(a.lowOrder>>>16)+(b.lowOrder>>>16)+(c.lowOrder>>>16)+(d.lowOrder>>>16)+(e>>>16);lowOrder=((msw&0xFFFF)<<16)|(e&0xFFFF);e=(a.highOrder&0xFFFF)+(b.highOrder&0xFFFF)+(c.highOrder&0xFFFF)+(d.highOrder&0xFFFF)+(msw>>>16);msw=(a.highOrder>>>16)+(b.highOrder>>>16)+(c.highOrder>>>16)+(d.highOrder>>>16)+(e>>>16);highOrder=((msw&0xFFFF)<<16)|(e&0xFFFF);return new Int_64(highOrder,lowOrder)},safeAdd_5=function(a,b,c,d,e){var f,msw,lowOrder,highOrder;f=(a.lowOrder&0xFFFF)+(b.lowOrder&0xFFFF)+(c.lowOrder&0xFFFF)+(d.lowOrder&0xFFFF)+(e.lowOrder&0xFFFF);msw=(a.lowOrder>>>16)+(b.lowOrder>>>16)+(c.lowOrder>>>16)+(d.lowOrder>>>16)+(e.lowOrder>>>16)+(f>>>16);lowOrder=((msw&0xFFFF)<<16)|(f&0xFFFF);f=(a.highOrder&0xFFFF)+(b.highOrder&0xFFFF)+(c.highOrder&0xFFFF)+(d.highOrder&0xFFFF)+(e.highOrder&0xFFFF)+(msw>>>16);msw=(a.highOrder>>>16)+(b.highOrder>>>16)+(c.highOrder>>>16)+(d.highOrder>>>16)+(e.highOrder>>>16)+(f>>>16);highOrder=((msw&0xFFFF)<<16)|(f&0xFFFF);return new Int_64(highOrder,lowOrder)},coreSHA2=function(j,k,l){var a,b,c,d,e,f,g,h,T1,T2,H,lengthPosition,i,t,K,W=[],appendedMessageLength;if(l==="SHA-384"||l==="SHA-512"){lengthPosition=(((k+128)>>10)<<5)+31;K=[new Int_64(0x428a2f98,0xd728ae22),new Int_64(0x71374491,0x23ef65cd),new Int_64(0xb5c0fbcf,0xec4d3b2f),new Int_64(0xe9b5dba5,0x8189dbbc),new Int_64(0x3956c25b,0xf348b538),new Int_64(0x59f111f1,0xb605d019),new Int_64(0x923f82a4,0xaf194f9b),new Int_64(0xab1c5ed5,0xda6d8118),new Int_64(0xd807aa98,0xa3030242),new Int_64(0x12835b01,0x45706fbe),new Int_64(0x243185be,0x4ee4b28c),new Int_64(0x550c7dc3,0xd5ffb4e2),new Int_64(0x72be5d74,0xf27b896f),new Int_64(0x80deb1fe,0x3b1696b1),new Int_64(0x9bdc06a7,0x25c71235),new Int_64(0xc19bf174,0xcf692694),new Int_64(0xe49b69c1,0x9ef14ad2),new Int_64(0xefbe4786,0x384f25e3),new Int_64(0x0fc19dc6,0x8b8cd5b5),new Int_64(0x240ca1cc,0x77ac9c65),new Int_64(0x2de92c6f,0x592b0275),new Int_64(0x4a7484aa,0x6ea6e483),new Int_64(0x5cb0a9dc,0xbd41fbd4),new Int_64(0x76f988da,0x831153b5),nLine truncated
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
#! /usr/bin/env python
|
||||
'''
|
||||
jsSHA HMAC Test Result Generator
|
||||
Version 1.0 Copyright Brian Turek 2009
|
||||
Distributed under the BSD License
|
||||
See http://jssha.sourceforge.net/ for more information
|
||||
'''
|
||||
import hashlib
|
||||
import hmac
|
||||
|
||||
def main():
|
||||
'''
|
||||
main()
|
||||
|
||||
Calculates the HMAC of the test vectors given in FIPS-198a for full
|
||||
length HMACs. Uses double the key sizes for SHA-384 and SHA-512 as
|
||||
they have double the block size
|
||||
'''
|
||||
# shortKey tests for handling of key lengths less than the block size
|
||||
shortTxt = b'Sample #2'
|
||||
shortKey = bytes.fromhex('30313233 34353637 38393a3b 3c3d3e3f 40414243')
|
||||
|
||||
# medKey tests for handling of keys lengths equal to the block size
|
||||
medTxt = b'Sample #1'
|
||||
medKey = bytes.fromhex('00010203 04050607 08090a0b 0c0d0e0f 10111213' +
|
||||
'14151617 18191a1b 1c1d1e1f 20212223 24252627 28292a2b 2c2d2e2f'+
|
||||
'30313233 34353637 38393a3b 3c3d3e3f')
|
||||
|
||||
# largeKey tests for handling of keys lengths greater than the block size
|
||||
largeTxt = b'Sample #3'
|
||||
largeKey = bytes.fromhex('50515253 54555657 58595a5b 5c5d5e5f 60616263'+
|
||||
'64656667 68696a6b 6c6d6e6f 70717273 74757677 78797a7b 7c7d7e7f' +
|
||||
'80818283 84858687 88898a8b 8c8d8e8f 90919293 94959697 98999a9b' +
|
||||
'9c9d9e9f a0a1a2a3 a4a5a6a7 a8a9aaab acadaeaf b0b1b2b3')
|
||||
|
||||
# Perform the SHA-1 Tests
|
||||
print('\nSHA-1 Short Key Result:')
|
||||
print(hmac.new(shortKey, shortTxt, hashlib.sha1).hexdigest())
|
||||
print('\nSHA-1 Medium Key Result:')
|
||||
print(hmac.new(medKey, medTxt, hashlib.sha1).hexdigest())
|
||||
print('\nSHA-1 Large Key Result:')
|
||||
print(hmac.new(largeKey, largeTxt, hashlib.sha1).hexdigest())
|
||||
|
||||
# Perform the SHA-224 Tests
|
||||
print('\nSHA-224 Short Key Result:')
|
||||
print(hmac.new(shortKey, shortTxt, hashlib.sha224).hexdigest())
|
||||
print('\nSHA-224 Medium Key Result:')
|
||||
print(hmac.new(medKey, medTxt, hashlib.sha224).hexdigest())
|
||||
print('\nSHA-224 Large Key Result:')
|
||||
print(hmac.new(largeKey, largeTxt, hashlib.sha224).hexdigest())
|
||||
|
||||
# Perform the SHA-256 Tests
|
||||
print('\nSHA-256 Short Key Result:')
|
||||
print(hmac.new(shortKey, shortTxt, hashlib.sha256).hexdigest())
|
||||
print('\nSHA-256 Medium Key Result:')
|
||||
print(hmac.new(medKey, medTxt, hashlib.sha256).hexdigest())
|
||||
print('\nSHA-256 Large Key Result:')
|
||||
print(hmac.new(largeKey, largeTxt, hashlib.sha256).hexdigest())
|
||||
|
||||
# Since SHA-384 and SHA-512 take double the block size, double the key
|
||||
# length so the tests act against the same functions as above
|
||||
shortKey = shortKey * 2
|
||||
medKey = medKey * 2
|
||||
largeKey = largeKey * 2
|
||||
|
||||
# Perform the SHA-384 Tests
|
||||
print('\nSHA-384 Short Key Result:')
|
||||
print(hmac.new(shortKey, shortTxt, hashlib.sha384).hexdigest())
|
||||
print('\nSHA-384 Medium Key Result:')
|
||||
print(hmac.new(medKey, medTxt, hashlib.sha384).hexdigest())
|
||||
print('\nSHA-384 Large Key Result:')
|
||||
print(hmac.new(largeKey, largeTxt, hashlib.sha384).hexdigest())
|
||||
|
||||
# Perform the SHA-512 Tests
|
||||
print('\nSHA-512 Short Key Result:')
|
||||
print(hmac.new(shortKey, shortTxt, hashlib.sha512).hexdigest())
|
||||
print('\nSHA-512 Medium Key Result:')
|
||||
print(hmac.new(medKey, medTxt, hashlib.sha512).hexdigest())
|
||||
print('\nSHA-512 Large Key Result:')
|
||||
print(hmac.new(largeKey, largeTxt, hashlib.sha512).hexdigest())
|
||||
|
||||
if ('__main__' == __name__):
|
||||
main()
|
||||
@@ -0,0 +1,519 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<title>jsSHA (http://jssha.sourceforge.net/) - Test</title>
|
||||
<script type="text/javascript" src="../src/sha.js"></script>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<style type="text/css">
|
||||
label
|
||||
{
|
||||
width: 290px;
|
||||
display: block;
|
||||
float: left;
|
||||
text-align: right;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
.correct
|
||||
{
|
||||
color: #00FF00;
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
|
||||
.incorrect
|
||||
{
|
||||
color: #FF0000;
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
function calcHashes()
|
||||
{
|
||||
calcHash("sha1-short", "SHA-1");
|
||||
calcHash("sha1-long", "SHA-1");
|
||||
calcHash("sha224-short", "SHA-224");
|
||||
calcHash("sha224-long", "SHA-224");
|
||||
calcHash("sha256-short", "SHA-256");
|
||||
calcHash("sha256-long", "SHA-256");
|
||||
calcHash("sha384-short", "SHA-384");
|
||||
calcHash("sha384-long", "SHA-384");
|
||||
calcHash("sha512-long", "SHA-512");
|
||||
calcHash("sha512-short", "SHA-512");
|
||||
calcHMAC('hmac-sha1-short', "ASCII", "ASCII", "SHA-1");
|
||||
calcHMAC('hmac-sha1-med', "ASCII", "HEX", "SHA-1");
|
||||
calcHMAC('hmac-sha1-large', "HEX", "HEX", "SHA-1");
|
||||
calcHMAC('hmac-sha224-short', "ASCII", "ASCII", "SHA-224");
|
||||
calcHMAC('hmac-sha224-med', "ASCII", "HEX", "SHA-224");
|
||||
calcHMAC('hmac-sha224-large', "HEX", "HEX", "SHA-224");
|
||||
calcHMAC('hmac-sha256-short', "ASCII", "ASCII", "SHA-256");
|
||||
calcHMAC('hmac-sha256-med', "ASCII", "HEX", "SHA-256");
|
||||
calcHMAC('hmac-sha256-large', "HEX", "HEX", "SHA-256");
|
||||
calcHMAC('hmac-sha384-short', "ASCII", "ASCII", "SHA-384");
|
||||
calcHMAC('hmac-sha384-med', "ASCII", "HEX", "SHA-384");
|
||||
calcHMAC('hmac-sha384-large', "HEX", "HEX", "SHA-384");
|
||||
calcHMAC('hmac-sha512-short', "ASCII", "ASCII", "SHA-512");
|
||||
calcHMAC('hmac-sha512-med', "ASCII", "HEX", "SHA-512");
|
||||
calcHMAC('hmac-sha512-large', "HEX", "HEX", "SHA-512");
|
||||
}
|
||||
|
||||
function calcHash(fieldGroupName, variant)
|
||||
{
|
||||
var tmp = document.getElementById(fieldGroupName+"-ascii-comp");
|
||||
|
||||
var shaObj = new jsSHA(document.getElementById(fieldGroupName+"-ascii-input").value, "ASCII");
|
||||
|
||||
document.getElementById(fieldGroupName+"-ascii-result").value = shaObj.getHash(variant, "HEX");
|
||||
if (document.getElementById(fieldGroupName+"-ascii-result").value == document.getElementById(fieldGroupName+"-correct").value)
|
||||
{
|
||||
tmp.className = "correct";
|
||||
tmp.innerHTML = "Match!";
|
||||
} else {
|
||||
tmp.className = "incorrect";
|
||||
tmp.innerHTML = "Mismatch!";
|
||||
}
|
||||
|
||||
tmp = document.getElementById(fieldGroupName+"-hex-comp");
|
||||
|
||||
shaObj = new jsSHA(document.getElementById(fieldGroupName+"-hex-input").value, "HEX");
|
||||
|
||||
document.getElementById(fieldGroupName+"-hex-result").value = shaObj.getHash(variant, "HEX");
|
||||
if (document.getElementById(fieldGroupName+"-hex-result").value == document.getElementById(fieldGroupName+"-correct").value)
|
||||
{
|
||||
tmp.className = "correct";
|
||||
tmp.innerHTML = "Match!";
|
||||
} else {
|
||||
tmp.className = "incorrect";
|
||||
tmp.innerHTML = "Mismatch!";
|
||||
}
|
||||
}
|
||||
|
||||
function calcHMAC(fieldGroupName, textFormat, keyFormat, variant)
|
||||
{
|
||||
var tmp = document.getElementById(fieldGroupName+"-comp");
|
||||
|
||||
var shaObj = new jsSHA(document.getElementById(fieldGroupName+"-text").value, textFormat);
|
||||
|
||||
document.getElementById(fieldGroupName+"-result").value = shaObj.getHMAC(document.getElementById(fieldGroupName+"-key").value, keyFormat, variant, "HEX");
|
||||
if (document.getElementById(fieldGroupName+"-result").value == document.getElementById(fieldGroupName+"-correct").value)
|
||||
{
|
||||
tmp.className = "correct";
|
||||
tmp.innerHTML = "Match!";
|
||||
} else {
|
||||
tmp.className = "incorrect";
|
||||
tmp.innerHTML = "Mismatch!";
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body onload="calcHashes()">
|
||||
<h1><a href="http://jssha.sourceforge.net/">jsSHA</a> Hash Test Page</h1>
|
||||
<p>
|
||||
The short/long inputs as well as their correct hashes are supplied by the FIPS 180-2 specification; it can be found at <a href="http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf">http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf</a>. The short/medium/large inputs for HMAC and their corresponding correct hashes (at least for SHA-1) can be found at <a href="http://csrc.nist.gov/publications/fips/fips198/fips-198a.pdf">http://csrc.nist.gov/publications/fips/fips198/fips-198a.pdf</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<span style="font-weight: bold">Instructions:</span> By default, this page should load 10 of the 15 test vectors given by the FIPS 180-2 specification and 3 of the 4 test vectors given by the FIPS 198a specification. You may also change any of the input values and then click off the input box to have the hash update.
|
||||
</p>
|
||||
<form method="get" action="test.html" onsubmit="return false">
|
||||
<fieldset>
|
||||
<legend>SHA-1 Tests</legend>
|
||||
<div>
|
||||
<label for="sha1-short-ascii-input">SHA-1 Med ASCII Input:</label><input type="text" size="5" value="abc" id="sha1-short-ascii-input" onchange="calcHash('sha1-short', 'SHA-1')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha1-short-ascii-result">SHA-1 Med ASCII Result:</label><input type="text" size="50" disabled="disabled" id="sha1-short-ascii-result" />
|
||||
<span id="sha1-short-ascii-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha1-short-hex-input">SHA-1 Med Hex Input:</label><input type="text" size="10" value="616263" id="sha1-short-hex-input" onchange="calcHash('sha1-short', 'SHA-1')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha1-short-hex-result">SHA-1 Med Hex Result:</label><input type="text" size="50" disabled="disabled" id="sha1-short-hex-result" />
|
||||
<span id="sha1-short-hex-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha1-short-correct">SHA-1 Med Correct:</label><input type="text" size="50" value="a9993e364706816aba3e25717850c26c9cd0d89d" disabled="disabled" id="sha1-short-correct" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha1-long-ascii-input">SHA-1 Long ASCII Input:</label><input type="text" size="60" value="abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" id="sha1-long-ascii-input" onchange="calcHash('sha1-long', 'SHA-1')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha1-long-ascii-result">SHA-1 Long ASCII Result:</label><input type="text" size="50" disabled="disabled" id="sha1-long-ascii-result" />
|
||||
<span id="sha1-long-ascii-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha1-long-hex-input">SHA-1 Long Hex Input:</label><input type="text" size="140" value="6162636462636465636465666465666765666768666768696768696A68696A6B696A6B6C6A6B6C6D6B6C6D6E6C6D6E6F6D6E6F706E6F7071" id="sha1-long-hex-input" onchange="calcHash('sha1-long', 'SHA-1')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha1-long-hex-result">SHA-1 Long Hex Result:</label><input type="text" size="50" disabled="disabled" id="sha1-long-hex-result" />
|
||||
<span id="sha1-long-hex-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha1-long-correct">SHA-1 Long Correct:</label><input type="text" size="50" value="84983e441c3bd26ebaae4aa1f95129e5e54670f1" disabled="disabled" id="sha1-long-correct" />
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>SHA-224 Tests</legend>
|
||||
<div>
|
||||
<label for="sha224-short-ascii-input">SHA-224 Med ASCII Input:</label><input type="text" size="5" value="abc" id="sha224-short-ascii-input" onchange="calcHash('sha224-short', 'SHA-224')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha224-short-ascii-result">SHA-224 Med ASCII Result:</label><input type="text" size="65" disabled="disabled" id="sha224-short-ascii-result" />
|
||||
<span id="sha224-short-ascii-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha224-short-hex-input">SHA-224 Med Hex Input:</label><input type="text" size="10" value="616263" id="sha224-short-hex-input" onchange="calcHash('sha224-short', 'SHA-224')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha224-short-hex-result">SHA-224 Med Hex Result:</label><input type="text" size="65" disabled="disabled" id="sha224-short-hex-result" />
|
||||
<span id="sha224-short-hex-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha224-short-correct">SHA-224 Med Correct:</label><input type="text" size="65" value="23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7" disabled="disabled" id="sha224-short-correct" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha224-long-ascii-input">SHA-224 Long ASCII Input:</label><input type="text" size="60" value="abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" id="sha224-long-ascii-input" onchange="calcHash('sha224-long', 'SHA-224')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha224-long-ascii-result">SHA-224 Long ASCII Result:</label><input type="text" size="65" disabled="disabled" id="sha224-long-ascii-result" />
|
||||
<span id="sha224-long-ascii-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha224-long-hex-input">SHA-224 Long Hex Input:</label><input type="text" size="140" value="6162636462636465636465666465666765666768666768696768696A68696A6B696A6B6C6A6B6C6D6B6C6D6E6C6D6E6F6D6E6F706E6F7071" id="sha224-long-hex-input" onchange="calcHash('sha224-long', 'SHA-224')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha224-long-hex-result">SHA-224 Long Hex Result:</label><input type="text" size="65" disabled="disabled" id="sha224-long-hex-result" />
|
||||
<span id="sha224-long-hex-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha224-long-correct">SHA-224 Long Correct:</label><input type="text" size="65" value="75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525" disabled="disabled" id="sha224-long-correct" />
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>SHA-256 Tests</legend>
|
||||
<div>
|
||||
<label for="sha256-short-ascii-input">SHA-256 Med ASCII Input:</label><input type="text" size="5" value="abc" id="sha256-short-ascii-input" onchange="calcHash('sha256-short', 'SHA-256')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha256-short-ascii-result">SHA-256 Med ASCII Result:</label><input type="text" size="75" disabled="disabled" id="sha256-short-ascii-result" />
|
||||
<span id="sha256-short-ascii-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha256-short-hex-input">SHA-256 Med Hex Input:</label><input type="text" size="10" value="616263" id="sha256-short-hex-input" onchange="calcHash('sha256-short', 'SHA-256')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha256-short-hex-result">SHA-256 Med Hex Result:</label><input type="text" size="75" disabled="disabled" id="sha256-short-hex-result" />
|
||||
<span id="sha256-short-hex-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha256-short-correct">SHA-256 Med Correct:</label><input type="text" size="75" value="ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" disabled="disabled" id="sha256-short-correct" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha256-long-ascii-input">SHA-256 Long ASCII Input:</label><input type="text" size="60" value="abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" id="sha256-long-ascii-input" onchange="calcHash('sha256-long', 'SHA-256')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha256-long-ascii-result">SHA-256 Long ASCII Result:</label><input type="text" size="75" disabled="disabled" id="sha256-long-ascii-result" />
|
||||
<span id="sha256-long-ascii-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha256-long-hex-input">SHA-256 Long Hex Input:</label><input type="text" size="140" value="6162636462636465636465666465666765666768666768696768696A68696A6B696A6B6C6A6B6C6D6B6C6D6E6C6D6E6F6D6E6F706E6F7071" id="sha256-long-hex-input" onchange="calcHash('sha256-long', 'SHA-256')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha256-long-hex-result">SHA-256 Long Hex Result:</label><input type="text" size="75" disabled="disabled" id="sha256-long-hex-result" />
|
||||
<span id="sha256-long-hex-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha256-long-correct">SHA-256 Long Correct:</label><input type="text" size="75" value="248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1" disabled="disabled" id="sha256-long-correct" />
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>SHA-384 Tests</legend>
|
||||
<div>
|
||||
<label for="sha384-short-ascii-input">SHA-384 Med ASCII Input:</label><input type="text" size="5" value="abc" id="sha384-short-ascii-input" onchange="calcHash('sha384-short', 'SHA-384')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha384-short-ascii-result">SHA-384 Med ASCII Result:</label><input type="text" size="115" disabled="disabled" id="sha384-short-ascii-result" />
|
||||
<span id="sha384-short-ascii-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha384-short-hex-input">SHA-384 Med Hex Input:</label><input type="text" size="10" value="616263" id="sha384-short-hex-input" onchange="calcHash('sha384-short', 'SHA-384')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha384-short-hex-result">SHA-384 Med Hex Result:</label><input type="text" size="115" disabled="disabled" id="sha384-short-hex-result" />
|
||||
<span id="sha384-short-hex-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha384-short-correct">SHA-384 Med Correct:</label><input type="text" size="115" value="cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7" disabled="disabled" id="sha384-short-correct" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha384-long-ascii-input">SHA-384 Long ASCII Input:</label><input type="text" size="120" value="abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" id="sha384-long-ascii-input" onchange="calcHash('sha384-long', 'SHA-384')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha384-long-ascii-result">SHA-384 Long ASCII Result:</label><input type="text" size="115" disabled="disabled" id="sha384-long-ascii-result" />
|
||||
<span id="sha384-long-ascii-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha384-long-hex-input">SHA-384 Long Hex Input:</label><input type="text" size="100" value="61626364656667686263646566676869636465666768696A6465666768696A6B65666768696A6B6C666768696A6B6C6D6768696A6B6C6D6E68696A6B6C6D6E6F696A6B6C6D6E6F706A6B6C6D6E6F70716B6C6D6E6F7071726C6D6E6F707172736D6E6F70717273746E6F707172737475" id="sha384-long-hex-input" onchange="calcHash('sha384-long', 'SHA-384')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha384-long-hex-result">SHA-384 Long Hex Result:</label><input type="text" size="115" disabled="disabled" id="sha384-long-hex-result" />
|
||||
<span id="sha384-long-hex-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha384-long-correct">SHA-384 Long Correct:</label><input type="text" size="115" value="09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039" disabled="disabled" id="sha384-long-correct" />
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>SHA-512 Tests</legend>
|
||||
<div>
|
||||
<label for="sha512-short-ascii-input">SHA-512 Med ASCII Input:</label><input type="text" size="5" value="abc" id="sha512-short-ascii-input" onchange="calcHash('sha512-short', 'SHA-512')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha512-short-ascii-result">SHA-512 Med ASCII Result:</label><input type="text" size="150" disabled="disabled" id="sha512-short-ascii-result" />
|
||||
<span id="sha512-short-ascii-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha512-short-hex-input">SHA-512 Med Hex Input:</label><input type="text" size="10" value="616263" id="sha512-short-hex-input" onchange="calcHash('sha512-short', 'SHA-512')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha512-short-hex-result">SHA-512 Med Hex Result:</label><input type="text" size="150" disabled="disabled" id="sha512-short-hex-result" />
|
||||
<span id="sha512-short-hex-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha512-short-correct">SHA-512 Med Correct:</label><input type="text" size="150" value="ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f" disabled="disabled" id="sha512-short-correct" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha512-long-ascii-input">SHA-512 Long ASCII Input:</label><input type="text" size="120" value="abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" id="sha512-long-ascii-input" onchange="calcHash('sha512-long', 'SHA-512')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha512-long-ascii-result">SHA-512 Long ASCII Result:</label><input type="text" size="150" disabled="disabled" id="sha512-long-ascii-result" />
|
||||
<span id="sha512-long-ascii-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha512-long-hex-input">SHA-512 Long Hex Input:</label><input type="text" size="100" value="61626364656667686263646566676869636465666768696A6465666768696A6B65666768696A6B6C666768696A6B6C6D6768696A6B6C6D6E68696A6B6C6D6E6F696A6B6C6D6E6F706A6B6C6D6E6F70716B6C6D6E6F7071726C6D6E6F707172736D6E6F70717273746E6F707172737475" id="sha512-long-hex-input" onchange="calcHash('sha512-long', 'SHA-512')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha512-long-hex-result">SHA-512 Long Hex Result:</label><input type="text" size="150" disabled="disabled" id="sha512-long-hex-result" />
|
||||
<span id="sha512-long-hex-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="sha512-long-correct">SHA-512 Long Correct:</label><input type="text" size="150" value="8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909" disabled="disabled" id="sha512-long-correct" />
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
<form method="get" action="test.html" onsubmit="return false">
|
||||
<fieldset>
|
||||
<legend>HMAC/SHA-1 Tests</legend>
|
||||
|
||||
<div>
|
||||
<label for="hmac-sha1-short-text">HMAC/SHA-1 Short ASCII Text:</label><input type="text" size="10" value="Sample #2" id="hmac-sha1-short-text" onchange="calcHMAC('hmac-sha1-short', 'ASCII', 'ASCII', 'SHA-1')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha1-short-key">HMAC/SHA-1 Short Hex Key:</label><input type="text" size="25" value="0123456789:;<=>?@ABC" id="hmac-sha1-short-key" onchange="calcHMAC('hmac-sha1-short', 'ASCII', 'ASCII', 'SHA-1')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha1-short-result">HMAC/SHA-1 Short Hex Result:</label><input type="text" size="45" disabled="disabled" id="hmac-sha1-short-result" />
|
||||
<span id="hmac-sha1-short-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha1-short-correct">HMAC/SHA-1 Short Correct:</label><input type="text" size="45" value="0922d3405faa3d194f82a45830737d5cc6c75d24" disabled="disabled" id="hmac-sha1-short-correct" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha1-med-text">HMAC/SHA-1 Med ASCII Text:</label><input type="text" size="10" value="Sample #1" id="hmac-sha1-med-text" onchange="calcHMAC('hmac-sha1-med', 'ASCII', 'HEX', 'SHA-1')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha1-med-key">HMAC/SHA-1 Med Hex Key:</label><input type="text" size="150" value="000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f" id="hmac-sha1-med-key" onchange="calcHMAC('hmac-sha1-med', 'ASCII', 'HEX', 'SHA-1')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha1-med-result">HMAC/SHA-1 Med Hex Result:</label><input type="text" size="45" disabled="disabled" id="hmac-sha1-med-result" />
|
||||
<span id="hmac-sha1-med-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha1-med-correct">HMAC/SHA-1 Med Correct:</label><input type="text" size="45" value="4f4ca3d5d68ba7cc0a1208c9c61e9c5da0403c0a" disabled="disabled" id="hmac-sha1-med-correct" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha1-large-text">HMAC/SHA-1 Large Hex Text:</label><input type="text" size="20" value="53616D706C65202333" id="hmac-sha1-large-text" onchange="calcHMAC('hmac-sha1-large', 'HEX', 'HEX', 'SHA-1')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha1-large-key">HMAC/SHA-1 Large Hex Key:</label><input type="text" size="100" value="505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3" id="hmac-sha1-large-key" onchange="calcHMAC('hmac-sha1-large', 'HEX', 'HEX', 'SHA-1')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha1-large-result">HMAC/SHA-1 Large Hex Result:</label><input type="text" size="45" disabled="disabled" id="hmac-sha1-large-result" />
|
||||
<span id="hmac-sha1-large-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha1-large-correct">HMAC/SHA-1 Large Correct:</label><input type="text" size="45" value="bcf41eab8bb2d802f3d05caf7cb092ecf8d1a3aa" disabled="disabled" id="hmac-sha1-large-correct" />
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>HMAC/SHA-224 Tests</legend>
|
||||
<div>
|
||||
<label for="hmac-sha224-short-text">HMAC/SHA-224 Short ASCII Text:</label><input type="text" size="10" value="Sample #2" id="hmac-sha224-short-text" onchange="calcHMAC('hmac-sha224-short', 'ASCII', 'ASCII', 'SHA-224')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha224-short-key">HMAC/SHA-224 Short Hex Key:</label><input type="text" size="25" value="0123456789:;<=>?@ABC" id="hmac-sha224-short-key" onchange="calcHMAC('hmac-sha224-short', 'ASCII', 'ASCII', 'SHA-224')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha224-short-result">HMAC/SHA-224 Short Hex Result:</label><input type="text" size="65" disabled="disabled" id="hmac-sha224-short-result" />
|
||||
<span id="hmac-sha224-short-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha224-short-correct">HMAC/SHA-224 Short Correct:</label><input type="text" size="65" value="ddef0a40cb7d50fb6ee6cea120ba26aa08f3077587b8ad1b8c8d12c7" disabled="disabled" id="hmac-sha224-short-correct" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha224-med-text">HMAC/SHA-224 Med ASCII Text:</label><input type="text" size="10" value="Sample #1" id="hmac-sha224-med-text" onchange="calcHMAC('hmac-sha224-med', 'ASCII', 'HEX', 'SHA-224')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha224-med-key">HMAC/SHA-224 Med Hex Key:</label><input type="text" size="150" value="000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f" id="hmac-sha224-med-key" onchange="calcHMAC('hmac-sha224-med', 'ASCII', 'HEX', 'SHA-224')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha224-med-result">HMAC/SHA-224 Med Hex Result:</label><input type="text" size="65" disabled="disabled" id="hmac-sha224-med-result" />
|
||||
<span id="hmac-sha224-med-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha224-med-correct">HMAC/SHA-224 Med Correct:</label><input type="text" size="65" value="a6a3e27f8b4cfaf2bd157cc5e87c5b5d7d7f22b009fa6644fbbd3813" disabled="disabled" id="hmac-sha224-med-correct" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha224-large-text">HMAC/SHA-224 Large Hex Text:</label><input type="text" size="20" value="53616D706C65202333" id="hmac-sha224-large-text" onchange="calcHMAC('hmac-sha224-large', 'HEX', 'HEX', 'SHA-224')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha224-large-key">HMAC/SHA-224 Large Hex Key:</label><input type="text" size="100" value="505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3" id="hmac-sha224-large-key" onchange="calcHMAC('hmac-sha224-large', 'HEX', 'HEX', 'SHA-224')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha224-large-result">HMAC/SHA-224 Large Hex Result:</label><input type="text" size="45" disabled="disabled" id="hmac-sha224-large-result" />
|
||||
<span id="hmac-sha224-large-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha224-large-correct">HMAC/SHA-224 Large Correct:</label><input type="text" size="45" value="9c2919912e4453d727292cee4c678d3e105fe316f1195ef9cfafe9f0" disabled="disabled" id="hmac-sha224-large-correct" />
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>HMAC/SHA-256 Tests</legend>
|
||||
<div>
|
||||
<label for="hmac-sha256-short-text">HMAC/SHA-256 Short ASCII Text:</label><input type="text" size="10" value="Sample #2" id="hmac-sha256-short-text" onchange="calcHMAC('hmac-sha256-short', 'ASCII', 'ASCII', 'SHA-256')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha256-short-key">HMAC/SHA-256 Short Hex Key:</label><input type="text" size="25" value="0123456789:;<=>?@ABC" id="hmac-sha256-short-key" onchange="calcHMAC('hmac-sha256-short', 'ASCII', 'ASCII', 'SHA-256')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha256-short-result">HMAC/SHA-256 Short Hex Result:</label><input type="text" size="75" disabled="disabled" id="hmac-sha256-short-result" />
|
||||
<span id="hmac-sha256-short-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha256-short-correct">HMAC/SHA-256 Short Correct:</label><input type="text" size="75" value="b8f20db541ea4309ca4ea9380cd0e834f71fbe9174a261380dc17eae6a3451d9" disabled="disabled" id="hmac-sha256-short-correct" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha256-med-text">HMAC/SHA-256 Med ASCII Text:</label><input type="text" size="10" value="Sample #1" id="hmac-sha256-med-text" onchange="calcHMAC('hmac-sha256-med', 'ASCII', 'HEX', 'SHA-256')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha256-med-key">HMAC/SHA-256 Med Hex Key:</label><input type="text" size="150" value="000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f" id="hmac-sha256-med-key" onchange="calcHMAC('hmac-sha256-med', 'ASCII', 'HEX', 'SHA-256')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha256-med-result">HMAC/SHA-256 Med Hex Result:</label><input type="text" size="75" disabled="disabled" id="hmac-sha256-med-result" />
|
||||
<span id="hmac-sha256-med-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha256-med-correct">HMAC/SHA-256 Med Correct:</label><input type="text" size="75" value="3519f0cddfa090f8ace819d9ae8501578c46920502c62baa47bfe6014864a93a" disabled="disabled" id="hmac-sha256-med-correct" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha256-large-text">HMAC/SHA-256 Large Hex Text:</label><input type="text" size="20" value="53616D706C65202333" id="hmac-sha256-large-text" onchange="calcHMAC('hmac-sha256-large', 'HEX', 'HEX', 'SHA-256')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha256-large-key">HMAC/SHA-256 Large Hex Key:</label><input type="text" size="100" value="505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3" id="hmac-sha256-large-key" onchange="calcHMAC('hmac-sha256-large', 'HEX', 'HEX', 'SHA-256')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha256-large-result">HMAC/SHA-256 Large Hex Result:</label><input type="text" size="75" disabled="disabled" id="hmac-sha256-large-result" />
|
||||
<span id="hmac-sha256-large-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha256-large-correct">HMAC/SHA-256 Large Correct:</label><input type="text" size="75" value="2d7d0d7f3e52ffe89d65c978f39d555bb48b0ba48d5b6eb404654ad1afdb4ca3" disabled="disabled" id="hmac-sha256-large-correct" />
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>HMAC/SHA-384 Tests</legend>
|
||||
<div>
|
||||
<label for="hmac-sha384-short-text">HMAC/SHA-384 Short ASCII Text:</label><input type="text" size="10" value="Sample #2" id="hmac-sha384-short-text" onchange="calcHMAC('hmac-sha384-short', 'ASCII', 'ASCII', 'SHA-384')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha384-short-key">HMAC/SHA-384 Short Hex Key:</label><input type="text" size="50" value="0123456789:;<=>?@ABC0123456789:;<=>?@ABC" id="hmac-sha384-short-key" onchange="calcHMAC('hmac-sha384-short', 'ASCII', 'ASCII', 'SHA-384')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha384-short-result">HMAC/SHA-384 Short Hex Result:</label><input type="text" size="115" disabled="disabled" id="hmac-sha384-short-result" />
|
||||
<span id="hmac-sha384-short-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha384-short-correct">HMAC/SHA-384 Short Correct:</label><input type="text" size="115" value="97ab4a9c2e17af122bb32b4b1678cff917ca700a111925f455ae25348214dcbd7d163c4a4e644e401b2f87cb1b752fc5" disabled="disabled" id="hmac-sha384-short-correct" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha384-med-text">HMAC/SHA-384 Med ASCII Text:</label><input type="text" size="10" value="Sample #1" id="hmac-sha384-med-text" onchange="calcHMAC('hmac-sha384-med', 'ASCII', 'HEX', 'SHA-384')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha384-med-key">HMAC/SHA-384 Med Hex Key:</label><input type="text" size="100" value="000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f" id="hmac-sha384-med-key" onchange="calcHMAC('hmac-sha384-med', 'ASCII', 'HEX', 'SHA-384')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha384-med-result">HMAC/SHA-384 Med Hex Result:</label><input type="text" size="115" disabled="disabled" id="hmac-sha384-med-result" />
|
||||
<span id="hmac-sha384-med-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha384-med-correct">HMAC/SHA-384 Med Correct:</label><input type="text" size="115" value="bed40c524441b2e0ebe20be79b914067a57a74adb4b008d9c2f9f944c89b0fa8ce23227002aa6c1d256ee276d697332e" disabled="disabled" id="hmac-sha384-med-correct" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha384-large-text">HMAC/SHA-384 Large Hex Text:</label><input type="text" size="20" value="53616D706C65202333" id="hmac-sha384-large-text" onchange="calcHMAC('hmac-sha384-large', 'HEX', 'HEX', 'SHA-384')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha384-large-key">HMAC/SHA-384 Large Hex Key:</label><input type="text" size="100" value="505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3" id="hmac-sha384-large-key" onchange="calcHMAC('hmac-sha384-large', 'HEX', 'HEX', 'SHA-384')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha384-large-result">HMAC/SHA-384 Large Hex Result:</label><input type="text" size="115" disabled="disabled" id="hmac-sha384-large-result" />
|
||||
<span id="hmac-sha384-large-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha384-large-correct">HMAC/SHA-384 Large Correct:</label><input type="text" size="115" value="96b8cfd4340494cd12bd2e4d5df413b5585020d6fa078659cdf938c35e3fcdee84af95e8e598481dc5f064126d561c31" disabled="disabled" id="hmac-sha384-large-correct" />
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>HMAC/SHA-512 Tests</legend>
|
||||
<div>
|
||||
<label for="hmac-sha512-short-text">HMAC/SHA-512 Short ASCII Text:</label><input type="text" size="10" value="Sample #2" id="hmac-sha512-short-text" onchange="calcHMAC('hmac-sha512-short', 'ASCII', 'ASCII', 'SHA-512')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha512-short-key">HMAC/SHA-512 Short Hex Key:</label><input type="text" size="50" value="0123456789:;<=>?@ABC0123456789:;<=>?@ABC" id="hmac-sha512-short-key" onchange="calcHMAC('hmac-sha512-short', 'ASCII', 'ASCII', 'SHA-512')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha512-short-result">HMAC/SHA-512 Short Hex Result:</label><input type="text" size="150" disabled="disabled" id="hmac-sha512-short-result" />
|
||||
<span id="hmac-sha512-short-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha512-short-correct">HMAC/SHA-512 Short Correct:</label><input type="text" size="150" value="74ed1131b8e37c0e18829b7ae7d99925664cfe055c2d01fa00d0f152ac321a50f3ef1ee91a36fd6248de60ede4196a4f9e5acca4981a09a91a0745d674ca11d3" disabled="disabled" id="hmac-sha512-short-correct" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha512-med-text">HMAC/SHA-512 Med ASCII Text:</label><input type="text" size="10" value="Sample #1" id="hmac-sha512-med-text" onchange="calcHMAC('hmac-sha512-med', 'ASCII', 'HEX', 'SHA-512')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha512-med-key">HMAC/SHA-512 Med Hex Key:</label><input type="text" size="100" value="000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f" id="hmac-sha512-med-key" onchange="calcHMAC('hmac-sha512-med', 'ASCII', 'HEX', 'SHA-512')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha512-med-result">HMAC/SHA-512 Med Hex Result:</label><input type="text" size="150" disabled="disabled" id="hmac-sha512-med-result" />
|
||||
<span id="hmac-sha512-med-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha512-med-correct">HMAC/SHA-512 Med Correct:</label><input type="text" size="150" value="e3c46b747b407ae103d75d94cc2247d6fef607a019e9dca6a1183966a163eb19317e7642da27b6e6ed22fea8224c493d5f20a458f83a555b94264253ddceb242" disabled="disabled" id="hmac-sha512-med-correct" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha512-large-text">HMAC/SHA-512 Large Hex Text:</label><input type="text" size="20" value="53616D706C65202333" id="hmac-sha512-large-text" onchange="calcHMAC('hmac-sha512-large', 'HEX', 'HEX', 'SHA-512')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha512-large-key">HMAC/SHA-512 Large Hex Key:</label><input type="text" size="100" value="505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3" id="hmac-sha512-large-key" onchange="calcHMAC('hmac-sha512-large', 'HEX', 'HEX', 'SHA-512')" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha512-large-result">HMAC/SHA-512 Large Hex Result:</label><input type="text" size="150" disabled="disabled" id="hmac-sha512-large-result" />
|
||||
<span id="hmac-sha512-large-comp"></span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="hmac-sha512-large-correct">HMAC/SHA-512 Large Correct:</label><input type="text" size="150" value="a2a8627f166e8c52d95fbf5c55271d466d43b73696e94977d08262f021d9a916f9d10f09f40db64e038c2ed3b16fbb9e61082c9173acfa86445612ccd4d8836c" disabled="disabled" id="hmac-sha512-large-correct" />
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
<html>
|
||||
<head>
|
||||
<script type='text/javascript' src='jsSHA/src/sha1.js'></script>
|
||||
<script type='text/javascript' src='passy.js'></script>
|
||||
<script type='text/javascript'>
|
||||
function UpdatePassy()
|
||||
{
|
||||
var site = document.getElementById('site').value;
|
||||
var password = document.getElementById('password').value;
|
||||
document.getElementById('result').value = passy(site,password)[0];
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<form>
|
||||
Site Name:<br/>
|
||||
<input type='text' id='site' onkeydown='UpdatePassy()' onkeyup='UpdatePassy()' onchange='UpdatePassy()'><br/>
|
||||
Secret Passphrase:<br/>
|
||||
<input type='password' id='password' onkeydown='UpdatePassy()' onkeyup='UpdatePassy()' onchange='UpdatePassy()'><br/>
|
||||
<hr/>
|
||||
Site Password:<br/>
|
||||
<input type='text' id='result' readonly onfocus='this.select()' onclick='this.select()' ondblclick='this.select()'>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Given a "text" (i.e. "amazon.com") and a "secret" (i.e. "mypassword") return an
|
||||
* array of four Passy'fied passwords.
|
||||
*/
|
||||
var passy = function(text,secret)
|
||||
{
|
||||
/*
|
||||
* function to make a password out of a hexadecimal string "0123456789abcdef".
|
||||
*
|
||||
* + substitutes symbols for every other digit [0-9]
|
||||
* + capitalize every other alpha [a-f]
|
||||
*
|
||||
*/
|
||||
var passify = function(hexstr)
|
||||
{
|
||||
// lookup table to convert a single character to a symbol
|
||||
var symtab = { "1":"!", "2":"@", "3":"#", "4":"$", "5":"%", "6":"^", "7":"&", "8":"*", "9":"(", "0":")" };
|
||||
|
||||
// convert every other numerical character to a symbol
|
||||
var odd = true;
|
||||
for(i=0;i<hexstr.length;++i)
|
||||
{
|
||||
// is this a digit-character?
|
||||
if ( /[0-9]/.test(hexstr[i]) )
|
||||
{
|
||||
if ( odd )
|
||||
{
|
||||
// substitute symbol for odd digit-characters, leave even digit-characters alone!
|
||||
hexstr = hexstr.slice(0,i) + symtab[hexstr[i]] + hexstr.slice(i+1,hexstr.length);
|
||||
}
|
||||
|
||||
// flip odd toggle
|
||||
odd = !odd;
|
||||
}
|
||||
}
|
||||
|
||||
// alternate uppercase/lowercase for alpha characters
|
||||
odd = true;
|
||||
for(i=0;i<hexstr.length;++i)
|
||||
{
|
||||
// is this an alpha-character?
|
||||
if ( /[a-f]/i.test(hexstr[i]) )
|
||||
{
|
||||
// set odd alpha-characters to uppercase, and even alpha-characters to lowercase
|
||||
hexstr =
|
||||
hexstr.slice(0,i) +
|
||||
( odd ? hexstr[i].toUpperCase() : hexstr[i].toLowerCase()) +
|
||||
hexstr.slice(i+1,hexstr.length);
|
||||
|
||||
// flip odd toggle
|
||||
odd = !odd;
|
||||
}
|
||||
}
|
||||
|
||||
// finished
|
||||
return hexstr;
|
||||
}
|
||||
|
||||
// get hmac
|
||||
var hmac = new jsSHA(text.toLowerCase(), "ASCII").getHMAC(secret, "ASCII", "HEX");
|
||||
|
||||
// split into four 10 character strings and "passify", and return the array
|
||||
return [
|
||||
passify(hmac.slice( 0,10)),
|
||||
passify(hmac.slice(10,20)),
|
||||
passify(hmac.slice(20,30)),
|
||||
passify(hmac.slice(30,40))];
|
||||
}
|
||||
Reference in new issue
Block a user