convert "passification" method to now substitute from a set of 32 characters, providing a true 6 bits of entropy per character
This commit is contained in:
1 parent
1ceed3af41
commit
2e7d71b7dd
3 files changed
+32
-49
No files matched your search
+6
-2
@@ -3,7 +3,11 @@
|
|||||||
<head>
|
<head>
|
||||||
|
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
var u=function(){function t(a){var d=[];do{d.unshift(a&255);a>>=8}while(a);return d}function s(a){var d=[],b,c=a.length;for(b=0;b<c;b++)d=d.concat(t(a.charCodeAt(b)));return d}function o(a){a=a.slice();var d=a.length*8,b=1732584193,c=4023233417,j=2562383102,g=271733878,h=3285377520,e,i,f,k,q,m,r,n,p;for(a.push(128);(a.length+8)%64;)a.push(0);a=a.concat([(d&1.8374686479671624E19)>>>56,(d&71776119061217280)>>>48,(d&280375465082880)>>>40,(d&1095216660480)>>>32,(d&4278190080)>>>24,(d&16711680)>>>16,(d& 65280)>>>8,d&255]);for(d=0;d<a.length/64;d++){e=a.slice(d*64,d*64+64);i=[];f=void 0;k=e.length;for(f=0;f<k;f+=4)i.push(e[f]<<24|e[f+1]<<16|e[f+2]<<8|e[f+3]);n=i;e=b;i=c;f=j;k=g;q=h;for(p=0;p<80;p++){m=p&15;if(p>=16){r=n[m+13&15]^n[m+8&15]^n[m+2&15]^n[m];n[m]=r<<1|r>>>31}r=p<20?(e<<5|e>>>27)+(k^i&(f^k))+q+1518500249+n[m]&4294967295:p<40?(e<<5|e>>>27)+(i^f^k)+q+1859775393+n[m]&4294967295:p<60?(e<<5|e>>>27)+(i&f|i&k|f&k)+q+2400959708+n[m]&4294967295:(e<<5|e>>>27)+(i^f^k)+q+3395469782+n[m]&4294967295; q=k;k=f;f=i<<30|i>>>2;i=e;e=r}b=b+e&4294967295;c=c+i&4294967295;j=j+f&4294967295;g=g+k&4294967295;h=h+q&4294967295}return[b>>>24&255,b>>>16&255,b>>>8&255,b&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,j>>>24&255,j>>>16&255,j>>>8&255,j&255,g>>>24&255,g>>>16&255,g>>>8&255,g&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255]}var l=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];return{a:function(a,d){var b=s(a),c=s(d),j=Array(64),g=Array(64),h;if(b.length>64)b=o(b);for(;b.length<64;)b.push(0); for(h=0;h<64;h++){j[h]=92^b[h];g[h]=54^b[h]}b=o(j.concat(o(g.concat(c))));c="";j=b.length;for(g=0;g<j;g++)c+=l[b[g]>>>4]+l[b[g]&15];return c}}}(); window.passy=function(t,s){function o(a){var d={"1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")"},b=true,c;for(c=0;c<a.length;++c)if(/[0-9]/.test(a[c])){if(b)a=a.slice(0,c)+d[a[c]]+a.slice(c+1,a.length);b=!b}b=true;for(c=0;c<a.length;++c)if(/[a-f]/i.test(a[c])){a=a.slice(0,c)+(b?a[c].toUpperCase():a[c].toLowerCase())+a.slice(c+1,a.length);b=!b}return a}var l=u.a(s,t);return[o(l.slice(0,10)),o(l.slice(10,20)),o(l.slice(20,30)),o(l.slice(30,40)),l.slice(0,10),l.slice(10, 20),l.slice(20,30),l.slice(30,40)]};
|
var u=function(){function t(c){var b=[];do{b.unshift(c&255);c>>=8}while(c);return b}function s(c){var b=[],a,d=c.length;for(a=0;a<d;a++)b=b.concat(t(c.charCodeAt(a)));return b}function p(c){c=c.slice();var b=c.length*8,a=1732584193,d=4023233417,g=2562383102,h=271733878,i=3285377520,e,j,f,k,o,l,r,m,n;for(c.push(128);(c.length+8)%64;)c.push(0);c=c.concat([(b&1.8374686479671624E19)>>>56,(b&71776119061217280)>>>48,(b&280375465082880)>>>40,(b&1095216660480)>>>32,(b&4278190080)>>>24,(b&16711680)>>>16,(b&
|
||||||
|
65280)>>>8,b&255]);for(b=0;b<c.length/64;b++){e=c.slice(b*64,b*64+64);j=[];f=void 0;k=e.length;for(f=0;f<k;f+=4)j.push(e[f]<<24|e[f+1]<<16|e[f+2]<<8|e[f+3]);m=j;e=a;j=d;f=g;k=h;o=i;for(n=0;n<80;n++){l=n&15;if(n>=16){r=m[l+13&15]^m[l+8&15]^m[l+2&15]^m[l];m[l]=r<<1|r>>>31}r=n<20?(e<<5|e>>>27)+(k^j&(f^k))+o+1518500249+m[l]&4294967295:n<40?(e<<5|e>>>27)+(j^f^k)+o+1859775393+m[l]&4294967295:n<60?(e<<5|e>>>27)+(j&f|j&k|f&k)+o+2400959708+m[l]&4294967295:(e<<5|e>>>27)+(j^f^k)+o+3395469782+m[l]&4294967295;
|
||||||
|
o=k;k=f;f=j<<30|j>>>2;j=e;e=r}a=a+e&4294967295;d=d+j&4294967295;g=g+f&4294967295;h=h+k&4294967295;i=i+o&4294967295}return[a>>>24&255,a>>>16&255,a>>>8&255,a&255,d>>>24&255,d>>>16&255,d>>>8&255,d&255,g>>>24&255,g>>>16&255,g>>>8&255,g&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255,i>>>24&255,i>>>16&255,i>>>8&255,i&255]}var q=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];return{g:function(c,b){var a=s(c),d=s(b),g=Array(64),h=Array(64),i;if(a.length>64)a=p(a);for(;a.length<64;)a.push(0);
|
||||||
|
for(i=0;i<64;i++){g[i]=92^a[i];h[i]=54^a[i]}a=p(g.concat(p(h.concat(d))));d="";g=a.length;for(h=0;h<g;h++)d+=q[a[h]>>>4]+q[a[h]&15];return d}}}();
|
||||||
|
window.passy=function(t,s){var p=u.g(s,t).toLowerCase();return[function(q){var c=["A","B","C","D","E","F","G","H","a","b","c","d","e","f","g","h","2","3","4","5","6","7","8","9","#","$","%","*","+","=","@","?"],b={"0":0,"1":1,"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,a:10,b:11,c:12,d:13,e:14,f:15},a="",d,g;for(d=0;d<q.length/2;++d){g=b[q[d*2]]*16+b[q[d*2+1]];a+=c[g%c.length]}return a}(p.slice(0,24)),p.slice(0,10)]};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
@@ -35,7 +39,7 @@ var u=function(){function t(a){var d=[];do{d.unshift(a&255);a>>=8}while(a);retur
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
document.getElementById('result').value = passy(site,password)[0];
|
document.getElementById('result').value = passy(site,password)[0];
|
||||||
document.getElementById('result_old').value = passy(site,password)[4];
|
document.getElementById('result_old').value = passy(site,password)[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// set timer to clear password field after a minute
|
// set timer to clear password field after a minute
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
document.getElementById('result').value = passy(site,password)[0];
|
document.getElementById('result').value = passy(site,password)[0];
|
||||||
document.getElementById('result_old').value = passy(site,password)[4];
|
document.getElementById('result_old').value = passy(site,password)[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// set timer to clear password field after a minute
|
// set timer to clear password field after a minute
|
||||||
|
|||||||
@@ -35,70 +35,49 @@ var passy = function(text,secret)
|
|||||||
/*
|
/*
|
||||||
* function to make a password out of a hexadecimal string "0123456789abcdef".
|
* function to make a password out of a hexadecimal string "0123456789abcdef".
|
||||||
*
|
*
|
||||||
* + substitutes symbols for every other digit [0-9]
|
* + substitutes one of 32 symbols for every two hex digits (octet)
|
||||||
* + capitalize every other alpha [a-f]
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
var passify = function(hexstr)
|
var passify = function(hexstr)
|
||||||
{
|
{
|
||||||
var
|
var
|
||||||
// lookup table to convert a single character to a symbol
|
// lookup table to convert a single character to a symbol
|
||||||
symtab = { "1":"!", "2":"@", "3":"#", "4":"$", "5":"%", "6":"^", "7":"&", "8":"*", "9":"(", "0":")" },
|
symtab = [
|
||||||
|
"A", "B", "C", "D", "E", "F", "G", "H",
|
||||||
|
"a", "b", "c", "d", "e", "f", "g", "h",
|
||||||
|
"2", "3", "4", "5", "6", "7", "8", "9",
|
||||||
|
"#", "$", "%", "*", "+", "=", "@", "?",
|
||||||
|
],
|
||||||
|
|
||||||
|
// lookup table to convert a single hex character to its decimal equivalent
|
||||||
|
hex2int = {
|
||||||
|
"0":0, "1":1, "2":2, "3":3, "4":4, "5":5, "6":6, "7":7,
|
||||||
|
"8":8, "9":9, "a":10, "b":11, "c":12, "d":13, "e":14, "f":15
|
||||||
|
},
|
||||||
|
|
||||||
|
// our result
|
||||||
|
result = "",
|
||||||
|
|
||||||
// misc
|
// misc
|
||||||
odd = true, i;
|
i, octet;
|
||||||
|
|
||||||
// convert every other numerical character to a symbol
|
// convert each octet in the hex string to one of our symbols
|
||||||
for(i=0;i<hexstr.length;++i)
|
for(i=0;i<hexstr.length/2;++i)
|
||||||
{
|
{
|
||||||
// is this a digit-character?
|
octet = hex2int[hexstr[i*2]]*16 + hex2int[hexstr[i*2+1]];
|
||||||
if ( /[0-9]/.test(hexstr[i]) )
|
result = result + symtab[ octet % symtab.length ];
|
||||||
{
|
|
||||||
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
|
// finished
|
||||||
return hexstr;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// get hmac
|
// get hmac
|
||||||
var hmac = SHA1.hmac(secret,text);
|
var hmac = (SHA1.hmac(secret,text)).toLowerCase();
|
||||||
|
|
||||||
// split into four 10 character strings and "passify", and return the array
|
// split into four 10 character strings and "passify", and return the array
|
||||||
// include the unpassified versions afterward
|
// include the unpassified versions afterward
|
||||||
return [
|
return [
|
||||||
passify(hmac.slice( 0,10)),
|
passify(hmac.slice( 0,24)),
|
||||||
passify(hmac.slice(10,20)),
|
hmac.slice( 0,10) ];
|
||||||
passify(hmac.slice(20,30)),
|
|
||||||
passify(hmac.slice(30,40)),
|
|
||||||
hmac.slice( 0,10),
|
|
||||||
hmac.slice(10,20),
|
|
||||||
hmac.slice(20,30),
|
|
||||||
hmac.slice(30,40)];
|
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user