Quirk in Konqueror 5 core JS ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Billam

    Quirk in Konqueror 5 core JS ?

    Greetings. This problem arises in the context of the CPAN module
    Crypt::Tea ... It works with IE, Mozilla, Netscape, Firefox, IE
    and Opera, but if you check out http://www.pjb.com.au/comp/test.html
    using Konqueror 5.0 (at least on linux) you will find:

    tea_code((20482 99521,595110280 ),
    (-764348263,55490 5533,637549562,-283747546))
    returns 1614127572, 339082849,
    should be -451692928, 1589210186,

    tea_decode((204 8299521,5951102 80),
    (-764348263,55490 5533,637549562,-283747546))
    returns 2022045126, -1848224228,
    should be -257148566, -1681954940,

    :-( Now these two functions are quite short, similar and simple:

    function tea_code (v, k) {
    // TEA. 2-int (64-bit) cyphertext block in v. 4-int (128-bit) key in k.
    var v0 = v[0]; var v1 = v[1];
    var k0 = k[0]; var k1 = k[1]; var k2 = k[2]; var k3 = k[3];
    var sum = 0; var n = 32;
    while (n-- > 0) {
    sum -= 1640531527; // TEA magic number 0x9e3779b9
    sum = sum|0; // force it back to 32-bit int
    v0 += ((v1<<4)+k0) ^ (v1+sum) ^ ((v1>>>5)+k1) ;
    v1 += ((v0<<4)+k2) ^ (v0+sum) ^ ((v0>>>5)+k3) ;
    }
    var w = new Array(); w[0] = v0|0; w[1] = v1|0; return w;
    }
    function tea_decode (v, k) {
    // TEA. 2-int (64-bit) cyphertext block in v. 4-int (128-bit) key in k.
    var v0 = v[0]; var v1 = v[1];
    var k0 = k[0]; var k1 = k[1]; var k2 = k[2]; var k3 = k[3];
    var sum = 0; var n = 32;
    sum = -957401312 ; // TEA magic number 0x9e3779b9<<5
    while (n-- > 0) {
    v1 -= ((v0<<4)+k2) ^ (v0+sum) ^ ((v0>>>5)+k3) ;
    v0 -= ((v1<<4)+k0) ^ (v1+sum) ^ ((v1>>>5)+k1) ;
    sum += 1640531527; // TEA magic number 0x9e3779b9 ;
    sum = sum|0; // force it back to 32-bit int
    }
    var w = new Array(); w[0] = v0|0; w[1] = v1|0; return w;
    }

    Is there perhaps some known quirk in Konqueror's handling
    of core operators like << >>> | or ^ ?

    Regards, Peter

    --

    Peter Billam, DPIWE/ILS/CIT/Servers, hbt/lnd/l8, 6233 3061
  • Peter Billam

    #2
    Re: Quirk in Konqueror 5 core JS ?

    In article <slrncmbfh2.31p .peter@pjb.dpiw e.tas.gov.au>, Peter Billam wrote:[color=blue]
    > Greetings. This problem arises in the context of the CPAN module
    > Crypt::Tea ... It works with IE, Mozilla, Netscape, Firefox, IE
    > and Opera, but if you check out http://www.pjb.com.au/comp/test.html
    > using Konqueror 5.0 (at least on linux) you will find:
    > ...
    > Is there perhaps some known quirk in Konqueror's handling
    > of core operators like << >>> | or ^ ?
    >[/color]
    The only difference I've been able to find is revealed by

    document.write( 'First, x = 16405315271<BR> x&gt;&gt;&gt; 5 = ');
    var x = 16405315271;
    document.write( x>>>5);
    document.write( '<BR>x&gt;&gt; 5 = ');
    document.write( x>>5);
    document.write( '<BR>Second, x = 0 | 16405315271<BR> x&gt;&gt;&gt; 5 = ');
    x = 0 | 16405315271;
    document.write( x>>>5);
    document.write( '<BR>x&gt;&gt; 5 = ');
    document.write( x>>5);

    which in Firefox gives
    First, x = 16405315271 (more than 32 bits!)
    x>>>5 = 110012918 <----------
    x>>5 = -24204810
    Second, x = 0 | 16405315271
    x>>>5 = 110012918
    x>>5 = -24204810

    but on Konqueror gives
    First, x = 16405315271
    x>>>5 = 67108864 <----------
    x>>5 = -24204810
    Second, x = 0 | 16405315271
    x>>>5 = 110012918
    x>>5 = -24204810

    Is this difference responsible for my problem ? If so, if anybody
    has any idea how to tweak functions tea_code and tea_decode so as to
    make Konqueror behave like the others, I'd be very happy to hear it ...

    Regards, Peter

    --

    Peter Billam, DPIWE/ILS/CIT/Servers, hbt/lnd/l8, 6233 3061

    Comment

    Working...