|
Science Forum Index » Cryptography Forum » Streambuddy unbreakable? You bet ;) Happy new year
Page 1 of 2 Goto page 1, 2 Next
|
| Author |
Message |
| JT |
Posted: Mon Dec 29, 2003 5:23 am |
|
|
|
Guest
|
<SCRIPT LANGUAGE="Javascript">
/*STREAMBUDDY
Nice variable stream cipher (1-256 byte key)
Salt+key then expansion to internal state of 2048 bit.
The permutation PRNG generates a perfect random stream
PRNGstream then xored upon text
Written 29/12 2003 by JT run in browser *have fun*
*/
/*PRNG*/
function streambuddy(key,tlength){
mixpad=new Array;permpad= new Array();permpad2= new Array();streaming=new Array();
streamout=new Array();permpad=key;j=0;infinit=true;q=0;
//Copy array
for(i=0;i<256;i++){
permpad2[i]=permpad[i];
}
permpad2.reverse();
while (q<tlength){
for (i=0;i<256;i++){
//First array
slot=permpad[i+1];
slot2=permpad[slot];
permpad[slot]=permpad[i];
permpad[i]=slot2;
//Second array
slot3=permpad2[i+1];
slot4=permpad2[slot3];
permpad2[slot3]=permpad2[i];
permpad2[i]=slot4;
}
for (i=0;i<256;i++){
//Mix Array
mixpad[i]=permpad[i]^permpad2[i];
//A new mixpad is used upon the PRNG stream every block
streaming[i]^=mixpad[i];
streamout[q++]=streaming[i];
}
}
return streamout;
}
/*KEYXP*/
function keyxp(arr,klength){
//Expansion
serie= new Array;
j=0;
for (i=0;i<256;i++) {
stop="no";
while (stop=="no"){
found="false";
for(k=0;k<i;k++){if (arr[j]==serie[k]){found="true";}}
if (found=="false")
{ serie[i]=arr[j];stop="yes";}
else {arr[j]=+arr[j]+1;}
if(arr[j]>255){arr[j]=0;}
}
j++;
if (j>klength-1)j=0;
}
//A shuffle to better mix the kongruential expanded values
for (k=0;k<42;k++) {
for (i=0;i<255;i++){
//First array
slot=serie[i+1];
slot2=serie[slot];
serie[slot]=serie[i];
serie[i]=slot2;
}
}
return serie;
}
/*SALT 32-bit*/
function salt(){
saltv=new Array();
for (i=0;i<4;i++){
saltv[i]=Math.round(255*Math.random());
}
document.cipher.saltf.value=saltv;
return saltv;
}
/*MAIN ENCODE*/
function encrypt(){
key = document.cipher.keyf.value;
text = document.cipher.textf.value;
textarr= new Array();
keyarr= new Array();
klength=key.length;
tlength=text.length;
//Keysalt 32-bit
salt(); //return saltv
for(i=0;i<4;i++){
keyarr[i]=saltv[i];
}
for(i=0;i<key.length;i++){
keyarr[i+4]=key.charCodeAt(i);
}
//Keyexpansion phase
//document.write(keyarr);
keyxp(keyarr,klength);//return serie
//Streamcreation phase
streambuddy(serie,tlength);//return streamout
for(i=0;i<text.length;i++){
textarr[i]=text.charCodeAt(i);
}
//Encoding phase
for(i=0;i<text.length;i++){
textarr[i]^=streamout[i];
}
document.cipher.cipherf.value=saltv+","+textarr;
}
/*MAIN DECODE*/
function decrypt(){
text = document.cipher.textf.value;
tlength=text.length;
todecipher=document.cipher.cipherf.value;
cipherarr=todecipher.split(",");
saltv = document.cipher.saltf.value;
keyarr=saltv.split(",");
key = document.cipher.keyf.value;
for(i=0;i<key.length;i++){
keyarr[i+4]=key.charCodeAt(i);
}
//document.write(keyarr);
klength=key.length;
keyxp(keyarr,klength);//return serie
streambuddy(serie,tlength);//return streamout
for(i=0;i<text.length;i++){
cipherarr[i+4]^=streamout[i];
}
document.decipher.decipherf.value=cipherarr;
}
</SCRIPT>
<HTML><BODY>
<FORM NAME=cipher onSubmit="encrypt(); return false;">
<input type=submit value="ENC"><BR>
KEY:<BR>
<TEXTAREA NAME="keyf" COLS=80></TEXTAREA><BR>
TEXT:<BR>
<TEXTAREA NAME="textf" COLS=80></TEXTAREA><BR>
GENERATED SALT:<BR>
<TEXTAREA NAME="saltf" COLS=80></TEXTAREA><BR>
ENCRYPTED:<BR>
<TEXTAREA NAME="cipherf" COLS=80></TEXTAREA><BR>
</FORM>
<FORM NAME=decipher onSubmit="decrypt(); return false;">
<input type=submit value="DEC"><BR>
DECRYPTED:<BR>
<TEXTAREA NAME="decipherf" COLS=80></TEXTAREA><BR>
</FORM>
</BODY></HTML> |
|
|
| Back to top |
|
| JT |
Posted: Mon Dec 29, 2003 4:10 pm |
|
|
|
Guest
|
Ooops did forget to add salt to keylength at expansion time 4 keybytes
lost never to be found again.
Correction:->klength=key.length+4; |
|
|
| Back to top |
|
| Simon G Best |
Posted: Wed Dec 31, 2003 2:46 pm |
|
|
|
Guest
|
JT wrote:
Quote:
The permutation PRNG generates a perfect random stream
No.
The 'P' in 'PRNG' stands for 'pseudo'.
Simon |
|
|
| Back to top |
|
| Simon G Best |
Posted: Wed Dec 31, 2003 2:46 pm |
|
|
|
Guest
|
JT wrote:
Quote:
The permutation PRNG generates a perfect random stream
No.
The 'P' in 'PRNG' stands for 'pseudo'.
Simon |
|
|
| Back to top |
|
| JT |
Posted: Thu Jan 01, 2004 1:00 am |
|
|
|
Guest
|
Simon G Best <s.g.best@btopenworld.com> wrote in message news:<3FF36FAA.5030406@btopenworld.com>...
Quote: No.
The 'P' in 'PRNG' stands for 'pseudo'.
Simon
You are right it is a perfect fake random stream nonedistinguishable
from a perfect random stream.
I can send you a real random stream 1MB stream, and
a 1MB perfect bluff random stream then you tell which stream real
random and which is fake.
JT |
|
|
| Back to top |
|
| Tom St Denis |
Posted: Thu Jan 01, 2004 1:05 am |
|
|
|
Guest
|
"JT" <jt64@bredband.net> wrote in message
news:2ecfd00b.0312312200.472f972d@posting.google.com...
Quote: Simon G Best <s.g.best@btopenworld.com> wrote in message
news:<3FF36FAA.5030406@btopenworld.com>...
No.
The 'P' in 'PRNG' stands for 'pseudo'.
Simon
You are right it is a perfect fake random stream nonedistinguishable
from a perfect random stream.
I can send you a real random stream 1MB stream, and
a 1MB perfect bluff random stream then you tell which stream real
random and which is fake.
Um, even the best PRNG algo will fail when it's period expires.
Tom |
|
|
| Back to top |
|
| Tom St Denis |
Posted: Thu Jan 01, 2004 1:05 am |
|
|
|
Guest
|
"JT" <jt64@bredband.net> wrote in message
news:2ecfd00b.0312312200.472f972d@posting.google.com...
Quote: Simon G Best <s.g.best@btopenworld.com> wrote in message
news:<3FF36FAA.5030406@btopenworld.com>...
No.
The 'P' in 'PRNG' stands for 'pseudo'.
Simon
You are right it is a perfect fake random stream nonedistinguishable
from a perfect random stream.
I can send you a real random stream 1MB stream, and
a 1MB perfect bluff random stream then you tell which stream real
random and which is fake.
Um, even the best PRNG algo will fail when it's period expires.
Tom |
|
|
| Back to top |
|
| Sir Spamsalot |
Posted: Thu Jan 01, 2004 9:06 am |
|
|
|
Guest
|
On 31 Dec 2003, jt64@bredband.net (JT) wrote:
Quote: You are right it is a perfect fake random stream nonedistinguishable
from a perfect random stream.
I can send you a real random stream 1MB stream, and
a 1MB perfect bluff random stream then you tell which stream real
random and which is fake.
In practice? Probably not with any reliability, but it *will* happen.
In theory? Of course.  |
|
|
| Back to top |
|
| Sir Spamsalot |
Posted: Thu Jan 01, 2004 9:06 am |
|
|
|
Guest
|
On 31 Dec 2003, jt64@bredband.net (JT) wrote:
Quote: You are right it is a perfect fake random stream nonedistinguishable
from a perfect random stream.
I can send you a real random stream 1MB stream, and
a 1MB perfect bluff random stream then you tell which stream real
random and which is fake.
In practice? Probably not with any reliability, but it *will* happen.
In theory? Of course.  |
|
|
| Back to top |
|
| JT |
Posted: Thu Jan 01, 2004 10:23 am |
|
|
|
Guest
|
Quote: Um, even the best PRNG algo will fail when it's period expires.
Tom
Well the period of this pring is somewhere in the range ~250!->256!
since there a neglieable amount of lockup states and none of them will
ever happen with my keyexpasion scheme. I dare you to show one how a
state that lead to a lockup would look like (not the lockup itself).
So i do not really worry about neither lockups or that the period
expire, our solar system will be long gone before any of todays
computers will come to the end of the prng period.
Maybe you should build a two deck,256 card xor mixed shuffle
codebookTom ... Just make shure you have plenty of space on your
harddrive hehehee
There is somewhere nearby 255! * 255! possible outcome blocks so you
better start right now.
Cheers |
|
|
| Back to top |
|
| JT |
Posted: Thu Jan 01, 2004 10:23 am |
|
|
|
Guest
|
Quote: Um, even the best PRNG algo will fail when it's period expires.
Tom
Well the period of this pring is somewhere in the range ~250!->256!
since there a neglieable amount of lockup states and none of them will
ever happen with my keyexpasion scheme. I dare you to show one how a
state that lead to a lockup would look like (not the lockup itself).
So i do not really worry about neither lockups or that the period
expire, our solar system will be long gone before any of todays
computers will come to the end of the prng period.
Maybe you should build a two deck,256 card xor mixed shuffle
codebookTom ... Just make shure you have plenty of space on your
harddrive hehehee
There is somewhere nearby 255! * 255! possible outcome blocks so you
better start right now.
Cheers |
|
|
| Back to top |
|
| Tom St Denis |
Posted: Thu Jan 01, 2004 10:26 am |
|
|
|
Guest
|
"JT" <jt64@bredband.net> wrote in message
news:2ecfd00b.0401010723.422a733b@posting.google.com...
Quote: Um, even the best PRNG algo will fail when it's period expires.
Tom
Well the period of this pring is somewhere in the range ~250!->256!
since there a neglieable amount of lockup states and none of them will
ever happen with my keyexpasion scheme. I dare you to show one how a
state that lead to a lockup would look like (not the lockup itself).
That isn't what I said and you know it.
However, it's your algo. I challenge you to prove it doesn't fall into any
weak keys.
Tom |
|
|
| Back to top |
|
| Tom St Denis |
Posted: Thu Jan 01, 2004 10:26 am |
|
|
|
Guest
|
"JT" <jt64@bredband.net> wrote in message
news:2ecfd00b.0401010723.422a733b@posting.google.com...
Quote: Um, even the best PRNG algo will fail when it's period expires.
Tom
Well the period of this pring is somewhere in the range ~250!->256!
since there a neglieable amount of lockup states and none of them will
ever happen with my keyexpasion scheme. I dare you to show one how a
state that lead to a lockup would look like (not the lockup itself).
That isn't what I said and you know it.
However, it's your algo. I challenge you to prove it doesn't fall into any
weak keys.
Tom |
|
|
| Back to top |
|
| Simon G Best |
Posted: Thu Jan 01, 2004 1:33 pm |
|
|
|
Guest
|
JT wrote:
Quote: Simon G Best <s.g.best@btopenworld.com> wrote in message news:<3FF36FAA.5030406@btopenworld.com>...
No.
The 'P' in 'PRNG' stands for 'pseudo'.
Simon
You are right it is a perfect fake random stream nonedistinguishable
from a perfect random stream.
Your use of the word 'perfect' was therefore imperfect. Tom St Denis
has already refuted your indistinguishability claim.
Quote: I can send you a real random stream 1MB stream, and
a 1MB perfect bluff random stream then you tell which stream real
random and which is fake.
JT
That would be a matter of practicality, not perfection. Besides, what
reason do we have to spend time and effort trying to distinguish your
PRNGs streams from truly random streams?
Simon |
|
|
| Back to top |
|
| Simon G Best |
Posted: Thu Jan 01, 2004 1:33 pm |
|
|
|
Guest
|
JT wrote:
Quote: Simon G Best <s.g.best@btopenworld.com> wrote in message news:<3FF36FAA.5030406@btopenworld.com>...
No.
The 'P' in 'PRNG' stands for 'pseudo'.
Simon
You are right it is a perfect fake random stream nonedistinguishable
from a perfect random stream.
Your use of the word 'perfect' was therefore imperfect. Tom St Denis
has already refuted your indistinguishability claim.
Quote: I can send you a real random stream 1MB stream, and
a 1MB perfect bluff random stream then you tell which stream real
random and which is fake.
JT
That would be a matter of practicality, not perfection. Besides, what
reason do we have to spend time and effort trying to distinguish your
PRNGs streams from truly random streams?
Simon |
|
|
| Back to top |
|
| |