[LON-CAPA-cvs] cvs: loncom /auth londes.js

www lon-capa-cvs@mail.lon-capa.org
Sat, 23 Mar 2002 11:59:22 -0000


www		Sat Mar 23 06:59:22 2002 EDT

  Modified files:              
    /loncom/auth	londes.js 
  Log:
  All bitwise functions except '^' already separated out, has self test.
  
  
Index: loncom/auth/londes.js
diff -u loncom/auth/londes.js:1.4 loncom/auth/londes.js:1.5
--- loncom/auth/londes.js:1.4	Sat Mar 23 06:27:41 2002
+++ loncom/auth/londes.js	Sat Mar 23 06:59:22 2002
@@ -3,7 +3,7 @@
 // Encryption Routines according to Data Encryption Standard DES
 // Federal Information Processing Standards Publication 46-2 (1993 Dec 30)
 //
-// $Id: londes.js,v 1.4 2002/03/23 11:27:41 www Exp $
+// $Id: londes.js,v 1.5 2002/03/23 11:59:22 www Exp $
 //
 // Copyright Michigan State University Board of Trustees
 //
@@ -75,10 +75,16 @@
    return value&bit[i];
 }
 
+// General OR function
+
+function orvalue(a,b) {
+   return a|b;
+}
+
 // Function to OR with bit i
 
 function orbit(value,i) {
-   return value|bit[i];
+   return orvalue(value,bit[i]);
 }
 
 // Initialize table arrays and perform self test
@@ -148,7 +154,7 @@
 // C.H. Meyer, S.M. Matyas, John Wiley and Sons, 1982, pg. 160
 
      uextkey=0x1234567;
-     lextkey=bit[31]|0x9abcdef;
+     lextkey=orbit(0x9abcdef,31);
      ublock=uextkey;
      lblock=lextkey;
      ip();
@@ -182,8 +188,8 @@
      window.status="Self test .";
 
 // According to NBS 500-20 IP and E test
-     ublock=bit[28]|0x66b40b4;
-     lblock=bit[30]|0xaba4bd6;
+     ublock=orbit(0x66b40b4,28);
+     lblock=orbit(0xaba4bd6,30);
      uextkey=0x1010101;
      lextkey=0x1010101;
      initkeys();
@@ -199,8 +205,8 @@
 // According to NBS 500-20 ptest
      ublock=0;
      lblock=0;
-     uextkey=bit[28]|0x29116;
-     lextkey=bit[31]|bit[28]|0x8100101;
+     uextkey=orbit(0x29116,28);
+     lextkey=orbit(orbit(0x8100101,28),31);
      initkeys();
      encrypt();    
      var st=hexstring(ublock);
@@ -212,12 +218,12 @@
      window.status="Self test ...";
 
 // According to NBS 500-20 S-box test
-     ublock=bit[28]|bit[29]|0x553228;
-     lblock=bit[29]|bit[30]|0xd6f295a;
+     ublock=orbit(orbit(0x553228,28),29);
+     lblock=orbit(orbit(0xd6f295a,29),30);
      var orgu=ublock;
      var orgl=lblock;
-     uextkey=bit[28]|0xc587f1c;
-     lextkey=bit[28]|0x3924fef;
+     uextkey=orbit(0xc587f1c,28);
+     lextkey=orbit(0x3924fef,28);
      initkeys();
      encrypt();
      var st=hexstring(ublock);
@@ -395,7 +401,7 @@
        for (var kj=0; kj<=3; kj++) {
           if (andbit(uadd,ki-23+kj)!=0) { j=orbit(j,kj); }
        }
-       rv=rv|sbarr[ks*64+i*16+j];
+       rv=orvalue(rv,sbarr[ks*64+i*16+j]);
        ks++;
     } 
     for (var ki=18;ki>=0;ki=ki-6) {
@@ -407,7 +413,7 @@
        for (var kj=0; kj<=3; kj++) {
           if (andbit(ladd,ki+1+kj)!=0) { j=orbit(j,kj); }
        }
-       rv=rv|sbarr[ks*64+i*16+j];
+       rv=orvalue(rv,sbarr[ks*64+i*16+j]);
        ks++;
     }
     permute();